Mon Jul 25 05:42:22 2022 UTC ()
doc/guide: document how PKGPATH is typically used


(rillig)
diff -r1.87 -r1.88 pkgsrc/doc/guide/files/build.xml

cvs diff -r1.87 -r1.88 pkgsrc/doc/guide/files/build.xml (switch to unified diff)

--- pkgsrc/doc/guide/files/build.xml 2022/05/21 11:42:29 1.87
+++ pkgsrc/doc/guide/files/build.xml 2022/07/25 05:42:22 1.88
@@ -1,1160 +1,1172 @@ @@ -1,1160 +1,1172 @@
1<!-- $NetBSD: build.xml,v 1.87 2022/05/21 11:42:29 nia Exp $ --> 1<!-- $NetBSD: build.xml,v 1.88 2022/07/25 05:42:22 rillig Exp $ -->
2 2
3<chapter id="build"> 3<chapter id="build">
4 <title>The build process</title> 4 <title>The build process</title>
5 5
6 <sect1 id="build.intro"> 6 <sect1 id="build.intro">
7 <title>Introduction</title> 7 <title>Introduction</title>
8 8
9 <para>This chapter gives a detailed description on how a package is 9 <para>This chapter gives a detailed description on how a package is
10 built. Building a package is separated into different 10 built. Building a package is separated into different
11 <emphasis>phases</emphasis> (for example <varname>fetch</varname>, 11 <emphasis>phases</emphasis> (for example <varname>fetch</varname>,
12 <varname>build</varname>, <varname>install</varname>), all of which are 12 <varname>build</varname>, <varname>install</varname>), all of which are
13 described in the following sections. Each phase is split into 13 described in the following sections. Each phase is split into
14 so-called <emphasis>stages</emphasis>, which take the name of the 14 so-called <emphasis>stages</emphasis>, which take the name of the
15 containing phase, prefixed by one of <varname>pre-</varname>, 15 containing phase, prefixed by one of <varname>pre-</varname>,
16 <varname>do-</varname> or <varname>post-</varname>. (Examples are 16 <varname>do-</varname> or <varname>post-</varname>. (Examples are
17 <varname>pre-configure</varname>, <varname>post-build</varname>.) Most 17 <varname>pre-configure</varname>, <varname>post-build</varname>.) Most
18 of the actual work is done in the <varname>do-*</varname> stages.</para> 18 of the actual work is done in the <varname>do-*</varname> stages.</para>
19 19
20 <para>Never override the regular targets (like 20 <para>Never override the regular targets (like
21 <varname>fetch</varname>), if you have to, override the 21 <varname>fetch</varname>), if you have to, override the
22 <varname>do-*</varname> ones instead.</para> 22 <varname>do-*</varname> ones instead.</para>
23 23
24 <para>The basic steps for building a program are always the same. First 24 <para>The basic steps for building a program are always the same. First
25 the program's source (<emphasis>distfile</emphasis>) must be brought to 25 the program's source (<emphasis>distfile</emphasis>) must be brought to
26 the local system and then extracted. After any pkgsrc-specific patches 26 the local system and then extracted. After any pkgsrc-specific patches
27 to compile properly are applied, the software can be configured, then 27 to compile properly are applied, the software can be configured, then
28 built (usually by compiling), and finally the generated binaries, etc. 28 built (usually by compiling), and finally the generated binaries, etc.
29 can be put into place on the system.</para> 29 can be put into place on the system.</para>
30 30
31 <para>To get more details about what is happening at each step, 31 <para>To get more details about what is happening at each step,
32 you can set the <varname>PKG_VERBOSE</varname> variable, or the 32 you can set the <varname>PKG_VERBOSE</varname> variable, or the
33 <varname>PATCH_DEBUG</varname> variable if you are just interested 33 <varname>PATCH_DEBUG</varname> variable if you are just interested
34 in more details about the <emphasis>patch</emphasis> step.</para> 34 in more details about the <emphasis>patch</emphasis> step.</para>
35 </sect1> 35 </sect1>
36 36
37 <sect1 id="build.prefix"> 37 <sect1 id="build.prefix">
38 <title>Program location</title> 38 <title>Program location</title>
39 39
40 <para>Before outlining the process performed by the &os; package system in 40 <para>Before outlining the process performed by the &os; package system in
41 the next section, here's a brief discussion on where programs are 41 the next section, here's a brief discussion on where programs are
42 installed, and which variables influence this.</para> 42 installed, and which variables influence this.</para>
43 43
44 <para>The automatic variable <varname>PREFIX</varname> indicates 44 <para>The automatic variable <varname>PREFIX</varname> indicates
45 where all files of the final program shall be installed. It is 45 where all files of the final program shall be installed. It is
46 usually set to <varname>LOCALBASE</varname> 46 usually set to <varname>LOCALBASE</varname>
47 (<filename>/usr/pkg</filename>), or <varname>CROSSBASE</varname> 47 (<filename>/usr/pkg</filename>), or <varname>CROSSBASE</varname>
48 for pkgs in the <filename>cross</filename> category. The value of 48 for pkgs in the <filename>cross</filename> category. The value of
49 <varname>PREFIX</varname> needs to be put 49 <varname>PREFIX</varname> needs to be put
50 into the various places in the program's source where paths to 50 into the various places in the program's source where paths to
51 these files are encoded. See <xref 51 these files are encoded. See <xref
52 linkend="components.patches"/> and <xref 52 linkend="components.patches"/> and <xref
53 linkend="fixes.libtool"/> for more details.</para> 53 linkend="fixes.libtool"/> for more details.</para>
54 54
55 <para>When choosing which of these variables to use, 55 <para>When choosing which of these variables to use,
56 follow the following rules:</para> 56 follow the following rules:</para>
57 57
58 <itemizedlist> 58 <itemizedlist>
59 <listitem> 59 <listitem>
60 <para><varname>PREFIX</varname> always points to the location 60 <para><varname>PREFIX</varname> always points to the location
61 where the current pkg will be installed. When referring to a 61 where the current pkg will be installed. When referring to a
62 pkg's own installation path, use 62 pkg's own installation path, use
63 <quote>${PREFIX}</quote>.</para> 63 <quote>${PREFIX}</quote>.</para>
64 </listitem> 64 </listitem>
65 65
66 <listitem> 66 <listitem>
67 <para><varname>LOCALBASE</varname> is where all pkgs 67 <para><varname>LOCALBASE</varname> is where all pkgs
68 are installed. If you need to construct a -I or -L argument 68 are installed. If you need to construct a -I or -L argument
69 to the compiler to find includes and libraries installed by 69 to the compiler to find includes and libraries installed by
70 another pkg, use <quote>${LOCALBASE}</quote>. The name 70 another pkg, use <quote>${LOCALBASE}</quote>. The name
71 <varname>LOCALBASE</varname> stems from FreeBSD, which 71 <varname>LOCALBASE</varname> stems from FreeBSD, which
72 installed all packages in <filename>/usr/local</filename>. As 72 installed all packages in <filename>/usr/local</filename>. As
73 pkgsrc leaves <filename>/usr/local</filename> for the system 73 pkgsrc leaves <filename>/usr/local</filename> for the system
74 administrator, this variable is a misnomer.</para> 74 administrator, this variable is a misnomer.</para>
75 </listitem> 75 </listitem>
76 76
77 <listitem> 77 <listitem>
78 <para><varname>X11BASE</varname> is where the actual X11 78 <para><varname>X11BASE</varname> is where the actual X11
79 distribution (from xsrc, etc.) is installed. When looking for 79 distribution (from xsrc, etc.) is installed. When looking for
80 <emphasis>standard</emphasis> X11 includes (not those 80 <emphasis>standard</emphasis> X11 includes (not those
81 installed by a package), use <quote>${X11BASE}</quote>.</para> 81 installed by a package), use <quote>${X11BASE}</quote>.</para>
82 </listitem> 82 </listitem>
83 83
84 <listitem> 84 <listitem>
85 <para>X11-based packages using imake must set 85 <para>X11-based packages using imake must set
86 <varname>USE_IMAKE</varname> to be installed correctly under 86 <varname>USE_IMAKE</varname> to be installed correctly under
87 <varname>LOCALBASE</varname>.</para> 87 <varname>LOCALBASE</varname>.</para>
88 </listitem> 88 </listitem>
89 89
90 <listitem> 90 <listitem>
91 <para>Within <filename>${PREFIX}</filename>, packages should 91 <para>Within <filename>${PREFIX}</filename>, packages should
92 install files according to &man.hier.7;, with the exception that 92 install files according to &man.hier.7;, with the exception that
93 manual pages go into <filename>${PREFIX}/man</filename>, not 93 manual pages go into <filename>${PREFIX}/man</filename>, not
94 <filename>${PREFIX}/share/man</filename>.</para> 94 <filename>${PREFIX}/share/man</filename>.</para>
95 </listitem> 95 </listitem>
96 </itemizedlist> 96 </itemizedlist>
97 </sect1> 97 </sect1>
98 98
99 <sect1 id="build.builddirs"> 99 <sect1 id="build.builddirs">
100 <title>Directories used during the build process</title> 100 <title>Directories used during the build process</title>
101 101
102 <para>When building a package, various directories are used to store 102 <para>When building a package, various directories are used to store
103 source files, temporary files, pkgsrc-internal files, and so on. These 103 source files, temporary files, pkgsrc-internal files, and so on. These
104 directories are explained here.</para> 104 directories are explained here.</para>
105 105
106 <para>Some of the directory variables contain relative pathnames. There 106 <para>Some of the directory variables contain relative pathnames. There
107 are two common base directories for these relative directories: 107 are two common base directories for these relative directories:
108 <varname>PKGSRCDIR/PKGPATH</varname> is used for directories that are 108 <varname>PKGSRCDIR/PKGPATH</varname> is used for directories that are
109 pkgsrc-specific. <varname>WRKSRC</varname> is used for directories 109 pkgsrc-specific. <varname>WRKSRC</varname> is used for directories
110 inside the package itself.</para> 110 inside the package itself.</para>
111 111
112 <variablelist> 112 <variablelist>
113 113
114 <varlistentry><term><varname>PKGSRCDIR</varname></term> 114 <varlistentry><term><varname>PKGSRCDIR</varname></term>
115 <listitem><para>This is an absolute pathname that points to the pkgsrc 115 <listitem><para>This is an absolute pathname that points to the pkgsrc
116 root directory. Generally, you don't need 116 root directory. Generally, you don't need
117 it.</para></listitem></varlistentry> 117 it.</para></listitem></varlistentry>
118 118
119 <varlistentry><term><varname>PKGDIR</varname></term> 119 <varlistentry><term><varname>PKGDIR</varname></term>
120 <listitem><para>This is an absolute pathname that points to the 120 <listitem><para>This is an absolute pathname that points to the
121 current package.</para></listitem></varlistentry> 121 current package.</para></listitem></varlistentry>
122 122
123 <varlistentry><term><varname>PKGPATH</varname></term> 123 <varlistentry><term><varname>PKGPATH</varname></term>
124 <listitem><para>This is a pathname relative to 124 <listitem><para>This is a pathname relative to
125 <varname>PKGSRCDIR</varname> that points to the current 125 <varname>PKGSRCDIR</varname> that points to the current package.
126 package.</para></listitem></varlistentry> 126 It is defined after including <filename>bsd.prefs.mk</filename>
 127 and can be used in makefile fragments that are used by several
 128 packages to distinguish between these packages. Other variables
 129 that would serve the same purpose are <varname>PKGBASE</varname>
 130 and <varname>PKGNAME</varname>, but these are only defined after
 131 including <filename>bsd.pkg.mk</filename>, which is too
 132 late.</para>
 133
 134 <para>In &mk.conf;, the pkgsrc user can use
 135 <varname>PKGPATH</varname> to tweak variables like
 136 <varname>MAKE_JOBS</varname> and
 137 <varname>CFLAGS</varname>.</para></listitem></varlistentry>
