Tue Aug 11 20:32:59 2020 UTC ()
fixes.html: Expand Github versioning guide

Split section on Github commits into two:

1. Commits before the first release (recommend 0.0.0.N)
2. Commits between releases (use git describe --tags)

Also clean up indentation and remove zero-width space chars that were not
rendering properly.


(bacon)
diff -r1.158 -r1.159 pkgsrc/doc/guide/files/fixes.xml

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

--- pkgsrc/doc/guide/files/fixes.xml 2020/06/18 20:30:12 1.158
+++ pkgsrc/doc/guide/files/fixes.xml 2020/08/11 20:32:58 1.159
@@ -1,2060 +1,2088 @@ @@ -1,2060 +1,2088 @@
1<!-- $NetBSD: fixes.xml,v 1.158 2020/06/18 20:30:12 wiz Exp $ --> 1<!-- $NetBSD: fixes.xml,v 1.159 2020/08/11 20:32:58 bacon 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 a user might 473 <para>Your package may conflict with other packages a user might
474 already have installed on his system, e.g. if your package 474 already have installed on his 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 or has the same <varname>PKGNAME</varname>.</para> 476 tree or has the same <varname>PKGNAME</varname>.</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 and after committing that file, ask pkgsrc-security@NetBSD.org to 571 and after committing that file, ask pkgsrc-security@NetBSD.org to
572 update the file on ftp.NetBSD.org.</para> 572 update the file on ftp.NetBSD.org.</para>
573 573
574 <para>After fixing the vulnerability by a patch, its 574 <para>After fixing the vulnerability by a patch, its
575 <varname>PKGREVISION</varname> should be increased (this is of 575 <varname>PKGREVISION</varname> should be increased (this is of
576 course not necessary if the problem is fixed by using a newer 576 course not necessary if the problem is fixed by using a newer
577 release of the software), and the pattern in the 577 release of the software), and the pattern in the
578 pkg-vulnerabilities file must be updated.</para> 578 pkg-vulnerabilities file must be updated.</para>
579 579
580 <para>Also, if the fix should be applied to the stable pkgsrc 580 <para>Also, if the fix should be applied to the stable pkgsrc
581 branch, be sure to submit a pullup request!</para> 581 branch, be sure to submit a pullup request!</para>
582 582
583 <para>Binary packages already on ftp.NetBSD.org will be handled 583 <para>Binary packages already on ftp.NetBSD.org will be handled
584 semi-automatically by a weekly cron job.</para> 584 semi-automatically by a weekly cron job.</para>
585 </sect2> 585 </sect2>
586 586
587 587
588 <sect2 id="bumping-pkgrevision"> 588 <sect2 id="bumping-pkgrevision">
589 <title>How to handle incrementing versions when fixing an existing package</title> 589 <title>How to handle incrementing versions when fixing an existing package</title>
590 590
591 <para>When making fixes to an existing package it can be useful 591 <para>When making fixes to an existing package it can be useful
592 to change the version number in <varname>PKGNAME</varname>. To 592 to change the version number in <varname>PKGNAME</varname>. To
593 avoid conflicting with future versions by the original author, a 593 avoid conflicting with future versions by the original author, a
594 <quote>nb1</quote>, <quote>nb2</quote>, ... suffix can be used 594 <quote>nb1</quote>, <quote>nb2</quote>, ... suffix can be used
595 on package versions by setting <varname>PKGREVISION=1</varname> 595 on package versions by setting <varname>PKGREVISION=1</varname>
596 (2, ...). The <quote>nb</quote> is treated like a 596 (2, ...). The <quote>nb</quote> is treated like a
597 <quote>.</quote> by the package tools. e.g.</para> 597 <quote>.</quote> by the package tools. e.g.</para>
598 598
599<programlisting> 599<programlisting>
600DISTNAME= foo-17.42 600DISTNAME= foo-17.42
601PKGREVISION= 9 601PKGREVISION= 9
602</programlisting> 602</programlisting>
603 603
604 <para>will result in a <varname>PKGNAME</varname> of 604 <para>will result in a <varname>PKGNAME</varname> of
605 <quote>foo-17.42nb9</quote>. If you want to use the original 605 <quote>foo-17.42nb9</quote>. If you want to use the original
606 value of <varname>PKGNAME</varname> without the <quote>nbX</quote> 606 value of <varname>PKGNAME</varname> without the <quote>nbX</quote>
607 suffix, e.g. for setting <varname>DIST_SUBDIR</varname>, use 607 suffix, e.g. for setting <varname>DIST_SUBDIR</varname>, use
608 <varname>PKGNAME_NOREV</varname>.</para> 608 <varname>PKGNAME_NOREV</varname>.</para>
609 609
610 <para>When a new release of the package is released, the 610 <para>When a new release of the package is released, the
611 <varname>PKGREVISION</varname> should be removed, e.g. on a new 611 <varname>PKGREVISION</varname> should be removed, e.g. on a new
612 minor release of the above package, things should be like:</para> 612 minor release of the above package, things should be like:</para>
613 613
614<programlisting> 614<programlisting>
615DISTNAME= foo-17.43 615DISTNAME= foo-17.43
616</programlisting> 616</programlisting>
617 617
618 <para><varname>PKGREVISION</varname> should be incremented for any 618 <para><varname>PKGREVISION</varname> should be incremented for any
619 non-trivial change in the resulting binary package. Without a 619 non-trivial change in the resulting binary package. Without a
620 <varname>PKGREVISION</varname> bump, someone with the previous 620 <varname>PKGREVISION</varname> bump, someone with the previous
621 version installed has no way of knowing that their package is out 621 version installed has no way of knowing that their package is out
622 of date. Thus, changes without increasing 622 of date. Thus, changes without increasing
623 <varname>PKGREVISION</varname> are essentially labeled "this is so 623 <varname>PKGREVISION</varname> are essentially labeled "this is so
624 trivial that no reasonable person would want to upgrade", and this 624 trivial that no reasonable person would want to upgrade", and this
625 is the rough test for when increasing 625 is the rough test for when increasing
626 <varname>PKGREVISION</varname> is appropriate. Examples of 626 <varname>PKGREVISION</varname> is appropriate. Examples of
627 changes that do not merit increasing 627 changes that do not merit increasing
628 <varname>PKGREVISION</varname> are:</para> 628 <varname>PKGREVISION</varname> are:</para>
629 629
630 <itemizedlist> 630 <itemizedlist>
631 631
632 <listitem><para>Changing <varname>HOMEPAGE</varname>, 632 <listitem><para>Changing <varname>HOMEPAGE</varname>,
633 <varname>MAINTAINER</varname>, <varname>OWNER</varname>, or 633 <varname>MAINTAINER</varname>, <varname>OWNER</varname>, or
634 comments in Makefile.</para></listitem> 634 comments in Makefile.</para></listitem>
635 635
636 <listitem><para>Changing build variables if the resulting binary 636 <listitem><para>Changing build variables if the resulting binary
637 package is the same.</para></listitem> 637 package is the same.</para></listitem>
638 638
639 <listitem><para>Changing 639 <listitem><para>Changing
640 <filename>DESCR</filename>.</para></listitem> 640 <filename>DESCR</filename>.</para></listitem>
641 641
642 <listitem><para>Adding <varname>PKG_OPTIONS</varname> if the 642 <listitem><para>Adding <varname>PKG_OPTIONS</varname> if the
643 default options don't change.</para></listitem> 643 default options don't change.</para></listitem>
644 644
645 </itemizedlist> 645 </itemizedlist>
646 646
647 <para>Examples of changes that do merit an increase to 647 <para>Examples of changes that do merit an increase to
648 <varname>PKGREVISION</varname> include:</para> 648 <varname>PKGREVISION</varname> include:</para>
649 649
650 <itemizedlist> 650 <itemizedlist>
651 651
652 <listitem><para>Security fixes</para></listitem> 652 <listitem><para>Security fixes</para></listitem>
653 653
654 <listitem><para>Changes or additions to a patch 654 <listitem><para>Changes or additions to a patch
655 file</para></listitem> 655 file</para></listitem>
656 656
657 <listitem><para>Changes to the 657 <listitem><para>Changes to the
658 <filename>PLIST</filename></para></listitem> 658 <filename>PLIST</filename></para></listitem>
659 659
660 <listitem><para>A dependency is changed or 660 <listitem><para>A dependency is changed or
661 renamed.</para></listitem> 661 renamed.</para></listitem>
662 662
663 </itemizedlist> 663 </itemizedlist>
664 664
665 <para>PKGREVISION must also be incremented when dependencies have ABI 665 <para>PKGREVISION must also be incremented when dependencies have ABI
666 changes.</para> 666 changes.</para>
667 </sect2> 667 </sect2>
668 668
669<sect2 id="fixes.subst"> 669<sect2 id="fixes.subst">
670<title>Substituting variable text in the package files (the SUBST framework)</title> 670<title>Substituting variable text in the package files (the SUBST framework)</title>
671 671
672<para>When you want to replace the same text in multiple files, or 672<para>When you want to replace the same text in multiple files, or
673multiple times in the same file, it is cumbersome to maintain a patch 673multiple times in the same file, it is cumbersome to maintain a patch
674file for this. This is where the SUBST framework steps in. It provides an 674file for this. This is where the SUBST framework steps in. It provides an
675easy-to-use interface for replacing text in files. It just needs the 675easy-to-use interface for replacing text in files. It just needs the
676following information:</para> 676following information:</para>
677 677
678<itemizedlist> 678<itemizedlist>
679 679
680<listitem><para>In which phase of the package build cycle should the 680<listitem><para>In which phase of the package build cycle should the
681replacement happen?</para></listitem> 681replacement happen?</para></listitem>
682 682
683<listitem><para>In which files should the replacement 683<listitem><para>In which files should the replacement
684happen?</para></listitem> 684happen?</para></listitem>
685 685
686<listitem><para>Which text should be replaced with 686<listitem><para>Which text should be replaced with
687what?</para></listitem> 687what?</para></listitem>
688 688
689</itemizedlist> 689</itemizedlist>
690 690
691<para>This information is encoded in a block of <varname>SUBST</varname> 691<para>This information is encoded in a block of <varname>SUBST</varname>
692variables. A minimal example is:</para> 692variables. A minimal example is:</para>
693 693
694<programlisting> 694<programlisting>
695SUBST_CLASSES+= paths 695SUBST_CLASSES+= paths
696SUBST_STAGE.paths= pre-configure 696SUBST_STAGE.paths= pre-configure
697SUBST_FILES.paths= src/*.c 697SUBST_FILES.paths= src/*.c
698SUBST_SED.paths= -e 's,/usr/local,${PREFIX},g' 698SUBST_SED.paths= -e 's,/usr/local,${PREFIX},g'
699</programlisting> 699</programlisting>
700 700
701<para>Translated into English, it means: In the pre-configure stage (that 701<para>Translated into English, it means: In the pre-configure stage (that
702is, after applying the patches from the patches/ directory and before 702is, after applying the patches from the patches/ directory and before
703running the configure script and the portability check), replace the text 703running the configure script and the portability check), replace the text
704<literal>/usr/local</literal> with the content of the variable 704<literal>/usr/local</literal> with the content of the variable
705<varname>PREFIX</varname>.</para> 705<varname>PREFIX</varname>.</para>
706 706
707<para>Each SUBST block starts by appending an identifier to 707<para>Each SUBST block starts by appending an identifier to
708<varname>SUBST_CLASSES</varname> (note the <literal>+=</literal>). This 708<varname>SUBST_CLASSES</varname> (note the <literal>+=</literal>). This
709identifier can be chosen freely by the package. If there should ever be 709identifier can be chosen freely by the package. If there should ever be
710duplicate identifiers, the pkgsrc infrastructure will catch this and fail 710duplicate identifiers, the pkgsrc infrastructure will catch this and fail
711early, so don't worry about name collisions.</para> 711early, so don't worry about name collisions.</para>
712 712
713<para>Except for <varname>SUBST_CLASSES</varname>, all variables in a 713<para>Except for <varname>SUBST_CLASSES</varname>, all variables in a
714SUBST block are parameterized using this identifier. In the remainder of 714SUBST block are parameterized using this identifier. In the remainder of
715this section, these parameterized variables are written as 715this section, these parameterized variables are written as
716<varname>SUBST_STAGE.*</varname>.</para> 716<varname>SUBST_STAGE.*</varname>.</para>
717 717
718<programlisting> 718<programlisting>
719SUBST_CLASSES+= paths 719SUBST_CLASSES+= paths
720SUBST_STAGE.paths= pre-configure 720SUBST_STAGE.paths= pre-configure
721SUBST_MESSAGE.paths= Fixing absolute paths. 721SUBST_MESSAGE.paths= Fixing absolute paths.
722SUBST_FILES.paths= src/*.c 722SUBST_FILES.paths= src/*.c
723SUBST_FILES.paths+= scripts/*.sh 723SUBST_FILES.paths+= scripts/*.sh
724SUBST_SED.paths= -e 's,"/usr/local,"${PREFIX},g' 724SUBST_SED.paths= -e 's,"/usr/local,"${PREFIX},g'
725SUBST_SED.paths+= -e 's,"/var/log,"${VARBASE}/log,g' 725SUBST_SED.paths+= -e 's,"/var/log,"${VARBASE}/log,g'
726SUBST_VARS.paths= LOCALBASE PREFIX PKGVERSION 726SUBST_VARS.paths= LOCALBASE PREFIX PKGVERSION
727</programlisting> 727</programlisting>
728 728
729<para>To get a complete picture about the SUBST substitutions, run 729<para>To get a complete picture about the SUBST substitutions, run
730<command>bmake show-all-subst</command>. If something doesn't work as 730<command>bmake show-all-subst</command>. If something doesn't work as
731expected, run pkglint on the package, which detects several typical 731expected, run pkglint on the package, which detects several typical
732mistakes surrounding the SUBST blocks. For any questions that might 732mistakes surrounding the SUBST blocks. For any questions that might
733remain after this, have a look at 733remain after this, have a look at
734<filename>mk/subst.mk</filename>.</para> 734<filename>mk/subst.mk</filename>.</para>
735 735
736<sect3 id="fixes.subst.when"> 736<sect3 id="fixes.subst.when">
737<title>Choosing the time where the substitutions happen</title> 737<title>Choosing the time where the substitutions happen</title>
738 738
739<para>The <varname>SUBST_STAGE.*</varname> is one of 739<para>The <varname>SUBST_STAGE.*</varname> is one of
740{pre,do,post}-{extract,patch,configure,build,test,install}. Of these, 740{pre,do,post}-{extract,patch,configure,build,test,install}. Of these,
741<literal>pre-configure</literal> is used most often, by far. The most 741<literal>pre-configure</literal> is used most often, by far. The most
742popular stages are, in chronological order:</para> 742popular stages are, in chronological order:</para>
743 743
744<variablelist> 744<variablelist>
745 745
746<varlistentry><term><literal>post-extract</literal></term> 746<varlistentry><term><literal>post-extract</literal></term>
747<listitem><para>The substitutions are applied immediately after the 747<listitem><para>The substitutions are applied immediately after the
748distfiles are extracted. Running <command>bmake extract</command> on the 748distfiles are extracted. Running <command>bmake extract</command> on the
749package will leave no traces of the original files.</para> 749package will leave no traces of the original files.</para>
750 750
751<para>When the substitution applies to files for which there is also a 751<para>When the substitution applies to files for which there is also a
752patch in the <filename>patches/</filename> directory, this means that the 752patch in the <filename>patches/</filename> directory, this means that the
753patches will be computed based on the result of the substitution. When 753patches will be computed based on the result of the substitution. When
754these patches are sent to the upstream maintainer later, to be fixed in 754these patches are sent to the upstream maintainer later, to be fixed in
755the upstream package, these patches may no longer match what the upstream 755the upstream package, these patches may no longer match what the upstream
756author is used to. Because of this, <literal>pre-configure</literal> is 756author is used to. Because of this, <literal>pre-configure</literal> is
757often a better choice.</para></listitem></varlistentry> 757often a better choice.</para></listitem></varlistentry>
758 758
759<varlistentry><term><literal>pre-configure</literal></term> 759<varlistentry><term><literal>pre-configure</literal></term>
760<listitem><para>The substitutions are applied after the patches from the 760<listitem><para>The substitutions are applied after the patches from the
761<filename>patches/</filename> directory. This makes it possible to run 761<filename>patches/</filename> directory. This makes it possible to run
762<command>bmake patch</command> on the package, after which the patches 762<command>bmake patch</command> on the package, after which the patches
763can be edited using the tools pkgvi and mkpatches from the <filename 763can be edited using the tools pkgvi and mkpatches from the <filename
764role="pkg">pkgtools/pkgdiff</filename> package.</para> 764role="pkg">pkgtools/pkgdiff</filename> package.</para>
765 765
766<para>When updating the patches, it is helpful to explicitly separate the 766<para>When updating the patches, it is helpful to explicitly separate the
767<command>bmake patch</command> from the <command>bmake 767<command>bmake patch</command> from the <command>bmake
768configure</command>, and to only edit the patches between these commands. 768configure</command>, and to only edit the patches between these commands.
769Otherwise the substitutions from the SUBST block will end up in the patch 769Otherwise the substitutions from the SUBST block will end up in the patch
770file. When this happens in really obvious ways, pkglint will complain 770file. When this happens in really obvious ways, pkglint will complain
771about patches that contain a hard-coded <literal>/usr/pkg</literal> 771about patches that contain a hard-coded <literal>/usr/pkg</literal>
772instead of the correct and intended <literal>@PREFIX@</literal>, but it 772instead of the correct and intended <literal>@PREFIX@</literal>, but it
773can only detect these really obvious 773can only detect these really obvious
774cases.</para></listitem></varlistentry> 774cases.</para></listitem></varlistentry>
775 775
776<varlistentry><term><literal>do-configure</literal></term> 776<varlistentry><term><literal>do-configure</literal></term>
777<listitem><para>This stage should only be used if the package defines a 777<listitem><para>This stage should only be used if the package defines a
778<literal>pre-configure</literal> action itself, and the substitution must 778<literal>pre-configure</literal> action itself, and the substitution must
779happen after that. Typical examples are packages that use the 779happen after that. Typical examples are packages that use the
780<literal>pre-configure</literal> stage to regenerate the GNU configure 780<literal>pre-configure</literal> stage to regenerate the GNU configure
781script from 781script from
782<filename>configure.ac</filename>.</para></listitem></varlistentry> 782<filename>configure.ac</filename>.</para></listitem></varlistentry>
783 783
784<varlistentry><term><literal>post-configure</literal></term> 784<varlistentry><term><literal>post-configure</literal></term>
785<listitem><para>This stage is used to fix up any mistakes by the 785<listitem><para>This stage is used to fix up any mistakes by the
786configure stage.</para></listitem></varlistentry> 786configure stage.</para></listitem></varlistentry>
787 787
788<varlistentry><term><literal>pre-build</literal></term> 788<varlistentry><term><literal>pre-build</literal></term>
789<listitem><para>This stage should only be used for substitutions that are 789<listitem><para>This stage should only be used for substitutions that are
790clearly related to building the package, not for fixing the 790clearly related to building the package, not for fixing the
791configuration. Substitutions for pathnames (such as replacing 791configuration. Substitutions for pathnames (such as replacing
792<filename>/usr/local</filename> with <literal>${PREFIX}</literal>) or 792<filename>/usr/local</filename> with <literal>${PREFIX}</literal>) or
793user names (such as replacing <literal>@MY_USER@</literal> with the 793user names (such as replacing <literal>@MY_USER@</literal> with the
794actual username) belong in pre-configure or post-configure 794actual username) belong in pre-configure or post-configure
795instead.</para></listitem></varlistentry> 795instead.</para></listitem></varlistentry>
796 796
797<varlistentry><term><literal>post-build</literal></term> 797<varlistentry><term><literal>post-build</literal></term>
798<listitem><para>Just as with pre-build, this stage should only be used 798<listitem><para>Just as with pre-build, this stage should only be used
799for substitutions that are clearly related to building the package, not 799for substitutions that are clearly related to building the package, not
800for fixing the configuration. Substitutions for pathnames (such as 800for fixing the configuration. Substitutions for pathnames (such as
801replacing <filename>/usr/local</filename> with 801replacing <filename>/usr/local</filename> with
802<literal>${PREFIX}</literal>) or user names (such as replacing 802<literal>${PREFIX}</literal>) or user names (such as replacing
803<literal>@MY_USER@</literal> with the actual username) belong in 803<literal>@MY_USER@</literal> with the actual username) belong in
804pre-configure or post-configure instead.</para> 804pre-configure or post-configure instead.</para>
805 805
806<para>A typical use is to update pkg-config files to include the rpath 806<para>A typical use is to update pkg-config files to include the rpath
807compiler options.</para></listitem></varlistentry> 807compiler options.</para></listitem></varlistentry>
808 808
809<varlistentry><term><literal>pre-install</literal></term> 809<varlistentry><term><literal>pre-install</literal></term>
810<listitem><para>In general, the install phase should be as simple as 810<listitem><para>In general, the install phase should be as simple as
811possible. As with the pre-build and post-build stages, it should not be 811possible. As with the pre-build and post-build stages, it should not be
812used to fix pathnames or user names, these belong in pre-configure 812used to fix pathnames or user names, these belong in pre-configure
813instead. There are only few legitimate use cases for applying 813instead. There are only few legitimate use cases for applying
814substitutions in this stage.</para></listitem></varlistentry> 814substitutions in this stage.</para></listitem></varlistentry>
815 815
816</variablelist> 816</variablelist>
817 817
818</sect3> 818</sect3>
819 819
820<sect3 id="fixes.subst.where"> 820<sect3 id="fixes.subst.where">
821<title>Choosing the files where the substitutions happen</title> 821<title>Choosing the files where the substitutions happen</title>
822 822
823<para>The <varname>SUBST_FILES.*</varname> variable contains a list of 823<para>The <varname>SUBST_FILES.*</varname> variable contains a list of
824filename patterns. These patterns are relative to 824filename patterns. These patterns are relative to
825<varname>WRKSRC</varname> since that is where most substitutions happen. 825<varname>WRKSRC</varname> since that is where most substitutions happen.
826A typical example is:</para> 826A typical example is:</para>
827 827
828<programlisting> 828<programlisting>
829SUBST_FILES.path= Makefile */Makefile */*/Makefile *.[ch] 829SUBST_FILES.path= Makefile */Makefile */*/Makefile *.[ch]
830</programlisting> 830</programlisting>
831 831
832 832
833<para>The above patterns, especially the last, are quite broad. The SUBST 833<para>The above patterns, especially the last, are quite broad. The SUBST
834implementation checks that each filename pattern that is mentioned here 834implementation checks that each filename pattern that is mentioned here
835has an effect. For example, if none of the 835has an effect. For example, if none of the
836<filename>*/*/Makefile</filename> files contains the patterns to be found 836<filename>*/*/Makefile</filename> files contains the patterns to be found
837and substituted, that filename pattern is redundant and should be left 837and substituted, that filename pattern is redundant and should be left
838out. By default, the SUBST framework will complain with an error message. 838out. By default, the SUBST framework will complain with an error message.
839If the text to be substituted occurs in some of the files from a single 839If the text to be substituted occurs in some of the files from a single
840pattern, but not in all of them, that is totally ok, and the SUBST 840pattern, but not in all of them, that is totally ok, and the SUBST
841framework will only print an INFO message for those files.</para> 841framework will only print an INFO message for those files.</para>
842 842
843<para>If there is a good reason for having redundant filename patterns, 843<para>If there is a good reason for having redundant filename patterns,
844set <varname>SUBST_NOOP_OK.*</varname> to <literal>yes</literal>.</para> 844set <varname>SUBST_NOOP_OK.*</varname> to <literal>yes</literal>.</para>
845 845
846<para>Another popular way of choosing the files for the substitutions is 846<para>Another popular way of choosing the files for the substitutions is
847via a shell command, like this:</para> 847via a shell command, like this:</para>
848 848
849<programlisting> 849<programlisting>
850C_FILES_CMD= cd ${WRKSRC} &amp;&amp; ${FIND} . -name '*.c' 850C_FILES_CMD= cd ${WRKSRC} &amp;&amp; ${FIND} . -name '*.c'
851SUBST_FILES.path= ${C_FILES_CMD:sh} 851SUBST_FILES.path= ${C_FILES_CMD:sh}
852</programlisting> 852</programlisting>
853 853
854<para>The variable name <varname>C_FILES_CMD</varname> in this example is 854<para>The variable name <varname>C_FILES_CMD</varname> in this example is
855freely chosen and independent of the SUBST framework.</para> 855freely chosen and independent of the SUBST framework.</para>
856 856
857<para>In this variant, the <varname>SUBST_FILES.*</varname> variable 857<para>In this variant, the <varname>SUBST_FILES.*</varname> variable
858lists each file individually. Thereby chances are higher that there are 858lists each file individually. Thereby chances are higher that there are
859filename patterns in which no substitution happens. Since the SUBST 859filename patterns in which no substitution happens. Since the SUBST
860framework cannot know whether the filename patterns in 860framework cannot know whether the filename patterns in
861<varname>SUBST_FILES.*</varname> have been explicitly listed in the 861<varname>SUBST_FILES.*</varname> have been explicitly listed in the
862Makefile (where any redundant filename pattern would be suspicious) or 862Makefile (where any redundant filename pattern would be suspicious) or
863been generated by a shell command (in which redundant filename patterns 863been generated by a shell command (in which redundant filename patterns
864are more likely and to be expected), it will complain about these 864are more likely and to be expected), it will complain about these
865redundant filename patterns. Therefore, SUBST blocks that use a shell 865redundant filename patterns. Therefore, SUBST blocks that use a shell
866command to generate the list of filename patterns often need to set 866command to generate the list of filename patterns often need to set
867<varname>SUBST_NOOP_OK.*</varname> to <literal>yes</literal>.</para> 867<varname>SUBST_NOOP_OK.*</varname> to <literal>yes</literal>.</para>
868 868
869</sect3> 869</sect3>
870 870
871<sect3 id="fixes.subst.what"> 871<sect3 id="fixes.subst.what">
872<title>Choosing what to substitute</title> 872<title>Choosing what to substitute</title>
873 873
874<para>In most cases, the substitutions are given using one or more 874<para>In most cases, the substitutions are given using one or more
875&man.sed.1; commands, like this:</para> 875&man.sed.1; commands, like this:</para>
876 876
877<programlisting> 877<programlisting>
878SUBST_SED.path= -e 's|/usr/local|${PREFIX}|g' 878SUBST_SED.path= -e 's|/usr/local|${PREFIX}|g'
879</programlisting> 879</programlisting>
880 880
881<para>Each of the sed commands needs to be preceded by the 881<para>Each of the sed commands needs to be preceded by the
882<literal>-e</literal> option and should be specified on a line of its 882<literal>-e</literal> option and should be specified on a line of its
883own, to avoid hiding short sed commands at the end of a line.</para> 883own, to avoid hiding short sed commands at the end of a line.</para>
884 884
885<para>Since the sed commands often contain shell metacharacters as the 885<para>Since the sed commands often contain shell metacharacters as the
886separator (the <literal>|</literal> in the above example), it is common 886separator (the <literal>|</literal> in the above example), it is common
887to enclose them in single quotes.</para> 887to enclose them in single quotes.</para>
888 888
889<para>A common substitution is to replace placeholders of the form 889<para>A common substitution is to replace placeholders of the form
890<literal>@VARNAME@</literal> with their pkgsrc counterpart variable 890<literal>@VARNAME@</literal> with their pkgsrc counterpart variable
891<literal>${VARNAME}</literal>. A typical example is:</para> 891<literal>${VARNAME}</literal>. A typical example is:</para>
892 892
893<programlisting> 893<programlisting>
894SUBST_VARS.path= PREFIX 894SUBST_VARS.path= PREFIX
895</programlisting> 895</programlisting>
896 896
897<para>This type of substitutions is typically done by the GNU configure 897<para>This type of substitutions is typically done by the GNU configure
898scripts during the do-configure stage, but in some cases these need to be 898scripts during the do-configure stage, but in some cases these need to be
899overridden. The same pattern is also used when a package defines patches 899overridden. The same pattern is also used when a package defines patches
900that replace previously hard-coded paths like 900that replace previously hard-coded paths like
901<literal>/usr/local</literal> with a <literal>@PREFIX@</literal> 901<literal>/usr/local</literal> with a <literal>@PREFIX@</literal>
902placeholder first, which then gets substituted by the actual 902placeholder first, which then gets substituted by the actual
903<literal>${PREFIX}</literal> in the pre-configure stage. In many of these 903<literal>${PREFIX}</literal> in the pre-configure stage. In many of these
904cases, it works equally well to just use the SUBST framework to directly 904cases, it works equally well to just use the SUBST framework to directly
905replace <literal>/usr/local</literal> with <literal>${PREFIX}</literal>, 905replace <literal>/usr/local</literal> with <literal>${PREFIX}</literal>,
906thereby omitting the intermediate patch file.</para> 906thereby omitting the intermediate patch file.</para>
907 907
908<para>If the above is not flexible enough, it is possible to not use sed 908<para>If the above is not flexible enough, it is possible to not use sed
909at all for the substitution but to specify an entirely different command, 909at all for the substitution but to specify an entirely different command,
910like this:</para> 910like this:</para>
911 911
912<programlisting> 912<programlisting>
913SUBST_FILTER_CMD.path= LC_ALL=C ${TR} -d '\r' 913SUBST_FILTER_CMD.path= LC_ALL=C ${TR} -d '\r'
914</programlisting> 914</programlisting>
915 915
916<para>This is used for the few remaining packages in which the 916<para>This is used for the few remaining packages in which the
917distributed files use Windows-style line endings that need to be 917distributed files use Windows-style line endings that need to be
918converted to UNIX-style line endings.</para> 918converted to UNIX-style line endings.</para>
919 919
920</sect3> 920</sect3>
921 921
922<sect3 id="fixes.subst.other"> 922<sect3 id="fixes.subst.other">
923<title>Other SUBST variables</title> 923<title>Other SUBST variables</title>
924 924
925<para>When a SUBST block is applied during a package build, a message is 925<para>When a SUBST block is applied during a package build, a message is
926logged. The default message is fine for most purposes but can be 926logged. The default message is fine for most purposes but can be
927overridden by setting <literal>SUBST_MESSAGE.*</literal> to an individual 927overridden by setting <literal>SUBST_MESSAGE.*</literal> to an individual
928message.</para> 928message.</para>
929 929
930</sect3> 930</sect3>
931 931
932</sect2> 932</sect2>
933 933
934</sect1> 934</sect1>
935 935
936<sect1 id="fixes.fetch"> 936<sect1 id="fixes.fetch">
937 <title>The <emphasis>fetch</emphasis> phase</title> 937 <title>The <emphasis>fetch</emphasis> phase</title>
938 938
939 <sect2 id="no-plain-download"> 939 <sect2 id="no-plain-download">
940 <title>Packages whose distfiles aren't available for plain downloading</title> 940 <title>Packages whose distfiles aren't available for plain downloading</title>
941 941
942 <para>If you need to download from a dynamic URL you can set 942 <para>If you need to download from a dynamic URL you can set
943 <varname>DYNAMIC_MASTER_SITES</varname> and a <command>make 943 <varname>DYNAMIC_MASTER_SITES</varname> and a <command>make
944 fetch</command> will call <filename>files/getsite.sh</filename> 944 fetch</command> will call <filename>files/getsite.sh</filename>
945 with the name of each file to download as an argument, expecting 945 with the name of each file to download as an argument, expecting
946 it to output the URL of the directory from which to download 946 it to output the URL of the directory from which to download
947 it. <filename role="pkg">graphics/ns-cult3d</filename> is an 947 it. <filename role="pkg">graphics/ns-cult3d</filename> is an
948 example of this usage.</para> 948 example of this usage.</para>
949 949
950 <para>If the download can't be automated, because the user must 950 <para>If the download can't be automated, because the user must
951 submit personal information to apply for a password, or must pay 951 submit personal information to apply for a password, or must pay
952 for the source, or whatever, you can set 952 for the source, or whatever, you can set
953 <varname>FETCH_MESSAGE</varname> to a list of lines that are 953 <varname>FETCH_MESSAGE</varname> to a list of lines that are
954 displayed to the user before aborting the build. Example:</para> 954 displayed to the user before aborting the build. Example:</para>
955 955
956<programlisting> 956<programlisting>
957FETCH_MESSAGE= "Please download the files" 957FETCH_MESSAGE= "Please download the files"
958FETCH_MESSAGE+= " "${DISTFILES:Q} 958FETCH_MESSAGE+= " "${DISTFILES:Q}
959FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"." 959FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
960</programlisting> 960</programlisting>
961 961
962 </sect2> 962 </sect2>
963 963
964 964
965 <sect2 id="modified-distfiles-same-name"> 965 <sect2 id="modified-distfiles-same-name">
966 <title>How to handle modified distfiles with the 'old' name</title> 966 <title>How to handle modified distfiles with the 'old' name</title>
967 967
968 <para>Sometimes authors of a software package make some 968 <para>Sometimes authors of a software package make some
969 modifications after the software was released, and they put up a 969 modifications after the software was released, and they put up a
970 new distfile without changing the package's version number. If a 970 new distfile without changing the package's version number. If a
971 package is already in pkgsrc at that time, the checksum will 971 package is already in pkgsrc at that time, the checksum will
972 no longer match. The contents of the new distfile should be 972 no longer match. The contents of the new distfile should be
973 compared against the old one before changing anything, to make 973 compared against the old one before changing anything, to make
974 sure the distfile was really updated on purpose, and that 974 sure the distfile was really updated on purpose, and that
975 no trojan horse or so crept in. 975 no trojan horse or so crept in.
976 Please mention that the distfiles were compared and what was found 976 Please mention that the distfiles were compared and what was found
977 in your commit message.</para> 977 in your commit message.</para>
978 <para>Then, the correct way to work around this is to set 978 <para>Then, the correct way to work around this is to set
979 <varname>DIST_SUBDIR</varname> to a unique directory name, usually 979 <varname>DIST_SUBDIR</varname> to a unique directory name, usually
980 based on <varname>PKGNAME_NOREV</varname> (but take care with 980 based on <varname>PKGNAME_NOREV</varname> (but take care with
981 python or ruby packages, where <varname>PKGNAME</varname> includes 981 python or ruby packages, where <varname>PKGNAME</varname> includes
982 a variable prefix). All <varname>DISTFILES</varname> and 982 a variable prefix). All <varname>DISTFILES</varname> and
983 <varname>PATCHFILES</varname> for this package will be put in that 983 <varname>PATCHFILES</varname> for this package will be put in that
984 subdirectory of the local distfiles directory. (See <xref 984 subdirectory of the local distfiles directory. (See <xref
985 linkend="bumping-pkgrevision"/> for more details.) In case this 985 linkend="bumping-pkgrevision"/> for more details.) In case this
986 happens more often, <varname>PKGNAME</varname> can be used (thus 986 happens more often, <varname>PKGNAME</varname> can be used (thus
987 including the <filename>nbX</filename> suffix) or a date stamp can 987 including the <filename>nbX</filename> suffix) or a date stamp can
988 be appended, like 988 be appended, like
989 <varname>${PKGNAME_NOREV}-YYYYMMDD</varname>.</para> 989 <varname>${PKGNAME_NOREV}-YYYYMMDD</varname>.</para>
990 990
991 <para><varname>DIST_SUBDIR</varname> is also used when a distfile's 991 <para><varname>DIST_SUBDIR</varname> is also used when a distfile's
992 name does not contain a version and the distfile is apt to change. In 992 name does not contain a version and the distfile is apt to change. In
993 cases where the likelihood of this is very small, 993 cases where the likelihood of this is very small,
994 <varname>DIST_SUBDIR</varname> might not be required. Additionally, 994 <varname>DIST_SUBDIR</varname> might not be required. Additionally,
995 <varname>DIST_SUBDIR</varname> must not be removed unless the 995 <varname>DIST_SUBDIR</varname> must not be removed unless the
996 distfile name changes, even if a package is being moved or 996 distfile name changes, even if a package is being moved or
997 renamed.</para> 997 renamed.</para>
998 998
999 <para>Do not forget regenerating the <filename>distinfo</filename> file 999 <para>Do not forget regenerating the <filename>distinfo</filename> file
1000 after that, since it contains the <varname>DIST_SUBDIR</varname> 1000 after that, since it contains the <varname>DIST_SUBDIR</varname>
1001 path in the filenames. 1001 path in the filenames.
1002 Also, increase the PKGREVISION if the installed package is different. 1002 Also, increase the PKGREVISION if the installed package is different.
1003 Furthermore, a mail to the package's authors seems appropriate 1003 Furthermore, a mail to the package's authors seems appropriate
1004 telling them that changing distfiles after releases without 1004 telling them that changing distfiles after releases without
1005 changing the file names is not good practice.</para> 1005 changing the file names is not good practice.</para>
1006 </sect2> 1006 </sect2>
1007 1007
1008 <sect2 id="build.fetch.github"> 1008 <sect2 id="build.fetch.github">
1009 <title>Packages hosted on github.com</title> 1009 <title>Packages hosted on github.com</title>
1010 1010
1011 <para>Helper methods exist for packages hosted on github.com which 1011 <para>Helper methods exist for packages hosted on github.com which
1012 will often have distfile names that clash with other packages, for 1012 will often have distfile names that clash with other packages, for
1013 example <filename>1.0.tar.gz</filename>. Use one of the three recipes 1013 example <filename>1.0.tar.gz</filename>. Use one of the three recipes
1014 from below:</para> 1014 from below:</para>
1015 1015
1016 <sect3 id="build.fetch.github.tag"> 1016 <sect3 id="build.fetch.github.tag">
1017 <title>Fetch based on a tagged release</title> 1017 <title>Fetch based on a tagged release</title>
1018 1018
1019 <para>If your distfile URL looks similar to 1019 <para>If your distfile URL looks similar to
1020 <literal>https://github.com/username/exampleproject/archive/v1.0.zip</literal>, 1020 <literal>https://github.com/username/example/archive/v1.0.zip</literal>,
1021 then you are packaging a tagged release.</para> 1021 then you are packaging a tagged release.</para>
1022 1022
1023<programlisting> 1023<programlisting>
1024DISTNAME= exampleproject-1.0 1024DISTNAME= example-1.0
1025MASTER_SITES= ${MASTER_SITE_GITHUB:=username/} 1025MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1026#GITHUB_PROJECT= # can be omitted if same as DISTNAME 1026#GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1027GITHUB_TAG= v${PKGVERSION_NOREV} 1027GITHUB_TAG= v${PKGVERSION_NOREV}
1028EXTRACT_SUFX= .zip 1028EXTRACT_SUFX= .zip
1029</programlisting> 1029</programlisting>
1030 1030
1031 </sect3> 1031 </sect3>
1032 1032
1033 <sect3 id="build.fetch.github.commit"> 1033 <sect3 id="build.fetch.github.commit.prerelease">
1034 <title>Fetch based on a specific commit</title> 1034 <title>Fetch based on a specific commit before the first release</title>
1035 1035
1036 <para>If your distfile URL looks similar to 1036 <para>If your distfile looks similar to
1037 <literal>https://github.com&#x200B;/example&#x200B;/example&#x200B;/archive&#x200B;/988881adc9fc3655077dc2d4d757d480b5ea0e11.tar.gz</literal>, 1037 <literal>https://github.com/username/example/archive/988881adc9fc3655077dc2d4d757d480b5ea0e11</literal> and is from a commit before the first
1038 then you are packaging a specific commit not tied to a 1038 release, then set the package version to 0.0.0.N, where N is the number
1039 release.</para> 1039 of commits to the repository, and set GITHUB_TAG to the commit hash.
 1040 This will (almost) ensure that the first tagged release will have a
 1041 version greater than this one so that package upgrades will function
 1042 properly.</para>
1040 1043
1041<programlisting> 1044<programlisting>
1042DISTNAME= example-1.0 1045DISTNAME= example-0.0.0.347
1043MASTER_SITES= ${MASTER_SITE_GITHUB:=example/} 1046MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1044#GITHUB_PROJECT= # can be omitted if same as DISTNAME 1047#GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1045GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11 1048GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
1046</programlisting> 1049</programlisting>
 1050 </sect3>
 1051
 1052 <sect3 id="build.fetch.github.commit.postrelease">
 1053 <title>Fetch based on a specific commit after a release</title>
1047 1054
 1055 <para>If your distfile looks similar to
 1056 <literal>https://github.com/username/example/archive/988881adc9fc3655077dc2d4d757d480b5ea0e11</literal> and is from a commit after a release,
 1057 then include the last release version and the commit count since that
 1058 release in the package version and set GITHUB_TAG to the commit hash.
 1059 The latest release and commit count are shown in the output of
 1060 "git describe --tags":
 1061 </para>
 1062
 1063<screen>
 1064# git clone https://github.com/username/example
 1065# cd example
 1066# git describe --tags
 10671.2.3-5-g988881a
 1068</screen>
 1069
 1070<programlisting>
 1071DISTNAME= example-1.2.3.5
 1072MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
 1073#GITHUB_PROJECT= example # can be omitted if same as DISTNAME
 1074GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
 1075</programlisting>
1048 </sect3> 1076 </sect3>
1049 1077
1050 <sect3 id="build.fetch.github.release"> 1078 <sect3 id="build.fetch.github.release">
1051 <title>Fetch based on release</title> 1079 <title>Fetch based on release</title>
1052 1080
1053 <para>If your distfile URL looks similar to 1081 <para>If your distfile URL looks similar to
1054 <literal>https://github.com&#x200B;/username/exampleproject&#x200B;/releases&#x200B;/download&#x200B;/rel-1.6&#x200B;/offensive-1.6.zip</literal>, 1082 <literal>https://github.com/username/example/releases/download/rel-1.6/offensive-1.6.zip</literal>,
1055 then you are packaging a release.</para> 1083 then you are packaging a release.</para>
1056 1084
1057<programlisting> 1085<programlisting>
1058DISTNAME= offensive-1.6 1086DISTNAME= offensive-1.6
1059PKGNAME= ${DISTNAME:S/offensive/proper/} 1087PKGNAME= ${DISTNAME:S/offensive/proper/}
1060MASTER_SITES= ${MASTER_SITE_GITHUB:=username/} 1088MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1061GITHUB_PROJECT= exampleproject 1089GITHUB_PROJECT= example
1062GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME} 1090GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
1063EXTRACT_SUFX= .zip 1091EXTRACT_SUFX= .zip
1064</programlisting> 1092</programlisting>
1065 </sect3> 1093 </sect3>
1066 </sect2> 1094 </sect2>
1067</sect1> 1095</sect1>
1068 1096
1069 1097
1070<sect1 id="fixes.configure"> 1098<sect1 id="fixes.configure">
1071 <title>The <emphasis>configure</emphasis> phase</title> 1099 <title>The <emphasis>configure</emphasis> phase</title>
1072 1100
1073 <sect2 id="fixes.libtool"> 1101 <sect2 id="fixes.libtool">
1074 <title>Shared libraries - libtool</title> 1102 <title>Shared libraries - libtool</title>
1075 1103
1076 <para>pkgsrc supports many different machines, with different 1104 <para>pkgsrc supports many different machines, with different
1077 object formats like a.out and ELF, and varying abilities to do 1105 object formats like a.out and ELF, and varying abilities to do
1078 shared library and dynamic loading at all. To accompany this, 1106 shared library and dynamic loading at all. To accompany this,
1079 varying commands and options have to be passed to the 1107 varying commands and options have to be passed to the
1080 compiler, linker, etc. to get the Right Thing, which can be 1108 compiler, linker, etc. to get the Right Thing, which can be
1081 pretty annoying especially if you don't have all the machines 1109 pretty annoying especially if you don't have all the machines
1082 at your hand to test things. The 1110 at your hand to test things. The
1083 <filename role="pkg">devel/libtool</filename> pkg 1111 <filename role="pkg">devel/libtool</filename> pkg
1084 can help here, as it just <quote>knows</quote> how to build 1112 can help here, as it just <quote>knows</quote> how to build
1085 both static and dynamic libraries from a set of source files, 1113 both static and dynamic libraries from a set of source files,
1086 thus being platform-independent.</para> 1114 thus being platform-independent.</para>
1087 1115
1088 <para>Here's how to use libtool in a package in seven simple 1116 <para>Here's how to use libtool in a package in seven simple
1089 steps:</para> 1117 steps:</para>
1090 1118
1091 <orderedlist> 1119 <orderedlist>
1092 <listitem> 1120 <listitem>
1093 <para>Add <varname>USE_LIBTOOL=yes</varname> to the package 1121 <para>Add <varname>USE_LIBTOOL=yes</varname> to the package
1094 Makefile.</para> 1122 Makefile.</para>
1095 </listitem> 1123 </listitem>
1096 1124
1097 <listitem> 1125 <listitem>
1098 <para>For library objects, use <quote>${LIBTOOL} --mode=compile 1126 <para>For library objects, use <quote>${LIBTOOL} --mode=compile
1099 ${CC}</quote> in place of <quote>${CC}</quote>. You could even 1127 ${CC}</quote> in place of <quote>${CC}</quote>. You could even
1100 add it to the definition of <varname>CC</varname>, if only 1128 add it to the definition of <varname>CC</varname>, if only
1101 libraries are being built in a given Makefile. This one command 1129 libraries are being built in a given Makefile. This one command
1102 will build both PIC and non-PIC library objects, so you need not 1130 will build both PIC and non-PIC library objects, so you need not
1103 have separate shared and non-shared library rules.</para> 1131 have separate shared and non-shared library rules.</para>
1104 </listitem> 1132 </listitem>
1105 1133
1106 <listitem> 1134 <listitem>
1107 <para>For the linking of the library, remove any 1135 <para>For the linking of the library, remove any
1108 <quote>ar</quote>, <quote>ranlib</quote>, and <quote>ld 1136 <quote>ar</quote>, <quote>ranlib</quote>, and <quote>ld
1109 -Bshareable</quote> commands, and instead use:</para> 1137 -Bshareable</quote> commands, and instead use:</para>
1110 1138
1111<programlisting> 1139<programlisting>
1112${LIBTOOL} --mode=link \ 1140${LIBTOOL} --mode=link \
1113 ${CC} -o ${.TARGET:.a=.la} \ 1141 ${CC} -o ${.TARGET:.a=.la} \
1114 ${OBJS:.o=.lo} \ 1142 ${OBJS:.o=.lo} \
1115 -rpath ${PREFIX}/lib \ 1143 -rpath ${PREFIX}/lib \
1116 -version-info major:minor 1144 -version-info major:minor
1117</programlisting> 1145</programlisting>
1118 1146
1119 <para>Note that the library is changed to have a 1147 <para>Note that the library is changed to have a
1120 <filename>.la</filename> extension, and the objects are 1148 <filename>.la</filename> extension, and the objects are
1121 changed to have a <filename>.lo</filename> 1149 changed to have a <filename>.lo</filename>
1122 extension. Change <varname>OBJS</varname> as 1150 extension. Change <varname>OBJS</varname> as
1123 necessary. This automatically creates all of the 1151 necessary. This automatically creates all of the
1124 <filename>.a</filename>, 1152 <filename>.a</filename>,
1125 <filename>.so.major.minor</filename>, and ELF symlinks (if 1153 <filename>.so.major.minor</filename>, and ELF symlinks (if
1126 necessary) in the build directory. Be sure to include 1154 necessary) in the build directory. Be sure to include
1127 <quote>-version-info</quote>, especially when major and 1155 <quote>-version-info</quote>, especially when major and
1128 minor are zero, as libtool will otherwise strip off the 1156 minor are zero, as libtool will otherwise strip off the
1129 shared library version.</para> 1157 shared library version.</para>
1130 1158
1131 <para>From the libtool manual:</para> 1159 <para>From the libtool manual:</para>
1132 1160
1133<programlisting> 1161<programlisting>
1134So, libtool library versions are described by three integers: 1162So, libtool library versions are described by three integers:
1135 1163
1136CURRENT 1164CURRENT
1137The most recent interface number that this library implements. 1165The most recent interface number that this library implements.
1138 1166
1139REVISION 1167REVISION
1140The implementation number of the CURRENT interface. 1168The implementation number of the CURRENT interface.
1141 1169
1142AGE 1170AGE
1143The difference between the newest and oldest interfaces that 1171The difference between the newest and oldest interfaces that
1144this library implements. In other words, the library implements 1172this library implements. In other words, the library implements
1145all the interface numbers in the range from number `CURRENT - 1173all the interface numbers in the range from number `CURRENT -
1146AGE' to `CURRENT'. 1174AGE' to `CURRENT'.
1147 1175
1148If two libraries have identical CURRENT and AGE numbers, then the 1176If two libraries have identical CURRENT and AGE numbers, then the
1149dynamic linker chooses the library with the greater REVISION number. 1177dynamic linker chooses the library with the greater REVISION number.
1150</programlisting> 1178</programlisting>
1151 1179
1152 <para>The <quote>-release</quote> option will produce 1180 <para>The <quote>-release</quote> option will produce
1153 different results for a.out and ELF (excluding symlinks) 1181 different results for a.out and ELF (excluding symlinks)
1154 in only one case. An ELF library of the form 1182 in only one case. An ELF library of the form
1155 <quote>libfoo-release.so.<emphasis>x</emphasis>.<emphasis>y</emphasis></quote> 1183 <quote>libfoo-release.so.<emphasis>x</emphasis>.<emphasis>y</emphasis></quote>
1156 will have a symlink of 1184 will have a symlink of
1157 <quote>libfoo.so.<emphasis>x</emphasis>.<emphasis>y</emphasis></quote> 1185 <quote>libfoo.so.<emphasis>x</emphasis>.<emphasis>y</emphasis></quote>
1158 on an a.out platform. This is handled 1186 on an a.out platform. This is handled
1159 automatically.</para> 1187 automatically.</para>
1160 1188
1161 <para>The <quote>-rpath argument</quote> is the install 1189 <para>The <quote>-rpath argument</quote> is the install
1162 directory of the library being built.</para> 1190 directory of the library being built.</para>
1163 1191
1164 <para>In the <filename>PLIST</filename>, include only the 1192 <para>In the <filename>PLIST</filename>, include only the
1165 <filename>.la</filename> file, the other files will be 1193 <filename>.la</filename> file, the other files will be
1166 added automatically.</para> 1194 added automatically.</para>
1167 </listitem> 1195 </listitem>
1168 1196
1169 <listitem> 1197 <listitem>
1170 <para>When linking shared object (<filename>.so</filename>) 1198 <para>When linking shared object (<filename>.so</filename>)
1171 files, i.e. files that are loaded via &man.dlopen.3;, NOT 1199 files, i.e. files that are loaded via &man.dlopen.3;, NOT
1172 shared libraries, use <quote>-module 1200 shared libraries, use <quote>-module
1173 -avoid-version</quote> to prevent them getting version 1201 -avoid-version</quote> to prevent them getting version
1174 tacked on.</para> 1202 tacked on.</para>
1175 1203
1176 <para>The <filename>PLIST</filename> file gets the 1204 <para>The <filename>PLIST</filename> file gets the
1177 <filename>foo.so</filename> entry.</para> 1205 <filename>foo.so</filename> entry.</para>
1178 </listitem> 1206 </listitem>
1179 1207
1180 <listitem> 1208 <listitem>
1181 <para>When linking programs that depend on these libraries 1209 <para>When linking programs that depend on these libraries
1182 <emphasis>before</emphasis> they are installed, preface 1210 <emphasis>before</emphasis> they are installed, preface
1183 the &man.cc.1; or &man.ld.1; line with <quote>${LIBTOOL} 1211 the &man.cc.1; or &man.ld.1; line with <quote>${LIBTOOL}
1184 --mode=link</quote>, and it will find the correct 1212 --mode=link</quote>, and it will find the correct
1185 libraries (static or shared), but please be aware that 1213 libraries (static or shared), but please be aware that
1186 libtool will not allow you to specify a relative path in 1214 libtool will not allow you to specify a relative path in
1187 -L (such as <quote>-L../somelib</quote>), because it 1215 -L (such as <quote>-L../somelib</quote>), because it
1188 expects you to change that argument to be the 1216 expects you to change that argument to be the
1189 <filename>.la</filename> file. e.g.</para> 1217 <filename>.la</filename> file. e.g.</para>
1190 1218
1191<programlisting> 1219<programlisting>
1192${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib 1220${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
1193</programlisting> 1221</programlisting>
1194 1222
1195 <para>should be changed to:</para> 1223 <para>should be changed to:</para>
1196 1224
1197<programlisting> 1225<programlisting>
1198${LIBTOOL} --mode=link ${CC} -o <replaceable>someprog</replaceable> <replaceable>../somelib/somelib.la</replaceable> 1226${LIBTOOL} --mode=link ${CC} -o <replaceable>someprog</replaceable> <replaceable>../somelib/somelib.la</replaceable>
1199</programlisting> 1227</programlisting>
1200 1228
1201 <para>and it will do the right thing with the libraries.</para> 1229 <para>and it will do the right thing with the libraries.</para>
1202 </listitem> 1230 </listitem>
1203 1231
1204 <listitem> 1232 <listitem>
1205 <para>When installing libraries, preface the &man.install.1; 1233 <para>When installing libraries, preface the &man.install.1;
1206 or &man.cp.1; command with <quote>${LIBTOOL} 1234 or &man.cp.1; command with <quote>${LIBTOOL}
1207 --mode=install</quote>, and change the library name to 1235 --mode=install</quote>, and change the library name to
1208 <filename>.la</filename>. e.g.</para> 1236 <filename>.la</filename>. e.g.</para>
1209 1237
1210<programlisting> 1238<programlisting>
1211${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib 1239${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1212</programlisting> 1240</programlisting>
1213 1241
1214 <para>This will install the static <filename>.a</filename>, 1242 <para>This will install the static <filename>.a</filename>,
1215 shared library, any needed symlinks, and run 1243 shared library, any needed symlinks, and run
1216 &man.ldconfig.8;.</para> 1244 &man.ldconfig.8;.</para>
1217 </listitem> 1245 </listitem>
1218 1246
1219 <listitem> 1247 <listitem>
1220 <para>In your <filename>PLIST</filename>, include only 1248 <para>In your <filename>PLIST</filename>, include only
1221 the <filename>.la</filename> 1249 the <filename>.la</filename>
1222 file (this is a change from previous behaviour).</para> 1250 file (this is a change from previous behaviour).</para>
1223 </listitem> 1251 </listitem>
1224 </orderedlist> 1252 </orderedlist>
1225 </sect2> 1253 </sect2>
1226 1254
1227 1255
1228 <sect2 id="using-libtool"> 1256 <sect2 id="using-libtool">
1229 <title>Using libtool on GNU packages that already support libtool</title> 1257 <title>Using libtool on GNU packages that already support libtool</title>
1230 1258
1231 <para>Add <varname>USE_LIBTOOL=yes</varname> to the 1259 <para>Add <varname>USE_LIBTOOL=yes</varname> to the
1232 package Makefile. This will override the package's own libtool 1260 package Makefile. This will override the package's own libtool
1233 in most cases. For older libtool using packages, libtool is 1261 in most cases. For older libtool using packages, libtool is
1234 made by ltconfig script during the do-configure step; you can 1262 made by ltconfig script during the do-configure step; you can
1235 check the libtool script location by doing <command>make 1263 check the libtool script location by doing <command>make
1236 configure; find work*/ -name libtool</command>.</para> 1264 configure; find work*/ -name libtool</command>.</para>
1237 1265
1238 <para><varname>LIBTOOL_OVERRIDE</varname> specifies which libtool 1266 <para><varname>LIBTOOL_OVERRIDE</varname> specifies which libtool
1239 scripts, relative to <varname>WRKSRC</varname>, to override. By 1267 scripts, relative to <varname>WRKSRC</varname>, to override. By
1240 default, it is set to <quote>libtool */libtool 1268 default, it is set to <quote>libtool */libtool
1241 */*/libtool</quote>. If this does not match the location of the 1269 */*/libtool</quote>. If this does not match the location of the
1242 package's libtool script(s), set it as appropriate.</para> 1270 package's libtool script(s), set it as appropriate.</para>
1243 1271
1244 <para>If you do not need <filename>*.a</filename> static 1272 <para>If you do not need <filename>*.a</filename> static
1245 libraries built and installed, then use 1273 libraries built and installed, then use
1246 <varname>SHLIBTOOL_OVERRIDE</varname> instead.</para> 1274 <varname>SHLIBTOOL_OVERRIDE</varname> instead.</para>
1247 1275
1248 <para>If your package makes use of the platform-independent library 1276 <para>If your package makes use of the platform-independent library
1249 for loading dynamic shared objects, that comes with libtool 1277 for loading dynamic shared objects, that comes with libtool
1250 (libltdl), you should include devel/libltdl/buildlink3.mk.</para> 1278 (libltdl), you should include devel/libltdl/buildlink3.mk.</para>
1251 1279
1252 <para>Some packages use libtool incorrectly so that the package 1280 <para>Some packages use libtool incorrectly so that the package
1253 may not work or build in some circumstances. Some of the more 1281 may not work or build in some circumstances. Some of the more
1254 common errors are:</para> 1282 common errors are:</para>
1255 1283
1256 <itemizedlist> 1284 <itemizedlist>
1257 <listitem> 1285 <listitem>
1258 <para>The inclusion of a shared object (-module) as a dependent library in an 1286 <para>The inclusion of a shared object (-module) as a dependent library in an
1259 executable or library. This in itself isn't a problem if one of two things 1287 executable or library. This in itself isn't a problem if one of two things
1260 has been done:</para> 1288 has been done:</para>
1261 1289
1262 <orderedlist> 1290 <orderedlist>
1263 <listitem> 1291 <listitem>
1264 <para>The shared object is named correctly, i.e. 1292 <para>The shared object is named correctly, i.e.
1265 <filename>libfoo.la</filename>, not 1293 <filename>libfoo.la</filename>, not
1266 <filename>foo.la</filename></para> 1294 <filename>foo.la</filename></para>
1267 </listitem> 1295 </listitem>
1268 1296
1269 <listitem> 1297 <listitem>
1270 <para>The -dlopen option is used when linking an executable.</para> 1298 <para>The -dlopen option is used when linking an executable.</para>
1271 </listitem> 1299 </listitem>
1272 </orderedlist> 1300 </orderedlist>
1273 </listitem> 1301 </listitem>
1274 1302
1275 <listitem> 1303 <listitem>
1276 <para>The use of libltdl without the correct calls to initialisation routines. 1304 <para>The use of libltdl without the correct calls to initialisation routines.
1277 The function lt_dlinit() should be called and the macro 1305 The function lt_dlinit() should be called and the macro
1278 <varname>LTDL_SET_PRELOADED_SYMBOLS</varname> included in 1306 <varname>LTDL_SET_PRELOADED_SYMBOLS</varname> included in
1279 executables.</para> 1307 executables.</para>
1280 </listitem> 1308 </listitem>
1281 </itemizedlist> 1309 </itemizedlist>
1282 </sect2> 1310 </sect2>
1283 1311
1284 1312
1285 <sect2 id="autoconf-automake"> 1313 <sect2 id="autoconf-automake">
1286 <title>GNU Autoconf/Automake</title> 1314 <title>GNU Autoconf/Automake</title>
1287 1315
1288 <para>If a package needs GNU autoconf or automake to be executed 1316 <para>If a package needs GNU autoconf or automake to be executed
1289 to regenerate the configure script and Makefile.in makefile 1317 to regenerate the configure script and Makefile.in makefile
1290 templates, then they should be executed in a pre-configure 1318 templates, then they should be executed in a pre-configure
1291 target.</para> 1319 target.</para>
1292 1320
1293 <para>For packages that need only autoconf:</para> 1321 <para>For packages that need only autoconf:</para>
1294 1322
1295<programlisting> 1323<programlisting>
1296AUTOCONF_REQD= 2.50 # if default version is not good enough 1324AUTOCONF_REQD= 2.50 # if default version is not good enough
1297USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13 1325USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
1298... 1326...
1299 1327
1300pre-configure: 1328pre-configure:
1301 cd ${WRKSRC} &amp;&amp; autoconf 1329 cd ${WRKSRC} &amp;&amp; autoconf
1302 1330
1303... 1331...
1304</programlisting> 1332</programlisting>
1305 1333
1306 <para>and for packages that need automake and autoconf:</para> 1334 <para>and for packages that need automake and autoconf:</para>
1307 1335
1308<programlisting> 1336<programlisting>
1309AUTOMAKE_REQD= 1.7.1 # if default version is not good enough 1337AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
1310USE_TOOLS+= automake # use "automake14" for automake-1.4 1338USE_TOOLS+= automake # use "automake14" for automake-1.4
1311... 1339...
1312 1340
1313pre-configure: 1341pre-configure:
1314 set -e; cd ${WRKSRC}; \ 1342 set -e; cd ${WRKSRC}; \
1315 aclocal; autoheader; automake -a --foreign -i; autoconf 1343 aclocal; autoheader; automake -a --foreign -i; autoconf
1316 1344
1317... 1345...
1318</programlisting> 1346</programlisting>
1319 1347
1320 <para>Packages which use GNU Automake will almost certainly 1348 <para>Packages which use GNU Automake will almost certainly
1321 require GNU Make.</para> 1349 require GNU Make.</para>
1322 1350
1323 <para>There are times when the configure process makes 1351 <para>There are times when the configure process makes
1324 additional changes to the generated files, which then causes 1352 additional changes to the generated files, which then causes
1325 the build process to try to re-execute the automake sequence. 1353 the build process to try to re-execute the automake sequence.
1326 This is prevented by touching various files in the configure 1354 This is prevented by touching various files in the configure
1327 stage. If this causes problems with your package you can set 1355 stage. If this causes problems with your package you can set
1328 <varname>AUTOMAKE_OVERRIDE=NO</varname> in the package 1356 <varname>AUTOMAKE_OVERRIDE=NO</varname> in the package
1329 Makefile.</para> 1357 Makefile.</para>
1330 </sect2> 1358 </sect2>
1331</sect1> 1359</sect1>
1332 1360
1333<sect1 id="programming-languages"> 1361<sect1 id="programming-languages">
1334 <title>Programming languages</title> 1362 <title>Programming languages</title>
1335 1363
1336 <sect2 id="basic-programming-languages"> 1364 <sect2 id="basic-programming-languages">
1337 <title>C, C++, and Fortran</title> 1365 <title>C, C++, and Fortran</title>
1338 1366
1339 <para>Compilers for the C, C++, and Fortran languages comes with 1367 <para>Compilers for the C, C++, and Fortran languages comes with
1340 the NetBSD base system. By default, pkgsrc assumes that a package 1368 the NetBSD base system. By default, pkgsrc assumes that a package
1341 is written in C and will hide all other compilers (via the wrapper 1369 is written in C and will hide all other compilers (via the wrapper
1342 framework, see <xref linkend="buildlink" />).</para> 1370 framework, see <xref linkend="buildlink" />).</para>
1343 1371
1344 <para>To declare which language's compiler a package needs, set 1372 <para>To declare which language's compiler a package needs, set
1345 the <varname>USE_LANGUAGES</varname> variable. Allowed values 1373 the <varname>USE_LANGUAGES</varname> variable. Allowed values
1346 currently are <quote>c</quote>, <quote>c++</quote>, and 1374 currently are <quote>c</quote>, <quote>c++</quote>, and
1347 <quote>fortran</quote> (and any combination). The default is 1375 <quote>fortran</quote> (and any combination). The default is
1348 <quote>c</quote>. Packages using GNU configure scripts, even if 1376 <quote>c</quote>. Packages using GNU configure scripts, even if
1349 written in C++, usually need a C compiler for the configure 1377 written in C++, usually need a C compiler for the configure
1350 phase.</para> 1378 phase.</para>
1351 </sect2> 1379 </sect2>
1352 1380
1353 <sect2 id="java-programming-language"> 1381 <sect2 id="java-programming-language">
1354 <title>Java</title> 1382 <title>Java</title>
1355 1383
1356 <para>If a program is written in Java, use the Java framework in 1384 <para>If a program is written in Java, use the Java framework in
1357 pkgsrc. The package must include 1385 pkgsrc. The package must include
1358 <filename>../../mk/java-vm.mk</filename>. This Makefile fragment 1386 <filename>../../mk/java-vm.mk</filename>. This Makefile fragment
1359 provides the following variables:</para> 1387 provides the following variables:</para>
1360 1388
1361 <itemizedlist> 1389 <itemizedlist>
1362 <listitem><para><varname>USE_JAVA</varname> defines if a build 1390 <listitem><para><varname>USE_JAVA</varname> defines if a build
1363 dependency on the JDK is added. If 1391 dependency on the JDK is added. If
1364 <varname>USE_JAVA</varname> is set to <quote>run</quote>, then 1392 <varname>USE_JAVA</varname> is set to <quote>run</quote>, then
1365 there is only a runtime dependency on the JDK. The default is 1393 there is only a runtime dependency on the JDK. The default is
1366 <quote>yes</quote>, which also adds a build dependency on the 1394 <quote>yes</quote>, which also adds a build dependency on the
1367 JDK.</para></listitem> 1395 JDK.</para></listitem>
1368 1396
1369 <listitem><para>Set <varname>USE_JAVA2</varname> to declare that 1397 <listitem><para>Set <varname>USE_JAVA2</varname> to declare that
1370 a package needs a Java2 implementation. The supported values 1398 a package needs a Java2 implementation. The supported values
1371 are <quote>yes</quote>, <quote>1.4</quote>, and 1399 are <quote>yes</quote>, <quote>1.4</quote>, and
1372 <quote>1.5</quote>. <quote>yes</quote> accepts any Java2 1400 <quote>1.5</quote>. <quote>yes</quote> accepts any Java2
1373 implementation, <quote>1.4</quote> insists on versions 1.4 or 1401 implementation, <quote>1.4</quote> insists on versions 1.4 or
1374 above, and <quote>1.5</quote> only accepts versions 1.5 or 1402 above, and <quote>1.5</quote> only accepts versions 1.5 or
1375 above. This variable is not set by default.</para></listitem> 1403 above. This variable is not set by default.</para></listitem>
1376 1404
1377 <listitem><para><varname>PKG_JAVA_HOME</varname> is 1405 <listitem><para><varname>PKG_JAVA_HOME</varname> is
1378 automatically set to the runtime location of the used Java 1406 automatically set to the runtime location of the used Java
1379 implementation dependency. It may be used to set 1407 implementation dependency. It may be used to set
1380 <varname>JAVA_HOME</varname> to a good value if the program 1408 <varname>JAVA_HOME</varname> to a good value if the program
1381 needs this variable to be defined. 1409 needs this variable to be defined.
1382 </para></listitem> 1410 </para></listitem>
1383 <!-- XXX: describe PKG_JVM_DEFAULT and PKG_JVMS_ACCEPTED, but 1411 <!-- XXX: describe PKG_JVM_DEFAULT and PKG_JVMS_ACCEPTED, but
1384 not here --> 1412 not here -->
1385 </itemizedlist> 1413 </itemizedlist>
1386 </sect2> 1414 </sect2>
1387 1415
1388 <sect2 id="perl-scripts"> 1416 <sect2 id="perl-scripts">
1389 <title>Packages containing perl scripts</title> 1417 <title>Packages containing perl scripts</title>
1390 1418
1391 <para>If your package contains interpreted perl scripts, add 1419 <para>If your package contains interpreted perl scripts, add
1392 <quote>perl</quote> to the <varname>USE_TOOLS</varname> variable 1420 <quote>perl</quote> to the <varname>USE_TOOLS</varname> variable
1393 and set <varname>REPLACE_PERL</varname> to ensure that the proper 1421 and set <varname>REPLACE_PERL</varname> to ensure that the proper
1394 interpreter path is set. <varname>REPLACE_PERL</varname> should 1422 interpreter path is set. <varname>REPLACE_PERL</varname> should
1395 contain a list of scripts, relative to <varname>WRKSRC</varname>, 1423 contain a list of scripts, relative to <varname>WRKSRC</varname>,
1396 that you want adjusted. Every occurrence of 1424 that you want adjusted. Every occurrence of
1397 <filename>*/bin/perl</filename> in a she-bang line will be 1425 <filename>*/bin/perl</filename> in a she-bang line will be
1398 replaced with the full path to the perl executable.</para> 1426 replaced with the full path to the perl executable.</para>
1399 1427
1400 <para>If a particular version of perl is needed, set the 1428 <para>If a particular version of perl is needed, set the
1401 <varname>PERL5_REQD</varname> variable to the version number. The 1429 <varname>PERL5_REQD</varname> variable to the version number. The
1402 default is <quote>5.0</quote>.</para> 1430 default is <quote>5.0</quote>.</para>
1403 1431
1404 <para>See <xref linkend="perl-modules" /> for information 1432 <para>See <xref linkend="perl-modules" /> for information
1405 about handling perl modules.</para> 1433 about handling perl modules.</para>
1406 </sect2> 1434 </sect2>
1407 1435
1408 <sect2 id="shell-scripts"> 1436 <sect2 id="shell-scripts">
1409 <title>Packages containing shell scripts</title> 1437 <title>Packages containing shell scripts</title>
1410 1438
1411 <para><varname>REPLACE_SH</varname>, 1439 <para><varname>REPLACE_SH</varname>,
1412 <varname>REPLACE_BASH</varname>, <varname>REPLACE_CSH</varname>, 1440 <varname>REPLACE_BASH</varname>, <varname>REPLACE_CSH</varname>,
1413 and <varname>REPLACE_KSH</varname> can be used to replace shell 1441 and <varname>REPLACE_KSH</varname> can be used to replace shell
1414 hash bangs in files. Please use the appropriate one, prefering 1442 hash bangs in files. Please use the appropriate one, prefering
1415 <varname>REPLACE_SH</varname> in case this shell is sufficient. 1443 <varname>REPLACE_SH</varname> in case this shell is sufficient.
1416 Each should contain a list of scripts, relative to 1444 Each should contain a list of scripts, relative to
1417 <varname>WRKSRC</varname>, that you want adjusted. Every 1445 <varname>WRKSRC</varname>, that you want adjusted. Every
1418 occurrence of the matching shell in a she-bang line will be 1446 occurrence of the matching shell in a she-bang line will be
1419 replaced with the full path to the shell executable. 1447 replaced with the full path to the shell executable.
1420 When using <varname>REPLACE_BASH</varname>, don't forget to add 1448 When using <varname>REPLACE_BASH</varname>, don't forget to add
1421 <filename>bash</filename> to <varname>USE_TOOLS</varname>.</para> 1449 <filename>bash</filename> to <varname>USE_TOOLS</varname>.</para>
1422 </sect2> 1450 </sect2>
1423 1451
1424 <sect2 id="other-programming-languages"> 1452 <sect2 id="other-programming-languages">
1425 <title>Other programming languages</title> 1453 <title>Other programming languages</title>
1426 1454
1427 <para>Currently, there is no special handling for other languages 1455 <para>Currently, there is no special handling for other languages
1428 in pkgsrc. If a compiler package provides a 1456 in pkgsrc. If a compiler package provides a
1429 <filename>buildlink3.mk</filename> file, include that, otherwise 1457 <filename>buildlink3.mk</filename> file, include that, otherwise
1430 just add a (build) dependency on the appropriate compiler 1458 just add a (build) dependency on the appropriate compiler
1431 package.</para> 1459 package.</para>
1432 </sect2> 1460 </sect2>
1433</sect1> 1461</sect1>
1434 1462
1435<sect1 id="fixes.build"> 1463<sect1 id="fixes.build">
1436 <title>The <emphasis>build</emphasis> phase</title> 1464 <title>The <emphasis>build</emphasis> phase</title>
1437 1465
1438 <para>The most common failures when building a package are that 1466 <para>The most common failures when building a package are that
1439 some platforms do not provide certain header files, functions or 1467 some platforms do not provide certain header files, functions or
1440 libraries, or they provide the functions in a library that the 1468 libraries, or they provide the functions in a library that the
1441 original package author didn't know. To work around this, you 1469 original package author didn't know. To work around this, you
1442 can rewrite the source code in most cases so that it does not 1470 can rewrite the source code in most cases so that it does not
1443 use the missing functions or provides a replacement function.</para> 1471 use the missing functions or provides a replacement function.</para>
1444 1472
1445<sect2 id="fixes.build.cpp"> 1473<sect2 id="fixes.build.cpp">
1446<title>Compiling C and C++ code conditionally</title> 1474<title>Compiling C and C++ code conditionally</title>
1447 1475
1448 <para>If a package already comes with a GNU configure script, the 1476 <para>If a package already comes with a GNU configure script, the
1449 preferred way to fix the build failure is to change the 1477 preferred way to fix the build failure is to change the
1450 configure script, not the code. In the other cases, you can 1478 configure script, not the code. In the other cases, you can
1451 utilize the C preprocessor, which defines certain macros 1479 utilize the C preprocessor, which defines certain macros
1452 depending on the operating system and hardware architecture it 1480 depending on the operating system and hardware architecture it
1453 compiles for. These macros can be queried using for example 1481 compiles for. These macros can be queried using for example
1454 <varname>#if defined(__i386)</varname>. Almost every operating 1482 <varname>#if defined(__i386)</varname>. Almost every operating
1455 system, hardware architecture and compiler has its own macro. 1483 system, hardware architecture and compiler has its own macro.
1456 For example, if the macros <varname>__GNUC__</varname>, 1484 For example, if the macros <varname>__GNUC__</varname>,
1457 <varname>__i386__</varname> and <varname>__NetBSD__</varname> 1485 <varname>__i386__</varname> and <varname>__NetBSD__</varname>
1458 are all defined, you know that you are using NetBSD on an i386 1486 are all defined, you know that you are using NetBSD on an i386
1459 compatible CPU, and your compiler is GCC.</para> 1487 compatible CPU, and your compiler is GCC.</para>
1460 1488
1461 <para>The list of the following macros for hardware and 1489 <para>The list of the following macros for hardware and
1462 operating system depends on the compiler that is used. For 1490 operating system depends on the compiler that is used. For
1463 example, if you want to conditionally compile code on Solaris, 1491 example, if you want to conditionally compile code on Solaris,
1464 don't use <varname>__sun__</varname>, as the SunPro compiler 1492 don't use <varname>__sun__</varname>, as the SunPro compiler
1465 does not define it. Use <varname>__sun</varname> instead.</para> 1493 does not define it. Use <varname>__sun</varname> instead.</para>
1466 1494
1467<sect3 id="fixes.build.cpp.os"> 1495<sect3 id="fixes.build.cpp.os">
1468<title>C preprocessor macros to identify the operating system</title> 1496<title>C preprocessor macros to identify the operating system</title>
1469 1497
1470 <para>To distinguish between 4.4 BSD-derived systems and the 1498 <para>To distinguish between 4.4 BSD-derived systems and the
1471 rest of the world, you should use the following code.</para> 1499 rest of the world, you should use the following code.</para>
1472 1500
1473<programlisting> 1501<programlisting>
1474#include &lt;sys/param.h&gt; 1502#include &lt;sys/param.h&gt;
1475#if (defined(BSD) &amp;&amp; BSD &gt;= 199306) 1503#if (defined(BSD) &amp;&amp; BSD &gt;= 199306)
1476/* BSD-specific code goes here */ 1504/* BSD-specific code goes here */
1477#else 1505#else
1478/* non-BSD-specific code goes here */ 1506/* non-BSD-specific code goes here */
1479#endif 1507#endif
1480</programlisting> 1508</programlisting>
1481 1509
1482 <para>If this distinction is not fine enough, you can also test 1510 <para>If this distinction is not fine enough, you can also test
1483 for the following macros.</para> 1511 for the following macros.</para>
1484 1512
1485<programlisting> 1513<programlisting>
1486Cygwin __CYGWIN__ 1514Cygwin __CYGWIN__
1487DragonFly __DragonFly__ 1515DragonFly __DragonFly__
1488FreeBSD __FreeBSD__ 1516FreeBSD __FreeBSD__
1489Haiku __HAIKU__ 1517Haiku __HAIKU__
1490Interix __INTERIX 1518Interix __INTERIX
1491IRIX __sgi (TODO: get a definite source for this) 1519IRIX __sgi (TODO: get a definite source for this)
1492Linux linux, __linux, __linux__ 1520Linux linux, __linux, __linux__
1493Mac OS X __APPLE__ 1521Mac OS X __APPLE__
1494MirBSD __MirBSD__ (__OpenBSD__ is also defined) 1522MirBSD __MirBSD__ (__OpenBSD__ is also defined)
1495Minix3 __minix 1523Minix3 __minix
1496NetBSD __NetBSD__ 1524NetBSD __NetBSD__
1497OpenBSD __OpenBSD__ 1525OpenBSD __OpenBSD__
1498Solaris sun, __sun 1526Solaris sun, __sun
1499</programlisting> 1527</programlisting>
1500 1528
1501</sect3> 1529</sect3>
1502<sect3 id="fixes.build.cpp.arch"> 1530<sect3 id="fixes.build.cpp.arch">
1503<title>C preprocessor macros to identify the hardware architecture</title> 1531<title>C preprocessor macros to identify the hardware architecture</title>
1504 1532
1505<programlisting> 1533<programlisting>
1506i386 i386, __i386, __i386__ 1534i386 i386, __i386, __i386__
1507MIPS __mips 1535MIPS __mips
1508SPARC sparc, __sparc 1536SPARC sparc, __sparc
1509</programlisting> 1537</programlisting>
1510 1538
1511</sect3> 1539</sect3>
1512<sect3 id="fixes.build.cpp.compiler"> 1540<sect3 id="fixes.build.cpp.compiler">
1513<title>C preprocessor macros to identify the compiler</title> 1541<title>C preprocessor macros to identify the compiler</title>
1514 1542
1515<programlisting> 1543<programlisting>
1516GCC __GNUC__ (major version), __GNUC_MINOR__ 1544GCC __GNUC__ (major version), __GNUC_MINOR__
1517MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41) 1545MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
1518SunPro __SUNPRO_C (0x570 for Sun C 5.7) 1546SunPro __SUNPRO_C (0x570 for Sun C 5.7)
1519SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8) 1547SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
1520</programlisting> 1548</programlisting>
1521 1549
1522</sect3> 1550</sect3>
1523</sect2> 1551</sect2>
1524<sect2 id="compiler-bugs"> 1552<sect2 id="compiler-bugs">
1525<title>How to handle compiler bugs</title> 1553<title>How to handle compiler bugs</title>
1526 1554
1527 <para>Some source files trigger bugs in the compiler, based on 1555 <para>Some source files trigger bugs in the compiler, based on
1528 combinations of compiler version and architecture and almost 1556 combinations of compiler version and architecture and almost
1529 always relation to optimisation being enabled. Common symptoms 1557 always relation to optimisation being enabled. Common symptoms
1530 are gcc internal errors or never finishing compiling a 1558 are gcc internal errors or never finishing compiling a
1531 file.</para> 1559 file.</para>
1532 1560
1533 <para>Typically, a workaround involves testing the 1561 <para>Typically, a workaround involves testing the
1534 <varname>MACHINE_ARCH</varname> and compiler version, disabling 1562 <varname>MACHINE_ARCH</varname> and compiler version, disabling
1535 optimisation for that combination of file, 1563 optimisation for that combination of file,
1536 <varname>MACHINE_ARCH</varname> and compiler.</para> 1564 <varname>MACHINE_ARCH</varname> and compiler.</para>
1537 1565
1538 <para>This used to be a big problem in the past, but is rarely 1566 <para>This used to be a big problem in the past, but is rarely
1539 needed now as compiler technology has matured. If you still need 1567 needed now as compiler technology has matured. If you still need
1540 to add a compiler specific workaround, please do so in the file 1568 to add a compiler specific workaround, please do so in the file
1541 <filename>hacks.mk</filename> and describe the symptom and 1569 <filename>hacks.mk</filename> and describe the symptom and
1542 compiler version as detailed as possible.</para> 1570 compiler version as detailed as possible.</para>
1543 1571
1544</sect2> 1572</sect2>
1545 1573
1546<sect2 id="fixes.build.header"> 1574<sect2 id="fixes.build.header">
1547<title>No such file or directory</title> 1575<title>No such file or directory</title>
1548 1576
1549<para>Compilation sometimes fails with an error message like this:</para> 1577<para>Compilation sometimes fails with an error message like this:</para>
1550 1578
1551<programlisting> 1579<programlisting>
1552.../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10: 1580.../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
1553 fatal error: pango/pango.h: No such file or directory 1581 fatal error: pango/pango.h: No such file or directory
1554</programlisting> 1582</programlisting>
1555 1583
1556<para>The proper way to fix this problem depends on the type of the 1584<para>The proper way to fix this problem depends on the type of the
1557header, which is described in the following sections.</para> 1585header, which is described in the following sections.</para>
1558 1586
1559<sect3 id="fixes.build.header.bl3"> 1587<sect3 id="fixes.build.header.bl3">
1560<title>Headers from other packages</title> 1588<title>Headers from other packages</title>
1561 1589
1562<para>If the header name looks like it comes from a different package, 1590<para>If the header name looks like it comes from a different package,
1563that other package should be included via the buildlink3 1591that other package should be included via the buildlink3
1564framework.</para> 1592framework.</para>
1565 1593
1566<para>First, look whether the header is somewhere in the buildlink3 1594<para>First, look whether the header is somewhere in the buildlink3
1567directory below <varname>WRKDIR</varname>. In the above case of 1595directory below <varname>WRKDIR</varname>. In the above case of
1568the missing Pango header:</para> 1596the missing Pango header:</para>
1569 1597
1570<programlisting> 1598<programlisting>
1571&uprompt; find work/.buildlink/ -print | grep -F pango/pango.h 1599&uprompt; find work/.buildlink/ -print | grep -F pango/pango.h
1572</programlisting> 1600</programlisting>
1573 1601
1574<para>In the case of Pango, the output is:</para> 1602<para>In the case of Pango, the output is:</para>
1575 1603
1576<programlisting> 1604<programlisting>
1577work/.buildlink/include/pango-1.0/pango/pango.h 1605work/.buildlink/include/pango-1.0/pango/pango.h
1578</programlisting> 1606</programlisting>
1579 1607
1580<para>If the <filename>pango/pango.h</filename> file were placed directly 1608<para>If the <filename>pango/pango.h</filename> file were placed directly
1581in the <filename>.buildlink</filename> directory, it would have been 1609in the <filename>.buildlink</filename> directory, it would have been
1582found automatically. There is an extra <filename>pango-1.0</filename> 1610found automatically. There is an extra <filename>pango-1.0</filename>
1583path component though, which means that the compiler command line must 1611path component though, which means that the compiler command line must
1584contain an option of the form 1612contain an option of the form
1585<literal>-I${BUILDLINK3_PREFIX.pango}/include/pango-1.0</literal>. In 1613<literal>-I${BUILDLINK3_PREFIX.pango}/include/pango-1.0</literal>. In
1586most cases this option is generated by the configure script, which can be examined using:</para> 1614most cases this option is generated by the configure script, which can be examined using:</para>
1587 1615
1588<programlisting> 1616<programlisting>
1589&uprompt; $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile 1617&uprompt; $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
1590-I/usr/pkg/include/pango-1.0 1618-I/usr/pkg/include/pango-1.0
1591-I/usr/pkg/include/pango-1.0 1619-I/usr/pkg/include/pango-1.0
1592-I/usr/pkg/include/pango-1.0 1620-I/usr/pkg/include/pango-1.0
1593-I/usr/pkg/include/pango-1.0 1621-I/usr/pkg/include/pango-1.0
1594-I/usr/pkg/include/pango-1.0 1622-I/usr/pkg/include/pango-1.0
1595</programlisting> 1623</programlisting>
1596 1624
1597<para>This looks good. These options are transformed by the buildlink 1625<para>This looks good. These options are transformed by the buildlink
1598wrapper to refer to the correct path inside 1626wrapper to refer to the correct path inside
1599<filename>work/.buildlink</filename>.</para> 1627<filename>work/.buildlink</filename>.</para>
1600 1628
1601<para>Since the compilation fails though, examine the compiler command 1629<para>Since the compilation fails though, examine the compiler command
1602lines in <filename>work/.work.log</filename> to see whether the 1630lines in <filename>work/.work.log</filename> to see whether the
1603<literal>-I</literal> option is included in the particular command 1631<literal>-I</literal> option is included in the particular command
1604line.</para> 1632line.</para>
1605 1633
1606<para>To further analyze the situation, run <command>bmake 1634<para>To further analyze the situation, run <command>bmake
1607build-env</command>, which sets up an interactive, realistic environment 1635build-env</command>, which sets up an interactive, realistic environment
1608including all the pkgsrc wrapper commands and environment variables. From 1636including all the pkgsrc wrapper commands and environment variables. From
1609there, try to compile some simple example programs that use the 1637there, try to compile some simple example programs that use the
1610header.</para> 1638header.</para>
1611 1639
1612</sect3> 1640</sect3>
1613 1641
1614<sect3 id="fixes.build.header.gen"> 1642<sect3 id="fixes.build.header.gen">
1615<title>Headers generated during the build</title> 1643<title>Headers generated during the build</title>
1616 1644
1617<para>If the name of the header seems to come from the package itself, 1645<para>If the name of the header seems to come from the package itself,
1618and if the build is run with parallel jobs, the package may have some 1646and if the build is run with parallel jobs, the package may have some
1619undeclared dependencies between the <filename>.c</filename> and the 1647undeclared dependencies between the <filename>.c</filename> and the
1620<filename>.h</filename> files, and a C file is compiled before its 1648<filename>.h</filename> files, and a C file is compiled before its
1621required header is generated.</para> 1649required header is generated.</para>
1622 1650
1623<para>To see whether the build runs with parallel jobs, run 1651<para>To see whether the build runs with parallel jobs, run
1624<command>bmake show-all-build | grep JOBS</command>. Its output looks 1652<command>bmake show-all-build | grep JOBS</command>. Its output looks
1625like this:</para> 1653like this:</para>
1626 1654
1627<programlisting> 1655<programlisting>
1628 usr MAKE_JOBS= 7 1656 usr MAKE_JOBS= 7
1629 pkg MAKE_JOBS_SAFE # undefined 1657 pkg MAKE_JOBS_SAFE # undefined
1630 def _MAKE_JOBS_N= 7 1658 def _MAKE_JOBS_N= 7
1631</programlisting> 1659</programlisting>
1632 1660
1633<para>In this case the pkgsrc user has asked pkgsrc to build packages 1661<para>In this case the pkgsrc user has asked pkgsrc to build packages
1634with 7 jobs in parallel (<varname>MAKE_JOBS</varname>). The 1662with 7 jobs in parallel (<varname>MAKE_JOBS</varname>). The
1635package could have disabled parallel builds by setting 1663package could have disabled parallel builds by setting
1636<varname>MAKE_JOBS_SAFE</varname> to <literal>no</literal>, but 1664<varname>MAKE_JOBS_SAFE</varname> to <literal>no</literal>, but
1637in this case it hasn't.</para> 1665in this case it hasn't.</para>
1638 1666
1639<para>To see whether the build failure is caused by parallel builds, 1667<para>To see whether the build failure is caused by parallel builds,
1640first save the exact error message and a bit of context, maybe you need 1668first save the exact error message and a bit of context, maybe you need
1641it later for reporting a bug. Next, run:</para> 1669it later for reporting a bug. Next, run:</para>
1642 1670
1643<programlisting> 1671<programlisting>
1644MAKE_JOBS_SAFE=no bmake clean build 1672MAKE_JOBS_SAFE=no bmake clean build
1645</programlisting> 1673</programlisting>
1646 1674
1647<para>If that succeeds, <ulink 1675<para>If that succeeds, <ulink
1648url="https://www.NetBSD.org/cgi-bin/sendpr.cgi?gndb=netbsd">file a bug 1676url="https://www.NetBSD.org/cgi-bin/sendpr.cgi?gndb=netbsd">file a bug
1649report</ulink> against the pkgsrc package, including the exact error 1677report</ulink> against the pkgsrc package, including the exact error
1650message and the contents of your &mk.conf; file.</para> 1678message and the contents of your &mk.conf; file.</para>
1651 1679
1652</sect3> 1680</sect3>
1653 1681
1654<sect3 id="fixes.build.header.symlink"> 1682<sect3 id="fixes.build.header.symlink">
1655<title>Symlinks</title> 1683<title>Symlinks</title>
1656 1684
1657<para>Pkgsrc does not work reliably if any of 1685<para>Pkgsrc does not work reliably if any of
1658<varname>LOCALBASE</varname>, <varname>VARBASE</varname> or 1686<varname>LOCALBASE</varname>, <varname>VARBASE</varname> or
1659<varname>WRKDIR</varname> contains a symlink. Since 2019Q2, the pkgsrc 1687<varname>WRKDIR</varname> contains a symlink. Since 2019Q2, the pkgsrc
1660bootstrap program prevents installing pkgsrc in symlink-based 1688bootstrap program prevents installing pkgsrc in symlink-based
1661directories. Existing pkgsrc installations are not checked for symlinks 1689directories. Existing pkgsrc installations are not checked for symlinks
1662though.</para> 1690though.</para>
1663 1691
1664<para>The "No such file or directory" error messages are a typical 1692<para>The "No such file or directory" error messages are a typical
1665symptom of symlinks, and it's quite difficult to find out that this is 1693symptom of symlinks, and it's quite difficult to find out that this is
1666the actual cause.</para> 1694the actual cause.</para>
1667 1695
1668</sect3> 1696</sect3>
1669 1697
1670<sect3 id="fixes.build.header.stale"> 1698<sect3 id="fixes.build.header.stale">
1671<title>Stale working directories</title> 1699<title>Stale working directories</title>
1672 1700
1673<para>When building a hierarchy of packages, it may happen that one 1701<para>When building a hierarchy of packages, it may happen that one
1674package is built and then pkgsrc is updated. This situation can provoke 1702package is built and then pkgsrc is updated. This situation can provoke
1675various hard to diagnose build errors. To clean up the situation:</para> 1703various hard to diagnose build errors. To clean up the situation:</para>
1676 1704
1677<programlisting> 1705<programlisting>
1678&uprompt; (cd ../../ && test -f mk/bsd.pkg.mk && rm -rf */*/work) 1706&uprompt; (cd ../../ && test -f mk/bsd.pkg.mk && rm -rf */*/work)
1679</programlisting> 1707</programlisting>
1680 1708
1681<para>(The test for <filename>bsd.pkg.mk</filename> just prevents running 1709<para>(The test for <filename>bsd.pkg.mk</filename> just prevents running
1682this command in the wrong directory.)</para> 1710this command in the wrong directory.)</para>
1683 1711
1684<para>If you have set <varname>WRKOBJDIR</varname> in &mk.conf;, remove 1712<para>If you have set <varname>WRKOBJDIR</varname> in &mk.conf;, remove
1685that directory as well.</para> 1713that directory as well.</para>
1686 1714
1687</sect3> 1715</sect3>
1688 1716
1689<sect3 id="fixes.build.header.misc"> 1717<sect3 id="fixes.build.header.misc">
1690<title>Other possible reasons</title> 1718<title>Other possible reasons</title>
1691 1719
1692<para>On platforms other than BSD, third-party packages are installed in 1720<para>On platforms other than BSD, third-party packages are installed in
1693<filename>/usr/include</filename>, together with the base system. This 1721<filename>/usr/include</filename>, together with the base system. This
1694means that pkgsrc cannot distinguish between headers provided by the base 1722means that pkgsrc cannot distinguish between headers provided by the base
1695system (which it needs) and headers from third-party packages (which are 1723system (which it needs) and headers from third-party packages (which are
1696often included in pkgsrc as well). This can lead to subtle version 1724often included in pkgsrc as well). This can lead to subtle version
1697mismatches.</para> 1725mismatches.</para>
1698 1726
1699<para>In pkgsrc installations that have been active for several years, it 1727<para>In pkgsrc installations that have been active for several years, it
1700may happen that some files are manually deleted. To exclude this unlikely 1728may happen that some files are manually deleted. To exclude this unlikely
1701reason, run <command>pkg_admin check</command>.</para> 1729reason, run <command>pkg_admin check</command>.</para>
1702 1730
1703<para>It may help to run <command>pkg_admin rebuild-tree</command> to 1731<para>It may help to run <command>pkg_admin rebuild-tree</command> to
1704check/fix dependencies.</para> 1732check/fix dependencies.</para>
1705 1733
1706<para>If all of the above doesn't help, see <xref linkend="help-user"/> 1734<para>If all of the above doesn't help, see <xref linkend="help-user"/>
1707for contact information. Be prepared to describe what you have tried so 1735for contact information. Be prepared to describe what you have tried so
1708far and what any error messages were.</para> 1736far and what any error messages were.</para>
1709 1737
1710</sect3> 1738</sect3>
1711 1739
1712</sect2> 1740</sect2>
1713 1741
1714<sect2 id="undefined-reference"> 1742<sect2 id="undefined-reference">
1715<title>Undefined reference to <quote>...</quote></title> 1743<title>Undefined reference to <quote>...</quote></title>
1716 1744
1717 <para>This error message often means that a package did not 1745 <para>This error message often means that a package did not
1718 link to a shared library it needs. The following functions are 1746 link to a shared library it needs. The following functions are
1719 known to cause this error message over and over.</para> 1747 known to cause this error message over and over.</para>
1720 1748
1721 <informaltable id="undefined-reference-functions"> 1749 <informaltable id="undefined-reference-functions">
1722 <tgroup cols="3"> 1750 <tgroup cols="3">
1723 <thead><row><entry>Function</entry><entry>Library</entry><entry>Affected platforms</entry></row></thead> 1751 <thead><row><entry>Function</entry><entry>Library</entry><entry>Affected platforms</entry></row></thead>
1724 <tbody> 1752 <tbody>
1725 <row><entry>accept, bind, connect</entry><entry>-lsocket</entry><entry>Solaris</entry></row> 1753 <row><entry>accept, bind, connect</entry><entry>-lsocket</entry><entry>Solaris</entry></row>
1726 <row><entry>crypt</entry><entry>-lcrypt</entry><entry>DragonFly, NetBSD</entry></row> 1754 <row><entry>crypt</entry><entry>-lcrypt</entry><entry>DragonFly, NetBSD</entry></row>
1727 <row><entry>dlopen, dlsym</entry><entry>-ldl</entry><entry>Linux</entry></row> 1755 <row><entry>dlopen, dlsym</entry><entry>-ldl</entry><entry>Linux</entry></row>
1728 <row><entry>gethost*</entry><entry>-lnsl</entry><entry>Solaris</entry></row> 1756 <row><entry>gethost*</entry><entry>-lnsl</entry><entry>Solaris</entry></row>
1729 <row><entry>inet_aton</entry><entry>-lresolv</entry><entry>Solaris</entry></row> 1757 <row><entry>inet_aton</entry><entry>-lresolv</entry><entry>Solaris</entry></row>
1730 <row><entry>nanosleep, sem_*, timer_*</entry><entry>-lrt</entry><entry>Solaris</entry></row> 1758 <row><entry>nanosleep, sem_*, timer_*</entry><entry>-lrt</entry><entry>Solaris</entry></row>
1731 <row><entry>openpty</entry><entry>-lutil</entry><entry>Linux</entry></row> 1759 <row><entry>openpty</entry><entry>-lutil</entry><entry>Linux</entry></row>
1732 </tbody> 1760 </tbody>
1733 </tgroup> 1761 </tgroup>
1734 </informaltable> 1762 </informaltable>
1735 1763
1736 <para>To fix these linker errors, it is often sufficient to say 1764 <para>To fix these linker errors, it is often sufficient to say
1737 <literal>LIBS.<replaceable>OperatingSystem</replaceable>+= 1765 <literal>LIBS.<replaceable>OperatingSystem</replaceable>+=
1738 -l<replaceable>foo</replaceable></literal> to the package 1766 -l<replaceable>foo</replaceable></literal> to the package
1739 <filename>Makefile</filename> and then say <command>bmake clean; 1767 <filename>Makefile</filename> and then say <command>bmake clean;
1740 bmake</command>.</para> 1768 bmake</command>.</para>
1741 1769
1742<sect3 id="undefined-reference-sunpro"> 1770<sect3 id="undefined-reference-sunpro">
1743<title>Special issue: The SunPro compiler</title> 1771<title>Special issue: The SunPro compiler</title>
1744 1772
1745<para>When you are using the SunPro compiler, there is another 1773<para>When you are using the SunPro compiler, there is another
1746possibility. That compiler cannot handle the following code:</para> 1774possibility. That compiler cannot handle the following code:</para>
1747 1775
1748<programlisting> 1776<programlisting>
1749extern int extern_func(int); 1777extern int extern_func(int);
1750 1778
1751static inline int 1779static inline int
1752inline_func(int x) 1780inline_func(int x)
1753{ 1781{
1754 return extern_func(x); 1782 return extern_func(x);
1755} 1783}
1756 1784
1757int main(void) 1785int main(void)
1758{ 1786{
1759 return 0; 1787 return 0;
1760} 1788}
1761</programlisting> 1789</programlisting>
1762 1790
1763<para>It generates the code for <function>inline_func</function> even if 1791<para>It generates the code for <function>inline_func</function> even if
1764that function is never used. This code then refers to 1792that function is never used. This code then refers to
1765<function>extern_func</function>, which can usually not be resolved. To 1793<function>extern_func</function>, which can usually not be resolved. To
1766solve this problem you can try to tell the package to disable inlining 1794solve this problem you can try to tell the package to disable inlining
1767of functions.</para> 1795of functions.</para>
1768 1796
1769</sect3> 1797</sect3>
1770 1798
1771 </sect2> 1799 </sect2>
1772 1800
1773 <sect2 id="out-of-memory"> 1801 <sect2 id="out-of-memory">
1774 <title>Running out of memory</title> 1802 <title>Running out of memory</title>
1775 1803
1776 <para>Sometimes packages fail to build because the compiler runs 1804 <para>Sometimes packages fail to build because the compiler runs
1777 into an operating system specific soft limit. With the 1805 into an operating system specific soft limit. With the
1778 <varname>UNLIMIT_RESOURCES</varname> variable pkgsrc can be told 1806 <varname>UNLIMIT_RESOURCES</varname> variable pkgsrc can be told
1779 to unlimit the resources. Currently, the allowed values are any combination of 1807 to unlimit the resources. Currently, the allowed values are any combination of
1780 <quote>cputime</quote>, <quote>datasize</quote>, 1808 <quote>cputime</quote>, <quote>datasize</quote>,
1781 <quote>memorysize</quote>, and <quote>stacksize</quote>. 1809 <quote>memorysize</quote>, and <quote>stacksize</quote>.
1782 Setting this variable is similar to running the shell builtin 1810 Setting this variable is similar to running the shell builtin
1783 <command>ulimit</command> command to raise the maximum data 1811 <command>ulimit</command> command to raise the maximum data
1784 segment size or maximum stack size of a process, respectively, to 1812 segment size or maximum stack size of a process, respectively, to
1785 their hard limits.</para> 1813 their hard limits.</para>
1786 </sect2> 1814 </sect2>
1787</sect1> 1815</sect1>
1788 1816
1789<sect1 id="fixes.install"> 1817<sect1 id="fixes.install">
1790 <title>The <emphasis>install</emphasis> phase</title> 1818 <title>The <emphasis>install</emphasis> phase</title>
1791 1819
1792 <sect2 id="install-scripts"> 1820 <sect2 id="install-scripts">
1793 <title>Creating needed directories</title> 1821 <title>Creating needed directories</title>
1794 1822
1795 <para>The BSD-compatible <command>install</command> supplied 1823 <para>The BSD-compatible <command>install</command> supplied
1796 with some operating systems cannot create more than one 1824 with some operating systems cannot create more than one
1797 directory at a time. As such, you should call 1825 directory at a time. As such, you should call
1798 <literal>${INSTALL_*_DIR}</literal> like this:</para> 1826 <literal>${INSTALL_*_DIR}</literal> like this:</para>
1799 1827
1800<programlisting> 1828<programlisting>
1801${INSTALL_DATA_DIR} ${PREFIX}/dir1 1829${INSTALL_DATA_DIR} ${PREFIX}/dir1
1802${INSTALL_DATA_DIR} ${PREFIX}/dir2 1830${INSTALL_DATA_DIR} ${PREFIX}/dir2
1803</programlisting> 1831</programlisting>
1804 1832
1805 <para>You can also just append <quote><literal>dir1 1833 <para>You can also just append <quote><literal>dir1
1806 dir2</literal></quote> to the 1834 dir2</literal></quote> to the
1807 <varname>INSTALLATION_DIRS</varname> variable, which will 1835 <varname>INSTALLATION_DIRS</varname> variable, which will
1808 automatically do the right thing.</para> 1836 automatically do the right thing.</para>
1809 1837
1810 </sect2> 1838 </sect2>
1811 <sect2 id="where-to-install-documentation"> 1839 <sect2 id="where-to-install-documentation">
1812 <title>Where to install documentation</title> 1840 <title>Where to install documentation</title>
1813 1841
1814 <para>In general, documentation should be installed into 1842 <para>In general, documentation should be installed into
1815 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or 1843 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or
1816 <filename>${PREFIX}/share/doc/${PKGNAME}</filename> (the latter 1844 <filename>${PREFIX}/share/doc/${PKGNAME}</filename> (the latter
1817 includes the version number of the package).</para> 1845 includes the version number of the package).</para>
1818 1846
1819 <para>Many modern packages using GNU autoconf allow to set the 1847 <para>Many modern packages using GNU autoconf allow to set the
1820 directory where HTML documentation is installed with the 1848 directory where HTML documentation is installed with the
1821 <quote>--with-html-dir</quote> option. Sometimes using this flag 1849 <quote>--with-html-dir</quote> option. Sometimes using this flag
1822 is needed because otherwise the documentation ends up in 1850 is needed because otherwise the documentation ends up in
1823 <filename>${PREFIX}/share/doc/html</filename> or other 1851 <filename>${PREFIX}/share/doc/html</filename> or other
1824 places.</para> 1852 places.</para>
1825 1853
1826 <para>An exception to the above is that library API documentation 1854 <para>An exception to the above is that library API documentation
1827 generated with the <filename 1855 generated with the <filename
1828 role="pkg">textproc/gtk-doc</filename> tools, for use by special 1856 role="pkg">textproc/gtk-doc</filename> tools, for use by special
1829 browsers (devhelp) should be left at their default location, which 1857 browsers (devhelp) should be left at their default location, which
1830 is <filename>${PREFIX}/share/gtk-doc</filename>. Such 1858 is <filename>${PREFIX}/share/gtk-doc</filename>. Such
1831 documentation can be recognized from files ending in 1859 documentation can be recognized from files ending in
1832 <filename>.devhelp</filename> or <filename>.devhelp2</filename>. 1860 <filename>.devhelp</filename> or <filename>.devhelp2</filename>.
1833 (It is also acceptable to install such files in 1861 (It is also acceptable to install such files in
1834 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or 1862 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or
1835 <filename>${PREFIX}/share/doc/${PKGNAME}</filename>; the 1863 <filename>${PREFIX}/share/doc/${PKGNAME}</filename>; the
1836 <filename>.devhelp*</filename> file must be directly in that 1864 <filename>.devhelp*</filename> file must be directly in that
1837 directory then, no additional subdirectory level is allowed in 1865 directory then, no additional subdirectory level is allowed in
1838 this case. This is usually achieved by using 1866 this case. This is usually achieved by using
1839 <quote>--with-html-dir=${PREFIX}/share/doc</quote>. 1867 <quote>--with-html-dir=${PREFIX}/share/doc</quote>.
1840 <filename>${PREFIX}/share/gtk-doc</filename> is preferred 1868 <filename>${PREFIX}/share/gtk-doc</filename> is preferred
1841 though.)</para> 1869 though.)</para>
1842 1870
1843 </sect2> 1871 </sect2>
1844 1872
1845 <sect2 id="installing-score-files"> 1873 <sect2 id="installing-score-files">
1846 <title>Installing highscore files</title> 1874 <title>Installing highscore files</title>
1847 1875
1848 <para>Certain packages, most of them in the games category, install 1876 <para>Certain packages, most of them in the games category, install
1849 a score file that allows all users on the system to record their 1877 a score file that allows all users on the system to record their
1850 highscores. In order for this to work, the binaries need to be 1878 highscores. In order for this to work, the binaries need to be
1851 installed setgid and the score files owned by the appropriate 1879 installed setgid and the score files owned by the appropriate
1852 group and/or owner (traditionally the "games" user/group). Set 1880 group and/or owner (traditionally the "games" user/group). Set
1853 <varname>USE_GAMESGROUP</varname> to yes to support this. The 1881 <varname>USE_GAMESGROUP</varname> to yes to support this. The
1854 following variables, documented in more detail in 1882 following variables, documented in more detail in
1855 <filename>mk/defaults/mk.conf</filename>, control this 1883 <filename>mk/defaults/mk.conf</filename>, control this
1856 behaviour: <varname>GAMEDATAMODE</varname>, 1884 behaviour: <varname>GAMEDATAMODE</varname>,
1857 <varname>GAMEDIRMODE</varname>, <varname>GAMES_GROUP</varname>, 1885 <varname>GAMEDIRMODE</varname>, <varname>GAMES_GROUP</varname>,
1858 <varname>GAMEMODE</varname>, <varname>GAME_USER</varname>. 1886 <varname>GAMEMODE</varname>, <varname>GAME_USER</varname>.
1859 Other useful variables are: <varname>GAMEDIR_PERMS</varname>, 1887 Other useful variables are: <varname>GAMEDIR_PERMS</varname>,
1860 <varname>GAMEDATA_PERMS</varname> and 1888 <varname>GAMEDATA_PERMS</varname> and
1861 <varname>SETGID_GAMES_PERMS</varname>.</para> 1889 <varname>SETGID_GAMES_PERMS</varname>.</para>
1862 1890
1863 <para>An example that illustrates some of the variables described above is 1891 <para>An example that illustrates some of the variables described above is
1864 <filename>games/moon-buggy</filename>. <varname>OWN_DIRS_PERMS</varname> is 1892 <filename>games/moon-buggy</filename>. <varname>OWN_DIRS_PERMS</varname> is
1865 used to properly set directory permissions of the directory where the 1893 used to properly set directory permissions of the directory where the
1866 scorefile is saved, <varname>REQD_FILES_PERMS</varname> is used to create a 1894 scorefile is saved, <varname>REQD_FILES_PERMS</varname> is used to create a
1867 dummy scorefile (<filename>mbscore</filename>) with the proper permissions 1895 dummy scorefile (<filename>mbscore</filename>) with the proper permissions
1868 and <varname>SPECIAL_PERMS</varname> is used to install setgid the game 1896 and <varname>SPECIAL_PERMS</varname> is used to install setgid the game
1869 binary:</para> 1897 binary:</para>
1870 1898
1871<programlisting> 1899<programlisting>
1872USE_GAMESGROUP= yes 1900USE_GAMESGROUP= yes
1873 1901
1874BUILD_DEFS+= VARBASE 1902BUILD_DEFS+= VARBASE
1875 1903
1876OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS} 1904OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
1877REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS} 1905REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
1878SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS} 1906SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
1879</programlisting> 1907</programlisting>
1880 1908
1881 <para>Various <varname>INSTALL_*</varname> variables are also available: 1909 <para>Various <varname>INSTALL_*</varname> variables are also available:
1882 <varname>INSTALL_GAME</varname> to install setgid game binaries, 1910 <varname>INSTALL_GAME</varname> to install setgid game binaries,
1883 <varname>INSTALL_GAME_DIR</varname> to install game directories that are 1911 <varname>INSTALL_GAME_DIR</varname> to install game directories that are
1884 needed to be accessed by setgid games and 1912 needed to be accessed by setgid games and
1885 <varname>INSTALL_GAME_DATA</varname> to install scorefiles.</para> 1913 <varname>INSTALL_GAME_DATA</varname> to install scorefiles.</para>
1886 1914
1887 <para>A package should therefore never hard code file ownership or 1915 <para>A package should therefore never hard code file ownership or
1888 access permissions but rely on <varname>*_PERMS</varname> as described above 1916 access permissions but rely on <varname>*_PERMS</varname> as described above
1889 or alternatively on <varname>INSTALL_GAME</varname>, 1917 or alternatively on <varname>INSTALL_GAME</varname>,
1890 <varname>INSTALL_GAME_DATA</varname> and 1918 <varname>INSTALL_GAME_DATA</varname> and
1891 <varname>INSTALL_GAME_DIR</varname> to set these correctly.</para> 1919 <varname>INSTALL_GAME_DIR</varname> to set these correctly.</para>
1892 </sect2> 1920 </sect2>
1893 1921
1894 <sect2 id="destdir-support"> 1922 <sect2 id="destdir-support">
1895 <title>Adding DESTDIR support to packages</title> 1923 <title>Adding DESTDIR support to packages</title>
1896 1924
1897 <para><varname>DESTDIR</varname> support means that a package 1925 <para><varname>DESTDIR</varname> support means that a package
1898 installs into a staging directory, not the final location of the 1926 installs into a staging directory, not the final location of the
1899 files. Then a binary package is created which can be used for 1927 files. Then a binary package is created which can be used for
1900 installation as usual. There are two ways: Either the package must 1928 installation as usual. There are two ways: Either the package must
1901 install as root (<quote>destdir</quote>) or the package can 1929 install as root (<quote>destdir</quote>) or the package can
1902 install as non-root user (<quote>user-destdir</quote>).</para> 1930 install as non-root user (<quote>user-destdir</quote>).</para>
1903 1931
1904 <itemizedlist> 1932 <itemizedlist>
1905 <listitem><para><varname>PKG_DESTDIR_SUPPORT</varname> has to be 1933 <listitem><para><varname>PKG_DESTDIR_SUPPORT</varname> has to be
1906 set to <quote>destdir</quote> or <quote>user-destdir</quote>. 1934 set to <quote>destdir</quote> or <quote>user-destdir</quote>.
1907 By default <varname>PKG_DESTDIR_SUPPORT</varname> 1935 By default <varname>PKG_DESTDIR_SUPPORT</varname>
1908 is set to <quote>user-destdir</quote> to help catching more 1936 is set to <quote>user-destdir</quote> to help catching more
1909 potential packaging problems. If bsd.prefs.mk is included in the Makefile, 1937 potential packaging problems. If bsd.prefs.mk is included in the Makefile,
1910 <varname>PKG_DESTDIR_SUPPORT</varname> needs to be set before 1938 <varname>PKG_DESTDIR_SUPPORT</varname> needs to be set before
1911 the inclusion.</para></listitem> 1939 the inclusion.</para></listitem>
1912 1940
1913 <listitem><para>All installation operations have to be prefixed with 1941 <listitem><para>All installation operations have to be prefixed with
1914 <filename>${DESTDIR}</filename>.</para></listitem> 1942 <filename>${DESTDIR}</filename>.</para></listitem>
1915 1943
1916 <listitem><para>automake gets this DESTDIR mostly right 1944 <listitem><para>automake gets this DESTDIR mostly right
1917 automatically. Many manual rules and pre/post-install often are 1945 automatically. Many manual rules and pre/post-install often are
1918 incorrect; fix them.</para></listitem> 1946 incorrect; fix them.</para></listitem>
1919 1947
1920 <listitem><para>If files are installed with special owner/group 1948 <listitem><para>If files are installed with special owner/group
1921 use <varname>SPECIAL_PERMS</varname>.</para></listitem> 1949 use <varname>SPECIAL_PERMS</varname>.</para></listitem>
1922 1950
1923 <listitem><para>In general, packages should support 1951 <listitem><para>In general, packages should support
1924 <varname>UNPRIVILEGED</varname> to be able to use 1952 <varname>UNPRIVILEGED</varname> to be able to use
1925 DESTDIR.</para></listitem> 1953 DESTDIR.</para></listitem>
1926 1954
1927 </itemizedlist> 1955 </itemizedlist>
1928 </sect2> 1956 </sect2>
1929 1957
1930 1958
1931 <sect2 id="hardcoded-paths"> 1959 <sect2 id="hardcoded-paths">
1932 <title>Packages with hardcoded paths to other interpreters</title> 1960 <title>Packages with hardcoded paths to other interpreters</title>
1933 1961
1934 <para>Your package may also contain scripts with hardcoded paths to 1962 <para>Your package may also contain scripts with hardcoded paths to
1935 other interpreters besides (or as well as) perl. To correct the 1963 other interpreters besides (or as well as) perl. To correct the
1936 full pathname to the script interpreter, you need to set the 1964 full pathname to the script interpreter, you need to set the
1937 following definitions in your <filename>Makefile</filename> (we 1965 following definitions in your <filename>Makefile</filename> (we
1938 shall use <command>tclsh</command> in this example):</para> 1966 shall use <command>tclsh</command> in this example):</para>
1939 1967
1940<programlisting> 1968<programlisting>
1941REPLACE_INTERPRETER+= tcl 1969REPLACE_INTERPRETER+= tcl
1942REPLACE.tcl.old= .*/bin/tclsh 1970REPLACE.tcl.old= .*/bin/tclsh
1943REPLACE.tcl.new= ${PREFIX}/bin/tclsh 1971REPLACE.tcl.new= ${PREFIX}/bin/tclsh
1944REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed, 1972REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
1945# relative to ${WRKSRC}, just as in REPLACE_PERL 1973# relative to ${WRKSRC}, just as in REPLACE_PERL
1946</programlisting> 1974</programlisting>
1947 1975
1948 <note><para>Before March 2006, these variables were called 1976 <note><para>Before March 2006, these variables were called
1949 <varname>_REPLACE.*</varname> and 1977 <varname>_REPLACE.*</varname> and
1950 <varname>_REPLACE_FILES.*</varname>.</para></note> 1978 <varname>_REPLACE_FILES.*</varname>.</para></note>
1951 1979
1952 </sect2> 1980 </sect2>
1953 1981
1954 1982
1955 <sect2 id="perl-modules"> 1983 <sect2 id="perl-modules">
1956 <title>Packages installing perl modules</title> 1984 <title>Packages installing perl modules</title>
1957 1985
1958 <para>Makefiles of packages providing perl5 modules should include 1986 <para>Makefiles of packages providing perl5 modules should include
1959 the Makefile fragment 1987 the Makefile fragment
1960 <filename>../../lang/perl5/module.mk</filename>. It provides a 1988 <filename>../../lang/perl5/module.mk</filename>. It provides a
1961 <command>do-configure</command> target for the standard perl 1989 <command>do-configure</command> target for the standard perl
1962 configuration for such modules as well as various hooks to tune 1990 configuration for such modules as well as various hooks to tune
1963 this configuration. See comments in this file for 1991 this configuration. See comments in this file for
1964 details.</para> 1992 details.</para>
1965 1993
1966 <para>Perl5 modules will install into different places depending 1994 <para>Perl5 modules will install into different places depending
1967 on the version of perl used during the build process. To 1995 on the version of perl used during the build process. To
1968 address this, pkgsrc will append lines to the 1996 address this, pkgsrc will append lines to the
1969 <filename>PLIST</filename> corresponding to the files listed in 1997 <filename>PLIST</filename> corresponding to the files listed in
1970 the installed <filename>.packlist</filename> file generated by 1998 the installed <filename>.packlist</filename> file generated by
1971 most perl5 modules. This is invoked by defining 1999 most perl5 modules. This is invoked by defining
1972 <varname>PERL5_PACKLIST</varname> to a space-separated list of 2000 <varname>PERL5_PACKLIST</varname> to a space-separated list of
1973 packlist files relative to <varname>PERL5_PACKLIST_DIR</varname> 2001 packlist files relative to <varname>PERL5_PACKLIST_DIR</varname>
1974 (<varname>PERL5_INSTALLVENDORARCH</varname> by default), 2002 (<varname>PERL5_INSTALLVENDORARCH</varname> by default),
1975 e.g.:</para> 2003 e.g.:</para>
1976 2004
1977<programlisting> 2005<programlisting>
1978PERL5_PACKLIST= auto/Pg/.packlist 2006PERL5_PACKLIST= auto/Pg/.packlist
1979</programlisting> 2007</programlisting>
1980 2008
1981 <para>The perl5 config variables 2009 <para>The perl5 config variables
1982 <varname>installarchlib</varname>, 2010 <varname>installarchlib</varname>,
1983 <varname>installscript</varname>, 2011 <varname>installscript</varname>,
1984 <varname>installvendorbin</varname>, 2012 <varname>installvendorbin</varname>,
1985 <varname>installvendorscript</varname>, 2013 <varname>installvendorscript</varname>,
1986 <varname>installvendorarch</varname>, 2014 <varname>installvendorarch</varname>,
1987 <varname>installvendorlib</varname>, 2015 <varname>installvendorlib</varname>,
1988 <varname>installvendorman1dir</varname>, and 2016 <varname>installvendorman1dir</varname>, and
1989 <varname>installvendorman3dir</varname> represent those 2017 <varname>installvendorman3dir</varname> represent those
1990 locations in which components of perl5 modules may be installed, 2018 locations in which components of perl5 modules may be installed,
1991 provided as variable with uppercase and prefixed with 2019 provided as variable with uppercase and prefixed with
1992 <varname>PERL5_</varname>, e.g. <varname>PERL5_INSTALLARCHLIB</varname> 2020 <varname>PERL5_</varname>, e.g. <varname>PERL5_INSTALLARCHLIB</varname>
1993 and may be used by perl5 packages that don't have a packlist. 2021 and may be used by perl5 packages that don't have a packlist.
1994 These variables are also substituted for in the 2022 These variables are also substituted for in the
1995 <filename>PLIST</filename> as uppercase prefixed with 2023 <filename>PLIST</filename> as uppercase prefixed with
1996 <varname>PERL5_SUB_</varname>.</para> 2024 <varname>PERL5_SUB_</varname>.</para>
1997 </sect2> 2025 </sect2>
1998 2026
1999 2027
2000 <sect2 id="faq.info-files"> 2028 <sect2 id="faq.info-files">
2001 <title>Packages installing info files</title> 2029 <title>Packages installing info files</title>
2002 2030
2003 <para>Some packages install info files or use the 2031 <para>Some packages install info files or use the
2004 <quote>makeinfo</quote> or <quote>install-info</quote> 2032 <quote>makeinfo</quote> or <quote>install-info</quote>
2005 commands. <varname>INFO_FILES</varname> should be defined in 2033 commands. <varname>INFO_FILES</varname> should be defined in
2006 the package Makefile so that <filename>INSTALL</filename> and 2034 the package Makefile so that <filename>INSTALL</filename> and
2007 <filename>DEINSTALL</filename> scripts will be generated to 2035 <filename>DEINSTALL</filename> scripts will be generated to
2008 handle registration of the info files in the Info directory 2036 handle registration of the info files in the Info directory
2009 file. The <quote>install-info</quote> command used for the info 2037 file. The <quote>install-info</quote> command used for the info
2010 files registration is either provided by the system, or by a 2038 files registration is either provided by the system, or by a
2011 special purpose package automatically added as dependency if 2039 special purpose package automatically added as dependency if
2012 needed.</para> 2040 needed.</para>
2013 2041
2014 <para><varname>PKGINFODIR</varname> is the directory under 2042 <para><varname>PKGINFODIR</varname> is the directory under
2015 <filename>${PREFIX}</filename> where info files are primarily 2043 <filename>${PREFIX}</filename> where info files are primarily
2016 located. <varname>PKGINFODIR</varname> defaults to 2044 located. <varname>PKGINFODIR</varname> defaults to
2017 <quote>info</quote> and can be overridden by the user.</para> 2045 <quote>info</quote> and can be overridden by the user.</para>
2018 2046
2019 <para>The info files for the package should be listed in the 2047 <para>The info files for the package should be listed in the
2020 package <filename>PLIST</filename>; however any split info files 2048 package <filename>PLIST</filename>; however any split info files
2021 need not be listed.</para> 2049 need not be listed.</para>
2022 2050
2023 <para>A package which needs the <quote>makeinfo</quote> command 2051 <para>A package which needs the <quote>makeinfo</quote> command
2024 at build time must add <quote>makeinfo</quote> to 2052 at build time must add <quote>makeinfo</quote> to
2025 <varname>USE_TOOLS</varname> in its Makefile. If a minimum 2053 <varname>USE_TOOLS</varname> in its Makefile. If a minimum
2026 version of the <quote>makeinfo</quote> command is needed it 2054 version of the <quote>makeinfo</quote> command is needed it
2027 should be noted with the <varname>TEXINFO_REQD</varname> 2055 should be noted with the <varname>TEXINFO_REQD</varname>
2028 variable in the package <filename>Makefile</filename>. By 2056 variable in the package <filename>Makefile</filename>. By
2029 default, a minimum version of 3.12 is required. If the system 2057 default, a minimum version of 3.12 is required. If the system
2030 does not provide a <command>makeinfo</command> command or if it 2058 does not provide a <command>makeinfo</command> command or if it
2031 does not match the required minimum, a build dependency on the 2059 does not match the required minimum, a build dependency on the
2032 <filename role="pkg">devel/gtexinfo</filename> package will 2060 <filename role="pkg">devel/gtexinfo</filename> package will
2033 be added automatically.</para> 2061 be added automatically.</para>
2034 2062
2035 <para>The build and installation process of the software provided 2063 <para>The build and installation process of the software provided
2036 by the package should not use the 2064 by the package should not use the
2037 <command>install-info</command> command as the registration of 2065 <command>install-info</command> command as the registration of
2038 info files is the task of the package 2066 info files is the task of the package
2039 <filename>INSTALL</filename> script, and it must use the 2067 <filename>INSTALL</filename> script, and it must use the
2040 appropriate <command>makeinfo</command> command.</para> 2068 appropriate <command>makeinfo</command> command.</para>
2041 2069
2042 <para>To achieve this goal, the pkgsrc infrastructure creates 2070 <para>To achieve this goal, the pkgsrc infrastructure creates
2043 overriding scripts for the <command>install-info</command> and 2071 overriding scripts for the <command>install-info</command> and
2044 <command>makeinfo</command> commands in a directory listed early 2072 <command>makeinfo</command> commands in a directory listed early
2045 in <varname>PATH</varname>.</para> 2073 in <varname>PATH</varname>.</para>
2046 2074
2047 <para>The script overriding <command>install-info</command> has 2075 <para>The script overriding <command>install-info</command> has
2048 no effect except the logging of a message. The script overriding 2076 no effect except the logging of a message. The script overriding
2049 <command>makeinfo</command> logs a message and according to the 2077 <command>makeinfo</command> logs a message and according to the
2050 value of <varname>TEXINFO_REQD</varname> either runs the appropriate 2078 value of <varname>TEXINFO_REQD</varname> either runs the appropriate
2051 <command>makeinfo</command> command or exit on error.</para> 2079 <command>makeinfo</command> command or exit on error.</para>
2052 </sect2> 2080 </sect2>
2053 2081
2054 <sect2 id="manpages"> 2082 <sect2 id="manpages">
2055 <title>Packages installing man pages</title> 2083 <title>Packages installing man pages</title>
2056 2084
2057 <para>All packages that install manual pages should install them 2085 <para>All packages that install manual pages should install them
2058 into the same directory, so that there is one common place to look 2086 into the same directory, so that there is one common place to look
2059 for them. In pkgsrc, this place is 2087 for them. In pkgsrc, this place is
2060 <literal>${PREFIX}/${PKGMANDIR}</literal>, and this expression 2088 <literal>${PREFIX}/${PKGMANDIR}</literal>, and this expression