Fri Dec 3 07:52:33 2021 UTC ()
guide: update USE_LANGUAGES section, add missing file to PLIST


(wiz)
diff -r1.5 -r1.6 pkgsrc/doc/guide/PLIST
diff -r1.166 -r1.167 pkgsrc/doc/guide/files/fixes.xml

cvs diff -r1.5 -r1.6 pkgsrc/doc/guide/PLIST (switch to unified diff)

--- pkgsrc/doc/guide/PLIST 2020/06/21 04:32:36 1.5
+++ pkgsrc/doc/guide/PLIST 2021/12/03 07:52:32 1.6
@@ -1,43 +1,44 @@ @@ -1,43 +1,44 @@
1@comment $NetBSD: PLIST,v 1.5 2020/06/21 04:32:36 rillig Exp $ 1@comment $NetBSD: PLIST,v 1.6 2021/12/03 07:52:32 wiz Exp $
2${PLIST.html}share/doc/pkgsrc/binary.html 2${PLIST.html}share/doc/pkgsrc/binary.html
3${PLIST.html}share/doc/pkgsrc/build.html 3${PLIST.html}share/doc/pkgsrc/build.html
4${PLIST.html}share/doc/pkgsrc/buildlink.html 4${PLIST.html}share/doc/pkgsrc/buildlink.html
5${PLIST.html}share/doc/pkgsrc/bulk.html 5${PLIST.html}share/doc/pkgsrc/bulk.html
6${PLIST.html}share/doc/pkgsrc/components.html 6${PLIST.html}share/doc/pkgsrc/components.html
7${PLIST.html}share/doc/pkgsrc/configuring.html 7${PLIST.html}share/doc/pkgsrc/configuring.html
8${PLIST.html}share/doc/pkgsrc/creating.html 8${PLIST.html}share/doc/pkgsrc/creating.html
9${PLIST.html}share/doc/pkgsrc/developers-guide.html 9${PLIST.html}share/doc/pkgsrc/developers-guide.html
10${PLIST.html}share/doc/pkgsrc/devfaq.html 10${PLIST.html}share/doc/pkgsrc/devfaq.html
11${PLIST.html}share/doc/pkgsrc/editing.html 11${PLIST.html}share/doc/pkgsrc/editing.html
12${PLIST.html}share/doc/pkgsrc/examples.html 12${PLIST.html}share/doc/pkgsrc/examples.html
13${PLIST.html}share/doc/pkgsrc/faq.html 13${PLIST.html}share/doc/pkgsrc/faq.html
14${PLIST.html}share/doc/pkgsrc/files.html 14${PLIST.html}share/doc/pkgsrc/files.html
15${PLIST.html}share/doc/pkgsrc/fixes.html 15${PLIST.html}share/doc/pkgsrc/fixes.html
16${PLIST.html}share/doc/pkgsrc/ftp-layout.html 16${PLIST.html}share/doc/pkgsrc/ftp-layout.html
17${PLIST.html}share/doc/pkgsrc/getting.html 17${PLIST.html}share/doc/pkgsrc/getting.html
18${PLIST.html}share/doc/pkgsrc/global.css 18${PLIST.html}share/doc/pkgsrc/global.css
19${PLIST.html}share/doc/pkgsrc/gnome.html 19${PLIST.html}share/doc/pkgsrc/gnome.html
 20${PLIST.html}share/doc/pkgsrc/hardening.html
20${PLIST.html}share/doc/pkgsrc/help-devel.html 21${PLIST.html}share/doc/pkgsrc/help-devel.html
21${PLIST.html}share/doc/pkgsrc/help-topics.html 22${PLIST.html}share/doc/pkgsrc/help-topics.html
22${PLIST.html}share/doc/pkgsrc/help-user.html 23${PLIST.html}share/doc/pkgsrc/help-user.html
23${PLIST.html}share/doc/pkgsrc/index.html 24${PLIST.html}share/doc/pkgsrc/index.html
24${PLIST.html}share/doc/pkgsrc/infr.design.html 25${PLIST.html}share/doc/pkgsrc/infr.design.html
25${PLIST.html}share/doc/pkgsrc/infrastructure.html 26${PLIST.html}share/doc/pkgsrc/infrastructure.html
26${PLIST.html}share/doc/pkgsrc/introduction.html 27${PLIST.html}share/doc/pkgsrc/introduction.html
27${PLIST.html}share/doc/pkgsrc/logs.html 28${PLIST.html}share/doc/pkgsrc/logs.html
28${PLIST.html}share/doc/pkgsrc/makefile.html 29${PLIST.html}share/doc/pkgsrc/makefile.html
29${PLIST.html}share/doc/pkgsrc/options.html 30${PLIST.html}share/doc/pkgsrc/options.html
30${PLIST.html}share/doc/pkgsrc/pkginstall.html 31${PLIST.html}share/doc/pkgsrc/pkginstall.html
31${PLIST.html}share/doc/pkgsrc/pkgsrc.html 
32${PLIST.epub}share/doc/pkgsrc/pkgsrc.epub 32${PLIST.epub}share/doc/pkgsrc/pkgsrc.epub
 33${PLIST.html}share/doc/pkgsrc/pkgsrc.html
33${PLIST.pdf}share/doc/pkgsrc/pkgsrc.pdf 34${PLIST.pdf}share/doc/pkgsrc/pkgsrc.pdf
34${PLIST.pdf}share/doc/pkgsrc/pkgsrc.ps 35${PLIST.pdf}share/doc/pkgsrc/pkgsrc.ps
35${PLIST.ascii}share/doc/pkgsrc/pkgsrc.txt 36${PLIST.ascii}share/doc/pkgsrc/pkgsrc.txt
36${PLIST.html}share/doc/pkgsrc/platforms.html 37${PLIST.html}share/doc/pkgsrc/platforms.html
37${PLIST.html}share/doc/pkgsrc/plist.html 38${PLIST.html}share/doc/pkgsrc/plist.html
38${PLIST.html}share/doc/pkgsrc/porting.html 39${PLIST.html}share/doc/pkgsrc/porting.html
39${PLIST.html}share/doc/pkgsrc/regression.html 40${PLIST.html}share/doc/pkgsrc/regression.html
40${PLIST.html}share/doc/pkgsrc/submit.html 41${PLIST.html}share/doc/pkgsrc/submit.html
41${PLIST.html}share/doc/pkgsrc/tools.html 42${PLIST.html}share/doc/pkgsrc/tools.html
42${PLIST.html}share/doc/pkgsrc/users-guide.html 43${PLIST.html}share/doc/pkgsrc/users-guide.html
43${PLIST.html}share/doc/pkgsrc/using.html 44${PLIST.html}share/doc/pkgsrc/using.html

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

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