127 138
128 <varlistentry><term><varname>WRKDIR</varname></term> 139 <varlistentry><term><varname>WRKDIR</varname></term>
129 <listitem><para>This is an absolute pathname pointing to the directory 140 <listitem><para>This is an absolute pathname pointing to the directory
130 where all work takes place. The distfiles are extracted to this 141 where all work takes place. The distfiles are extracted to this
131 directory. It also contains temporary directories and log files used by 142 directory. It also contains temporary directories and log files used by
132 the various pkgsrc frameworks, like <emphasis>buildlink</emphasis> or 143 the various pkgsrc frameworks, like <emphasis>buildlink</emphasis> or
133 the <emphasis>wrappers</emphasis>.</para></listitem></varlistentry> 144 the <emphasis>wrappers</emphasis>.</para></listitem></varlistentry>
134 145
135 <varlistentry><term><varname>WRKSRC</varname></term> 146 <varlistentry><term><varname>WRKSRC</varname></term>
136 <listitem><para>This is an absolute pathname pointing to the directory 147 <listitem><para>This is an absolute pathname pointing to the directory
137 where the distfiles are extracted. It is usually a direct subdirectory 148 where the distfiles are extracted. It is usually a direct subdirectory
138 of <varname>WRKDIR</varname>, and often it's the only directory entry 149 of <varname>WRKDIR</varname>, and often it's the only directory entry
139 that isn't hidden. This variable may be changed by a package 150 that isn't hidden. This variable may be changed by a package
140 <filename>Makefile</filename>.</para></listitem></varlistentry> 151 <filename>Makefile</filename>.</para></listitem></varlistentry>
141 152
142 </variablelist> 153 </variablelist>
143 154
144 <para>The <varname>CREATE_WRKDIR_SYMLINK</varname> definition takes either 155 <para>The <varname>CREATE_WRKDIR_SYMLINK</varname> definition takes either
145 the value <emphasis>yes</emphasis> or <emphasis>no</emphasis> and defaults 156 the value <emphasis>yes</emphasis> or <emphasis>no</emphasis> and defaults
146 to <emphasis>no</emphasis>. It indicates whether a symbolic link to the 157 to <emphasis>no</emphasis>. It indicates whether a symbolic link to the
147 <varname>WRKDIR</varname> is to be created in the pkgsrc entry's directory. 158 <varname>WRKDIR</varname> is to be created in the pkgsrc entry's directory.
148 If users would like to have their pkgsrc trees behave in a 159 If users would like to have their pkgsrc trees behave in a
149 read-only manner, then the value of 160 read-only manner, then the value of
150 <varname>CREATE_WRKDIR_SYMLINK</varname> should be set to 161 <varname>CREATE_WRKDIR_SYMLINK</varname> should be set to
151 <emphasis>no</emphasis>.</para> 162 <emphasis>no</emphasis>.</para>
152 </sect1> 163 </sect1>
153 164
154 <sect1 id="build.running"> 165 <sect1 id="build.running">
155 <title>Running a phase</title> 166 <title>Running a phase</title>
156 167
157 <para>You can run a particular phase by typing <command>make 168 <para>You can run a particular phase by typing <command>make
158 phase</command>, where <emphasis>phase</emphasis> is the name of the 169 <replaceable>phase</replaceable></command>, where
159 phase. This will automatically run all phases that are required for this 170 <replaceable>phase</replaceable> is the name of the phase. This will
160 phase. The default phase is <varname>build</varname>, that is, when you 171 automatically run all phases that are required for this phase. The
161 run <command>make</command> without parameters in a package directory, 172 default phase is <varname>build</varname>, that is, when you run
 173 <command>make</command> without parameters in a package directory,
162 the package will be built, but not installed.</para> 174 the package will be built, but not installed.</para>
163 175
164 </sect1> 176 </sect1>
165 177
166 <sect1 id="build.fetch"> 178 <sect1 id="build.fetch">
167 <title>The <emphasis>fetch</emphasis> phase</title> 179 <title>The <emphasis>fetch</emphasis> phase</title>
168 180
169 <para>The first step in building a package is to fetch the 181 <para>The first step in building a package is to fetch the
170 distribution files (distfiles) from the sites that are providing 182 distribution files (distfiles) from the sites that are providing
171 them. This is the task of the <emphasis>fetch</emphasis> 183 them. This is the task of the <emphasis>fetch</emphasis>
172 phase.</para> 184 phase.</para>
173 185
174 <sect2 id="build.fetch.what"> 186 <sect2 id="build.fetch.what">
175 <title>What to fetch and where to get it from</title> 187 <title>What to fetch and where to get it from</title>
176 188
177 <para>In simple cases, <varname>MASTER_SITES</varname> 189 <para>In simple cases, <varname>MASTER_SITES</varname>
178 defines all URLs from where the distfile, whose name is 190 defines all URLs from where the distfile, whose name is
179 derived from the <varname>DISTNAME</varname> variable, is 191 derived from the <varname>DISTNAME</varname> variable, is
180 fetched. The more complicated cases are described 192 fetched. The more complicated cases are described
181 below.</para> 193 below.</para>
182 194
183 <para>The variable <varname>DISTFILES</varname> specifies 195 <para>The variable <varname>DISTFILES</varname> specifies
184 the list of distfiles that have to be fetched. Its value 196 the list of distfiles that have to be fetched. Its value
185 defaults to <literal>${DEFAULT_DISTFILES}</literal> and 197 defaults to <literal>${DEFAULT_DISTFILES}</literal> and
186 its value is <literal>${DISTNAME}${EXTRACT_SUFX}</literal>, 198 its value is <literal>${DISTNAME}${EXTRACT_SUFX}</literal>,
187 so that most packages don't need to define it at all. 199 so that most packages don't need to define it at all.
188 <varname>EXTRACT_SUFX</varname> is 200 <varname>EXTRACT_SUFX</varname> is
189 <literal>.tar.gz</literal> by default, but can be changed 201 <literal>.tar.gz</literal> by default, but can be changed
190 freely. Note that if your package requires additional 202 freely. Note that if your package requires additional
191 distfiles to the default one, you cannot just append the 203 distfiles to the default one, you cannot just append the
192 additional filenames using the <literal>+=</literal> 204 additional filenames using the <literal>+=</literal>
193 operator, but you have write for example:</para> 205 operator, but you have write for example:</para>
194 206
195<programlisting> 207<programlisting>
196DISTFILES= ${DEFAULT_DISTFILES} additional-files.tar.gz 208DISTFILES= ${DEFAULT_DISTFILES} additional-files.tar.gz
197</programlisting> 209</programlisting>
198 210
199 <para>Each distfile is fetched from a list of sites, usually 211 <para>Each distfile is fetched from a list of sites, usually
200 <varname>MASTER_SITES</varname>. If the package has multiple 212 <varname>MASTER_SITES</varname>. If the package has multiple
201 <varname>DISTFILES</varname> or multiple 213 <varname>DISTFILES</varname> or multiple
202 <varname>PATCHFILES</varname> from different sites, you can 214 <varname>PATCHFILES</varname> from different sites, you can
203 set 215 set
204 <varname>SITES.<replaceable>distfile</replaceable></varname> 216 <varname>SITES.<replaceable>distfile</replaceable></varname>
205 to the list of URLs where the file 217 to the list of URLs where the file
206 <filename><replaceable>distfile</replaceable></filename> 218 <filename><replaceable>distfile</replaceable></filename>
207 (including the suffix) can be found.</para> 219 (including the suffix) can be found.</para>
208 220
209<programlisting> 221<programlisting>
210DISTFILES= ${DISTNAME}${EXTRACT_SUFX} 222DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
211DISTFILES+= foo-file.tar.gz 223DISTFILES+= foo-file.tar.gz
212SITES.foo-file.tar.gz= \ 224SITES.foo-file.tar.gz= \
213https://www.somewhere.com/somehow/ \ 225https://www.somewhere.com/somehow/ \
214https://www.somewhereelse.com/mirror/somehow/ 226https://www.somewhereelse.com/mirror/somehow/
215</programlisting> 227</programlisting>
216 228
217 <para>When actually fetching the distfiles, each item from 229 <para>When actually fetching the distfiles, each item from
218 <varname>MASTER_SITES</varname> or 230 <varname>MASTER_SITES</varname> or
219 <varname>SITES.*</varname> gets the name of each distfile 231 <varname>SITES.*</varname> gets the name of each distfile
220 appended to it, without an intermediate slash. Therefore, 232 appended to it, without an intermediate slash. Therefore,
221 all site values have to end with a slash or other separator 233 all site values have to end with a slash or other separator
222 character. This allows for example to set 234 character. This allows for example to set
223 <varname>MASTER_SITES</varname> to a URL of a CGI script 235 <varname>MASTER_SITES</varname> to a URL of a CGI script
224 that gets the name of the distfile as a parameter. In this 236 that gets the name of the distfile as a parameter. In this
225 case, the definition would look like:</para> 237 case, the definition would look like:</para>
226 238
227<programlisting> 239<programlisting>
228MASTER_SITES= https://www.example.com/download.cgi?file= 240MASTER_SITES= https://www.example.com/download.cgi?file=
229</programlisting> 241</programlisting>
230 242
231 <para> The exception to this rule are URLs starting with a dash. 243 <para> The exception to this rule are URLs starting with a dash.
232 In that case the URL is taken as is, fetched and the result 244 In that case the URL is taken as is, fetched and the result
233 stored under the name of the distfile. You can use this style 245 stored under the name of the distfile. You can use this style
234 for the case when the download URL style does not match the 246 for the case when the download URL style does not match the
235 above common case. For example, if permanent download URL is a 247 above common case. For example, if permanent download URL is a
236 redirector to the real download URL, or the download file name 248 redirector to the real download URL, or the download file name
237 is offered by an HTTP Content-Disposition header. In the 249 is offered by an HTTP Content-Disposition header. In the
238 following example, <filename>foo-1.0.0.tar.gz</filename> will be 250 following example, <filename>foo-1.0.0.tar.gz</filename> will be
239 created instead of the default 251 created instead of the default
240 <filename>v1.0.0.tar.gz</filename>.</para> 252 <filename>v1.0.0.tar.gz</filename>.</para>
241 253
242<programlisting> 254<programlisting>
243DISTNAME= foo-1.0.0 255DISTNAME= foo-1.0.0
244MASTER_SITES= -https://www.example.com/archive/v1.0.0.tar.gz 256MASTER_SITES= -https://www.example.com/archive/v1.0.0.tar.gz
245</programlisting> 257</programlisting>
246 258
247 <para>There are some predefined values for 259 <para>There are some predefined values for
248 <varname>MASTER_SITES</varname>, which can be used in 260 <varname>MASTER_SITES</varname>, which can be used in
249 packages. The names of the variables should speak for 261 packages. The names of the variables should speak for
250 themselves.</para> 262 themselves.</para>
251 263
252@master_sites@ 264@master_sites@
253 265
254 <para>Some explanations for the less self-explaining ones: 266 <para>Some explanations for the less self-explaining ones:
255 <varname>MASTER_SITE_BACKUP</varname> contains backup sites 267 <varname>MASTER_SITE_BACKUP</varname> contains backup sites
256 for packages that are maintained in <ulink 268 for packages that are maintained in <ulink
257 url="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/${DIST_SUBDIR}" 269 url="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/${DIST_SUBDIR}"
258 />. <varname>MASTER_SITE_LOCAL</varname> contains local 270 />. <varname>MASTER_SITE_LOCAL</varname> contains local
259 package source distributions that are maintained in <ulink 271 package source distributions that are maintained in <ulink
260 url="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/LOCAL_PORTS/" 272 url="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/LOCAL_PORTS/"
261 />.</para> 273 />.</para>
262 274
263 <para>If you choose one of these predefined sites, you may 275 <para>If you choose one of these predefined sites, you may
264 want to specify a subdirectory of that site. Since these 276 want to specify a subdirectory of that site. Since these
265 macros may expand to more than one actual site, you 277 macros may expand to more than one actual site, you
266 <emphasis>must</emphasis> use the following construct to 278 <emphasis>must</emphasis> use the following construct to
267 specify a subdirectory:</para> 279 specify a subdirectory:</para>
268 280
269<programlisting> 281<programlisting>
270MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/} 282MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
271MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/} 283MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
272</programlisting> 284</programlisting>
273 285
274 <para>Note the trailing slash after the subdirectory 286 <para>Note the trailing slash after the subdirectory
275 name.</para> 287 name.</para>
276 288
277 </sect2> 289 </sect2>
278 <sect2 id="build.fetch.how"> 290 <sect2 id="build.fetch.how">
279 <title>How are the files fetched?</title> 291 <title>How are the files fetched?</title>
280 292
281 <para>The <emphasis>fetch</emphasis> phase makes sure that 293 <para>The <emphasis>fetch</emphasis> phase makes sure that
282 all the distfiles exist in a local directory 294 all the distfiles exist in a local directory
283 (<varname>DISTDIR</varname>, which can be set by the pkgsrc 295 (<varname>DISTDIR</varname>, which can be set by the pkgsrc
284 user). If the files do not exist, they are fetched using 296 user). If the files do not exist, they are fetched using
285 commands of the form</para> 297 commands of the form</para>
286 298
287<programlisting> 299<programlisting>
288${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS} 300${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
289</programlisting> 301</programlisting>
290 302
291 <para>where <literal>${site}</literal> varies through 303 <para>where <literal>${site}</literal> varies through
292 several possibilities in turn: first, 304 several possibilities in turn: first,
293 <varname>MASTER_SITE_OVERRIDE</varname> is tried, then the 305 <varname>MASTER_SITE_OVERRIDE</varname> is tried, then the
294 sites specified in either <varname>SITES.file</varname> if 306 sites specified in either <varname>SITES.file</varname> if
295 defined, else <varname>MASTER_SITES</varname> or 307 defined, else <varname>MASTER_SITES</varname> or
296 <varname>PATCH_SITES</varname>, as applies, then finally the 308 <varname>PATCH_SITES</varname>, as applies, then finally the
297 value of <varname>MASTER_SITE_BACKUP</varname>. The order of 309 value of <varname>MASTER_SITE_BACKUP</varname>. The order of
298 all except the first and the last can be optionally sorted 310 all except the first and the last can be optionally sorted
299 by the user, via setting either 311 by the user, via setting either
300 <varname>MASTER_SORT_RANDOM</varname>, and 312 <varname>MASTER_SORT_RANDOM</varname>, and
301 <varname>MASTER_SORT_AWK</varname> or 313 <varname>MASTER_SORT_AWK</varname> or
302 <varname>MASTER_SORT_REGEX</varname>.</para> 314 <varname>MASTER_SORT_REGEX</varname>.</para>
303 315
304 <para> The specific command and arguments used depend on the 316 <para> The specific command and arguments used depend on the
305 <varname>FETCH_USING</varname> parameter. The example above is 317 <varname>FETCH_USING</varname> parameter. The example above is
306 for <literal>FETCH_USING=custom</literal>.</para> 318 for <literal>FETCH_USING=custom</literal>.</para>
307 319
308 <para>The distfiles mirror run by the NetBSD Foundation uses the 320 <para>The distfiles mirror run by the NetBSD Foundation uses the
309 <emphasis>mirror-distfiles</emphasis> target to mirror the 321 <emphasis>mirror-distfiles</emphasis> target to mirror the
310 distfiles, if they are freely distributable. Packages setting 322 distfiles, if they are freely distributable. Packages setting
311 <varname>NO_SRC_ON_FTP</varname> (usually to 323 <varname>NO_SRC_ON_FTP</varname> (usually to
312 <quote>${RESTRICTED}</quote>) will not have their distfiles 324 <quote>${RESTRICTED}</quote>) will not have their distfiles
313 mirrored.</para> 325 mirrored.</para>
314 </sect2> 326 </sect2>
315 327
316 </sect1> 328 </sect1>
317 329
318 <sect1 id="build.checksum"> 330 <sect1 id="build.checksum">
319 <title>The <emphasis>checksum</emphasis> phase</title> 331 <title>The <emphasis>checksum</emphasis> phase</title>
320 332
321 <para>After the distfile(s) are fetched, their checksum is 333 <para>After the distfile(s) are fetched, their checksum is
322 generated and compared with the checksums stored in the 334 generated and compared with the checksums stored in the
323 distinfo file. If the checksums don't match, the build is 335 distinfo file. If the checksums don't match, the build is
324 aborted. This is to ensure the same distfile is used for 336 aborted. This is to ensure the same distfile is used for
325 building, and that the distfile wasn't changed, e.g. by some 337 building, and that the distfile wasn't changed, e.g. by some
326 malign force, deliberately changed distfiles on the master 338 malign force, deliberately changed distfiles on the master
327 distribution site or network lossage.</para> 339 distribution site or network lossage.</para>
328 340
329 </sect1> 341 </sect1>
330 342
331 <sect1 id="build.extract"> 343 <sect1 id="build.extract">
332 <title>The <emphasis>extract</emphasis> phase</title> 344 <title>The <emphasis>extract</emphasis> phase</title>
333 345
334 <para>When the distfiles are present on the local system, they 346 <para>When the distfiles are present on the local system, they
335 need to be extracted, as they usually come in the form of some 347 need to be extracted, as they usually come in the form of some
336 compressed archive format.</para> 348 compressed archive format.</para>
337 349
338 <para>By default, all <varname>DISTFILES</varname> are 350 <para>By default, all <varname>DISTFILES</varname> are
339 extracted. If you only need some of them, you can set the 351 extracted. If you only need some of them, you can set the
340 <varname>EXTRACT_ONLY</varname> variable to the list of those 352 <varname>EXTRACT_ONLY</varname> variable to the list of those
341 files.</para> 353 files.</para>
342 354
343 <para>Extracting the files is usually done by a little 355 <para>Extracting the files is usually done by a little
344 program, <filename>mk/extract/extract</filename>, which 356 program, <filename>mk/extract/extract</filename>, which
345 already knows how to extract various archive formats, so most 357 already knows how to extract various archive formats, so most
346 likely you will not need to change anything here. But if you 358 likely you will not need to change anything here. But if you
347 need, the following variables may help you:</para> 359 need, the following variables may help you:</para>
348 360
349 <variablelist> 361 <variablelist>
350 362
351 <varlistentry><term><varname>EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</varname></term> 363 <varlistentry><term><varname>EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</varname></term>
352 <listitem><para>Use these variables to override the default 364 <listitem><para>Use these variables to override the default
353 options for an extract command, which are defined in 365 options for an extract command, which are defined in
354 <filename>mk/extract/extract</filename>.</para></listitem></varlistentry> 366 <filename>mk/extract/extract</filename>.</para></listitem></varlistentry>
355 367
356 <varlistentry><term><varname>EXTRACT_USING</varname></term> 368 <varlistentry><term><varname>EXTRACT_USING</varname></term>
357 <listitem><para>This variable can be set to 369 <listitem><para>This variable can be set to
358 <literal>bsdtar</literal>, <literal>gtar</literal>, <literal>nbtar</literal> 370 <literal>bsdtar</literal>, <literal>gtar</literal>, <literal>nbtar</literal>
359 (which is the default value), <literal>pax</literal>, or an 371 (which is the default value), <literal>pax</literal>, or an
360 absolute pathname pointing to the command with which tar 372 absolute pathname pointing to the command with which tar
361 archives should be extracted. It is preferred to choose bsdtar over gtar 373 archives should be extracted. It is preferred to choose bsdtar over gtar
362 if NetBSD's pax-as-tar is not good enough.</para></listitem></varlistentry> 374 if NetBSD's pax-as-tar is not good enough.</para></listitem></varlistentry>
363 375
364 </variablelist> 376 </variablelist>
365 377
366 <para>If the <filename>extract</filename> program doesn't 378 <para>If the <filename>extract</filename> program doesn't
367 serve your needs, you can also override the 379 serve your needs, you can also override the
368 <varname>EXTRACT_CMD</varname> variable, which holds the 380 <varname>EXTRACT_CMD</varname> variable, which holds the
369 command used for extracting the files. This command is 381 command used for extracting the files. This command is
370 executed in the <filename>${WRKSRC}</filename> 382 executed in the <filename>${WRKSRC}</filename>
371 directory. During execution of this command, the shell 383 directory. During execution of this command, the shell
372 variable <varname>extract_file</varname> holds the absolute 384 variable <varname>extract_file</varname> holds the absolute
373 pathname of the file that is going to be extracted.</para> 385 pathname of the file that is going to be extracted.</para>
374 386
375 <para>And if that still does not suffice, you can override the 387 <para>And if that still does not suffice, you can override the
376 <varname>do-extract</varname> target in the package 388 <varname>do-extract</varname> target in the package
377 Makefile.</para> 389 Makefile.</para>
378 390
379 </sect1> 391 </sect1>
380 392
381 <sect1 id="build.patch"> 393 <sect1 id="build.patch">
382 <title>The <emphasis>patch</emphasis> phase</title> 394 <title>The <emphasis>patch</emphasis> phase</title>
383 395
384 <para>After extraction, all the patches named by the 396 <para>After extraction, all the patches named by the
385 <varname>PATCHFILES</varname>, those present in the patches 397 <varname>PATCHFILES</varname>, those present in the patches
386 subdirectory of the package as well as in 398 subdirectory of the package as well as in
387 $LOCALPATCHES/$PKGPATH (e.g. 399 $LOCALPATCHES/$PKGPATH (e.g.
388 <filename>/usr/local/patches/graphics/png</filename>) are 400 <filename>/usr/local/patches/graphics/png</filename>) are
389 applied. Patchfiles ending in <filename>.Z</filename> or 401 applied. Patchfiles ending in <filename>.Z</filename> or
390 <filename>.gz</filename> are uncompressed before they are 402 <filename>.gz</filename> are uncompressed before they are
391 applied, files ending in <filename>.orig</filename> or 403 applied, files ending in <filename>.orig</filename> or
392 <filename>.rej</filename> are ignored. Any special options to 404 <filename>.rej</filename> are ignored. Any special options to
393 &man.patch.1; can be handed in 405 &man.patch.1; can be handed in
394 <varname>PATCH_DIST_ARGS</varname>. See <xref 406 <varname>PATCH_DIST_ARGS</varname>. See <xref
395 linkend="components.patches"/> for more details.</para> 407 linkend="components.patches"/> for more details.</para>
396 408
397 <para>By default &man.patch.1; is given special arguments to make it 409 <para>By default &man.patch.1; is given special arguments to make it
398 fail if the expected text from the patch context is not found in the 410 fail if the expected text from the patch context is not found in the
399 patched file. If that happens, fix the patch file by comparing it 411 patched file. If that happens, fix the patch file by comparing it
400 with the actual text in the file to be patched.</para> 412 with the actual text in the file to be patched.</para>
401 413
402 </sect1> 414 </sect1>
403 415
404 <sect1 id="build.tools"> 416 <sect1 id="build.tools">
405 <title>The <emphasis>tools</emphasis> phase</title> 417 <title>The <emphasis>tools</emphasis> phase</title>
406 418
407 <para>This is covered in <xref linkend="tools"/>. 419 <para>This is covered in <xref linkend="tools"/>.
408 </para> 420 </para>
409 421
410 </sect1> 422 </sect1>
411 423
412 <sect1 id="build.wrapper"> 424 <sect1 id="build.wrapper">
413 <title>The <emphasis>wrapper</emphasis> phase</title> 425 <title>The <emphasis>wrapper</emphasis> phase</title>
414 426
415 <para>This phase creates wrapper programs for the compilers and 427 <para>This phase creates wrapper programs for the compilers and
416 linkers. The following variables can be used to tweak the 428 linkers. The following variables can be used to tweak the
417 wrappers.</para> 429 wrappers.</para>
418 430
419 <variablelist> 431 <variablelist>
420 432
421 <varlistentry><term><varname>ECHO_WRAPPER_MSG</varname></term> 433 <varlistentry><term><varname>ECHO_WRAPPER_MSG</varname></term>
422 <listitem><para>The command used to print progress 434 <listitem><para>The command used to print progress
423 messages. Does nothing by default. Set to 435 messages. Does nothing by default. Set to
424 <literal>${ECHO}</literal> to see the progress 436 <literal>${ECHO}</literal> to see the progress
425 messages.</para></listitem></varlistentry> 437 messages.</para></listitem></varlistentry>
426 438
427 <varlistentry><term><varname>WRAPPER_DEBUG</varname></term> 439 <varlistentry><term><varname>WRAPPER_DEBUG</varname></term>
428 <listitem><para>This variable can be set to 440 <listitem><para>This variable can be set to
429 <literal>yes</literal> (default) or <literal>no</literal>, 441 <literal>yes</literal> (default) or <literal>no</literal>,
430 depending on whether you want additional information in the 442 depending on whether you want additional information in the
431 wrapper log file.</para></listitem></varlistentry> 443 wrapper log file.</para></listitem></varlistentry>
432 444
433 <varlistentry><term><varname>WRAPPER_UPDATE_CACHE</varname></term> 445 <varlistentry><term><varname>WRAPPER_UPDATE_CACHE</varname></term>
434 <listitem><para>This variable can be set to 446 <listitem><para>This variable can be set to
435 <literal>yes</literal> or <literal>no</literal>, depending 447 <literal>yes</literal> or <literal>no</literal>, depending
436 on whether the wrapper should use its cache, which will 448 on whether the wrapper should use its cache, which will
437 improve the speed. The default value is 449 improve the speed. The default value is
438 <literal>yes</literal>, but is forced to 450 <literal>yes</literal>, but is forced to
439 <literal>no</literal> if the platform does not support 451 <literal>no</literal> if the platform does not support
440 it.</para></listitem></varlistentry> 452 it.</para></listitem></varlistentry>
441 453
442 <varlistentry><term><varname>WRAPPER_REORDER_CMDS</varname></term> 454 <varlistentry><term><varname>WRAPPER_REORDER_CMDS</varname></term>
443 455
444 <listitem><para>A list of reordering commands. A reordering 456 <listitem><para>A list of reordering commands. A reordering
445 command has the form 457 command has the form
446 <literal>reorder:l:<replaceable>lib1</replaceable>:<replaceable>lib2</replaceable></literal>. 458 <literal>reorder:l:<replaceable>lib1</replaceable>:<replaceable>lib2</replaceable></literal>.
447 It ensures that that 459 It ensures that that
448 <literal>-l<replaceable>lib1</replaceable></literal> occurs 460 <literal>-l<replaceable>lib1</replaceable></literal> occurs
449 before <literal>-l<replaceable>lib2</replaceable></literal>. 461 before <literal>-l<replaceable>lib2</replaceable></literal>.
450 </para></listitem></varlistentry> 462 </para></listitem></varlistentry>
451 463
452 </variablelist> 464 </variablelist>
453 </sect1> 465 </sect1>
454 466
455 <sect1 id="build.configure"> 467 <sect1 id="build.configure">
456 <title>The <emphasis>configure</emphasis> phase</title> 468 <title>The <emphasis>configure</emphasis> phase</title>
457 469
458 <para>Most pieces of software need information on the header 470 <para>Most pieces of software need information on the header
459 files, system calls, and library routines which are available 471 files, system calls, and library routines which are available
460 on the platform they run on. The process of determining this 472 on the platform they run on. The process of determining this
461 information is known as configuration, and is usually 473 information is known as configuration, and is usually
462 automated. In most cases, a script is supplied with the 474 automated. In most cases, a script is supplied with the
463 distfiles, and its invocation results in generation of header 475 distfiles, and its invocation results in generation of header
464 files, Makefiles, etc.</para> 476 files, Makefiles, etc.</para>
465 477
466 <para>If the package contains a configure script, this can be 478 <para>If the package contains a configure script, this can be
467 invoked by setting <varname>HAS_CONFIGURE</varname> to 479 invoked by setting <varname>HAS_CONFIGURE</varname> to
468 <quote>yes</quote>. If the configure script is a GNU autoconf 480 <quote>yes</quote>. If the configure script is a GNU autoconf
469 script, you should set <varname>GNU_CONFIGURE</varname> to 481 script, you should set <varname>GNU_CONFIGURE</varname> to
470 <quote>yes</quote> instead.</para> 482 <quote>yes</quote> instead.</para>
471 483
472 <para>In the <literal>do-configure</literal> stage, a rough 484 <para>In the <literal>do-configure</literal> stage, a rough
473 equivalent of the following command is run. See 485 equivalent of the following command is run. See
474 <filename>mk/configure/configure.mk</filename>, target 486 <filename>mk/configure/configure.mk</filename>, target
475 <literal>do-configure-script</literal> for the exact 487 <literal>do-configure-script</literal> for the exact
476 definition.</para> 488 definition.</para>
477 489
478<programlisting> 490<programlisting>
479.for dir in ${CONFIGURE_DIRS} 491.for dir in ${CONFIGURE_DIRS}
480 cd ${WRKSRC} &amp;&amp; cd ${dir} \ 492 cd ${WRKSRC} &amp;&amp; cd ${dir} \
481 &amp;&amp; env ${CONFIGURE_ENV} \ 493 &amp;&amp; env ${CONFIGURE_ENV} \
482 ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS} 494 ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
483.endfor 495.endfor
484</programlisting> 496</programlisting>
485 497
486 <para><varname>CONFIGURE_DIRS</varname> (default: 498 <para><varname>CONFIGURE_DIRS</varname> (default:
487 <quote>.</quote>) is a list of pathnames relative to 499 <quote>.</quote>) is a list of pathnames relative to
488 <varname>WRKSRC</varname>. In each of these directories, the 500 <varname>WRKSRC</varname>. In each of these directories, the
489 configure script is run with the environment 501 configure script is run with the environment
490 <varname>CONFIGURE_ENV</varname> and arguments 502 <varname>CONFIGURE_ENV</varname> and arguments
491 <varname>CONFIGURE_ARGS</varname>. The variables 503 <varname>CONFIGURE_ARGS</varname>. The variables
492 <varname>CONFIGURE_ENV</varname>, 504 <varname>CONFIGURE_ENV</varname>,
493 <varname>CONFIGURE_SCRIPT</varname> (default: 505 <varname>CONFIGURE_SCRIPT</varname> (default:
494 <quote>./configure</quote>) and 506 <quote>./configure</quote>) and
495 <varname>CONFIGURE_ARGS</varname> may all be changed by the 507 <varname>CONFIGURE_ARGS</varname> may all be changed by the
496 package.</para> 508 package.</para>
497 509
498 <para>If the program uses the Perl way of configuration (mainly Perl 510 <para>If the program uses the Perl way of configuration (mainly Perl
499 modules, but not only), i.e. a file called 511 modules, but not only), i.e. a file called
500 <filename>Makefile.PL</filename>, it should include 512 <filename>Makefile.PL</filename>, it should include
501 <filename>../../lang/perl5/module.mk</filename>. To set any parameter for 513 <filename>../../lang/perl5/module.mk</filename>. To set any parameter for
502 <filename>Makefile.PL</filename> use the <varname>MAKE_PARAMS</varname> 514 <filename>Makefile.PL</filename> use the <varname>MAKE_PARAMS</varname>
503 variable (e.g., <literal>MAKE_PARAMS+=foo=bar</literal></para> 515 variable (e.g., <literal>MAKE_PARAMS+=foo=bar</literal></para>
504 516
505 <para>If the program uses an <filename>Imakefile</filename> 517 <para>If the program uses an <filename>Imakefile</filename>
506 for configuration, the appropriate steps can be invoked by 518 for configuration, the appropriate steps can be invoked by
507 setting <varname>USE_IMAKE</varname> to 519 setting <varname>USE_IMAKE</varname> to
508 <quote>yes</quote>. If you only need xmkmf, add it to <varname>USE_TOOLS</varname>. 520 <quote>yes</quote>. If you only need xmkmf, add it to <varname>USE_TOOLS</varname>.
509 You can add variables to xmkmf's environment by adding them to the 521 You can add variables to xmkmf's environment by adding them to the
510 <varname>SCRIPTS_ENV</varname> variable.</para> 522 <varname>SCRIPTS_ENV</varname> variable.</para>
511 523
512 <para>If the program uses <filename>cmake</filename> 524 <para>If the program uses <filename>cmake</filename>
513 for configuration, the appropriate steps can be invoked by 525 for configuration, the appropriate steps can be invoked by
514 setting <varname>USE_CMAKE</varname> to <quote>yes</quote>. 526 setting <varname>USE_CMAKE</varname> to <quote>yes</quote>.
515 You can add variables to cmake's environment by adding them to the 527 You can add variables to cmake's environment by adding them to the
516 <varname>CONFIGURE_ENV</varname> variable and arguments to cmake 528 <varname>CONFIGURE_ENV</varname> variable and arguments to cmake
517 by adding them to the <varname>CMAKE_ARGS</varname> variable. 529 by adding them to the <varname>CMAKE_ARGS</varname> variable.
518 The top directory argument is given by the 530 The top directory argument is given by the
519 <varname>CMAKE_ARG_PATH</varname> variable, that defaults to 531 <varname>CMAKE_ARG_PATH</varname> variable, that defaults to
520 <quote>.</quote> (relative to <varname>CONFIGURE_DIRS</varname>)</para> 532 <quote>.</quote> (relative to <varname>CONFIGURE_DIRS</varname>)</para>
521 533
522 <para>If there is no configure step at all, set 534 <para>If there is no configure step at all, set
523 <varname>NO_CONFIGURE</varname> to <quote>yes</quote>.</para> 535 <varname>NO_CONFIGURE</varname> to <quote>yes</quote>.</para>
524 </sect1> 536 </sect1>
525 537
526 <sect1 id="build.build"> 538 <sect1 id="build.build">
527 <title>The <emphasis>build</emphasis> phase</title> 539 <title>The <emphasis>build</emphasis> phase</title>
528 540
529 <para>For building a package, a rough equivalent of the following 541 <para>For building a package, a rough equivalent of the following
530 code is executed; see <filename>mk/build/build.mk</filename>, target 542 code is executed; see <filename>mk/build/build.mk</filename>, target
531 <literal>do-build</literal> for the exact definition.</para> 543 <literal>do-build</literal> for the exact definition.</para>
532 544
533<programlisting> 545<programlisting>
534.for dir in ${BUILD_DIRS} 546.for dir in ${BUILD_DIRS}
535 cd ${WRKSRC} &amp;&amp; cd ${dir} \ 547 cd ${WRKSRC} &amp;&amp; cd ${dir} \
536 &amp;&amp; env ${MAKE_ENV} \ 548 &amp;&amp; env ${MAKE_ENV} \
537 ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \ 549 ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
538 -f ${MAKE_FILE} \ 550 -f ${MAKE_FILE} \
539 ${BUILD_TARGET} 551 ${BUILD_TARGET}
540.endfor 552.endfor
541</programlisting> 553</programlisting>
542 554
543 <para><varname>BUILD_DIRS</varname> (default: 555 <para><varname>BUILD_DIRS</varname> (default:
544 <quote>.</quote>) is a list of pathnames relative to 556 <quote>.</quote>) is a list of pathnames relative to
545 <varname>WRKSRC</varname>. In each of these directories, 557 <varname>WRKSRC</varname>. In each of these directories,
546 <varname>MAKE_PROGRAM</varname> is run with the environment 558 <varname>MAKE_PROGRAM</varname> is run with the environment
547 <varname>MAKE_ENV</varname> and arguments 559 <varname>MAKE_ENV</varname> and arguments
548 <varname>BUILD_MAKE_FLAGS</varname>. The variables 560 <varname>BUILD_MAKE_FLAGS</varname>. The variables
549 <varname>MAKE_ENV</varname>, 561 <varname>MAKE_ENV</varname>,
550 <varname>BUILD_MAKE_FLAGS</varname>, 562 <varname>BUILD_MAKE_FLAGS</varname>,
551 <varname>MAKE_FILE</varname> and 563 <varname>MAKE_FILE</varname> and
552 <varname>BUILD_TARGET</varname> may all be changed by the 564 <varname>BUILD_TARGET</varname> may all be changed by the
553 package.</para> 565 package.</para>
554 566
555 <para>The default value of <varname>MAKE_PROGRAM</varname> is 567 <para>The default value of <varname>MAKE_PROGRAM</varname> is
556 <quote>gmake</quote> if <varname>USE_TOOLS</varname> contains 568 <quote>gmake</quote> if <varname>USE_TOOLS</varname> contains
557 <quote>gmake</quote>, <quote>make</quote> otherwise. The 569 <quote>gmake</quote>, <quote>make</quote> otherwise. The
558 default value of <varname>MAKE_FILE</varname> is 570 default value of <varname>MAKE_FILE</varname> is
559 <quote>Makefile</quote>, and <varname>BUILD_TARGET</varname> 571 <quote>Makefile</quote>, and <varname>BUILD_TARGET</varname>
560 defaults to <quote>all</quote>.</para> 572 defaults to <quote>all</quote>.</para>
561 573
562 <para>If there is no build step at all, set 574 <para>If there is no build step at all, set
563 <varname>NO_BUILD</varname> to <quote>yes</quote>.</para> 575 <varname>NO_BUILD</varname> to <quote>yes</quote>.</para>
564 </sect1> 576 </sect1>
565 577
566 <sect1 id="build.test"> 578 <sect1 id="build.test">
567 <title>The <emphasis>test</emphasis> phase</title> 579 <title>The <emphasis>test</emphasis> phase</title>
568 580
569 <para>[TODO]</para> 581 <para>[TODO]</para>
570 582
571 </sect1> 583 </sect1>
572 584
573 <sect1 id="build.install"> 585 <sect1 id="build.install">
574 <title>The <emphasis>install</emphasis> phase</title> 586 <title>The <emphasis>install</emphasis> phase</title>
575 587
576 <para>Once the build stage has completed, the final step is to 588 <para>Once the build stage has completed, the final step is to
577 install the software in public directories, so users can 589 install the software in public directories, so users can
578 access the programs and files.</para> 590 access the programs and files.</para>
579 591
580 <para>In the <emphasis>install</emphasis> phase, a rough equivalent 592 <para>In the <emphasis>install</emphasis> phase, a rough equivalent
581 of the following code is executed; see 593 of the following code is executed; see
582 <filename>mk/install/install.mk</filename>, target 594 <filename>mk/install/install.mk</filename>, target
583 <literal>do-install</literal> for the exact definition. Additionally, 595 <literal>do-install</literal> for the exact definition. Additionally,
584 before and after this code, several consistency checks are run 596 before and after this code, several consistency checks are run
585 against the files-to-be-installed, see 597 against the files-to-be-installed, see
586 <filename>mk/check/*.mk</filename> for details.</para> 598 <filename>mk/check/*.mk</filename> for details.</para>
587 599
588<programlisting> 600<programlisting>
589.for dir in ${INSTALL_DIRS} 601.for dir in ${INSTALL_DIRS}
590 cd ${WRKSRC} &amp;&amp; cd ${dir} \ 602 cd ${WRKSRC} &amp;&amp; cd ${dir} \
591 &amp;&amp; env ${INSTALL_ENV} ${MAKE_ENV} \ 603 &amp;&amp; env ${INSTALL_ENV} ${MAKE_ENV} \
592 ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \ 604 ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \
593 -f ${MAKE_FILE} ${INSTALL_TARGET} 605 -f ${MAKE_FILE} ${INSTALL_TARGET}
594.endfor 606.endfor
595</programlisting> 607</programlisting>
596 608
597 <para>The variable's meanings are analogous to the ones in the 609 <para>The variable's meanings are analogous to the ones in the
598 <emphasis>build</emphasis> phase. 610 <emphasis>build</emphasis> phase.
599 <varname>INSTALL_DIRS</varname> defaults to 611 <varname>INSTALL_DIRS</varname> defaults to
600 <varname>BUILD_DIRS</varname>. <varname>INSTALL_TARGET</varname> 612 <varname>BUILD_DIRS</varname>. <varname>INSTALL_TARGET</varname>
601 is <quote>install</quote> by default, plus 613 is <quote>install</quote> by default, plus
602 <quote>install.man</quote> if <varname>USE_IMAKE</varname> is 614 <quote>install.man</quote> if <varname>USE_IMAKE</varname> is
603 defined and <varname>NO_INSTALL_MANPAGES</varname> is not 615 defined and <varname>NO_INSTALL_MANPAGES</varname> is not
604 defined.</para> 616 defined.</para>
605 617
606 <para>In the <emphasis>install</emphasis> phase, the following 618 <para>In the <emphasis>install</emphasis> phase, the following
607 variables are useful. They are all variations of the 619 variables are useful. They are all variations of the
608 &man.install.1; command that have the owner, group and 620 &man.install.1; command that have the owner, group and
609 permissions preset. <varname>INSTALL</varname> is the plain 621 permissions preset. <varname>INSTALL</varname> is the plain
610 install command. The specialized variants, together with their 622 install command. The specialized variants, together with their
611 intended use, are:</para> 623 intended use, are:</para>
612 624
613 <variablelist> 625 <variablelist>
614 <varlistentry><term><varname>INSTALL_PROGRAM_DIR</varname></term> 626 <varlistentry><term><varname>INSTALL_PROGRAM_DIR</varname></term>
615 <listitem><para>directories that contain 627 <listitem><para>directories that contain
616 binaries</para></listitem></varlistentry> 628 binaries</para></listitem></varlistentry>
617 629
618 <varlistentry><term><varname>INSTALL_SCRIPT_DIR</varname></term> 630 <varlistentry><term><varname>INSTALL_SCRIPT_DIR</varname></term>
619 <listitem><para>directories that contain 631 <listitem><para>directories that contain
620 scripts</para></listitem></varlistentry> 632 scripts</para></listitem></varlistentry>
621 633
622 <varlistentry><term><varname>INSTALL_LIB_DIR</varname></term> 634 <varlistentry><term><varname>INSTALL_LIB_DIR</varname></term>
623 <listitem><para>directories that contain shared and static 635 <listitem><para>directories that contain shared and static
624 libraries</para></listitem></varlistentry> 636 libraries</para></listitem></varlistentry>
625 637
626 <varlistentry><term><varname>INSTALL_DATA_DIR</varname></term> 638 <varlistentry><term><varname>INSTALL_DATA_DIR</varname></term>
627 <listitem><para>directories that contain data 639 <listitem><para>directories that contain data
628 files</para></listitem></varlistentry> 640 files</para></listitem></varlistentry>
629 641
630 <varlistentry><term><varname>INSTALL_MAN_DIR</varname></term> 642 <varlistentry><term><varname>INSTALL_MAN_DIR</varname></term>
631 <listitem><para>directories that contain man 643 <listitem><para>directories that contain man
632 pages</para></listitem></varlistentry> 644 pages</para></listitem></varlistentry>
633 645
634 <varlistentry><term><varname>INSTALL_GAME_DIR</varname></term> 646 <varlistentry><term><varname>INSTALL_GAME_DIR</varname></term>
635 <listitem><para>directories that contain data files for games 647 <listitem><para>directories that contain data files for games
636 </para></listitem></varlistentry> 648 </para></listitem></varlistentry>
637 649
638 <varlistentry><term><varname>INSTALL_PROGRAM</varname></term> 650 <varlistentry><term><varname>INSTALL_PROGRAM</varname></term>
639 <listitem><para>binaries that can be stripped from debugging 651 <listitem><para>binaries that can be stripped from debugging
640 symbols</para></listitem></varlistentry> 652 symbols</para></listitem></varlistentry>
641 653
642 <varlistentry><term><varname>INSTALL_SCRIPT</varname></term> 654 <varlistentry><term><varname>INSTALL_SCRIPT</varname></term>
643 <listitem><para>binaries that cannot be 655 <listitem><para>binaries that cannot be
644 stripped</para></listitem></varlistentry> 656 stripped</para></listitem></varlistentry>
645 657
646 <varlistentry><term><varname>INSTALL_GAME</varname></term> 658 <varlistentry><term><varname>INSTALL_GAME</varname></term>
647 <listitem><para>game 659 <listitem><para>game
648 binaries</para></listitem></varlistentry> 660 binaries</para></listitem></varlistentry>
649 661
650 <varlistentry><term><varname>INSTALL_LIB</varname></term> 662 <varlistentry><term><varname>INSTALL_LIB</varname></term>
651 <listitem><para>shared and static 663 <listitem><para>shared and static
652 libraries</para></listitem></varlistentry> 664 libraries</para></listitem></varlistentry>
653 665
654 <varlistentry><term><varname>INSTALL_DATA</varname></term> 666 <varlistentry><term><varname>INSTALL_DATA</varname></term>
655 <listitem><para>data files</para></listitem></varlistentry> 667 <listitem><para>data files</para></listitem></varlistentry>
656 668
657 <varlistentry><term><varname>INSTALL_GAME_DATA</varname></term> 669 <varlistentry><term><varname>INSTALL_GAME_DATA</varname></term>
658 <listitem><para>data files for 670 <listitem><para>data files for
659 games</para></listitem></varlistentry> 671 games</para></listitem></varlistentry>
660 672
661 <varlistentry><term><varname>INSTALL_MAN</varname></term> 673 <varlistentry><term><varname>INSTALL_MAN</varname></term>
662 <listitem><para>man pages</para></listitem></varlistentry> 674 <listitem><para>man pages</para></listitem></varlistentry>
663 </variablelist> 675 </variablelist>
664 676
665 <para>Some other variables are:</para> 677 <para>Some other variables are:</para>
666 678
667 <variablelist> 679 <variablelist>
668 <varlistentry><term><varname>INSTALL_UNSTRIPPED</varname></term> 680 <varlistentry><term><varname>INSTALL_UNSTRIPPED</varname></term>
669 681
670 <listitem><para>If set to <literal>yes</literal>, do not run &man.strip.1; 682 <listitem><para>If set to <literal>yes</literal>, do not run &man.strip.1;
671 when installing binaries. Any debugging sections and symbols present in 683 when installing binaries. Any debugging sections and symbols present in
672 binaries will be preserved. 684 binaries will be preserved.
673 </para></listitem></varlistentry> 685 </para></listitem></varlistentry>
674 686
675 <varlistentry><term><varname>INSTALLATION_DIRS</varname></term> 687 <varlistentry><term><varname>INSTALLATION_DIRS</varname></term>
676 688
677 <listitem><para>A list of directories relative to 689 <listitem><para>A list of directories relative to
678 <varname>PREFIX</varname> that are created by pkgsrc at the 690 <varname>PREFIX</varname> that are created by pkgsrc at the
679 beginning of the <emphasis>install</emphasis> phase. 691 beginning of the <emphasis>install</emphasis> phase.
680 The package is supposed to create all needed directories itself 692 The package is supposed to create all needed directories itself
681 before installing files to it and list all other directories here. 693 before installing files to it and list all other directories here.
682 </para></listitem></varlistentry> 694 </para></listitem></varlistentry>
683 695
684 </variablelist> 696 </variablelist>
685 697
686 <para>In the rare cases that a package shouldn't install anything, 698 <para>In the rare cases that a package shouldn't install anything,
687 set <varname>NO_INSTALL</varname> to <quote>yes</quote>. This is 699 set <varname>NO_INSTALL</varname> to <quote>yes</quote>. This is
688 mostly relevant for packages in the <filename>regress</filename> 700 mostly relevant for packages in the <filename>regress</filename>
689 category.</para> 701 category.</para>
690 </sect1> 702 </sect1>
691 703
692 <sect1 id="build.package"> 704 <sect1 id="build.package">
693 <title>The <emphasis>package</emphasis> phase</title> 705 <title>The <emphasis>package</emphasis> phase</title>
694 706
695 <para>Once the install stage has completed, a binary package of 707 <para>Once the install stage has completed, a binary package of
696 the installed files can be built. These binary packages can be 708 the installed files can be built. These binary packages can be
697 used for quick installation without previous compilation, e.g. by 709 used for quick installation without previous compilation, e.g. by
698 the <command>make bin-install</command> or by using 710 the <command>make bin-install</command> or by using
699 <command>pkg_add</command>.</para> 711 <command>pkg_add</command>.</para>
700 712
701 <para>By default, the binary packages are created in 713 <para>By default, the binary packages are created in
702 <filename>${PACKAGES}/All</filename> and symlinks are created in 714 <filename>${PACKAGES}/All</filename> and symlinks are created in
703 <filename>${PACKAGES}/<replaceable>category</replaceable></filename>, 715 <filename>${PACKAGES}/<replaceable>category</replaceable></filename>,
704 one for each category in the <varname>CATEGORIES</varname> 716 one for each category in the <varname>CATEGORIES</varname>
705 variable. <varname>PACKAGES</varname> defaults to 717 variable. <varname>PACKAGES</varname> defaults to
706 <filename>pkgsrc/packages</filename>.</para> 718 <filename>pkgsrc/packages</filename>.</para>
707 </sect1> 719 </sect1>
708 720
709 <sect1 id="build.clean"> 721 <sect1 id="build.clean">
710 <title>Cleaning up</title> 722 <title>Cleaning up</title>
711 723
712 <para>Once you're finished with a package, you can clean the work 724 <para>Once you're finished with a package, you can clean the work
713 directory by running <command>make clean</command>. If you want 725 directory by running <command>make clean</command>. If you want
714 to clean the work directories of all dependencies too, use 726 to clean the work directories of all dependencies too, use
715 <command>make clean-depends</command>.</para> 727 <command>make clean-depends</command>.</para>
716 </sect1> 728 </sect1>
717 729
718 <sect1 id="build.helpful-targets"> 730 <sect1 id="build.helpful-targets">
719 <title>Other helpful targets</title> 731 <title>Other helpful targets</title>
720 732
721 <variablelist> 733 <variablelist>
722 <varlistentry> 734 <varlistentry>
723 <term>pre/post-*</term> 735 <term>pre/post-*</term>
724 736
725 <listitem> 737 <listitem>
726 <para>For any of the main targets described in the previous 738 <para>For any of the main targets described in the previous
727 section (configure, build, install, etc.), two auxiliary 739 section (configure, build, install, etc.), two auxiliary
728 targets exist with 740 targets exist with
729 <quote>pre-</quote> and <quote>post-</quote> used as a 741 <quote>pre-</quote> and <quote>post-</quote> used as a
730 prefix for the main target's name. These targets are 742 prefix for the main target's name. These targets are
731 invoked before and after the main target is called, 743 invoked before and after the main target is called,
732 allowing extra configuration or installation steps be 744 allowing extra configuration or installation steps be
733 performed from a package's Makefile, for example, which 745 performed from a package's Makefile, for example, which
734 a program's configure script or install target 746 a program's configure script or install target
735 omitted.</para> 747 omitted.</para>
736 748
737 <para>About 5% of the pkgsrc packages define their custom 749 <para>About 5% of the pkgsrc packages define their custom
738 post-extract target, another 5% define pre-configure, and 10% 750 post-extract target, another 5% define pre-configure, and 10%
739 define post-install. The other pre/post-* targets are defined 751 define post-install. The other pre/post-* targets are defined
740 even less often.</para> 752 even less often.</para>
741 </listitem> 753 </listitem>
742 </varlistentry> 754 </varlistentry>
743 755
744 <varlistentry> 756 <varlistentry>
745 <term>do-*</term> 757 <term>do-*</term>
746 758
747 <listitem> 759 <listitem>
748 <para>Should one of the main targets do the wrong thing, 760 <para>Should one of the main targets do the wrong thing,
749 and should there be no variable to fix this, you can 761 and should there be no variable to fix this, you can
750 redefine it with the do-* target. (Note that redefining 762 redefine it with the do-* target. (Note that redefining
751 the target itself instead of the do-* target is a bad 763 the target itself instead of the do-* target is a bad
752 idea, as the pre-* and post-* targets won't be called 764 idea, as the pre-* and post-* targets won't be called
753 anymore, etc.)</para> 765 anymore, etc.)</para>
754 766
755 <para>About 15% of the pkgsrc packages override the default 767 <para>About 15% of the pkgsrc packages override the default
756 do-install, the other do-* targets are overridden even less 768 do-install, the other do-* targets are overridden even less
757 often.</para> 769 often.</para>
758 </listitem> 770 </listitem>
759 </varlistentry> 771 </varlistentry>
760 772
761 <varlistentry> 773 <varlistentry>
762 <term>reinstall</term> 774 <term>reinstall</term>
763 775
764 <listitem> 776 <listitem>
765 <para>If you did a <command>make install</command> and 777 <para>If you did a <command>make install</command> and
766 you noticed some file was not installed properly, you 778 you noticed some file was not installed properly, you
767 can repeat the installation with this target, which will 779 can repeat the installation with this target, which will
768 ignore the <quote>already installed</quote> flag.</para> 780 ignore the <quote>already installed</quote> flag.</para>
769 781
770 <para>This is the default value of 782 <para>This is the default value of
771 <varname>DEPENDS_TARGET</varname> except in the case of 783 <varname>DEPENDS_TARGET</varname> except in the case of
772 <command>make update</command> and <command>make 784 <command>make update</command> and <command>make
773 package</command>, where the defaults are 785 package</command>, where the defaults are
774 <quote>package</quote> and <quote>update</quote>, 786 <quote>package</quote> and <quote>update</quote>,
775 respectively.</para> 787 respectively.</para>
776 </listitem> 788 </listitem>
777 </varlistentry> 789 </varlistentry>
778 790
779 <varlistentry> 791 <varlistentry>
780 <term>deinstall</term> 792 <term>deinstall</term>
781 793
782 <listitem> 794 <listitem>
783 <para>This target does a &man.pkg.delete.1; in the 795 <para>This target does a &man.pkg.delete.1; in the
784 current directory, effectively de-installing the 796 current directory, effectively de-installing the
785 package. The following variables can be used to tune the 797 package. The following variables can be used to tune the
786 behaviour:</para> 798 behaviour:</para>
787 799
788 <variablelist> 800 <variablelist>
789 <varlistentry> 801 <varlistentry>
790 <term><varname>PKG_VERBOSE</varname></term> 802 <term><varname>PKG_VERBOSE</varname></term>
791 803
792 <listitem> 804 <listitem>
793 <para>Add a "-v" to the &man.pkg.delete.1; command.</para> 805 <para>Add a "-v" to the &man.pkg.delete.1; command.</para>
794 </listitem> 806 </listitem>
795 </varlistentry> 807 </varlistentry>
796 808
797 <varlistentry> 809 <varlistentry>
798 <term><varname>DEINSTALLDEPENDS</varname></term> 810 <term><varname>DEINSTALLDEPENDS</varname></term>
799 811
800 <listitem> 812 <listitem>
801 <para>Remove all packages that require (depend on) 813 <para>Remove all packages that require (depend on)
802 the given package. This can be used to remove any 814 the given package. This can be used to remove any
803 packages that may have been pulled in by a given 815 packages that may have been pulled in by a given
804 package, e.g. if <command>make deinstall 816 package, e.g. if <command>make deinstall
805 DEINSTALLDEPENDS=1</command> is done in 817 DEINSTALLDEPENDS=1</command> is done in
806 <filename>pkgsrc/x11/kde</filename>, this is 818 <filename>pkgsrc/x11/kde</filename>, this is
807 likely to remove whole KDE. Works by adding 819 likely to remove whole KDE. Works by adding
808 <quote>-R</quote> to the &man.pkg.delete.1; 820 <quote>-R</quote> to the &man.pkg.delete.1;
809 command line.</para> 821 command line.</para>
810 </listitem> 822 </listitem>
811 </varlistentry> 823 </varlistentry>
812 </variablelist> 824 </variablelist>
813 </listitem> 825 </listitem>
814 </varlistentry> 826 </varlistentry>
815 827
816 <varlistentry> 828 <varlistentry>
817 <term>bin-install</term> 829 <term>bin-install</term>
818 830
819 <listitem> 831 <listitem>
820 <para>Install a binary package from local disk and via FTP 832 <para>Install a binary package from local disk and via FTP
821 from a list of sites (see the 833 from a list of sites (see the
822 <varname>BINPKG_SITES</varname> variable), and do a 834 <varname>BINPKG_SITES</varname> variable), and do a
823 <command>make package</command> if no binary package is 835 <command>make package</command> if no binary package is
824 available anywhere. The arguments given to 836 available anywhere. The arguments given to
825 <command>pkg_add</command> can be set via 837 <command>pkg_add</command> can be set via
826 <varname>BIN_INSTALL_FLAGS</varname> e.g., to do verbose 838 <varname>BIN_INSTALL_FLAGS</varname> e.g., to do verbose
827 operation, etc.</para> 839 operation, etc.</para>
828 </listitem> 840 </listitem>
829 </varlistentry> 841 </varlistentry>
830 842
831 <varlistentry> 843 <varlistentry>
832 <term>install-clean</term> 844 <term>install-clean</term>
833 845
834 <listitem> 846 <listitem>
835 <para>This target removes the state files for the "install" and later 847 <para>This target removes the state files for the "install" and later
836 phases so that the "install" target may be re-invoked. This can be 848 phases so that the "install" target may be re-invoked. This can be
837 used after editing the PLIST to install the package without 849 used after editing the PLIST to install the package without
838 rebuilding it.</para> 850 rebuilding it.</para>
839 </listitem> 851 </listitem>
840 </varlistentry> 852 </varlistentry>
841 853
842 <varlistentry> 854 <varlistentry>
843 <term>build-clean</term> 855 <term>build-clean</term>
844 856
845 <listitem> 857 <listitem>
846 <para>This target removes the state files for the "build" and later 858 <para>This target removes the state files for the "build" and later
847 phases so that the "build" target may be re-invoked.</para> 859 phases so that the "build" target may be re-invoked.</para>
848 </listitem> 860 </listitem>
849 </varlistentry> 861 </varlistentry>
850 862
851 <varlistentry> 863 <varlistentry>
852 <term>update</term> 864 <term>update</term>
853 865
854 <listitem> 866 <listitem>
855 <para>This target causes the current package to be 867 <para>This target causes the current package to be
856 updated to the latest version. The package and all 868 updated to the latest version. The package and all
857 depending packages first get de-installed, then current 869 depending packages first get de-installed, then current
858 versions of the corresponding packages get compiled and 870 versions of the corresponding packages get compiled and
859 installed. This is similar to manually noting which 871 installed. This is similar to manually noting which
860 packages are currently installed, then performing a 872 packages are currently installed, then performing a
861 series of <command>make deinstall</command> and 873 series of <command>make deinstall</command> and
862 <command>make install</command> (or whatever 874 <command>make install</command> (or whatever
863 <varname>UPDATE_TARGET</varname> is set to) for these 875 <varname>UPDATE_TARGET</varname> is set to) for these
864 packages.</para> 876 packages.</para>
865 877
866 <para>You can use the <quote>update</quote> target to 878 <para>You can use the <quote>update</quote> target to
867 resume package updating in case a previous <command>make 879 resume package updating in case a previous <command>make
868 update</command> was interrupted for some reason. 880 update</command> was interrupted for some reason.
869 However, in this case, make sure you don't call 881 However, in this case, make sure you don't call
870 <command>make clean</command> or otherwise remove the 882 <command>make clean</command> or otherwise remove the
871 list of dependent packages in <varname>WRKDIR</varname>. 883 list of dependent packages in <varname>WRKDIR</varname>.
872 Otherwise, you lose the ability to automatically update 884 Otherwise, you lose the ability to automatically update
873 the current package along with the dependent packages 885 the current package along with the dependent packages
874 you have installed.</para> 886 you have installed.</para>
875 887
876 <para>Resuming an interrupted <command>make 888 <para>Resuming an interrupted <command>make
877 update</command> will only work as long as the package 889 update</command> will only work as long as the package
878 tree remains unchanged. If the source code for one of 890 tree remains unchanged. If the source code for one of
879 the packages to be updated has been changed, resuming 891 the packages to be updated has been changed, resuming
880 <command>make update</command> will most certainly 892 <command>make update</command> will most certainly
881 fail!</para> 893 fail!</para>
882 894
883 <para>The following variables can be used either on the 895 <para>The following variables can be used either on the
884 command line or in &mk.conf; to 896 command line or in &mk.conf; to
885 alter the behaviour of <command>make 897 alter the behaviour of <command>make
886 update</command>:</para> 898 update</command>:</para>
887 899
888 <variablelist> 900 <variablelist>
889 <varlistentry> 901 <varlistentry>
890 <term><varname>UPDATE_TARGET</varname></term> 902 <term><varname>UPDATE_TARGET</varname></term>
891 903
892 <listitem> 904 <listitem>
893 <para>Install target to recursively use for the 905 <para>Install target to recursively use for the
894 updated package and the dependent packages. 906 updated package and the dependent packages.
895 Defaults to <varname>DEPENDS_TARGET</varname> if 907 Defaults to <varname>DEPENDS_TARGET</varname> if
896 set, <quote>install</quote> otherwise for 908 set, <quote>install</quote> otherwise for
897 <command>make update</command>. Other good 909 <command>make update</command>. Other good
898 targets are <quote>package</quote> or 910 targets are <quote>package</quote> or
899 <quote>bin-install</quote>. Do not set this to 911 <quote>bin-install</quote>. Do not set this to
900 <quote>update</quote> or you will get stuck in an 912 <quote>update</quote> or you will get stuck in an
901 endless loop!</para> 913 endless loop!</para>
902 </listitem> 914 </listitem>
903 </varlistentry> 915 </varlistentry>
904 916
905 <varlistentry> 917 <varlistentry>
906 <term><varname>NOCLEAN</varname></term> 918 <term><varname>NOCLEAN</varname></term>
907 919
908 <listitem> 920 <listitem>
909 <para>Don't clean up after updating. Useful if 921 <para>Don't clean up after updating. Useful if
910 you want to leave the work sources of the updated 922 you want to leave the work sources of the updated
911 packages around for inspection or other purposes. 923 packages around for inspection or other purposes.
912 Be sure you eventually clean up the source tree 924 Be sure you eventually clean up the source tree
913 (see the <quote>clean-update</quote> target below) 925 (see the <quote>clean-update</quote> target below)
914 or you may run into troubles with old source code 926 or you may run into troubles with old source code
915 still lying around on your next 927 still lying around on your next
916 <command>make</command> or <command>make 928 <command>make</command> or <command>make
917 update</command>.</para> 929 update</command>.</para>
918 </listitem> 930 </listitem>
919 </varlistentry> 931 </varlistentry>
920 932
921 <varlistentry> 933 <varlistentry>
922 <term><varname>REINSTALL</varname></term> 934 <term><varname>REINSTALL</varname></term>
923 935
924 <listitem> 936 <listitem>
925 <para>Deinstall each package before installing 937 <para>Deinstall each package before installing
926 (making <varname>DEPENDS_TARGET</varname>). This 938 (making <varname>DEPENDS_TARGET</varname>). This
927 may be necessary if the 939 may be necessary if the
928 <quote>clean-update</quote> target (see below) was 940 <quote>clean-update</quote> target (see below) was
929 called after interrupting a running <command>make 941 called after interrupting a running <command>make
930 update</command>.</para> 942 update</command>.</para>
931 </listitem> 943 </listitem>
932 </varlistentry> 944 </varlistentry>
933 945
934 <varlistentry> 946 <varlistentry>
935 <term><varname>DEPENDS_TARGET</varname></term> 947 <term><varname>DEPENDS_TARGET</varname></term>
936 948
937 <listitem> 949 <listitem>
938 <para>Allows you to disable recursion and hardcode 950 <para>Allows you to disable recursion and hardcode
939 the target for packages. The default is 951 the target for packages. The default is
940 <quote>update</quote> for the update target, 952 <quote>update</quote> for the update target,
941 facilitating a recursive update of prerequisite 953 facilitating a recursive update of prerequisite
942 packages. Only set 954 packages. Only set
943 <varname>DEPENDS_TARGET</varname> if you want to 955 <varname>DEPENDS_TARGET</varname> if you want to
944 disable recursive updates. Use 956 disable recursive updates. Use
945 <varname>UPDATE_TARGET</varname> instead to just 957 <varname>UPDATE_TARGET</varname> instead to just
946 set a specific target for each package to be 958 set a specific target for each package to be
947 installed during <command>make update</command> 959 installed during <command>make update</command>
948 (see above).</para> 960 (see above).</para>
949 </listitem> 961 </listitem>
950 </varlistentry> 962 </varlistentry>
951 </variablelist> 963 </variablelist>
952 </listitem> 964 </listitem>
953 </varlistentry> 965 </varlistentry>
954 966
955 <varlistentry> 967 <varlistentry>
956 <term>clean-update</term> 968 <term>clean-update</term>
957 969
958 <listitem> 970 <listitem>
959 <para>Clean the source tree for all packages that would 971 <para>Clean the source tree for all packages that would
960 get updated if <command>make update</command> was called 972 get updated if <command>make update</command> was called
961 from the current directory. This target should not be 973 from the current directory. This target should not be
962 used if the current package (or any of its depending 974 used if the current package (or any of its depending
963 packages) have already been de-installed (e.g., after 975 packages) have already been de-installed (e.g., after
964 calling <command>make update</command>) or you may lose 976 calling <command>make update</command>) or you may lose
965 some packages you intended to update. As a rule of 977 some packages you intended to update. As a rule of
966 thumb: only use this target <emphasis>before</emphasis> 978 thumb: only use this target <emphasis>before</emphasis>
967 the first time you run <command>make update</command> 979 the first time you run <command>make update</command>
968 and only if you have a dirty package tree (e.g., if you 980 and only if you have a dirty package tree (e.g., if you
969 used <varname>NOCLEAN</varname>).</para> 981 used <varname>NOCLEAN</varname>).</para>
970 982
971 <para>If you are unsure about whether your tree is 983 <para>If you are unsure about whether your tree is
972 clean, you can either perform a <command>make 984 clean, you can either perform a <command>make
973 clean</command> at the top of the tree, or use the 985 clean</command> at the top of the tree, or use the
974 following sequence of commands from the directory of the 986 following sequence of commands from the directory of the
975 package you want to update (<emphasis>before</emphasis> 987 package you want to update (<emphasis>before</emphasis>
976 running <command>make update</command> for the first 988 running <command>make update</command> for the first
977 time, otherwise you lose all the packages you wanted to 989 time, otherwise you lose all the packages you wanted to
978 update!):</para> 990 update!):</para>
979 991
980 <screen> 992 <screen>
981&rprompt; <userinput>make clean-update</userinput> 993&rprompt; <userinput>make clean-update</userinput>
982&rprompt; <userinput>make clean CLEANDEPENDS=YES</userinput> 994&rprompt; <userinput>make clean CLEANDEPENDS=YES</userinput>
983&rprompt; <userinput>make update</userinput> 995&rprompt; <userinput>make update</userinput>
984 </screen> 996 </screen>
985 997
986 <para>The following variables can be used either on the 998 <para>The following variables can be used either on the
987 command line or in &mk.conf; to alter the behaviour of 999 command line or in &mk.conf; to alter the behaviour of
988 <command>make clean-update</command>:</para> 1000 <command>make clean-update</command>:</para>
989 1001
990 <variablelist> 1002 <variablelist>
991 <varlistentry> 1003 <varlistentry>
992 <term><varname>CLEAR_DIRLIST</varname></term> 1004 <term><varname>CLEAR_DIRLIST</varname></term>
993 1005
994 <listitem> 1006 <listitem>
995 <para>After <command>make clean</command>, do not 1007 <para>After <command>make clean</command>, do not
996 reconstruct the list of directories to update for 1008 reconstruct the list of directories to update for
997 this package. Only use this if <command>make 1009 this package. Only use this if <command>make
998 update</command> successfully installed all 1010 update</command> successfully installed all
999 packages you wanted to update. Normally, this is 1011 packages you wanted to update. Normally, this is
1000 done automatically on <command>make 1012 done automatically on <command>make
1001 update</command>, but may have been suppressed by 1013 update</command>, but may have been suppressed by
1002 the <varname>NOCLEAN</varname> variable (see 1014 the <varname>NOCLEAN</varname> variable (see
1003 above).</para> 1015 above).</para>
1004 </listitem> 1016 </listitem>
1005 </varlistentry> 1017 </varlistentry>
1006 </variablelist> 1018 </variablelist>
1007 </listitem> 1019 </listitem>
1008 </varlistentry> 1020 </varlistentry>
1009 1021
1010 <varlistentry> 1022 <varlistentry>
1011 <term>replace</term> 1023 <term>replace</term>
1012 1024
1013 <listitem> 1025 <listitem>
1014 <para>Update the installation of the current package. This 1026 <para>Update the installation of the current package. This
1015 differs from update in that it does not replace dependent 1027 differs from update in that it does not replace dependent
1016 packages. You will need to install <filename 1028 packages. You will need to install <filename
1017 role="pkg">pkgtools/pkg_tarup</filename> for this 1029 role="pkg">pkgtools/pkg_tarup</filename> for this
1018 target to work.</para> 1030 target to work.</para>
1019 1031
1020 <para><emphasis>Be careful when using this 1032 <para><emphasis>Be careful when using this
1021 target!</emphasis> There are no guarantees that dependent 1033 target!</emphasis> There are no guarantees that dependent
1022 packages will still work, in particular they will most 1034 packages will still work, in particular they will most
1023 certainly break if you <command>make replace</command> a 1035 certainly break if you <command>make replace</command> a
1024 library package whose shared library major version changed 1036 library package whose shared library major version changed
1025 between your installed version and the new one. For this 1037 between your installed version and the new one. For this
1026 reason, this target is not officially supported and only 1038 reason, this target is not officially supported and only
1027 recommended for advanced users.</para> 1039 recommended for advanced users.</para>
1028 </listitem> 1040 </listitem>
1029 </varlistentry> 1041 </varlistentry>
1030 1042
1031 <varlistentry> 1043 <varlistentry>
1032 <term>info</term> 1044 <term>info</term>
1033 1045
1034 <listitem> 1046 <listitem>
1035 <para>This target invokes &man.pkg.info.1; for the current 1047 <para>This target invokes &man.pkg.info.1; for the current
1036 package. You can use this to check which version of a 1048 package. You can use this to check which version of a
1037 package is installed.</para> 1049 package is installed.</para>
1038 </listitem> 1050 </listitem>
1039 </varlistentry> 1051 </varlistentry>
1040 1052
1041 <varlistentry> 1053 <varlistentry>
1042 <term>index</term> 1054 <term>index</term>
1043 1055
1044 <listitem> 1056 <listitem>
1045 <para>This is a top-level command, i.e. it should be used in 1057 <para>This is a top-level command, i.e. it should be used in
1046 the <filename>pkgsrc</filename> directory. It creates a 1058 the <filename>pkgsrc</filename> directory. It creates a
1047 database of all packages in the local pkgsrc tree, including 1059 database of all packages in the local pkgsrc tree, including
1048 dependencies, comment, maintainer, and some other useful 1060 dependencies, comment, maintainer, and some other useful
1049 information. Individual entries are created by running 1061 information. Individual entries are created by running
1050 <command>make describe</command> in the packages' 1062 <command>make describe</command> in the packages'
1051 directories. This index file is saved as 1063 directories. This index file is saved as
1052 <filename>pkgsrc/INDEX</filename>. It can be displayed in 1064 <filename>pkgsrc/INDEX</filename>. It can be displayed in
1053 verbose format by running <command>make 1065 verbose format by running <command>make
1054 print-index</command>. You can search in it with 1066 print-index</command>. You can search in it with
1055 <command>make search 1067 <command>make search
1056 key=<replaceable>something</replaceable></command>. You can 1068 key=<replaceable>something</replaceable></command>. You can
1057 extract a list of all packages that depend on a particular 1069 extract a list of all packages that depend on a particular
1058 one by running <command>make show-deps 1070 one by running <command>make show-deps
1059 PKG=<replaceable>somepackage</replaceable></command>.</para> 1071 PKG=<replaceable>somepackage</replaceable></command>.</para>
1060 1072
1061 <para>Running this command takes a very long time, some 1073 <para>Running this command takes a very long time, some
1062 hours even on fast machines!</para> 1074 hours even on fast machines!</para>
1063 </listitem> 1075 </listitem>
1064 </varlistentry> 1076 </varlistentry>
1065 1077
1066 1078
1067 <varlistentry> 1079 <varlistentry>
1068 <term>readme</term> 1080 <term>readme</term>
1069 1081
1070 <listitem> 1082 <listitem>
1071 <para>This target generates a 1083 <para>This target generates a
1072 <filename>index.html</filename> file, which can be 1084 <filename>index.html</filename> file, which can be
1073 viewed using a browser such as <filename 1085 viewed using a browser such as <filename
1074 role="pkg">www/firefox</filename> or <filename 1086 role="pkg">www/firefox</filename> or <filename
1075 role="pkg">www/links</filename>. The generated files 1087 role="pkg">www/links</filename>. The generated files
1076 contain references to any packages which are in the 1088 contain references to any packages which are in the
1077 <varname>PACKAGES</varname> directory on the local 1089 <varname>PACKAGES</varname> directory on the local
1078 host. The generated files can be made to refer to URLs 1090 host. The generated files can be made to refer to URLs
1079 based on <varname>FTP_PKG_URL_HOST</varname> and 1091 based on <varname>FTP_PKG_URL_HOST</varname> and
1080 <varname>FTP_PKG_URL_DIR</varname>. For example, if I 1092 <varname>FTP_PKG_URL_DIR</varname>. For example, if I
1081 wanted to generate <filename>index.html</filename> 1093 wanted to generate <filename>index.html</filename>
1082 files which pointed to binary packages on the local 1094 files which pointed to binary packages on the local
1083 machine, in the directory 1095 machine, in the directory
1084 <filename>/usr/packages</filename>, set 1096 <filename>/usr/packages</filename>, set
1085 <varname>FTP_PKG_URL_HOST=file://localhost</varname> and 1097 <varname>FTP_PKG_URL_HOST=file://localhost</varname> and
1086 <varname>FTP_PKG_URL_DIR=/usr/packages</varname>. The 1098 <varname>FTP_PKG_URL_DIR=/usr/packages</varname>. The
1087 <varname>${PACKAGES}</varname> directory and its 1099 <varname>${PACKAGES}</varname> directory and its
1088 subdirectories will be searched for all the binary 1100 subdirectories will be searched for all the binary
1089 packages.</para> 1101 packages.</para>
1090 1102
1091 <para>The target can be run at the toplevel or in category 1103 <para>The target can be run at the toplevel or in category
1092 directories, in which case it descends recursively.</para> 1104 directories, in which case it descends recursively.</para>
1093 </listitem> 1105 </listitem>
1094 </varlistentry> 1106 </varlistentry>
1095 1107
1096 <varlistentry> 1108 <varlistentry>
1097 <term>readme-all</term> 1109 <term>readme-all</term>
1098 1110
1099 <listitem> 1111 <listitem>
1100 <para>This is a top-level command, run it in 1112 <para>This is a top-level command, run it in
1101 <filename>pkgsrc</filename>. Use this target to create a 1113 <filename>pkgsrc</filename>. Use this target to create a
1102 file <filename>README-all.html</filename> which contains a 1114 file <filename>README-all.html</filename> which contains a
1103 list of all packages currently available in the &os; 1115 list of all packages currently available in the &os;
1104 Packages Collection, together with the category they belong 1116 Packages Collection, together with the category they belong
1105 to and a short description. This file is compiled from the 1117 to and a short description. This file is compiled from the
1106 <filename>pkgsrc/*/index.html</filename> files, so be sure 1118 <filename>pkgsrc/*/index.html</filename> files, so be sure
1107 to run this <emphasis>after</emphasis> a <command>make 1119 to run this <emphasis>after</emphasis> a <command>make
1108 readme</command>.</para> 1120 readme</command>.</para>
1109 </listitem> 1121 </listitem>
1110 </varlistentry> 1122 </varlistentry>
1111 1123
1112 <varlistentry> 1124 <varlistentry>
1113 <term>cdrom-readme</term> 1125 <term>cdrom-readme</term>
1114 1126
1115 <listitem> 1127 <listitem>
1116 <para>This is very much the same as the 1128 <para>This is very much the same as the
1117 <quote>readme</quote> target (see above), but is to be 1129 <quote>readme</quote> target (see above), but is to be
1118 used when generating a pkgsrc tree to be written to a 1130 used when generating a pkgsrc tree to be written to a
1119 CD-ROM. This target also produces 1131 CD-ROM. This target also produces
1120 <filename>index.html</filename> files, and can be made 1132 <filename>index.html</filename> files, and can be made
1121 to refer to URLs based on 1133 to refer to URLs based on
1122 <varname>CDROM_PKG_URL_HOST</varname> and 1134 <varname>CDROM_PKG_URL_HOST</varname> and
1123 <varname>CDROM_PKG_URL_DIR</varname>.</para> 1135 <varname>CDROM_PKG_URL_DIR</varname>.</para>
1124 </listitem> 1136 </listitem>
1125 </varlistentry> 1137 </varlistentry>
1126 1138
1127 <varlistentry> 1139 <varlistentry>
1128 <term>show-distfiles</term> 1140 <term>show-distfiles</term>
1129 1141
1130 <listitem> 1142 <listitem>
1131 <para>This target shows which distfiles and patchfiles 1143 <para>This target shows which distfiles and patchfiles
1132 are needed to build the package 1144 are needed to build the package
1133 (<varname>ALLFILES</varname>, which contains all 1145 (<varname>ALLFILES</varname>, which contains all
1134 <varname>DISTFILES</varname> and 1146 <varname>DISTFILES</varname> and
1135 <varname>PATCHFILES</varname>, but not 1147 <varname>PATCHFILES</varname>, but not
1136 <filename>patches/*</filename>).</para> 1148 <filename>patches/*</filename>).</para>
1137 </listitem> 1149 </listitem>
1138 </varlistentry> 1150 </varlistentry>
1139 1151
1140 <varlistentry> 1152 <varlistentry>
1141 <term>show-downlevel</term> 1153 <term>show-downlevel</term>
1142 1154
1143 <listitem> 1155 <listitem>
1144 <para>This target shows nothing if the package is not 1156 <para>This target shows nothing if the package is not
1145 installed. If a version of this package is installed, 1157 installed. If a version of this package is installed,
1146 but is not the version provided in this version of 1158 but is not the version provided in this version of
1147 pkgsrc, then a warning message is displayed. This target 1159 pkgsrc, then a warning message is displayed. This target
1148 can be used to show which of your installed packages are 1160 can be used to show which of your installed packages are
1149 downlevel, and so the old versions can be deleted, and 1161 downlevel, and so the old versions can be deleted, and
1150 the current ones added.</para> 1162 the current ones added.</para>
1151 </listitem> 1163 </listitem>
1152 </varlistentry> 1164 </varlistentry>
1153 1165
1154 <varlistentry> 1166 <varlistentry>
1155 <term>show-pkgsrc-dir</term> 1167 <term>show-pkgsrc-dir</term>
1156 1168
1157 <listitem> 1169 <listitem>
1158 <para>This target shows the directory in the pkgsrc 1170 <para>This target shows the directory in the pkgsrc
1159 hierarchy from which the package can be built and 1171 hierarchy from which the package can be built and
1160 installed. This may not be the same directory as the one 1172 installed. This may not be the same directory as the one