Fixup fromcvs/togit conversion
[pkgsrcv2.git] / doc / pkgsrc.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
5 <title>The pkgsrc guide</title>
6 <link rel="stylesheet" type="text/css" href="/global.css">
7 <meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
8 <meta name="description" content="pkgsrc is a centralized package management system for Unix-like operating systems. This guide provides information for users and developers of pkgsrc. It covers installation of binary and source packages, creation of binary and source packages and a high-level overview about the infrastructure.">
9 </head>
10 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book">
11 <div class="titlepage">
12 <div>
13 <div><h1 class="title">
14 <a name="the-pkgsrc-guide"></a>The pkgsrc guide</h1></div>
15 <div><h2 class="subtitle">Documentation on the NetBSD packages system</h2></div>
16 <div><div class="authorgroup">
17 <div class="author">
18 <h3 class="author">
19 <span class="firstname">Alistair</span> <span class="surname">Crooks</span>
20 </h3>
21 <div class="affiliation"><div class="address"><p><code class="email">&lt;<a class="email" href="mailto:agc@NetBSD.org">agc@NetBSD.org</a>&gt;</code></p></div></div>
22 </div>
23 <div class="author">
24 <h3 class="author">
25 <span class="firstname">Hubert</span> <span class="surname">Feyrer</span>
26 </h3>
27 <div class="affiliation"><div class="address"><p><code class="email">&lt;<a class="email" href="mailto:hubertf@NetBSD.org">hubertf@NetBSD.org</a>&gt;</code></p></div></div>
28 </div>
29 <h3 class="corpauthor">
30         The pkgsrc Developers
31       </h3>
32 </div></div>
33 <div><p class="copyright">Copyright © 1994-2007 The NetBSD Foundation, Inc</p></div>
34 <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.26 2007/09/18 08:17:21 rillig Exp $</p></div>
35 <div><div class="abstract">
36 <p class="title"><b>Abstract</b></p>
37 <p>pkgsrc is a centralized package management system for
38         Unix-like operating systems. This guide provides information for
39         users and developers of pkgsrc. It covers installation of binary
40         and source packages, creation of binary and source packages and
41         a high-level overview about the infrastructure.</p>
42 </div></div>
43 </div>
44 <hr>
45 </div>
46 <div class="toc">
47 <p><b>Table of Contents</b></p>
48 <dl>
49 <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
50 <dd><dl>
51 <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
52 <dd><dl>
53 <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
54 <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
55 </dl></dd>
56 <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
57 <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
58 <dd><dl><dt><span class="sect2"><a href="#term.roles">1.3.1. Roles involved in pkgsrc</a></span></dt></dl></dd>
59 <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
60 </dl></dd>
61 <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
62 <dd><dl>
63 <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
64 <dd><dl>
65 <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
66 <dd><dl>
67 <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar archive</a></span></dt>
68 <dt><span class="sect2"><a href="#getting-via-cvs">2.1.2. Via anonymous CVS</a></span></dt>
69 </dl></dd>
70 <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
71 <dd><dl>
72 <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
73 <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
74 </dl></dd>
75 </dl></dd>
76 <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
77 <dd><dl>
78 <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
79 <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
80 <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
81 <dd><dl>
82 <dt><span class="sect2"><a href="#cygwin">3.3.1. Cygwin</a></span></dt>
83 <dt><span class="sect2"><a href="#darwin">3.3.2. Darwin (Mac OS X)</a></span></dt>
84 <dt><span class="sect2"><a href="#freebsd">3.3.3. FreeBSD</a></span></dt>
85 <dt><span class="sect2"><a href="#interix">3.3.4. Interix</a></span></dt>
86 <dt><span class="sect2"><a href="#irix">3.3.5. IRIX</a></span></dt>
87 <dt><span class="sect2"><a href="#linux">3.3.6. Linux</a></span></dt>
88 <dt><span class="sect2"><a href="#openbsd">3.3.7. OpenBSD</a></span></dt>
89 <dt><span class="sect2"><a href="#solaris">3.3.8. Solaris</a></span></dt>
90 </dl></dd>
91 </dl></dd>
92 <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
93 <dd><dl>
94 <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
95 <dd><dl>
96 <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
97 <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
98 <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
99 <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
100 <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
101 <dt><span class="sect2"><a href="#pkg_versions">4.1.6. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
102 <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
103 <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
104 </dl></dd>
105 <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
106 <dd><dl>
107 <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
108 <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
109 <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
110 </dl></dd>
111 </dl></dd>
112 <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
113 <dd><dl>
114 <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
115 <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
116 <dt><span class="sect1"><a href="#variables-affecting-installation">5.3. Variables affecting the installation process</a></span></dt>
117 <dt><span class="sect1"><a href="#conf.compiler">5.4. Selecting and configuring the compiler</a></span></dt>
118 <dd><dl>
119 <dt><span class="sect2"><a href="#selecting-the-compiler">5.4.1. Selecting the compiler</a></span></dt>
120 <dt><span class="sect2"><a href="#conf.cflags">5.4.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
121 <dt><span class="sect2"><a href="#conf.ldflags">5.4.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
122 </dl></dd>
123 <dt><span class="sect1"><a href="#developer-advanced-settings">5.5. Developer/advanced settings</a></span></dt>
124 <dt><span class="sect1"><a href="#selecting-build-options">5.6. Selecting Build Options</a></span></dt>
125 </dl></dd>
126 <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
127 <dd><dl>
128 <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
129 <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
130 </dl></dd>
131 <dt><span class="chapter"><a href="#bulk">7. Creating binary packages for everything in pkgsrc (bulk
132 builds)</a></span></dt>
133 <dd><dl>
134 <dt><span class="sect1"><a href="#bulk.pre">7.1. Think first, build later</a></span></dt>
135 <dt><span class="sect1"><a href="#bulk.req">7.2. Requirements of a bulk build</a></span></dt>
136 <dt><span class="sect1"><a href="#bulk.old">7.3. Running an old-style bulk build</a></span></dt>
137 <dd><dl>
138 <dt><span class="sect2"><a href="#binary.configuration">7.3.1. Configuration</a></span></dt>
139 <dt><span class="sect2"><a href="#other-environmental-considerations">7.3.2. Other environmental considerations</a></span></dt>
140 <dt><span class="sect2"><a href="#operation">7.3.3. Operation</a></span></dt>
141 <dt><span class="sect2"><a href="#what-it-does">7.3.4. What it does</a></span></dt>
142 <dt><span class="sect2"><a href="#disk-space-requirements">7.3.5. Disk space requirements</a></span></dt>
143 <dt><span class="sect2"><a href="#setting-up-a-sandbox">7.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
144 <dt><span class="sect2"><a href="#building-a-partial-set">7.3.7. Building a partial set of packages</a></span></dt>
145 <dt><span class="sect2"><a href="#bulk-upload">7.3.8. Uploading results of a bulk build</a></span></dt>
146 </dl></dd>
147 <dt><span class="sect1"><a href="#bulk.pbulk">7.4. Running a pbulk-style bulk build</a></span></dt>
148 <dd><dl>
149 <dt><span class="sect2"><a href="#bulk.pbulk.prepare">7.4.1. Preparation</a></span></dt>
150 <dt><span class="sect2"><a href="#bulk.pbulk.conf">7.4.2. Configuration</a></span></dt>
151 </dl></dd>
152 <dt><span class="sect1"><a href="#creating-cdroms">7.5. Creating a multiple CD-ROM packages collection</a></span></dt>
153 <dd><dl><dt><span class="sect2"><a href="#cdpack-example">7.5.1. Example of cdpack</a></span></dt></dl></dd>
154 </dl></dd>
155 <dt><span class="chapter"><a href="#files">8. Directory layout of the installed files</a></span></dt>
156 <dd><dl>
157 <dt><span class="sect1"><a href="#files.localbase">8.1. File system layout in <code class="literal">${LOCALBASE}</code></a></span></dt>
158 <dt><span class="sect1"><a href="#files.varbase">8.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
159 </dl></dd>
160 <dt><span class="chapter"><a href="#faq">9. Frequently Asked Questions</a></span></dt>
161 <dd><dl>
162 <dt><span class="sect1"><a href="#mailing-list-pointers">9.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
163 <dt><span class="sect1"><a href="#pkgviews-docs">9.2. Where's the pkgviews documentation?</a></span></dt>
164 <dt><span class="sect1"><a href="#faq-pkgtools">9.3. Utilities for package management (pkgtools)</a></span></dt>
165 <dt><span class="sect1"><a href="#non-root-pkgsrc">9.4. How to use pkgsrc as non-root</a></span></dt>
166 <dt><span class="sect1"><a href="#resume-transfers">9.5. How to resume transfers when fetching distfiles?</a></span></dt>
167 <dt><span class="sect1"><a href="#x.org-from-pkgsrc">9.6. How can I install/use modular X.org from pkgsrc?</a></span></dt>
168 <dt><span class="sect1"><a href="#fetch-behind-firewall">9.7. How to fetch files from behind a firewall</a></span></dt>
169 <dt><span class="sect1"><a href="#passive-ftp">9.8. How do I tell <span class="command"><strong>make fetch</strong></span> to do passive FTP?</a></span></dt>
170 <dt><span class="sect1"><a href="#fetching-all-distfiles">9.9. How to fetch all distfiles at once</a></span></dt>
171 <dt><span class="sect1"><a href="#tmac.andoc-missing">9.10. What does <span class="quote">&#8220;<span class="quote">Don't know how to make
172 /usr/share/tmac/tmac.andoc</span>&#8221;</span> mean?</a></span></dt>
173 <dt><span class="sect1"><a href="#bsd.own.mk-missing">9.11. What does <span class="quote">&#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221;</span> mean?</a></span></dt>
174 <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">9.12. Using 'sudo' with pkgsrc</a></span></dt>
175 <dt><span class="sect1"><a href="#faq.conf">9.13. How do I change the location of configuration files?</a></span></dt>
176 <dt><span class="sect1"><a href="#audit-packages">9.14. Automated security checks</a></span></dt>
177 <dt><span class="sect1"><a href="#ufaq-cflags">9.15. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
178 <dt><span class="sect1"><a href="#ufaq-fail">9.16. A package does not build.  What shall I do?</a></span></dt>
179 <dt><span class="sect1"><a href="#faq.rcs-conflicts">9.17. What does <span class="quote">&#8220;<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>&#8221;</span> mean?</a></span></dt>
180 </dl></dd>
181 </dl></dd>
182 <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
183 <dd><dl>
184 <dt><span class="chapter"><a href="#creating">10. Creating a new pkgsrc package from scratch</a></span></dt>
185 <dd><dl>
186 <dt><span class="sect1"><a href="#creating.common">10.1. Common types of packages</a></span></dt>
187 <dd><dl>
188 <dt><span class="sect2"><a href="#creating.perl-module">10.1.1. Perl modules</a></span></dt>
189 <dt><span class="sect2"><a href="#creating.kde-app">10.1.2. KDE applications</a></span></dt>
190 <dt><span class="sect2"><a href="#creating.python-module">10.1.3. Python modules and programs</a></span></dt>
191 </dl></dd>
192 <dt><span class="sect1"><a href="#creating.examples">10.2. Examples</a></span></dt>
193 <dd><dl><dt><span class="sect2"><a href="#creating.nvu">10.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
194 </dl></dd>
195 <dt><span class="chapter"><a href="#components">11. Package components - files, directories and contents</a></span></dt>
196 <dd><dl>
197 <dt><span class="sect1"><a href="#components.Makefile">11.1. <code class="filename">Makefile</code></a></span></dt>
198 <dt><span class="sect1"><a href="#components.distinfo">11.2. <code class="filename">distinfo</code></a></span></dt>
199 <dt><span class="sect1"><a href="#components.patches">11.3. patches/*</a></span></dt>
200 <dd><dl>
201 <dt><span class="sect2"><a href="#components.patch.structure">11.3.1. Structure of a single patch file</a></span></dt>
202 <dt><span class="sect2"><a href="#components.patches.caveats">11.3.2. Creating patch files</a></span></dt>
203 <dt><span class="sect2"><a href="#components.patches.sources">11.3.3. Sources where the patch files come from</a></span></dt>
204 <dt><span class="sect2"><a href="#components.patches.guidelines">11.3.4. Patching guidelines</a></span></dt>
205 <dt><span class="sect2"><a href="#components.patches.feedback">11.3.5. Feedback to the author</a></span></dt>
206 </dl></dd>
207 <dt><span class="sect1"><a href="#other-mandatory-files">11.4. Other mandatory files</a></span></dt>
208 <dt><span class="sect1"><a href="#components.optional">11.5. Optional files</a></span></dt>
209 <dd><dl>
210 <dt><span class="sect2"><a href="#components.optional.bin">11.5.1. Files affecting the binary package</a></span></dt>
211 <dt><span class="sect2"><a href="#components.optional.build">11.5.2. Files affecting the build process</a></span></dt>
212 <dt><span class="sect2"><a href="#components.optional.none">11.5.3. Files affecting nothing at all</a></span></dt>
213 </dl></dd>
214 <dt><span class="sect1"><a href="#work-dir">11.6. <code class="filename">work*</code></a></span></dt>
215 <dt><span class="sect1"><a href="#files-dir">11.7. <code class="filename">files/*</code></a></span></dt>
216 </dl></dd>
217 <dt><span class="chapter"><a href="#makefile">12. Programming in <code class="filename">Makefile</code>s</a></span></dt>
218 <dd><dl>
219 <dt><span class="sect1"><a href="#makefile.style">12.1. Caveats</a></span></dt>
220 <dt><span class="sect1"><a href="#makefile.variables">12.2. <code class="filename">Makefile</code> variables</a></span></dt>
221 <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">12.2.1. Naming conventions</a></span></dt></dl></dd>
222 <dt><span class="sect1"><a href="#makefile.code">12.3. Code snippets</a></span></dt>
223 <dd><dl>
224 <dt><span class="sect2"><a href="#adding-to-list">12.3.1. Adding things to a list</a></span></dt>
225 <dt><span class="sect2"><a href="#converting-internal-to-external">12.3.2. Converting an internal list into an external list</a></span></dt>
226 <dt><span class="sect2"><a href="#passing-variable-to-shell">12.3.3. Passing variables to a shell command</a></span></dt>
227 <dt><span class="sect2"><a href="#quoting-guideline">12.3.4. Quoting guideline</a></span></dt>
228 <dt><span class="sect2"><a href="#bsd-make-bug-workaround">12.3.5. Workaround for a bug in BSD Make</a></span></dt>
229 </dl></dd>
230 </dl></dd>
231 <dt><span class="chapter"><a href="#plist">13. PLIST issues</a></span></dt>
232 <dd><dl>
233 <dt><span class="sect1"><a href="#rcs-id">13.1. RCS ID</a></span></dt>
234 <dt><span class="sect1"><a href="#automatic-plist-generation">13.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
235 <dt><span class="sect1"><a href="#print-PLIST">13.3. Tweaking output of <span class="command"><strong>make print-PLIST</strong></span></a></span></dt>
236 <dt><span class="sect1"><a href="#plist.misc">13.4. Variable substitution in PLIST</a></span></dt>
237 <dt><span class="sect1"><a href="#manpage-compression">13.5. Man page compression</a></span></dt>
238 <dt><span class="sect1"><a href="#using-PLIST_SRC">13.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
239 <dt><span class="sect1"><a href="#platform-specific-plist">13.7. Platform-specific and differing PLISTs</a></span></dt>
240 <dt><span class="sect1"><a href="#faq.common-dirs">13.8. Sharing directories between packages</a></span></dt>
241 </dl></dd>
242 <dt><span class="chapter"><a href="#buildlink">14. Buildlink methodology</a></span></dt>
243 <dd><dl>
244 <dt><span class="sect1"><a href="#converting-to-buildlink3">14.1. Converting packages to use buildlink3</a></span></dt>
245 <dt><span class="sect1"><a href="#creating-buildlink3.mk">14.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
246 <dd><dl>
247 <dt><span class="sect2"><a href="#anatomy-of-bl3">14.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
248 <dt><span class="sect2"><a href="#updating-buildlink-depends">14.2.2. Updating
249       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
250       and
251       <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
252       in <code class="filename">buildlink3.mk</code> files</a></span></dt>
253 </dl></dd>
254 <dt><span class="sect1"><a href="#writing-builtin.mk">14.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
255 <dd><dl>
256 <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">14.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
257 <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">14.3.2. Global preferences for native or pkgsrc software</a></span></dt>
258 </dl></dd>
259 </dl></dd>
260 <dt><span class="chapter"><a href="#pkginstall">15. The pkginstall framework</a></span></dt>
261 <dd><dl>
262 <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">15.1. Files and directories outside the installation prefix</a></span></dt>
263 <dd><dl>
264 <dt><span class="sect2"><a href="#dirs-outside-prefix">15.1.1. Directory manipulation</a></span></dt>
265 <dt><span class="sect2"><a href="#files-outside-prefix">15.1.2. File manipulation</a></span></dt>
266 </dl></dd>
267 <dt><span class="sect1"><a href="#conf-files">15.2. Configuration files</a></span></dt>
268 <dd><dl>
269 <dt><span class="sect2"><a href="#conf-files-sysconfdir">15.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
270 <dt><span class="sect2"><a href="#conf-files-configure">15.2.2. Telling the software where configuration files are</a></span></dt>
271 <dt><span class="sect2"><a href="#conf-files-patching">15.2.3. Patching installations</a></span></dt>
272 <dt><span class="sect2"><a href="#conf-files-disable">15.2.4. Disabling handling of configuration files</a></span></dt>
273 </dl></dd>
274 <dt><span class="sect1"><a href="#rcd-scripts">15.3. System startup scripts</a></span></dt>
275 <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">15.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
276 <dt><span class="sect1"><a href="#users-and-groups">15.4. System users and groups</a></span></dt>
277 <dt><span class="sect1"><a href="#shells">15.5. System shells</a></span></dt>
278 <dd><dl><dt><span class="sect2"><a href="#shells-disable">15.5.1. Disabling shell registration</a></span></dt></dl></dd>
279 <dt><span class="sect1"><a href="#fonts">15.6. Fonts</a></span></dt>
280 <dd><dl><dt><span class="sect2"><a href="#fonts-disable">15.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
281 </dl></dd>
282 <dt><span class="chapter"><a href="#options">16. Options handling</a></span></dt>
283 <dd><dl>
284 <dt><span class="sect1"><a href="#global-default-options">16.1. Global default options</a></span></dt>
285 <dt><span class="sect1"><a href="#converting-to-options">16.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
286 <dt><span class="sect1"><a href="#option-names">16.3. Option Names</a></span></dt>
287 <dt><span class="sect1"><a href="#option-build">16.4. Determining the options of dependencies</a></span></dt>
288 </dl></dd>
289 <dt><span class="chapter"><a href="#build">17. The build process</a></span></dt>
290 <dd><dl>
291 <dt><span class="sect1"><a href="#build.intro">17.1. Introduction</a></span></dt>
292 <dt><span class="sect1"><a href="#build.prefix">17.2. Program location</a></span></dt>
293 <dt><span class="sect1"><a href="#build.builddirs">17.3. Directories used during the build process</a></span></dt>
294 <dt><span class="sect1"><a href="#build.running">17.4. Running a phase</a></span></dt>
295 <dt><span class="sect1"><a href="#build.fetch">17.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
296 <dd><dl>
297 <dt><span class="sect2"><a href="#build.fetch.what">17.5.1. What to fetch and where to get it from</a></span></dt>
298 <dt><span class="sect2"><a href="#build.fetch.how">17.5.2. How are the files fetched?</a></span></dt>
299 </dl></dd>
300 <dt><span class="sect1"><a href="#build.checksum">17.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
301 <dt><span class="sect1"><a href="#build.extract">17.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
302 <dt><span class="sect1"><a href="#build.patch">17.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
303 <dt><span class="sect1"><a href="#build.tools">17.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
304 <dt><span class="sect1"><a href="#build.wrapper">17.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
305 <dt><span class="sect1"><a href="#build.configure">17.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
306 <dt><span class="sect1"><a href="#build.build">17.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
307 <dt><span class="sect1"><a href="#build.test">17.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
308 <dt><span class="sect1"><a href="#build.install">17.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
309 <dt><span class="sect1"><a href="#build.package">17.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
310 <dt><span class="sect1"><a href="#build.clean">17.16. Cleaning up</a></span></dt>
311 <dt><span class="sect1"><a href="#build.helpful-targets">17.17. Other helpful targets</a></span></dt>
312 </dl></dd>
313 <dt><span class="chapter"><a href="#tools">18. Tools needed for building or running</a></span></dt>
314 <dd><dl>
315 <dt><span class="sect1"><a href="#pkgsrc-tools">18.1. Tools for pkgsrc builds</a></span></dt>
316 <dt><span class="sect1"><a href="#package-tools">18.2. Tools needed by packages</a></span></dt>
317 <dt><span class="sect1"><a href="#platform-tools">18.3. Tools provided by platforms</a></span></dt>
318 <dt><span class="sect1"><a href="#tools.questions">18.4. Questions regarding the tools</a></span></dt>
319 </dl></dd>
320 <dt><span class="chapter"><a href="#fixes">19. Making your package work</a></span></dt>
321 <dd><dl>
322 <dt><span class="sect1"><a href="#general-operation">19.1. General operation</a></span></dt>
323 <dd><dl>
324 <dt><span class="sect2"><a href="#portability-of-packages">19.1.1. Portability of packages</a></span></dt>
325 <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">19.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
326 <dt><span class="sect2"><a href="#user-interaction">19.1.3. User interaction</a></span></dt>
327 <dt><span class="sect2"><a href="#handling-licenses">19.1.4. Handling licenses</a></span></dt>
328 <dt><span class="sect2"><a href="#restricted-packages">19.1.5. Restricted packages</a></span></dt>
329 <dt><span class="sect2"><a href="#dependencies">19.1.6. Handling dependencies</a></span></dt>
330 <dt><span class="sect2"><a href="#conflicts">19.1.7. Handling conflicts with other packages</a></span></dt>
331 <dt><span class="sect2"><a href="#not-building-packages">19.1.8. Packages that cannot or should not be built</a></span></dt>
332 <dt><span class="sect2"><a href="#undeletable-packages">19.1.9. Packages which should not be deleted, once installed</a></span></dt>
333 <dt><span class="sect2"><a href="#security-handling">19.1.10. Handling packages with security problems</a></span></dt>
334 <dt><span class="sect2"><a href="#bumping-pkgrevision">19.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
335 <dt><span class="sect2"><a href="#fixes.subst">19.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
336 </dl></dd>
337 <dt><span class="sect1"><a href="#fixes.fetch">19.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
338 <dd><dl>
339 <dt><span class="sect2"><a href="#no-plain-download">19.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
340 <dt><span class="sect2"><a href="#modified-distfiles-same-name">19.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
341 </dl></dd>
342 <dt><span class="sect1"><a href="#fixes.configure">19.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
343 <dd><dl>
344 <dt><span class="sect2"><a href="#fixes.libtool">19.3.1. Shared libraries - libtool</a></span></dt>
345 <dt><span class="sect2"><a href="#using-libtool">19.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
346 <dt><span class="sect2"><a href="#autoconf-automake">19.3.3. GNU Autoconf/Automake</a></span></dt>
347 </dl></dd>
348 <dt><span class="sect1"><a href="#programming-languages">19.4. Programming languages</a></span></dt>
349 <dd><dl>
350 <dt><span class="sect2"><a href="#basic-programming-languages">19.4.1. C, C++, and Fortran</a></span></dt>
351 <dt><span class="sect2"><a href="#java-programming-language">19.4.2. Java</a></span></dt>
352 <dt><span class="sect2"><a href="#perl-scripts">19.4.3. Packages containing perl scripts</a></span></dt>
353 <dt><span class="sect2"><a href="#shell-scripts">19.4.4. Packages containing shell scripts</a></span></dt>
354 <dt><span class="sect2"><a href="#other-programming-languages">19.4.5. Other programming languages</a></span></dt>
355 </dl></dd>
356 <dt><span class="sect1"><a href="#fixes.build">19.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
357 <dd><dl>
358 <dt><span class="sect2"><a href="#fixes.build.cpp">19.5.1. Compiling C and C++ code conditionally</a></span></dt>
359 <dt><span class="sect2"><a href="#compiler-bugs">19.5.2. How to handle compiler bugs</a></span></dt>
360 <dt><span class="sect2"><a href="#undefined-reference">19.5.3. Undefined reference to <span class="quote">&#8220;<span class="quote">...</span>&#8221;</span></a></span></dt>
361 <dt><span class="sect2"><a href="#out-of-memory">19.5.4. Running out of memory</a></span></dt>
362 </dl></dd>
363 <dt><span class="sect1"><a href="#fixes.install">19.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
364 <dd><dl>
365 <dt><span class="sect2"><a href="#install-scripts">19.6.1. Creating needed directories</a></span></dt>
366 <dt><span class="sect2"><a href="#where-to-install-documentation">19.6.2. Where to install documentation</a></span></dt>
367 <dt><span class="sect2"><a href="#installing-score-files">19.6.3. Installing highscore files</a></span></dt>
368 <dt><span class="sect2"><a href="#destdir-support">19.6.4. Adding DESTDIR support to packages</a></span></dt>
369 <dt><span class="sect2"><a href="#hardcoded-paths">19.6.5. Packages with hardcoded paths to other interpreters</a></span></dt>
370 <dt><span class="sect2"><a href="#perl-modules">19.6.6. Packages installing perl modules</a></span></dt>
371 <dt><span class="sect2"><a href="#faq.info-files">19.6.7. Packages installing info files</a></span></dt>
372 <dt><span class="sect2"><a href="#manpages">19.6.8. Packages installing man pages</a></span></dt>
373 <dt><span class="sect2"><a href="#gconf-data-files">19.6.9. Packages installing GConf data files</a></span></dt>
374 <dt><span class="sect2"><a href="#scrollkeeper-data-files">19.6.10. Packages installing scrollkeeper/rarian data files</a></span></dt>
375 <dt><span class="sect2"><a href="#x11-fonts">19.6.11. Packages installing X11 fonts</a></span></dt>
376 <dt><span class="sect2"><a href="#gtk2-modules">19.6.12. Packages installing GTK2 modules</a></span></dt>
377 <dt><span class="sect2"><a href="#sgml-xml-data">19.6.13. Packages installing SGML or XML data</a></span></dt>
378 <dt><span class="sect2"><a href="#mime-database">19.6.14. Packages installing extensions to the MIME database</a></span></dt>
379 <dt><span class="sect2"><a href="#intltool">19.6.15. Packages using intltool</a></span></dt>
380 <dt><span class="sect2"><a href="#startup-scripts">19.6.16. Packages installing startup scripts</a></span></dt>
381 <dt><span class="sect2"><a href="#tex-packages">19.6.17. Packages installing TeX modules</a></span></dt>
382 <dt><span class="sect2"><a href="#emulation-packages">19.6.18. Packages supporting running binaries in
383     emulation</a></span></dt>
384 <dt><span class="sect2"><a href="#hicolor-theme">19.6.19. Packages installing hicolor theme icons</a></span></dt>
385 <dt><span class="sect2"><a href="#desktop-files">19.6.20. Packages installing desktop files</a></span></dt>
386 </dl></dd>
387 <dt><span class="sect1"><a href="#punting">19.7. Marking packages as having problems</a></span></dt>
388 </dl></dd>
389 <dt><span class="chapter"><a href="#debug">20. Debugging</a></span></dt>
390 <dt><span class="chapter"><a href="#submit">21. Submitting and Committing</a></span></dt>
391 <dd><dl>
392 <dt><span class="sect1"><a href="#submitting-binary-packages">21.1. Submitting binary packages</a></span></dt>
393 <dt><span class="sect1"><a href="#submitting-your-package">21.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
394 <dt><span class="sect1"><a href="#general-notes-for-changes">21.3. General notes when adding, updating, or removing packages</a></span></dt>
395 <dt><span class="sect1"><a href="#committing-importing">21.4. Committing: Adding a package to CVS</a></span></dt>
396 <dt><span class="sect1"><a href="#updating-package">21.5. Updating a package to a newer version</a></span></dt>
397 <dt><span class="sect1"><a href="#renaming-package">21.6. Renaming a package in pkgsrc</a></span></dt>
398 <dt><span class="sect1"><a href="#moving-package">21.7. Moving a package in pkgsrc</a></span></dt>
399 </dl></dd>
400 <dt><span class="chapter"><a href="#devfaq">22. Frequently Asked Questions</a></span></dt>
401 <dt><span class="chapter"><a href="#gnome">23. GNOME packaging and porting</a></span></dt>
402 <dd><dl>
403 <dt><span class="sect1"><a href="#meta-packages">23.1. Meta packages</a></span></dt>
404 <dt><span class="sect1"><a href="#new-package">23.2. Packaging a GNOME application</a></span></dt>
405 <dt><span class="sect1"><a href="#full-update">23.3. Updating GNOME to a newer version</a></span></dt>
406 <dt><span class="sect1"><a href="#patching">23.4. Patching guidelines</a></span></dt>
407 </dl></dd>
408 </dl></dd>
409 <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
410 <dd><dl>
411 <dt><span class="chapter"><a href="#infr.design">24. Design of the pkgsrc infrastructure</a></span></dt>
412 <dd><dl>
413 <dt><span class="sect1"><a href="#infr.vardef">24.1. The meaning of variable definitions</a></span></dt>
414 <dt><span class="sect1"><a href="#infr.vardef.problems">24.2. Avoiding problems before they arise</a></span></dt>
415 <dt><span class="sect1"><a href="#infr.var">24.3. Variable evaluation</a></span></dt>
416 <dd><dl>
417 <dt><span class="sect2"><a href="#infr.var.load">24.3.1. At load time</a></span></dt>
418 <dt><span class="sect2"><a href="#infr.var.run">24.3.2. At runtime</a></span></dt>
419 </dl></dd>
420 <dt><span class="sect1"><a href="#infr.varspec">24.4. How can variables be specified?</a></span></dt>
421 <dt><span class="sect1"><a href="#infr.design.intf">24.5. Designing interfaces for Makefile fragments</a></span></dt>
422 <dd><dl>
423 <dt><span class="sect2"><a href="#infr.design.intf.proc">24.5.1. Procedures with parameters</a></span></dt>
424 <dt><span class="sect2"><a href="#infr.design.intf.action">24.5.2. Actions taken on behalf of parameters</a></span></dt>
425 </dl></dd>
426 <dt><span class="sect1"><a href="#infr.order">24.6. The order in which files are loaded</a></span></dt>
427 <dd><dl>
428 <dt><span class="sect2"><a href="#infr.order.prefs">24.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
429 <dt><span class="sect2"><a href="#infr.order.pkg">24.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
430 </dl></dd>
431 </dl></dd>
432 <dt><span class="chapter"><a href="#regression">25. Regression tests</a></span></dt>
433 <dd><dl>
434 <dt><span class="sect1"><a href="#regression.descr">25.1. The regression tests framework</a></span></dt>
435 <dt><span class="sect1"><a href="#regression.run">25.2. Running the regression tests</a></span></dt>
436 <dt><span class="sect1"><a href="#regression.new">25.3. Adding a new regression test</a></span></dt>
437 <dd><dl>
438 <dt><span class="sect2"><a href="#regression.fun.override">25.3.1. Overridable functions</a></span></dt>
439 <dt><span class="sect2"><a href="#regression.fun.helper">25.3.2. Helper functions</a></span></dt>
440 </dl></dd>
441 </dl></dd>
442 <dt><span class="chapter"><a href="#porting">26. Porting pkgsrc</a></span></dt>
443 <dd><dl>
444 <dt><span class="sect1"><a href="#porting.opsys">26.1. Porting pkgsrc to a new operating system</a></span></dt>
445 <dt><span class="sect1"><a href="#porting.compiler">26.2. Adding support for a new compiler</a></span></dt>
446 </dl></dd>
447 </dl></dd>
448 <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
449 <dd><dl>
450 <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
451 <dd><dl>
452 <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
453 <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
454 <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
455 <dt><span class="sect2"><a href="#checking-package-with-pkglint">A.1.4. Checking a package with <span class="command"><strong>pkglint</strong></span></a></span></dt>
456 </dl></dd>
457 <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
458 </dl></dd>
459 <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
460 <dd><dl>
461 <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
462 <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
463 </dl></dd>
464 <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
465 <dd><dl>
466 <dt><span class="sect1"><a href="#ftp-distfiles">C.1. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
467 <dt><span class="sect1"><a href="#ftp-misc">C.2. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
468 <dt><span class="sect1"><a href="#ftp-packages">C.3. <code class="filename">packages</code>: Binary packages</a></span></dt>
469 <dt><span class="sect1"><a href="#ftp-reports">C.4. <code class="filename">reports</code>: Bulk build reports</a></span></dt>
470 <dt><span class="sect1"><a href="#ftp-source">C.5. <code class="filename">current</code>,
471 <code class="filename">pkgsrc-20<em class="replaceable"><code>xx</code></em>Q<em class="replaceable"><code>y</code></em></code>:
472 source packages</a></span></dt>
473 </dl></dd>
474 <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
475 <dd><dl>
476 <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
477 <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
478 </dl></dd>
479 </dl>
480 </div>
481 <div class="list-of-tables">
482 <p><b>List of Tables</b></p>
483 <dl>
484 <dt>1.1. <a href="#supported-platforms">Platforms supported by pkgsrc</a>
485 </dt>
486 <dt>11.1. <a href="#patch-examples">Patching examples</a>
487 </dt>
488 <dt>23.1. <a href="#plist-handling">PLIST handling for GNOME packages</a>
489 </dt>
490 </dl>
491 </div>
492 <div class="chapter">
493 <div class="titlepage"><div><div><h1 class="title">
494 <a name="introduction"></a>Chapter 1. What is pkgsrc?</h1></div></div></div>
495 <div class="toc">
496 <p><b>Table of Contents</b></p>
497 <dl>
498 <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
499 <dd><dl>
500 <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
501 <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
502 </dl></dd>
503 <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
504 <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
505 <dd><dl><dt><span class="sect2"><a href="#term.roles">1.3.1. Roles involved in pkgsrc</a></span></dt></dl></dd>
506 <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
507 </dl>
508 </div>
509 <div class="sect1">
510 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
511 <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
512 <p>There is a lot of software freely available for Unix-based
513 systems, which is usually available in form of the source code. Before
514 such software can be used, it needs to be configured to the local
515 system, compiled and installed, and this is exactly what The NetBSD
516 Packages Collection (pkgsrc) does. pkgsrc also has some basic commands
517 to handle binary packages, so that not every user has to build the
518 packages for himself, which is a time-costly task.</p>
519 <p>pkgsrc currently contains several thousand packages,
520       including:</p>
521 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
522 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/apache/README.html" target="_top"><code class="filename">www/apache</code></a> - The Apache
523           web server</p></li>
524 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> - The Firefox
525           web browser</p></li>
526 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome/README.html" target="_top"><code class="filename">meta-pkgs/gnome</code></a> - The GNOME
527           Desktop Environment</p></li>
528 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a> - The K
529           Desktop Environment</p></li>
530 </ul></div>
531 <p>...just to name a few.</p>
532 <p>pkgsrc has built-in support for handling varying dependencies,
533       such as pthreads and X11, and extended features such as IPv6 support on
534       a range of platforms.</p>
535 <div class="sect2">
536 <div class="titlepage"><div><div><h3 class="title">
537 <a name="why-pkgsrc"></a>1.1.1. Why pkgsrc?</h3></div></div></div>
538 <p>
539 pkgsrc provides the following key features:
540 </p>
541 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
542 <li class="listitem"><p>Easy building of software from source as well as the creation
543   and installation of binary packages. The source and latest
544   patches are retrieved from a master or mirror download site, checksum
545   verified, then built on your system. Support for binary-only
546   distributions is available for both native platforms and NetBSD
547   emulated platforms.</p></li>
548 <li class="listitem"><p>All packages are installed in a consistent directory tree,
549   including binaries, libraries, man pages and other
550   documentation.</p></li>
551 <li class="listitem"><p>Package dependencies, including when performing package updates,
552   are handled automatically. The configuration files of various
553   packages are handled automatically during updates, so local changes
554   are preserved.</p></li>
555 <li class="listitem"><p>Like NetBSD, pkgsrc is designed with portability in mind and
556   consists of highly portable code. This allows the greatest speed of
557   development when porting to a new platform. This portability also
558   ensures that pkgsrc is <span class="emphasis"><em>consistent across all
559   platforms</em></span>.</p></li>
560 <li class="listitem"><p>The installation prefix, acceptable software licenses,
561   international encryption requirements and build-time options for a
562   large number of packages are all set in a simple, central
563   configuration file.</p></li>
564 <li class="listitem"><p>The entire source (not including the distribution files) is
565   freely available under a BSD license, so you may extend and adapt
566   pkgsrc to your needs. Support for local packages and patches is
567   available right out of the box, so you can configure it specifically
568   for your environment.</p></li>
569 </ul></div>
570 <p>The following principles are basic to pkgsrc:</p>
571 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
572 <li class="listitem"><p><span class="quote">&#8220;<span class="quote">It should only work if it's right.</span>&#8221;</span>
573 &mdash; That means, if a package contains bugs, it's better to find
574 them and to complain about them rather than to just install the package
575 and hope that it works. There are numerous checks in pkgsrc that try to
576 find such bugs: Static analysis tools (<a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>), build-time checks (portability
577 of shell scripts), and post-installation checks (installed files,
578 references to shared libraries, script interpreters).</p></li>
579 <li class="listitem"><p><span class="quote">&#8220;<span class="quote">If it works, it should work everywhere</span>&#8221;</span>
580 &mdash; Like NetBSD has been ported to many hardware architectures,
581 pkgsrc has been ported to many operating systems. Care is taken that
582 packages behave the same on all platforms.</p></li>
583 </ul></div>
584 </div>
585 <div class="sect2">
586 <div class="titlepage"><div><div><h3 class="title">
587 <a name="intro.platforms"></a>1.1.2. Supported platforms</h3></div></div></div>
588 <p>pkgsrc consists of both a source distribution and a binary
589 distribution for these operating systems. After retrieving the required
590 source or binaries, you can be up and running with pkgsrc in just
591 minutes!</p>
592 <p>pkgsrc was derived from FreeBSD's ports system, and
593       initially developed for NetBSD only. Since then, pkgsrc has
594       grown a lot, and now supports the following platforms:</p>
595 <div class="table">
596 <a name="supported-platforms"></a><p class="title"><b>Table 1.1. Platforms supported by pkgsrc</b></p>
597 <div class="table-contents"><table summary="Platforms supported by pkgsrc" border="1">
598 <colgroup>
599 <col>
600 <col>
601 </colgroup>
602 <thead><tr>
603 <th>Platform</th>
604 <th>Date Support Added</th>
605 </tr></thead>
606 <tbody>
607 <tr>
608 <td><a class="ulink" href="http://www.NetBSD.org/" target="_top">NetBSD</a></td>
609 <td align="center">Aug 1997</td>
610 </tr>
611 <tr>
612 <td><a class="ulink" href="http://wwws.sun.com/software/solaris/" target="_top">Solaris</a></td>
613 <td align="center">Mar 1999</td>
614 </tr>
615 <tr>
616 <td><a class="ulink" href="http://www.kernel.org/" target="_top">Linux</a></td>
617 <td align="center">Jun 1999</td>
618 </tr>
619 <tr>
620 <td>
621           <a class="ulink" href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
622           (<a class="ulink" href="http://developer.apple.com/macosx/" target="_top">Mac OS X</a>)
623         </td>
624 <td align="center">Oct 2001</td>
625 </tr>
626 <tr>
627 <td><a class="ulink" href="http://www.freebsd.org/" target="_top">FreeBSD</a></td>
628 <td align="center">Nov 2002</td>
629 </tr>
630 <tr>
631 <td><a class="ulink" href="http://www.openbsd.org/" target="_top">OpenBSD</a></td>
632 <td align="center">Nov 2002</td>
633 </tr>
634 <tr>
635 <td><a class="ulink" href="http://www.sgi.com/software/irix/" target="_top">IRIX</a></td>
636 <td align="center">Dec 2002</td>
637 </tr>
638 <tr>
639 <td>BSD/OS</td>
640 <td align="center">Dec 2003</td>
641 </tr>
642 <tr>
643 <td><a class="ulink" href="http://www-1.ibm.com/servers/aix/" target="_top">AIX</a></td>
644 <td align="center">Dec 2003</td>
645 </tr>
646 <tr>
647 <td>
648           <a class="ulink" href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a>
649           (Microsoft Windows Services for Unix)
650         </td>
651 <td align="center">Mar 2004</td>
652 </tr>
653 <tr>
654 <td><a class="ulink" href="http://www.dragonflybsd.org/" target="_top">DragonFlyBSD</a></td>
655 <td align="center">Oct 2004</td>
656 </tr>
657 <tr>
658 <td><a class="ulink" href="http://www.tru64.org/" target="_top">OSF/1</a></td>
659 <td align="center">Nov 2004</td>
660 </tr>
661 <tr>
662 <td><a class="ulink" href="http://www.hp.com/products1/unix/" target="_top">HP-UX</a></td>
663 <td align="center">Apr 2007</td>
664 </tr>
665 <tr>
666 <td><a class="ulink" href="http://www.haiku-os.org/" target="_top">Haiku</a></td>
667 <td align="center">Sep 2010</td>
668 </tr>
669 <tr>
670 <td><a class="ulink" href="http://www.mirbsd.org/" target="_top">MirBSD</a></td>
671 <td align="center">Aug 2011</td>
672 </tr>
673 <tr>
674 <td><a class="ulink" href="http://www.minix3.org/" target="_top">Minix3</a></td>
675 <td align="center">Nov 2011</td>
676 </tr>
677 <tr>
678 <td><a class="ulink" href="http://cygwin.com/" target="_top">Cygwin</a></td>
679 <td align="center">Mar 2013</td>
680 </tr>
681 </tbody>
682 </table></div>
683 </div>
684 <br class="table-break">
685 </div>
686 </div>
687 <div class="sect1">
688 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
689 <a name="overview"></a>1.2. Overview</h2></div></div></div>
690 <p>This document is divided into three parts. The first,
691         <a class="link" href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
692         describes how one can use one of the packages in the Package
693         Collection, either by installing a precompiled binary package,
694         or by building one's own copy using the NetBSD package system.
695         The second part, <a class="link" href="#developers-guide" title="Part II. The pkgsrc developer's guide">The pkgsrc developer's guide</a>, explains how to prepare a
696         package so it can be easily built by other NetBSD users without
697         knowing about the package's building details. The third part,
698         <a class="link" href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
699         is intended for those who want to understand how pkgsrc is
700         implemented.</p>
701 <p>This document is available in various formats:
702         <span class="simplelist"><a class="ulink" href="index.html" target="_top">HTML</a>, <a class="ulink" href="pkgsrc.pdf" target="_top">PDF</a>, <a class="ulink" href="pkgsrc.ps" target="_top">PS</a>, <a class="ulink" href="pkgsrc.txt" target="_top">TXT</a></span>.</p>
703 </div>
704 <div class="sect1">
705 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
706 <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
707 <p>There has been a lot of talk about <span class="quote">&#8220;<span class="quote">ports</span>&#8221;</span>,
708       <span class="quote">&#8220;<span class="quote">packages</span>&#8221;</span>, etc. so far. Here is a description of all the
709       terminology used within this document.</p>
710 <div class="variablelist"><dl class="variablelist">
711 <dt><span class="term">Package</span></dt>
712 <dd><p>A set of files and building instructions
713             that describe what's necessary
714             to build a certain piece of software using
715             pkgsrc. Packages are traditionally stored under
716             <code class="filename">/usr/pkgsrc</code>.</p></dd>
717 <dt><span class="term">The NetBSD package system</span></dt>
718 <dd><p>This is the former name of <span class="quote">&#8220;<span class="quote">pkgsrc</span>&#8221;</span>.  It
719           is part of the NetBSD operating system and can be bootstrapped
720           to run on non-NetBSD operating systems as well.  It handles
721           building (compiling), installing, and removing of
722           packages.</p></dd>
723 <dt><span class="term">Distfile</span></dt>
724 <dd><p>This term describes the file or files that are
725             provided by the author of the piece of software to
726             distribute his work. All the changes necessary to build on
727             NetBSD are reflected in the corresponding package. Usually
728             the distfile is in the form of a compressed tar-archive,
729             but other types are possible, too. Distfiles are usually
730             stored below
731             <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
732 <dt><span class="term">Port</span></dt>
733 <dd><p>This is the term used by FreeBSD and OpenBSD people
734             for what we call a package.
735             In NetBSD terminology, <span class="quote">&#8220;<span class="quote">port</span>&#8221;</span> refers to a different
736             architecture.</p></dd>
737 <dt><span class="term">Precompiled/binary package</span></dt>
738 <dd>
739 <p>A set of binaries built with pkgsrc from a distfile
740             and stuffed together in a single <code class="filename">.tgz</code>
741             file so it can be installed on machines of the same
742             machine architecture without the need to
743             recompile. Packages are usually generated in
744             <code class="filename">/usr/pkgsrc/packages</code>; there is also
745             an archive on <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/" target="_top">ftp.NetBSD.org</a>.</p>
746 <p>Sometimes, this is referred to by the term <span class="quote">&#8220;<span class="quote">package</span>&#8221;</span> too,
747             especially in the context of precompiled packages.</p>
748 </dd>
749 <dt><span class="term">Program</span></dt>
750 <dd><p>The piece of software to be installed which will be
751           constructed from all the files in the distfile by the
752           actions defined in the corresponding package.</p></dd>
753 </dl></div>
754 <div class="sect2">
755 <div class="titlepage"><div><div><h3 class="title">
756 <a name="term.roles"></a>1.3.1. Roles involved in pkgsrc</h3></div></div></div>
757 <div class="variablelist"><dl class="variablelist">
758 <dt><span class="term">pkgsrc users</span></dt>
759 <dd>
760 <p>The
761         pkgsrc users are people who use the packages provided by pkgsrc.
762         Typically they are system administrators. The people using the
763         software that is inside the packages (maybe called <span class="quote">&#8220;<span class="quote">end
764         users</span>&#8221;</span>) are not covered by the pkgsrc guide.</p>
765 <p>There are two kinds of pkgsrc users: Some only want to
766         install pre-built binary packages. Others build the pkgsrc
767         packages from source, either for installing them directly or for
768         building binary packages themselves. For pkgsrc users <a class="xref" href="#users-guide" title="Part I. The pkgsrc user's guide">Part I, &#8220;The pkgsrc user's guide&#8221;</a> should provide all necessary
769         documentation.</p>
770 </dd>
771 <dt><span class="term">package maintainers</span></dt>
772 <dd><p>A
773         package maintainer creates packages as described in <a class="xref" href="#developers-guide" title="Part II. The pkgsrc developer's guide">Part II, &#8220;The pkgsrc developer's guide&#8221;</a>.</p></dd>
774 <dt><span class="term">infrastructure developers</span></dt>
775 <dd><p>These people are involved in all those files
776         that live in the <code class="filename">mk/</code> directory and below.
777         Only these people should need to read through <a class="xref" href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">Part III, &#8220;The pkgsrc infrastructure internals&#8221;</a>, though others might be curious,
778         too.</p></dd>
779 </dl></div>
780 </div>
781 </div>
782 <div class="sect1">
783 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
784 <a name="typography"></a>1.4. Typography</h2></div></div></div>
785 <p>When giving examples for commands, shell prompts are used to
786       show if the command should/can be issued as root, or if
787       <span class="quote">&#8220;<span class="quote">normal</span>&#8221;</span> user privileges are sufficient. We use a
788       <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
789       shell prompt, assuming they use the C-shell or tcsh.</p>
790 </div>
791 </div>
792 <div class="part">
793 <div class="titlepage"><div><div><h1 class="title">
794 <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
795 <div class="toc">
796 <p><b>Table of Contents</b></p>
797 <dl>
798 <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
799 <dd><dl>
800 <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
801 <dd><dl>
802 <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar archive</a></span></dt>
803 <dt><span class="sect2"><a href="#getting-via-cvs">2.1.2. Via anonymous CVS</a></span></dt>
804 </dl></dd>
805 <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
806 <dd><dl>
807 <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
808 <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
809 </dl></dd>
810 </dl></dd>
811 <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
812 <dd><dl>
813 <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
814 <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
815 <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
816 <dd><dl>
817 <dt><span class="sect2"><a href="#cygwin">3.3.1. Cygwin</a></span></dt>
818 <dt><span class="sect2"><a href="#darwin">3.3.2. Darwin (Mac OS X)</a></span></dt>
819 <dt><span class="sect2"><a href="#freebsd">3.3.3. FreeBSD</a></span></dt>
820 <dt><span class="sect2"><a href="#interix">3.3.4. Interix</a></span></dt>
821 <dt><span class="sect2"><a href="#irix">3.3.5. IRIX</a></span></dt>
822 <dt><span class="sect2"><a href="#linux">3.3.6. Linux</a></span></dt>
823 <dt><span class="sect2"><a href="#openbsd">3.3.7. OpenBSD</a></span></dt>
824 <dt><span class="sect2"><a href="#solaris">3.3.8. Solaris</a></span></dt>
825 </dl></dd>
826 </dl></dd>
827 <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
828 <dd><dl>
829 <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
830 <dd><dl>
831 <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
832 <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
833 <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
834 <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
835 <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
836 <dt><span class="sect2"><a href="#pkg_versions">4.1.6. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
837 <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
838 <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
839 </dl></dd>
840 <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
841 <dd><dl>
842 <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
843 <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
844 <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
845 </dl></dd>
846 </dl></dd>
847 <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
848 <dd><dl>
849 <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
850 <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
851 <dt><span class="sect1"><a href="#variables-affecting-installation">5.3. Variables affecting the installation process</a></span></dt>
852 <dt><span class="sect1"><a href="#conf.compiler">5.4. Selecting and configuring the compiler</a></span></dt>
853 <dd><dl>
854 <dt><span class="sect2"><a href="#selecting-the-compiler">5.4.1. Selecting the compiler</a></span></dt>
855 <dt><span class="sect2"><a href="#conf.cflags">5.4.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
856 <dt><span class="sect2"><a href="#conf.ldflags">5.4.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
857 </dl></dd>
858 <dt><span class="sect1"><a href="#developer-advanced-settings">5.5. Developer/advanced settings</a></span></dt>
859 <dt><span class="sect1"><a href="#selecting-build-options">5.6. Selecting Build Options</a></span></dt>
860 </dl></dd>
861 <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
862 <dd><dl>
863 <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
864 <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
865 </dl></dd>
866 <dt><span class="chapter"><a href="#bulk">7. Creating binary packages for everything in pkgsrc (bulk
867 builds)</a></span></dt>
868 <dd><dl>
869 <dt><span class="sect1"><a href="#bulk.pre">7.1. Think first, build later</a></span></dt>
870 <dt><span class="sect1"><a href="#bulk.req">7.2. Requirements of a bulk build</a></span></dt>
871 <dt><span class="sect1"><a href="#bulk.old">7.3. Running an old-style bulk build</a></span></dt>
872 <dd><dl>
873 <dt><span class="sect2"><a href="#binary.configuration">7.3.1. Configuration</a></span></dt>
874 <dt><span class="sect2"><a href="#other-environmental-considerations">7.3.2. Other environmental considerations</a></span></dt>
875 <dt><span class="sect2"><a href="#operation">7.3.3. Operation</a></span></dt>
876 <dt><span class="sect2"><a href="#what-it-does">7.3.4. What it does</a></span></dt>
877 <dt><span class="sect2"><a href="#disk-space-requirements">7.3.5. Disk space requirements</a></span></dt>
878 <dt><span class="sect2"><a href="#setting-up-a-sandbox">7.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
879 <dt><span class="sect2"><a href="#building-a-partial-set">7.3.7. Building a partial set of packages</a></span></dt>
880 <dt><span class="sect2"><a href="#bulk-upload">7.3.8. Uploading results of a bulk build</a></span></dt>
881 </dl></dd>
882 <dt><span class="sect1"><a href="#bulk.pbulk">7.4. Running a pbulk-style bulk build</a></span></dt>
883 <dd><dl>
884 <dt><span class="sect2"><a href="#bulk.pbulk.prepare">7.4.1. Preparation</a></span></dt>
885 <dt><span class="sect2"><a href="#bulk.pbulk.conf">7.4.2. Configuration</a></span></dt>
886 </dl></dd>
887 <dt><span class="sect1"><a href="#creating-cdroms">7.5. Creating a multiple CD-ROM packages collection</a></span></dt>
888 <dd><dl><dt><span class="sect2"><a href="#cdpack-example">7.5.1. Example of cdpack</a></span></dt></dl></dd>
889 </dl></dd>
890 <dt><span class="chapter"><a href="#files">8. Directory layout of the installed files</a></span></dt>
891 <dd><dl>
892 <dt><span class="sect1"><a href="#files.localbase">8.1. File system layout in <code class="literal">${LOCALBASE}</code></a></span></dt>
893 <dt><span class="sect1"><a href="#files.varbase">8.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
894 </dl></dd>
895 <dt><span class="chapter"><a href="#faq">9. Frequently Asked Questions</a></span></dt>
896 <dd><dl>
897 <dt><span class="sect1"><a href="#mailing-list-pointers">9.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
898 <dt><span class="sect1"><a href="#pkgviews-docs">9.2. Where's the pkgviews documentation?</a></span></dt>
899 <dt><span class="sect1"><a href="#faq-pkgtools">9.3. Utilities for package management (pkgtools)</a></span></dt>
900 <dt><span class="sect1"><a href="#non-root-pkgsrc">9.4. How to use pkgsrc as non-root</a></span></dt>
901 <dt><span class="sect1"><a href="#resume-transfers">9.5. How to resume transfers when fetching distfiles?</a></span></dt>
902 <dt><span class="sect1"><a href="#x.org-from-pkgsrc">9.6. How can I install/use modular X.org from pkgsrc?</a></span></dt>
903 <dt><span class="sect1"><a href="#fetch-behind-firewall">9.7. How to fetch files from behind a firewall</a></span></dt>
904 <dt><span class="sect1"><a href="#passive-ftp">9.8. How do I tell <span class="command"><strong>make fetch</strong></span> to do passive FTP?</a></span></dt>
905 <dt><span class="sect1"><a href="#fetching-all-distfiles">9.9. How to fetch all distfiles at once</a></span></dt>
906 <dt><span class="sect1"><a href="#tmac.andoc-missing">9.10. What does <span class="quote">&#8220;<span class="quote">Don't know how to make
907 /usr/share/tmac/tmac.andoc</span>&#8221;</span> mean?</a></span></dt>
908 <dt><span class="sect1"><a href="#bsd.own.mk-missing">9.11. What does <span class="quote">&#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221;</span> mean?</a></span></dt>
909 <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">9.12. Using 'sudo' with pkgsrc</a></span></dt>
910 <dt><span class="sect1"><a href="#faq.conf">9.13. How do I change the location of configuration files?</a></span></dt>
911 <dt><span class="sect1"><a href="#audit-packages">9.14. Automated security checks</a></span></dt>
912 <dt><span class="sect1"><a href="#ufaq-cflags">9.15. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
913 <dt><span class="sect1"><a href="#ufaq-fail">9.16. A package does not build.  What shall I do?</a></span></dt>
914 <dt><span class="sect1"><a href="#faq.rcs-conflicts">9.17. What does <span class="quote">&#8220;<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>&#8221;</span> mean?</a></span></dt>
915 </dl></dd>
916 </dl>
917 </div>
918 <div class="chapter">
919 <div class="titlepage"><div><div><h2 class="title">
920 <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
921 <div class="toc">
922 <p><b>Table of Contents</b></p>
923 <dl>
924 <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
925 <dd><dl>
926 <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar archive</a></span></dt>
927 <dt><span class="sect2"><a href="#getting-via-cvs">2.1.2. Via anonymous CVS</a></span></dt>
928 </dl></dd>
929 <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
930 <dd><dl>
931 <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
932 <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
933 </dl></dd>
934 </dl>
935 </div>
936 <p>Before you download and extract the files, you need to decide
937 where you want to extract them. When using pkgsrc as root user, pkgsrc
938 is usually installed in <code class="filename">/usr/pkgsrc</code>. You are though
939 free to install the sources and binary packages wherever you want in
940 your filesystem, provided that the pathname does not contain white-space
941 or other characters that are interpreted specially by the shell and some
942 other programs. A safe bet is to use only letters, digits, underscores
943 and dashes.</p>
944 <div class="sect1">
945 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
946 <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
947 <p>Before you download any pkgsrc files, you should decide
948         whether you want the <span class="emphasis"><em>current</em></span> branch or the
949         <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
950         quarterly basis from the current branch and only gets modified
951         for security updates. The names of the stable branches are built
952         from the year and the quarter, for example
953         <code class="literal">2009Q1</code>.</p>
954 <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
955         want to download pkgsrc. You can get it as a tar file or via CVS.
956         Both ways are described here.</p>
957 <p>Note that tar archive contains CVS working copy.
958         Thus you can switch to using CVS at any later time.</p>
959 <p>Note also that quarterly branch is not frozen in stone.
960         It receives critical updates.</p>
961 <div class="sect2">
962 <div class="titlepage"><div><div><h3 class="title">
963 <a name="getting-via-tar"></a>2.1.1. As tar archive</h3></div></div></div>
964 <p>The primary download location for all pkgsrc files is
965         <a class="ulink" href="http://ftp.NetBSD.org/pub/pkgsrc/" target="_top">http://ftp.NetBSD.org/pub/pkgsrc/</a> or
966         <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>
967         (it points to the same location).
968         There are a number of subdirectories for different purposes,
969         which are described in detail in <a class="xref" href="#ftp-layout" title="Appendix C. Directory layout of the pkgsrc FTP server">Appendix C, <i>Directory layout of the pkgsrc FTP server</i></a>.</p>
970 <p>The tar archive for the current branch is in the directory
971         <code class="filename">current</code> and is called <a class="ulink" href="http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz" target="_top"><code class="filename">pkgsrc.tar.gz</code></a>.
972         It is autogenerated daily.</p>
973 <p>To save download time we provide bzip2- and
974         xz-compressed archives which are published at
975         <a class="ulink" href="http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.bz2" target="_top"><code class="filename">pkgsrc.tar.bz2</code></a>
976         and
977         <a class="ulink" href="http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.xz" target="_top"><code class="filename">pkgsrc.tar.xz</code></a>
978         respectively.
979         </p>
980 <p>You can fetch the same files using FTP.</p>
981 <p>The tar file for the stable branch 2009Q1 is in the
982         directory <code class="filename">pkgsrc-2009Q1</code> and is also called <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2009Q1/pkgsrc-2009Q1.tar.gz" target="_top"><code class="filename">pkgsrc-2009Q1.tar.gz</code></a>.</p>
983 <p>To download a pkgsrc stable tarball, run:</p>
984 <pre class="screen">
985 <code class="prompt">$</code> <strong class="userinput"><code>ftp ftp://ftp.NetBSD.org/pub/pkgsrc/<em class="replaceable"><code>pkgsrc-20xxQy</code></em>/<em class="replaceable"><code>pkgsrc-20xxQy</code></em>.tar.gz</code></strong></pre>
986 <p>Where <em class="replaceable"><code>pkgsrc-20xxQy</code></em> is the
987         stable branch to be downloaded, for example, 
988         <span class="quote">&#8220;<span class="quote">pkgsrc-2009Q1</span>&#8221;</span>.</p>
989 <p>You can use fetch it also using "wget", "curl",
990         or your web browser.</p>
991 <p>Then, extract it with:</p>
992 <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>tar -xzf <em class="replaceable"><code>pkgsrc-20xxQy</code></em>.tar.gz -C /usr</code></strong></pre>
993 <p>This will create the directory <code class="filename">pkgsrc/</code>
994         in <code class="filename">/usr/</code> and all the package source will be 
995         stored under <code class="filename">/usr/pkgsrc/</code>.</p>
996 <p>To download pkgsrc-current, run:</p>
997 <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz</code></strong></pre>
998 </div>
999 <div class="sect2">
1000 <div class="titlepage"><div><div><h3 class="title">
1001 <a name="getting-via-cvs"></a>2.1.2. Via anonymous CVS</h3></div></div></div>
1002 <p>To fetch a specific pkgsrc stable branch, run:</p>
1003 <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd /usr &amp;&amp; cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r <em class="replaceable"><code>pkgsrc-20xxQy</code></em> -P pkgsrc</code></strong>
1004 </pre>
1005 <p>Where <em class="replaceable"><code>pkgsrc-20xxQy</code></em> is the stable 
1006         branch to be checked out, for example, <span class="quote">&#8220;<span class="quote">pkgsrc-2009Q1</span>&#8221;</span></p>
1007 <p>This will create the directory <code class="filename">pkgsrc/</code> 
1008         in your <code class="filename">/usr/</code> directory and all the package source 
1009         will be stored under <code class="filename">/usr/pkgsrc/</code>.</p>
1010 <p>To fetch the pkgsrc current branch, run:</p>
1011 <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd /usr &amp;&amp; cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc</code></strong>
1012 </pre>
1013 <p>Refer to the <a class="ulink" href="http://www.NetBSD.org/mirrors/" target="_top">list of available mirrors</a> to choose a faster CVS mirror, if needed.</p>
1014 <p>If you get error messages from <code class="literal">rsh</code>, you need to set CVS_RSH variable. E.g.:</p>
1015 <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd /usr &amp;&amp; env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc</code></strong>
1016 </pre>
1017 <p>Refer to documentation on your command shell how to set CVS_RSH=ssh permanently.
1018         For Bourne shells, you can set it in your <code class="filename">.profile</code>
1019         or better globally in <code class="filename">/etc/profile</code>:</p>
1020 <pre class="programlisting">
1021 # set CVS remote shell command
1022 CVS_RSH=ssh
1023 export CVS_RSH
1024 </pre>
1025 <p>By default, CVS doesn't do things like most people would expect it to do.
1026         But there is a way to convince CVS, by creating a file called <code class="filename">.cvsrc</code>
1027         in your home directory and saving the following lines to it.
1028         This file will save you lots of headache and some bug reports, so we strongly recommend it.
1029         You can find an explanation of this file in the CVS documentation.</p>
1030 <pre class="programlisting">
1031 # recommended CVS configuration file from the pkgsrc guide
1032 cvs -q -z2
1033 checkout -P
1034 update -dP
1035 diff -upN
1036 rdiff -u
1037 release -d
1038 </pre>
1039 </div>
1040 </div>
1041 <div class="sect1">
1042 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1043 <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
1044 <p>The preferred way to keep pkgsrc up-to-date is via CVS
1045         (which also works if you have first installed it via a tar
1046         file). It saves bandwidth and hard disk activity, compared to
1047         downloading the tar file again.</p>
1048 <div class="sect2">
1049 <div class="titlepage"><div><div><h3 class="title">
1050 <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
1051 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
1052 <h3 class="title">Warning</h3>
1053 <p>When updating from a tar file, you first need to
1054         completely remove the old pkgsrc directory. Otherwise those
1055         files that have been removed from pkgsrc in the mean time will
1056         not be removed on your local disk, resulting in inconsistencies.
1057         When removing the old files, any changes that you have done to
1058         the pkgsrc files will be lost after updating. Therefore updating
1059         via CVS is strongly recommended.</p>
1060 </div>
1061 <p>Note that by default the distfiles and the binary packages
1062         are saved in the pkgsrc tree, so don't forget to rescue them
1063         before updating. You can also configure pkgsrc to use other than
1064         the default directories by setting the
1065         <code class="varname">DISTDIR</code> and <code class="varname">PACKAGES</code>
1066         variables. See <a class="xref" href="#configuring" title="Chapter 5. Configuring pkgsrc">Chapter 5, <i>Configuring pkgsrc</i></a> for the details.</p>
1067 <p>To update pkgsrc from a tar file, download the tar file as
1068         explained above. Then, make sure that you have not made any
1069         changes to the files in the pkgsrc directory. Remove the pkgsrc
1070         directory and extract the new tar file. Done.</p>
1071 </div>
1072 <div class="sect2">
1073 <div class="titlepage"><div><div><h3 class="title">
1074 <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
1075 <p>To update pkgsrc via CVS, change to the <code class="filename">pkgsrc</code> directory and run cvs:</p>
1076 <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd /usr/pkgsrc &amp;&amp; cvs update -dP</code></strong>
1077 </pre>
1078 <p>If you get error messages from <code class="literal">rsh</code>, you need to set CVS_RSH variable as described above. E.g.:</p>
1079 <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd /usr/pkgsrc &amp;&amp; env CVS_RSH=ssh cvs up -dP</code></strong>
1080 </pre>
1081 <div class="sect3">
1082 <div class="titlepage"><div><div><h4 class="title">
1083 <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
1084 <p>When updating pkgsrc, the CVS program keeps track of the
1085         branch you selected. But if you, for whatever reason, want to
1086         switch from the stable branch to the current one, you can do it
1087         by adding the option <span class="quote">&#8220;<span class="quote">-A</span>&#8221;</span> after the
1088         <span class="quote">&#8220;<span class="quote">update</span>&#8221;</span> keyword. To switch from the current branch
1089         back to the stable branch, add the
1090         <span class="quote">&#8220;<span class="quote">-rpkgsrc-2009Q3</span>&#8221;</span> option.</p>
1091 </div>
1092 <div class="sect3">
1093 <div class="titlepage"><div><div><h4 class="title">
1094 <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
1095 <p>When you update pkgsrc, the CVS program will only touch
1096         those files that are registered in the CVS repository. That
1097         means that any packages that you created on your own will stay
1098         unmodified. If you change files that are managed by CVS, later
1099         updates will try to merge your changes with those that have been
1100         done by others. See the CVS manual, chapter
1101         <span class="quote">&#8220;<span class="quote">update</span>&#8221;</span> for details.</p>
1102 </div>
1103 </div>
1104 </div>
1105 </div>
1106 <div class="chapter">
1107 <div class="titlepage"><div><div><h2 class="title">
1108 <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
1109 <div class="toc">
1110 <p><b>Table of Contents</b></p>
1111 <dl>
1112 <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
1113 <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
1114 <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
1115 <dd><dl>
1116 <dt><span class="sect2"><a href="#cygwin">3.3.1. Cygwin</a></span></dt>
1117 <dt><span class="sect2"><a href="#darwin">3.3.2. Darwin (Mac OS X)</a></span></dt>
1118 <dt><span class="sect2"><a href="#freebsd">3.3.3. FreeBSD</a></span></dt>
1119 <dt><span class="sect2"><a href="#interix">3.3.4. Interix</a></span></dt>
1120 <dt><span class="sect2"><a href="#irix">3.3.5. IRIX</a></span></dt>
1121 <dt><span class="sect2"><a href="#linux">3.3.6. Linux</a></span></dt>
1122 <dt><span class="sect2"><a href="#openbsd">3.3.7. OpenBSD</a></span></dt>
1123 <dt><span class="sect2"><a href="#solaris">3.3.8. Solaris</a></span></dt>
1124 </dl></dd>
1125 </dl>
1126 </div>
1127 <div class="sect1">
1128 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1129 <a name="binarydist"></a>3.1. Binary distribution</h2></div></div></div>
1130 <p>See <a class="xref" href="#using-pkg" title="4.1. Using binary packages">Section 4.1, &#8220;Using binary packages&#8221;</a>.</p>
1131 </div>
1132 <div class="sect1">
1133 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1134 <a name="bootstrapping-pkgsrc"></a>3.2. Bootstrapping pkgsrc</h2></div></div></div>
1135 <p>pkgsrc can be bootstrapped for use in two different modes:
1136     privileged and unprivileged one. In unprivileged mode in contrast
1137     to privileged one all programs are installed under one particular user
1138     and cannot utilise privileged operations (packages don't create
1139     special users and all special file permissions like setuid are ignored).
1140     </p>
1141 <p>Installing the bootstrap kit from source should be as simple as:</p>
1142 <pre class="screen">
1143 <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
1144 <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1145 <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong>
1146     </pre>
1147 <p>To bootstrap in unprivileged mode pass <span class="quote">&#8220;<span class="quote">--unprivileged</span>&#8221;</span> flag to <span class="command"><strong>bootstrap</strong></span></p>
1148 <p>By default, in privileged mode pkgsrc uses
1149     <code class="filename">/usr/pkg</code> for <span class="emphasis"><em>prefix</em></span>
1150     where programs will be installed in,
1151     and <code class="filename">/var/db/pkg</code> for the package database
1152     directory where pkgsrc will do its internal bookkeeping,
1153     <code class="filename">/var</code> is used as <span class="emphasis"><em>varbase</em></span>,
1154     where packages install their persistent data.
1155     In unprivileged mode pkgsrc uses
1156     <code class="filename">~/pkg</code> for <span class="emphasis"><em>prefix</em></span>,
1157     <code class="filename">~/pkg/var/db/pkg</code> for the package database,
1158     and <code class="filename">~/pkg/var</code> for <span class="emphasis"><em>varbase</em></span>.
1159     </p>
1160 <p>You can change default layout using command-line arguments.
1161     Run <span class="quote">&#8220;<span class="quote">./bootstrap --help</span>&#8221;</span> to get details.
1162     </p>
1163 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1164 <h3 class="title">Note</h3>
1165 <p>The bootstrap installs a <span class="command"><strong>bmake</strong></span> tool.
1166       Use this <span class="command"><strong>bmake</strong></span> when building via pkgsrc.
1167       For examples in this guide, use <span class="command"><strong>bmake</strong></span>
1168       instead of <span class="quote">&#8220;<span class="quote">make</span>&#8221;</span>.</p>
1169 </div>
1170 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1171 <h3 class="title">Note</h3>
1172 <p>It is possible to bootstrap multiple instances of pkgsrc
1173       using non-intersecting directories. Use <span class="command"><strong>bmake</strong></span>
1174       corresponding to the installation you're working with to build
1175       and install packages.
1176       </p>
1177 </div>
1178 </div>
1179 <div class="sect1">
1180 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1181 <a name="platform-specific-notes"></a>3.3. Platform-specific notes</h2></div></div></div>
1182 <p>Here are some platform-specific notes you should be aware of.</p>
1183 <div class="sect2">
1184 <div class="titlepage"><div><div><h3 class="title">
1185 <a name="cygwin"></a>3.3.1. Cygwin</h3></div></div></div>
1186 <p>Cygwin 1.7.x and later are supported.</p>
1187 <p>You need to install minimal base packages in `Base' category
1188       plus any of compiler, gcc, gcc4, and/or clang.
1189       For gcc and gcc4, C and C++ compiler will be installed by default,
1190       but you can install Fortran compiler additionally
1191       because it will be required to use libtool.
1192       If it is not installed (or too old), Fortran compiler will be
1193       installed with pkgsrc automatically.</p>
1194 <p>As noted in
1195       <a class="ulink" href="http://cygwin.com/faq-nochunks.html#faq.using.su" target="_top">Cygwin FAQ: `Why doesn't su work?'</a>,
1196       su(1) command has been in Cygwin distribution, but it has never worked.
1197       Unless you bootstrap pkgsrc with the --unprivileged option, workaround is:
1198       </p>
1199 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Right click "Cygwin Terminal" in your Start Menu,
1200           then pick "Run as administrator".</p></li></ul></div>
1201 </div>
1202 <div class="sect2">
1203 <div class="titlepage"><div><div><h3 class="title">
1204 <a name="darwin"></a>3.3.2. Darwin (Mac OS X)</h3></div></div></div>
1205 <p>Darwin 5.x and up are supported.</p>
1206 <p>Before you start, you need to download and install
1207       the Mac OS X Developer Tools from Apple's Developer Connection.
1208       This requires (free) membership. See
1209       <a class="ulink" href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
1210       for details. Also, make sure you install X11 (an optional
1211       package included with the Developer Tools) if you intend
1212       to build packages that use the X11 Window System.
1213       (If you don't want or need the full Xcode GUI,
1214       download and install Command Line Tools for Xcode.)</p>
1215 </div>
1216 <div class="sect2">
1217 <div class="titlepage"><div><div><h3 class="title">
1218 <a name="freebsd"></a>3.3.3. FreeBSD</h3></div></div></div>
1219 <p>FreeBSD 8.3 and 9.0 have been tested and are supported,
1220       other versions may work.</p>
1221 <p>Care should be taken so that the tools that this kit installs do not conflict
1222       with the FreeBSD userland tools. There are several steps:</p>
1223 <div class="orderedlist"><ol class="orderedlist" type="1">
1224 <li class="listitem"><p>FreeBSD stores its ports pkg database in
1225           <code class="filename">/var/db/pkg</code>. It is therefore
1226           recommended that you choose a different location (e.g.
1227           <code class="filename">/usr/pkgdb</code>) by
1228           using the --pkgdbdir option to the bootstrap script.</p></li>
1229 <li class="listitem">
1230 <p>If you do not intend to use the FreeBSD ports tools, it's probably a
1231           good idea to move them out of the way to avoid confusion, e.g.</p>
1232 <pre class="screen">
1233 <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1234 <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1235 <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1236 <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1237 <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
1238           </pre>
1239 </li>
1240 <li class="listitem"><p>An example <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file will be placed in
1241           <code class="filename">/etc/mk.conf.example</code> file
1242           when you use the bootstrap script.</p></li>
1243 </ol></div>
1244 </div>
1245 <div class="sect2">
1246 <div class="titlepage"><div><div><h3 class="title">
1247 <a name="interix"></a>3.3.4. Interix</h3></div></div></div>
1248 <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
1249       providing a Unix-like environment with a tighter kernel integration than
1250       available with Cygwin.  It is part of the Windows Services for Unix
1251       package, available for free for any licensed copy of Windows 2000, XP
1252       (not including XP Home), or 2003.  SFU can be downloaded from <a class="ulink" href="http://www.microsoft.com/windows/sfu/" target="_top">http://www.microsoft.com/windows/sfu/</a>.</p>
1253 <p>Services for Unix 3.5 has been tested.  3.0 or 3.1 may work, but
1254       are not officially supported.  (The main difference in 3.0/3.1 is lack
1255       of pthreads, but other parts of libc may also be lacking.)</p>
1256 <p>Services for Unix Applications (aka SUA) is an integrated
1257       component of Windows Server 2003 R2 (5.2), Windows Vista and
1258       Windows Server 2008 (6.0), Windows 7 and Windows Server 2008 R2
1259       (6.1).  As of this writing, the SUA's Interix 6.0 (32bit) and
1260       6.1 (64bit) subsystems have been tested.  Other versions may
1261       work as well. The Interix 5.x subsystem has not yet been tested
1262       with pkgsrc.</p>
1263 <div class="sect3">
1264 <div class="titlepage"><div><div><h4 class="title">
1265 <a name="platform.interix-sfu-install"></a>3.3.4.1. When installing Interix/SFU</h4></div></div></div>
1266 <p>At an absolute minimum, the following packages must be installed from
1267         the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
1268 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1269 <li class="listitem"><p>Utilities -&gt; Base Utilities</p></li>
1270 <li class="listitem"><p>Interix GNU Components -&gt; (all)</p></li>
1271 <li class="listitem"><p>Remote Connectivity</p></li>
1272 <li class="listitem"><p>Interix SDK</p></li>
1273 </ul></div>
1274 <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1275         "UNIX Perl".  That is Perl 5.6 without shared module support, installed to
1276         /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
1277         pkgsrc (or from a binary package).</p>
1278 <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1279         not need to be installed, but Remote Connectivity itself should be
1280         installed in order to have a working inetd.</p>
1281 <p>During installation you may be asked whether to enable setuid
1282         behavior for Interix programs, and whether to make pathnames default to
1283         case-sensitive.  Setuid should be enabled, and case-sensitivity MUST be
1284         enabled.  (Without case-sensitivity, a large number of packages including
1285         perl will not build.)</p>
1286 <p>NOTE:  Newer Windows service packs change the way binary execution
1287         works (via the Data Execution Prevention feature).  In order to use
1288         pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
1289         POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
1290         must be installed.  Hotfixes are available from Microsoft through a
1291         support contract; however, Debian Interix Port has made most Interix
1292         hotfixes available for personal use from <a class="ulink" href="http://www.debian-interix.net/hotfixes/" target="_top">http://www.debian-interix.net/hotfixes/</a>.</p>
1293 <p>In addition to the hotfix noted above, it may be necessary to
1294         disable Data Execution Prevention entirely to make Interix functional.
1295         This may happen only with certain types of CPUs; the cause is not fully
1296         understood at this time.  If gcc or other applications still segfault
1297         repeatedly after installing one of the hotfixes note above, the
1298         following option can be added to the appropriate "boot.ini" line on the
1299         Windows boot drive:  /NoExecute=AlwaysOff
1300         (WARNING, this will disable DEP completely, which may be a security
1301         risk if applications are often run as a user in the Administrators
1302         group!)</p>
1303 </div>
1304 <div class="sect3">
1305 <div class="titlepage"><div><div><h4 class="title">
1306 <a name="platform.interix-sfu-postinstall"></a>3.3.4.2. What to do if Interix/SFU is already installed</h4></div></div></div>
1307 <p>If SFU is already installed and you wish to alter these settings to work
1308         with pkgsrc, note the following things.</p>
1309 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1310 <li class="listitem"><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1311             Windows Services for UNIX, then click Change.  In the installer, choose
1312             Add or Remove, then uncheck Utilities-&gt;UNIX Perl.</p></li>
1313 <li class="listitem">
1314 <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1315             change the following registry key:</p>
1316 <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
1317 <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
1318 </li>
1319 <li class="listitem">
1320 <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1321             following registry key:</p>
1322 <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
1323 <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
1324 </li>
1325 </ul></div>
1326 </div>
1327 <div class="sect3">
1328 <div class="titlepage"><div><div><h4 class="title">
1329 <a name="platform.interix-notes"></a>3.3.4.3. Important notes for using pkgsrc</h4></div></div></div>
1330 <p>The package manager (either the pkgsrc "su" user, or the user
1331         running "pkg_add") must be a member of the local Administrators
1332         group.  Such a user must also be used to run the bootstrap.  This is
1333         slightly relaxed from the normal pkgsrc requirement of "root".</p>
1334 <p>The package manager should use a umask of 002.  "make install" will
1335         automatically complain if this is not the case.  This ensures that
1336         directories written in /var/db/pkg are Administrators-group writeable.</p>
1337 <p>The popular Interix binary packages from http://www.interopsystems.com/
1338         use an older version of pkgsrc's pkg_* tools.  Ideally, these should
1339         NOT be used in conjunction with pkgsrc.  If you choose to use them at
1340         the same time as the pkgsrc packages, ensure that you use the proper
1341         pkg_* tools for each type of binary package.</p>
1342 <p>The TERM setting used for DOS-type console windows (including those
1343         invoked by the csh and ksh startup shortcuts) is "interix".  Most systems
1344         don't have a termcap/terminfo entry for it, but the following .termcap
1345         entry provides adequate emulation in most cases:</p>
1346 <pre class="programlisting">
1347 interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
1348         </pre>
1349 </div>
1350 <div class="sect3">
1351 <div class="titlepage"><div><div><h4 class="title">
1352 <a name="platform.interix-limits"></a>3.3.4.4. Limitations of the Interix platform</h4></div></div></div>
1353 <p>Though Interix suffices as a familiar and flexible substitute
1354         for a full Unix-like platform, it has some drawbacks that should
1355         be noted for those desiring to make the most of Interix.</p>
1356 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1357 <li class="listitem">
1358 <p><span class="strong"><strong>X11:</strong></span></p>
1359 <p>Interix comes with the standard set of X11R6 client libraries,
1360           and can run X11 based applications, but it does
1361           <span class="emphasis"><em>not</em></span> come with an X server.  Some options are
1362           <a class="ulink" href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
1363           <a class="ulink" href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
1364           (available in a trimmed version for Interix from Interop Systems as the
1365           <a class="ulink" href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
1366           and the free X11 server included with
1367           <a class="ulink" href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1368 </li>
1369 <li class="listitem">
1370 <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
1371 <p>Because Interix runs in a completely different NT subsystem from
1372           Win32 applications, it does not currently support various X11
1373           protocol extensions for acceleration (such as MIT-SHM or DGA).
1374           Most interactive applications to a local X server will run
1375           reasonably fast, but full motion video and other graphics
1376           intensive applications may require a faster-than-expected CPU.</p>
1377 </li>
1378 <li class="listitem">
1379 <p><span class="strong"><strong>Audio:</strong></span></p>
1380 <p>Interix has no native support for audio output.  For audio
1381           support, pkgsrc uses the <span class="command"><strong>esound</strong></span> client/server
1382           audio system on Interix.  Unlike on most platforms, the
1383           <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/esound/README.html" target="_top"><code class="filename">audio/esound</code></a> package does
1384           <span class="emphasis"><em>not</em></span> contain the <span class="command"><strong>esd</strong></span>
1385           server component.  To output audio via an Interix host, the
1386           <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/emulators/cygwin_esound/README.html" target="_top"><code class="filename">emulators/cygwin_esound</code></a> package
1387           must also be installed.</p>
1388 </li>
1389 <li class="listitem">
1390 <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
1391 <p>Direct device access is not currently supported in Interix, so it
1392           is not currently possible to access CD/DVD drives, USB devices,
1393           or SCSI devices through non-filesystem means.  Among other things,
1394           this makes it impossible to use Interix directly for CD/DVD
1395           burning.</p>
1396 </li>
1397 <li class="listitem">
1398 <p><span class="strong"><strong>Tape drives:</strong></span></p>
1399 <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1400           drives are also not directly accessible in Interix.  However,
1401           support is in work to make tape drive access possible by using
1402           Cygwin as a bridge (similarly to audio bridged via Cygwin's
1403           esound server).</p>
1404 </li>
1405 </ul></div>
1406 </div>
1407 <div class="sect3">
1408 <div class="titlepage"><div><div><h4 class="title">
1409 <a name="platform.interix-knownissues"></a>3.3.4.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1410 <p>It is not necessary, in general, to have a "root" user on the
1411         Windows system; any member of the local Administrators group will
1412         suffice.  However, some packages currently assume that the user
1413         named "root" is the privileged user.  To accommodate these, you
1414         may create such a user; make sure it is in the local group
1415         Administrators (or your language equivalent).</p>
1416 <p><span class="command"><strong>pkg_add</strong></span> creates directories of mode
1417         0755, not 0775, in <code class="filename">$PKG_DBDIR</code>.  For the
1418         time being, install packages as the local Administrator (or
1419         your language equivalent), or run the following command after
1420         installing a package to work around the issue:</p>
1421 <pre class="screen">
1422 <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong>
1423         </pre>
1424 </div>
1425 </div>
1426 <div class="sect2">
1427 <div class="titlepage"><div><div><h3 class="title">
1428 <a name="irix"></a>3.3.5. IRIX</h3></div></div></div>
1429 <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1430       compiler (cc/c89).  Please set the <code class="varname">CC</code> environment variable
1431       according to your preference.  If you do not have a license for the MIPSpro
1432       compiler suite, you can download a gcc tardist file from <a class="ulink" href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
1433 <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1434       version of IRIX providing support for <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?if_indextoname+3+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">if_indextoname</span>(3)</span></a>, <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?if_nametoindex+3+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">if_nametoindex</span>(3)</span></a>,
1435       etc.</p>
1436 <p>At this point in time, pkgsrc only supports one ABI at a time.  That is, you cannot
1437         switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI.  If
1438         you start out using "abi=n32", that's what all your packages will be built
1439         with.</p>
1440 <p>Therefore, please make sure that you have no conflicting
1441       <code class="varname">CFLAGS</code> in your environment or the
1442       <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.  Particularly, make sure that you do not
1443       try to link n32 object files with lib64 or vice versa.  Check your
1444       <code class="filename">/etc/compiler.defaults</code>!</p>
1445 <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1446       please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
1447       as it appears that IRIX linker occasionally runs into issues when trying to
1448       link over a network-mounted file system.</p>
1449 <p>The bootstrapping process should set all the right options for programs such
1450       as imake(1), but you may want to set some options depending on your local
1451       setup.  Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1452       course, your compiler's man pages for details.</p>
1453 <p>If you are using SGI's MIPSPro compiler, please set
1454
1455       </p>
1456 <pre class="programlisting">
1457 PKGSRC_COMPILER=        mipspro
1458       </pre>
1459 <p>
1460
1461       in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.  Otherwise, pkgsrc will assume you
1462       are using gcc and may end up passing invalid flags to the compiler.  Note that
1463       bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1464       default.</p>
1465 <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1466       but want to make sure that MIPSPro is used, please set your <code class="varname">PATH</code>
1467       to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1468       <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1469       '--preserve-path' flag.</p>
1470 </div>
1471 <div class="sect2">
1472 <div class="titlepage"><div><div><h3 class="title">
1473 <a name="linux"></a>3.3.6. Linux</h3></div></div></div>
1474 <p>Some versions of Linux (for example Debian GNU/Linux) need
1475       either libtermcap or libcurses (libncurses).  Installing the
1476       distributions libncurses-dev package (or equivalent) should fix
1477       the problem.</p>
1478 <p>pkgsrc supports both gcc (GNU Compiler Collection) and icc
1479       (Intel C++ Compiler). gcc is the default. icc 8.0 and 8.1 on
1480       i386 have been tested.</p>
1481 <p>To bootstrap using icc, assuming the default icc installation
1482       directory:</p>
1483 <pre class="programlisting">
1484 env ICCBASE=/opt/intel/cc/10.1.008 ./bootstrap --compiler=icc
1485       </pre>
1486 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1487 <h3 class="title">Note</h3>
1488 <p>For icc 8.0 you must add `LDFLAGS=-static-libcxa' to this.</p>
1489 <p>For icc 8.1 you must add `LDFLAGS=-i-static' instead.</p>
1490 <p>For icc 10.1 neither of these appears to be necessary.</p>
1491 </div>
1492 <p>Use a value for ICCBASE that corresponds to the directory
1493       where icc is installed. After bootstrapping, set
1494       <code class="varname">ICCBASE</code> in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>:</p>
1495 <pre class="programlisting">
1496 ICCBASE=                /opt/intel/cc/10.1.008
1497       </pre>
1498 <p>The pkgsrc default for <code class="varname">ICCBASE</code> is
1499       <code class="filename">/opt/intel_cc_80</code>. This is the default
1500       install directory for icc 8.0. If you are using a more recent
1501       version, be sure to set the correct path explicitly.
1502       </p>
1503 <p>pkgsrc uses the static linking method of the runtime libraries
1504       provided by icc, so binaries can be run on other systems which do not
1505       have the shared libraries installed.</p>
1506 <p>Libtool, however, extracts a list of libraries from the
1507       <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?ld+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">ld</span>(1)</span></a> command run when linking a C++ shared library and
1508       records it, throwing away the -Bstatic and -Bdynamic options
1509       interspersed between the libraries.  This means that
1510       libtool-linked C++ shared libraries will have a runtime
1511       dependency on the icc libraries until this is fixed in
1512       libtool.</p>
1513 </div>
1514 <div class="sect2">
1515 <div class="titlepage"><div><div><h3 class="title">
1516 <a name="openbsd"></a>3.3.7. OpenBSD</h3></div></div></div>
1517 <p>OpenBSD 5.1 has been tested and supported,
1518       other versions may work.</p>
1519 <p>Care should be taken so that the tools that this kit installs do not conflict
1520       with the OpenBSD userland tools. There are several steps:</p>
1521 <div class="orderedlist"><ol class="orderedlist" type="1">
1522 <li class="listitem"><p>OpenBSD stores its ports pkg database in
1523           <code class="filename">/var/db/pkg</code>. It is therefore
1524           recommended that you choose a different location (e.g.
1525           <code class="filename">/usr/pkgdb</code>) by
1526           using the --pkgdbdir option to the bootstrap script.</p></li>
1527 <li class="listitem">
1528 <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1529           good idea to move them out of the way to avoid confusion, e.g.</p>
1530 <pre class="screen">
1531 <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1532 <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1533 <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1534 <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1535 <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
1536           </pre>
1537 </li>
1538 <li class="listitem">
1539 <p>An example <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file will be placed in
1540           <code class="filename">/etc/mk.conf.example</code> file
1541           when you use the bootstrap script. OpenBSD's make program uses
1542           <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>
1543           as well. You can work around this by enclosing all the pkgsrc-specific parts
1544           of the file with:</p>
1545 <pre class="programlisting">
1546 .ifdef BSD_PKG_MK
1547 # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
1548 .else
1549 # OpenBSD stuff
1550 .endif
1551           </pre>
1552 </li>
1553 </ol></div>
1554 </div>
1555 <div class="sect2">
1556 <div class="titlepage"><div><div><h3 class="title">
1557 <a name="solaris"></a>3.3.8. Solaris</h3></div></div></div>
1558 <p>Solaris 2.6 through 10 are supported on both x86 and sparc.
1559       You will need a working C compiler. Both gcc 4.5.3 and
1560       Sun WorkShop 5 have been tested.</p>
1561 <p>The following packages are required on Solaris 8 for the bootstrap
1562       process and to build packages.</p>
1563 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1564 <li class="listitem"><p>SUNWsprot</p></li>
1565 <li class="listitem"><p>SUNWarc</p></li>
1566 <li class="listitem"><p>SUNWbtool</p></li>
1567 <li class="listitem"><p>SUNWtoo</p></li>
1568 <li class="listitem"><p>SUNWlibm</p></li>
1569 </ul></div>
1570 <p>Please note that the use of GNU binutils on Solaris is
1571       <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1572 <p>Whichever compiler you use, please ensure the compiler tools and
1573       your $prefix are in your <code class="varname">PATH</code>. This includes
1574       <code class="filename">/usr/ccs/{bin,lib}</code>
1575       and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1576 <div class="sect3">
1577 <div class="titlepage"><div><div><h4 class="title">
1578 <a name="solaris-gcc-note"></a>3.3.8.1. If you are using gcc</h4></div></div></div>
1579 <p>It makes life much simpler if you only use the same gcc consistently
1580         for building all packages.</p>
1581 <p>It is recommended that an external gcc be used only for bootstrapping,
1582         then either build gcc from
1583         <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/lang/gcc46/README.html" target="_top"><code class="filename">lang/gcc46</code></a> or install a binary gcc
1584         package, then remove gcc used during bootstrapping.</p>
1585 <p>Binary packages of gcc can be found through <a class="ulink" href="http://www.sunfreeware.com/" target="_top">http://www.sunfreeware.com/</a>.</p>
1586 </div>
1587 <div class="sect3">
1588 <div class="titlepage"><div><div><h4 class="title">
1589 <a name="solaris-sun-workshop-note"></a>3.3.8.2. If you are using Sun WorkShop</h4></div></div></div>
1590 <p>You will need at least the following packages installed (from WorkShop
1591         5.0)</p>
1592 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1593 <li class="listitem"><p>SPROcc
1594           - Sun WorkShop Compiler C 5.0</p></li>
1595 <li class="listitem"><p>SPROcpl
1596           - Sun WorkShop Compiler C++ 5.0</p></li>
1597 <li class="listitem"><p>SPROild
1598           - Sun WorkShop Incremental Linker</p></li>
1599 <li class="listitem"><p>SPROlang
1600           - Sun WorkShop Compilers common components</p></li>
1601 </ul></div>
1602 <p>You should set the following variables in your
1603         <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file:</p>
1604 <pre class="programlisting">
1605 CC=     cc
1606 CXX=    CC
1607 CPP=    cc -E
1608 CXXCPP= CC -E
1609 </pre>
1610 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1611 <h3 class="title">Note</h3>
1612 <p>The <code class="varname">CPP</code> setting might break some
1613         packages that use the C preprocessor for processing things other
1614         than C source code.</p>
1615 </div>
1616 </div>
1617 <div class="sect3">
1618 <div class="titlepage"><div><div><h4 class="title">
1619 <a name="solaris-sunpro-64"></a>3.3.8.3. Building 64-bit binaries with SunPro</h4></div></div></div>
1620 <p>To build 64-bit packages, you just need to have the
1621         following lines in your <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file:</p>
1622 <pre class="programlisting">
1623 PKGSRC_COMPILER=        sunpro
1624 ABI=                    64
1625 </pre>
1626 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1627 <h3 class="title">Note</h3>
1628 <p>This setting has been tested for the SPARC
1629         architecture. Intel and AMD machines need some more
1630         work.</p>
1631 </div>
1632 </div>
1633 <div class="sect3">
1634 <div class="titlepage"><div><div><h4 class="title">
1635 <a name="plat.sunos.problems"></a>3.3.8.4. Common problems</h4></div></div></div>
1636 <p>Sometimes, when using <span class="command"><strong>libtool</strong></span>,
1637       <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1638       The workaround is to use another shell for the configure
1639       scripts, for example by installing <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a> and adding the following lines
1640       to your <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>:</p>
1641 <pre class="programlisting">
1642 CONFIG_SHELL=   ${LOCALBASE}/bin/bash
1643 WRAPPER_SHELL=  ${LOCALBASE}/bin/bash
1644       </pre>
1645 <p>Then, rebuild the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/libtool-base/README.html" target="_top"><code class="filename">devel/libtool-base</code></a> package.</p>
1646 </div>
1647 </div>
1648 </div>
1649 </div>
1650 <div class="chapter">
1651 <div class="titlepage"><div><div><h2 class="title">
1652 <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
1653 <div class="toc">
1654 <p><b>Table of Contents</b></p>
1655 <dl>
1656 <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
1657 <dd><dl>
1658 <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
1659 <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1660 <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
1661 <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
1662 <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
1663 <dt><span class="sect2"><a href="#pkg_versions">4.1.6. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
1664 <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
1665 <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1666 </dl></dd>
1667 <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
1668 <dd><dl>
1669 <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
1670 <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
1671 <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
1672 </dl></dd>
1673 </dl>
1674 </div>
1675 <p>Basically, there are two ways of using pkgsrc. The first
1676 is to only install the package tools and to use binary packages
1677 that someone else has prepared. This is the <span class="quote">&#8220;<span class="quote">pkg</span>&#8221;</span>
1678 in pkgsrc. The second way is to install the <span class="quote">&#8220;<span class="quote">src</span>&#8221;</span>
1679 of pkgsrc, too. Then you are able to build your own packages,
1680 and you can still use binary packages from someone else.</p>
1681 <div class="sect1">
1682 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1683 <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
1684 <p>On the <a class="ulink" href="ftp://ftp.NetBSD.org/" target="_top">ftp.NetBSD.org</a>
1685   server and its mirrors, there are collections of binary packages,
1686   ready to be installed. These binary packages have been built using the
1687   default settings for the directories, that is:</p>
1688 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1689 <li class="listitem"><p><code class="filename">/usr/pkg</code> for <code class="varname">LOCALBASE</code>, where most of the files are installed,</p></li>
1690 <li class="listitem"><p><code class="filename">/usr/pkg/etc</code> for configuration files,</p></li>
1691 <li class="listitem"><p><code class="filename">/var</code> for <code class="varname">VARBASE</code>, where those files are installed that may change after installation.</p></li>
1692 </ul></div>
1693 <p>If you cannot use these directories for whatever reasons (maybe
1694   because you're not root), you cannot use these binary packages, but
1695   have to build the packages yourself, which is explained in <a class="xref" href="#bootstrapping-pkgsrc" title="3.2. Bootstrapping pkgsrc">Section 3.2, &#8220;Bootstrapping pkgsrc&#8221;</a>.</p>
1696 <div class="sect2">
1697 <div class="titlepage"><div><div><h3 class="title">
1698 <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
1699 <p>To install binary packages, you first need to know from where
1700     to get them. The first place where you should look is on the main
1701     pkgsrc FTP server in the directory <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/" target="_top"><code class="filename">/pub/pkgsrc/packages</code></a>.</p>
1702 <p>This directory contains binary packages for multiple
1703     platforms. First, select your operating system. (Ignore the
1704     directories with version numbers attached to it, they just exist for
1705     legacy reasons.) Then, select your hardware architecture, and in the
1706     third step, the OS version and the <span class="quote">&#8220;<span class="quote">version</span>&#8221;</span> of pkgsrc.</p>
1707 <p>In this directory, you often find a file called
1708     <code class="filename">bootstrap.tar.gz</code> which contains the package
1709     management tools. If the file is missing, it is likely that your
1710     operating system already provides those tools. Download the file and
1711     extract it in the <code class="filename">/</code> directory. It will create
1712     the directories <code class="filename">/usr/pkg</code> (containing the tools
1713     for managing binary packages) and <code class="filename">/var/db/pkg</code>
1714     (the database of installed packages).</p>
1715 </div>
1716 <div class="sect2">
1717 <div class="titlepage"><div><div><h3 class="title">
1718 <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1719 <p>In the directory from the last section, there is a
1720     subdirectory called <code class="filename">All</code>, which contains all the
1721     binary packages that are available for the platform, excluding those
1722     that may not be distributed via FTP or CDROM (depending on which
1723     medium you are using).</p>
1724 <p>To install packages directly from an FTP or HTTP server, run
1725     the following commands in a Bourne-compatible shell (be sure to
1726     <span class="command"><strong>su</strong></span> to root first):</p>
1727 <pre class="screen">
1728 <code class="prompt">#</code> <strong class="userinput"><code>PATH="/usr/pkg/sbin:$PATH"</code></strong>
1729 <code class="prompt">#</code> <strong class="userinput"><code>PKG_PATH="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/<em class="replaceable"><code>OPSYS</code></em>/<em class="replaceable"><code>ARCH</code></em>/<em class="replaceable"><code>VERSIONS</code></em>/All"</code></strong>
1730 <code class="prompt">#</code> <strong class="userinput"><code>export PATH PKG_PATH</code></strong>
1731 </pre>
1732 <p>Instead of URLs, you can also use local paths, for example if
1733     you are installing from a set of CDROMs, DVDs or an NFS-mounted
1734     repository. If you want to install packages from multiple sources,
1735     you can separate them by a semicolon in
1736     <code class="varname">PKG_PATH</code>.</p>
1737 <p>After these preparations, installing a package is very
1738     easy:</p>
1739 <pre class="screen">
1740 <code class="prompt">#</code> <strong class="userinput"><code>pkg_add openoffice2</code></strong>
1741 <code class="prompt">#</code> <strong class="userinput"><code>pkg_add kde-3.5.7</code></strong>
1742 <code class="prompt">#</code> <strong class="userinput"><code>pkg_add ap2-php5-*</code></strong>
1743 </pre>
1744 <p>Note that any prerequisite packages needed to run the
1745     package in question will be installed, too, assuming they are
1746     present where you install from.</p>
1747 <p>Adding packages might install vulnerable packages.
1748     Thus you should run <span class="command"><strong>pkg_admin audit</strong></span>
1749     regularly, especially after installing new packages, and verify
1750     that the vulnerabilities are acceptable for your configuration.</p>
1751 <p>After you've installed packages, be sure to have
1752     <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1753     <code class="varname">PATH</code> so you can actually start the just
1754     installed program.</p>
1755 </div>
1756 <div class="sect2">
1757 <div class="titlepage"><div><div><h3 class="title">
1758 <a name="using.pkg_delete"></a>4.1.3. Deinstalling packages</h3></div></div></div>
1759 <p>To deinstall a package, it does not matter whether it was
1760     installed from source code or from a binary package. The
1761     <span class="command"><strong>pkg_delete</strong></span> command does not know it anyway.
1762     To delete a package, you can just run <span class="command"><strong>pkg_delete
1763     <em class="replaceable"><code>package-name</code></em></strong></span>. The package
1764     name can be given with or without version number. Wildcards can
1765     also be used to deinstall a set of packages, for example
1766     <code class="literal">*emacs*</code>. Be sure to include them in quotes,
1767     so that the shell does not expand them before
1768     <code class="literal">pkg_delete</code> sees them.</p>
1769 <p>The <code class="option">-r</code> option is very powerful: it
1770     removes all the packages that require the package in question
1771     and then removes the package itself. For example:
1772
1773     </p>
1774 <pre class="screen">
1775 <code class="prompt">#</code> <strong class="userinput"><code>pkg_delete -r jpeg</code></strong>
1776     </pre>
1777 <p>
1778
1779     will remove jpeg and all the packages that used it; this allows
1780     upgrading the jpeg package.</p>
1781 </div>
1782 <div class="sect2">
1783 <div class="titlepage"><div><div><h3 class="title">
1784 <a name="using.pkg_info"></a>4.1.4. Getting information about installed packages</h3></div></div></div>
1785 <p>The <span class="command"><strong>pkg_info</strong></span> shows information about
1786     installed packages or binary package files.</p>
1787 </div>
1788 <div class="sect2">
1789 <div class="titlepage"><div><div><h3 class="title">
1790 <a name="vulnerabilities"></a>4.1.5. Checking for security vulnerabilities in installed packages</h3></div></div></div>
1791 <p>
1792       The NetBSD Security-Officer and Packages Groups maintain a list of
1793       known security vulnerabilities to packages which are (or have been)
1794       included in pkgsrc.  The list is available from the NetBSD
1795       FTP site at <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities</a>.
1796     </p>
1797 <p>
1798       Through <span class="command"><strong>pkg_admin fetch-pkg-vulnerabilities</strong></span>,
1799       this list can be downloaded
1800       automatically, and a security audit of all packages installed on a system
1801       can take place.
1802     </p>
1803 <p>
1804       There are two components to auditing.  The first
1805       step, <span class="command"><strong>pkg_admin fetch-pkg-vulnerabilities</strong></span>,
1806       is for downloading
1807       the list of vulnerabilities from the NetBSD FTP site.  The second
1808       step, <span class="command"><strong>pkg_admin audit</strong></span>, checks to see if any of your
1809       installed packages are vulnerable.  If a package is vulnerable, you
1810       will see output similar to the following:
1811     </p>
1812 <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
1813     http://www.samba.org/samba/whatsnew/macroexploit.html</pre>
1814 <p>
1815       You may wish to have the
1816       <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
1817       file downloaded daily so that
1818       it remains current.  This may be done by adding an appropriate entry
1819       to the root users <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?crontab+5+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">crontab</span>(5)</span></a> entry.  For example the entry
1820       </p>
1821 <pre class="screen">
1822 # download vulnerabilities file
1823 0 3 * * * /usr/sbin/pkg_admin fetch-pkg-vulnerabilities &gt;/dev/null 2&gt;&amp;1
1824       </pre>
1825 <p>
1826       will update the vulnerability list every day at 3AM. You may wish to do
1827       this more often than once a day.
1828
1829       In addition, you may wish to run the package audit from the daily
1830       security script.  This may be accomplished by adding the following
1831       line to <code class="filename">/etc/security.local</code>:
1832       </p>
1833 <pre class="screen">
1834 /usr/sbin/pkg_admin audit
1835       </pre>
1836 <p>
1837     </p>
1838 </div>
1839 <div class="sect2">
1840 <div class="titlepage"><div><div><h3 class="title">
1841 <a name="pkg_versions"></a>4.1.6. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
1842 <p>
1843       Install <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/lintpkgsrc/README.html" target="_top"><code class="filename">pkgtools/lintpkgsrc</code></a> and run
1844       <span class="command"><strong>lintpkgsrc</strong></span> with the <span class="quote">&#8220;<span class="quote">-i</span>&#8221;</span>
1845       argument to check if your packages are up-to-date, e.g.
1846     </p>
1847 <pre class="screen">
1848 <code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
1849 ...
1850 Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
1851     </pre>
1852 <p>You can then use <span class="command"><strong>make update</strong></span> to update the
1853     package on your system and rebuild any dependencies.
1854     </p>
1855 </div>
1856 <div class="sect2">
1857 <div class="titlepage"><div><div><h3 class="title">
1858 <a name="using.pkg_admin"></a>4.1.7. Other administrative functions</h3></div></div></div>
1859 <p>The <span class="command"><strong>pkg_admin</strong></span> executes various
1860     administrative functions on the package system.</p>
1861 </div>
1862 <div class="sect2">
1863 <div class="titlepage"><div><div><h3 class="title">
1864 <a name="a-word-of-warning"></a>4.1.8. A word of warning</h3></div></div></div>
1865 <p>Please pay very careful attention to the warnings
1866     expressed in the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> manual page about the
1867     inherent dangers of installing binary packages which you did
1868     not create yourself, and the security holes that can be
1869     introduced onto your system by indiscriminate adding of such
1870     files.</p>
1871 <p>The same warning of course applies to every package you
1872     install from source when you haven't completely read and
1873     understood the source code of the package, the compiler that
1874     is used to build the package and all the other tools that are
1875     involved.</p>
1876 </div>
1877 </div>
1878 <div class="sect1">
1879 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1880 <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1881 <p>After obtaining pkgsrc, the <code class="filename">pkgsrc</code>
1882   directory now contains a set of packages, organized into
1883   categories. You can browse the online index of packages, or run
1884   <span class="command"><strong>make readme</strong></span> from the <code class="filename">pkgsrc</code>
1885   directory to build local <code class="filename">README.html</code> files for
1886   all packages, viewable with any web browser such as <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/lynx/README.html" target="_top"><code class="filename">www/lynx</code></a> or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a>.</p>
1887 <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages
1888   is <code class="filename">/usr/pkg</code>. If you wish to change this, you
1889   should do so by setting <code class="varname">LOCALBASE</code> in
1890   <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>. You should not try to use multiple
1891   different <code class="varname">LOCALBASE</code> definitions on the same
1892   system (inside a chroot is an exception). </p>
1893 <p>The rest of this chapter assumes that the package is already
1894   in pkgsrc. If it is not, see <a class="xref" href="#developers-guide" title="Part II. The pkgsrc developer's guide">Part II, &#8220;The pkgsrc developer's guide&#8221;</a> for
1895   instructions how to create your own packages.</p>
1896 <div class="sect2">
1897 <div class="titlepage"><div><div><h3 class="title">
1898 <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1899 <p>To build packages from source, you need a working C
1900     compiler. On NetBSD, you need to install the
1901     <span class="quote">&#8220;<span class="quote">comp</span>&#8221;</span> and the <span class="quote">&#8220;<span class="quote">text</span>&#8221;</span> distribution
1902     sets. If you want to build X11-related packages, the
1903     <span class="quote">&#8220;<span class="quote">xbase</span>&#8221;</span> and <span class="quote">&#8220;<span class="quote">xcomp</span>&#8221;</span> distribution
1904     sets are required, too.</p>
1905 </div>
1906 <div class="sect2">
1907 <div class="titlepage"><div><div><h3 class="title">
1908 <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
1909 <p>The first step for building a package is downloading the
1910     distfiles (i.e. the unmodified source). If they have not yet been
1911     downloaded, pkgsrc will fetch them automatically.</p>
1912 <p>If you have all files that you need in the
1913     <code class="filename">distfiles</code> directory,
1914     you don't need to connect. If the distfiles are on CD-ROM, you can
1915     mount the CD-ROM on <code class="filename">/cdrom</code> and add:
1916     </p>
1917 <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
1918 <p>
1919     to your <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.</p>
1920 <p>By default a list of distribution sites will be randomly
1921     intermixed to prevent huge load on servers which holding popular
1922     packages (for example, SourceForge.net mirrors). Thus, every
1923     time when you need to fetch yet another distfile all the mirrors
1924     will be tried in new (random) order. You can turn this feature
1925     off by setting <code class="varname">MASTER_SORT_RANDOM=NO</code> (for
1926     <code class="varname">PKG_DEVELOPER</code>s it's already disabled).</p>
1927 <p>You can overwrite some of the major distribution sites to
1928     fit to sites that are close to your own.  By setting one or two
1929     variables you can modify the order in which the master sites are
1930     accessed.  <code class="varname">MASTER_SORT</code> contains a whitespace
1931     delimited list of domain suffixes.
1932     <code class="varname">MASTER_SORT_REGEX</code> is even more flexible, it
1933     contains a whitespace delimited list of regular expressions.  It
1934     has higher priority than <code class="varname">MASTER_SORT</code>.  Have a
1935     look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find
1936     some examples.  This may save some of your bandwidth and
1937     time.</p>
1938 <p>You can change these settings either in your shell's environment, or,
1939     if you want to keep the settings, by editing the
1940     <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file,
1941     and adding the definitions there.</p>
1942 <p>
1943       If a package depends on many other packages (such as
1944       <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a>), the build process may
1945       alternate between periods of
1946       downloading source, and compiling. To ensure you have all the source
1947       downloaded initially you can run the command:
1948       </p>
1949 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
1950 <p>
1951       which will output and run a set of shell commands to fetch the
1952       necessary files into the <code class="filename">distfiles</code> directory.  You can
1953       also choose to download the files manually.
1954     </p>
1955 </div>
1956 <div class="sect2">
1957 <div class="titlepage"><div><div><h3 class="title">
1958 <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1959 <p>
1960       Once the software has downloaded, any patches will be applied, then it
1961       will be compiled for you. This may take some time depending on your
1962       computer, and how many other packages the software depends on and their
1963       compile time.
1964     </p>
1965 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1966 <h3 class="title">Note</h3>
1967 <p>If using bootstrap or pkgsrc on a non-NetBSD system,
1968     use the pkgsrc <span class="command"><strong>bmake</strong></span> command instead of
1969     <span class="quote">&#8220;<span class="quote">make</span>&#8221;</span> in the examples in this guide.</p>
1970 </div>
1971 <p>For example, type</p>
1972 <pre class="screen">
1973 <code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
1974 <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
1975     </pre>
1976 <p>at the shell prompt to build the various components of the
1977     package.</p>
1978 <p>The next stage is to actually install the newly compiled
1979     program onto your system. Do this by entering:
1980
1981     </p>
1982 <pre class="screen">
1983 <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
1984     </pre>
1985 <p>
1986
1987     while you are still in the directory for whatever package you
1988     are installing.</p>
1989 <p>Installing the package on your system may require you to
1990     be root.  However, pkgsrc has a
1991     <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
1992     to only become root for the actual installation step.</p>
1993 <p>That's it, the software should now be installed and setup for use.
1994     You can now enter:
1995
1996     </p>
1997 <pre class="screen">
1998 <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
1999     </pre>
2000 <p>
2001
2002     to remove the compiled files in the work directory, as you shouldn't need
2003     them any more. If other packages were also added to your system
2004     (dependencies) to allow your program to compile, you can tidy these up
2005     also with the command:</p>
2006 <pre class="screen">
2007 <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
2008     </pre>
2009 <p>Taking the figlet utility as an example, we can install it on our
2010     system by building as shown in <a class="xref" href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
2011 <p>The program is installed under the default root of the
2012     packages tree - <code class="filename">/usr/pkg</code>. Should this not
2013     conform to your tastes, set the <code class="varname">LOCALBASE</code>
2014     variable in your environment, and it will use that value as the
2015     root of your packages tree. So, to use
2016     <code class="filename">/usr/local</code>, set
2017     <code class="varname">LOCALBASE=/usr/local</code> in your environment.
2018     Please note that you should use a directory which is dedicated to
2019     packages and not shared with other programs (i.e., do not try and
2020     use <code class="varname">LOCALBASE=/usr</code>).  Also, you should not try
2021     to add any of your own files or directories (such as
2022     <code class="filename">src/</code>, <code class="filename">obj/</code>, or
2023     <code class="filename">pkgsrc/</code>) below the
2024     <code class="varname">LOCALBASE</code> tree.  This is to prevent possible
2025     conflicts between programs and other files installed by the
2026     package system and whatever else may have been installed
2027     there.</p>
2028 <p>Some packages look in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to
2029     alter some configuration options at build time.  Have a look at
2030     <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to get an overview
2031     of what will be set there by default.  Environment variables such
2032     as <code class="varname">LOCALBASE</code> can be set in
2033     <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to save having to remember to
2034     set them each time you want to use pkgsrc.</p>
2035 <p>Occasionally, people want to <span class="quote">&#8220;<span class="quote">look under the
2036     covers</span>&#8221;</span> to see what is going on when a package is building
2037     or being installed. This may be for debugging purposes, or out of
2038     simple curiosity. A number of utility values have been added to
2039     help with this.</p>
2040 <div class="orderedlist"><ol class="orderedlist" type="1">
2041 <li class="listitem">
2042 <p>If you invoke the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> command with
2043         <code class="varname">PKG_DEBUG_LEVEL=2</code>, then a huge amount of
2044         information will be displayed. For example,</p>
2045 <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
2046 <p>will show all the commands that are invoked, up to and
2047         including the <span class="quote">&#8220;<span class="quote">patch</span>&#8221;</span> stage.</p>
2048 </li>
2049 <li class="listitem">
2050 <p>If you want to know the value of a certain <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
2051         definition, then the <code class="varname">VARNAME</code> definition
2052         should be used, in conjunction with the show-var
2053         target. e.g. to show the expansion of the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
2054         variable <code class="varname">LOCALBASE</code>:</p>
2055 <pre class="screen">
2056 <code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
2057 /usr/pkg
2058 <code class="prompt">%</code>
2059         </pre>
2060 </li>
2061 </ol></div>
2062 <p>If you want to install a binary package that you've either
2063     created yourself (see next section), that you put into
2064     pkgsrc/packages manually or that is located on a remote FTP
2065     server, you can use the "bin-install" target. This target will
2066     install a binary package - if available - via <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>,
2067     else do a <span class="command"><strong>make package</strong></span>.  The list of remote FTP
2068     sites searched is kept in the variable
2069     <code class="varname">BINPKG_SITES</code>, which defaults to
2070     ftp.NetBSD.org. Any flags that should be added to <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>
2071     can be put into <code class="varname">BIN_INSTALL_FLAGS</code>.  See
2072     <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more
2073     details.</p>
2074 <p>A final word of warning: If you set up a system that has a
2075     non-standard setting for <code class="varname">LOCALBASE</code>, be sure to
2076     set that before any packages are installed, as you cannot use
2077     several directories for the same purpose. Doing so will result in
2078     pkgsrc not being able to properly detect your installed packages,
2079     and fail miserably. Note also that precompiled binary packages are
2080     usually built with the default <code class="varname">LOCALBASE</code> of
2081     <code class="filename">/usr/pkg</code>, and that you should
2082     <span class="emphasis"><em>not</em></span> install any if you use a non-standard
2083     <code class="varname">LOCALBASE</code>.</p>
2084 </div>
2085 </div>
2086 </div>
2087 <div class="chapter">
2088 <div class="titlepage"><div><div><h2 class="title">
2089 <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
2090 <div class="toc">
2091 <p><b>Table of Contents</b></p>
2092 <dl>
2093 <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
2094 <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
2095 <dt><span class="sect1"><a href="#variables-affecting-installation">5.3. Variables affecting the installation process</a></span></dt>
2096 <dt><span class="sect1"><a href="#conf.compiler">5.4. Selecting and configuring the compiler</a></span></dt>
2097 <dd><dl>
2098 <dt><span class="sect2"><a href="#selecting-the-compiler">5.4.1. Selecting the compiler</a></span></dt>
2099 <dt><span class="sect2"><a href="#conf.cflags">5.4.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
2100 <dt><span class="sect2"><a href="#conf.ldflags">5.4.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
2101 </dl></dd>
2102 <dt><span class="sect1"><a href="#developer-advanced-settings">5.5. Developer/advanced settings</a></span></dt>
2103 <dt><span class="sect1"><a href="#selecting-build-options">5.6. Selecting Build Options</a></span></dt>
2104 </dl>
2105 </div>
2106 <a name="mk.conf"></a><p>The whole pkgsrc system is configured in a single file, usually
2107 called <code class="filename">mk.conf</code>. In which directory pkgsrc looks for
2108 that file depends on the installation. On NetBSD, when you use
2109 <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> from the base system, it is in the directory
2110 <code class="filename">/etc/</code>. In all other cases the default location is
2111 <code class="literal">${PREFIX}/etc/</code>, depending on where you told the
2112 bootstrap program to install the binary packages.</p>
2113 <p>During the bootstrap, an example configuration file is created. To
2114 use that, you have to create the directory
2115 <code class="filename">${PREFIX}/etc</code> and copy the example file
2116 there.</p>
2117 <p>The format of the configuration file is that of the usual
2118 BSD-style <code class="filename">Makefile</code>s. The whole pkgsrc configuration
2119 is done by setting variables in this file. Note that you can define all
2120 kinds of variables, and no special error checking (for example for
2121 spelling mistakes) takes place, so you have to try it out to see if it
2122 works.</p>
2123 <div class="sect1">
2124 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2125 <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
2126 <p>In this section, you can find some variables that apply to all
2127     pkgsrc packages. A complete list of the variables that can be
2128     configured by the user is available in
2129     <code class="filename">mk/defaults/mk.conf</code>, together with some
2130     comments that describe each variable's intent.</p>
2131 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
2132 <li class="listitem"><p><code class="varname">LOCALBASE</code>: Where
2133             packages will be installed. The default is
2134             <code class="filename">/usr/pkg</code>. Do not mix binary packages
2135             with different <code class="varname">LOCALBASE</code>s!</p></li>
2136 <li class="listitem"><p><code class="varname">CROSSBASE</code>: Where
2137             <span class="quote">&#8220;<span class="quote">cross</span>&#8221;</span> category packages will be
2138             installed. The default is
2139             <code class="filename">${LOCALBASE}/cross</code>.</p></li>
2140 <li class="listitem"><p><code class="varname">X11BASE</code>: Where
2141             X11 is installed on the system. The default is
2142             <code class="filename">/usr/X11R6</code>.</p></li>
2143 <li class="listitem"><p><code class="varname">DISTDIR</code>: Where to store the
2144             downloaded copies of the original source distributions used
2145             for building pkgsrc packages. The default is
2146             <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
2147 <li class="listitem"><p><code class="varname">PKG_DBDIR</code>: Where the
2148             database about installed packages is stored.  The default is
2149             <code class="filename">/var/db/pkg</code>.</p></li>
2150 <li class="listitem"><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
2151             If set, override the packages'
2152             <code class="varname">MASTER_SITES</code> with this value.</p></li>
2153 <li class="listitem"><p><code class="varname">MASTER_SITE_BACKUP</code>:
2154             Backup location(s) for distribution files and patch files
2155             if not found locally or in
2156             <code class="filename">${MASTER_SITES}</code> or
2157             <code class="filename">${PATCH_SITES}</code> respectively.
2158             The defaults are
2159             <code class="filename">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/${DIST_SUBDIR}/</code>
2160             and
2161             <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
2162 <li class="listitem"><p><code class="varname">BINPKG_SITES</code>:
2163             List of sites carrying binary pkgs. <em class="replaceable"><code>rel</code></em> and
2164             <em class="replaceable"><code>arch</code></em> are replaced with OS
2165             release (<span class="quote">&#8220;<span class="quote">2.0</span>&#8221;</span>, etc.) and architecture
2166             (<span class="quote">&#8220;<span class="quote">mipsel</span>&#8221;</span>, etc.).</p></li>
2167 <li class="listitem"><p><code class="varname">ACCEPTABLE_LICENSES</code>:
2168             List of acceptable licenses. License names are case-sensitive.
2169             Whenever you try to build a package whose license is not in this
2170             list, you will get an error message. If the license condition is
2171             simple enough, the error message will include specific
2172             instructions on how to change this variable.</p></li>
2173 </ul></div>
2174 </div>
2175 <div class="sect1">
2176 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2177 <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
2178 <p>XXX
2179       </p>
2180 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
2181 <li class="listitem"><p><code class="varname">PACKAGES</code>: The top level
2182             directory for the binary packages. The default is
2183             <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
2184 <li class="listitem"><p><code class="varname">WRKOBJDIR</code>:
2185             The top level directory where, if defined, the separate
2186             working directories will get created, and symbolically
2187             linked to from <code class="filename">${WRKDIR}</code> (see below).
2188             This is useful for building packages on several
2189             architectures, then <code class="filename">${PKGSRCDIR}</code>
2190             can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
2191             is local to every architecture. (It should be noted that
2192             <code class="varname">PKGSRCDIR</code> should not be set by the user
2193             &mdash; it is an internal definition which refers to the
2194             root of the pkgsrc tree. It is possible to have many
2195             pkgsrc tree instances.)</p></li>
2196 <li class="listitem"><p><code class="varname">LOCALPATCHES</code>:
2197             Directory for local patches that aren't part of pkgsrc.
2198             See <a class="xref" href="#components.patches" title="11.3. patches/*">Section 11.3, &#8220;patches/*&#8221;</a> for more
2199             information.</p></li>
2200 <li class="listitem"><p><code class="varname">PKGMAKECONF</code>: Location of
2201             the <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file used by a package's
2202             BSD-style Makefile. If this is not set,
2203             <code class="varname">MAKECONF</code> is set to
2204             <code class="filename">/dev/null</code> to avoid picking up
2205             settings used by builds in <code class="filename">/usr/src</code>.</p></li>
2206 <li class="listitem"><p><code class="varname">DEPENDS_TARGET</code>:
2207             By default, dependencies are only installed, and no binary
2208             package is created for them. You can set this variable to
2209             <code class="literal">package</code> to automatically create binary
2210             packages after installing dependencies.</p></li>
2211 </ul></div>
2212 </div>
2213 <div class="sect1">
2214 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2215 <a name="variables-affecting-installation"></a>5.3. Variables affecting the installation process</h2></div></div></div>
2216 <p>Most packages support installation into a
2217     subdirectory of <code class="varname">WRKDIR</code>. This allows a package
2218     to be built, before the actual filesystem is touched. DESTDIR
2219     support exists in two variations:</p>
2220 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
2221 <li class="listitem"><p>Basic DESTDIR support means that the package
2222       installation and packaging is still run as root.</p></li>
2223 <li class="listitem"><p>Full DESTDIR support can run the complete
2224       build, installation and packaging as normal user. Root
2225       privileges are only needed to add packages.</p></li>
2226 </ul></div>
2227 <p>DESTDIR support is now the default. To switch back to non-DESTDIR,
2228     you can set
2229     <code class="varname">USE_DESTDIR=no</code>; this setting will be deprecated though,
2230     so it's preferable to convert a package to DESTDIR instead.</p>
2231 <p>DESTDIR support changes the behaviour of various targets
2232     slightly. To install a package after building it, use
2233     <code class="literal">package-install</code>. <code class="literal">package</code> and
2234     <code class="literal">install</code> don't do that any
2235     longer. <code class="literal">package-install</code> can be used as
2236     <code class="varname">DEPENDS_TARGET</code>.  <code class="literal">bin-install</code>
2237     will ask for the root password to install the package and fail,
2238     <code class="literal">package-install</code> will ask again.</p>
2239 <p>With basic DESTDIR support, <strong class="userinput"><code>make
2240     clean</code></strong> needs to be run as root.</p>
2241 <p>Considering the <code class="filename">foo/bar</code> package,
2242     DESTDIR full support can be tested using the following commands
2243
2244 </p>
2245 <pre class="programlisting">
2246 <code class="prompt">$</code> id
2247 uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
2248 <code class="prompt">$</code> mkdir $HOME/packages
2249 <code class="prompt">$</code> cd $PKGSRCDIR/foo/bar
2250 </pre>
2251 <p>
2252
2253     Verify <code class="varname">DESTDIR</code> full support, no root privileges
2254     should be needed
2255
2256 </p>
2257 <pre class="programlisting">
2258 <code class="prompt">$</code> make USE_DESTDIR=yes install
2259 </pre>
2260 <p>
2261
2262     Create a package without root privileges
2263
2264 </p>
2265 <pre class="programlisting">
2266 <code class="prompt">$</code> make USE_DESTDIR=yes PACKAGES=$HOME/packages package
2267 </pre>
2268 <p>
2269
2270     For the following command, you must be able to gain root
2271     privileges using <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?su+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">su</span>(1)</span></a>
2272
2273 </p>
2274 <pre class="programlisting">
2275 <code class="prompt">$</code> make USE_DESTDIR=yes PACKAGES=$HOME/packages package-install
2276 </pre>
2277 <p>
2278
2279     Then, as a simple user
2280
2281 </p>
2282 <pre class="programlisting">
2283 <code class="prompt">$</code> make clean
2284 </pre>
2285 <p>
2286
2287     </p>
2288 </div>
2289 <div class="sect1">
2290 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2291 <a name="conf.compiler"></a>5.4. Selecting and configuring the compiler</h2></div></div></div>
2292 <div class="sect2">
2293 <div class="titlepage"><div><div><h3 class="title">
2294 <a name="selecting-the-compiler"></a>5.4.1. Selecting the compiler</h3></div></div></div>
2295 <p>By default, pkgsrc will use GCC to build packages.  This may be
2296     overridden by setting the following variables in /etc/mk.conf:</p>
2297 <div class="variablelist"><dl class="variablelist">
2298 <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
2299 <dd>
2300 <p>This is a list of values specifying the chain of
2301           compilers to invoke when building packages.  Valid values
2302           are:</p>
2303 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
2304 <li class="listitem"><p><code class="varname">distcc</code>:
2305             distributed C/C++ (chainable)</p></li>
2306 <li class="listitem"><p><code class="varname">ccache</code>:
2307             compiler cache (chainable)</p></li>
2308 <li class="listitem"><p><code class="varname">gcc</code>:
2309             GNU C/C++ Compiler</p></li>
2310 <li class="listitem"><p><code class="varname">mipspro</code>:
2311             Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
2312 <li class="listitem"><p><code class="varname">mipspro</code>:
2313             Silicon Graphics, Inc. MIPSpro (o32)</p></li>
2314 <li class="listitem"><p><code class="varname">sunpro</code>:
2315             Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
2316 </ul></div>
2317 <p>The default is
2318           <span class="quote">&#8220;<span class="quote"><code class="varname">gcc</code></span>&#8221;</span>.  You can use
2319           <code class="varname">ccache</code> and/or
2320           <code class="varname">distcc</code> with an appropriate
2321           <code class="varname">PKGSRC_COMPILER</code> setting,
2322           e.g. <span class="quote">&#8220;<span class="quote"><code class="varname">ccache gcc</code></span>&#8221;</span>.  This
2323           variable should always be terminated with a value for
2324           a real compiler.  Note that only one real compiler
2325           should be listed (e.g. <span class="quote">&#8220;<span class="quote"><code class="varname">sunpro gcc</code></span>&#8221;</span>
2326           is not allowed).</p>
2327 </dd>
2328 <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
2329 <dd><p>This specifies the minimum version of GCC to use
2330           when building packages.  If the system GCC doesn't
2331           satisfy this requirement, then pkgsrc will build and
2332           install one of the GCC packages to use instead.</p></dd>
2333 </dl></div>
2334 </div>
2335 <div class="sect2">
2336 <div class="titlepage"><div><div><h3 class="title">
2337 <a name="conf.cflags"></a>5.4.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
2338 <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
2339         please make sure to use the <code class="literal">+=</code> operator
2340         instead of the <code class="literal">=</code> operator:</p>
2341 <pre class="programlisting">
2342 CFLAGS+=        -your -flags
2343 </pre>
2344 <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
2345         <span class="quote">&#8220;<span class="quote">+</span>&#8221;</span>) may lead to problems with packages that
2346         need to add their own flags.  You may want to take a look
2347         at the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a>
2348         package if you're interested in optimization specifically
2349         for the current CPU. </p>
2350 </div>
2351 <div class="sect2">
2352 <div class="titlepage"><div><div><h3 class="title">
2353 <a name="conf.ldflags"></a>5.4.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</h3></div></div></div>
2354 <p>If you want to pass flags to the linker, both in the configure
2355 step and the build step, you can do this in two ways.  Either set
2356 <code class="varname">LDFLAGS</code> or <code class="varname">LIBS</code>.  The difference
2357 between the two is that <code class="varname">LIBS</code> will be appended to
2358 the command line, while <code class="varname">LDFLAGS</code> come earlier.
2359 <code class="varname">LDFLAGS</code> is pre-loaded with rpath settings for ELF
2360 machines depending on the setting of <code class="varname">USE_IMAKE</code> or
2361 the inclusion of <code class="filename">mk/x11.buildlink3.mk</code>.  As with
2362 <code class="varname">CFLAGS</code>, if you do not wish to override these
2363 settings, use the <code class="literal">+=</code> operator:</p>
2364 <pre class="programlisting">
2365 LDFLAGS+=        -your -linkerflags
2366 </pre>
2367 </div>
2368 </div>
2369 <div class="sect1">
2370 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2371 <a name="developer-advanced-settings"></a>5.5. Developer/advanced settings</h2></div></div></div>
2372 <p>XXX
2373       </p>
2374 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
2375 <li class="listitem">
2376 <p><code class="varname">PKG_DEVELOPER</code>:
2377             Run some sanity checks that package developers want:
2378             </p>
2379 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
2380 <li class="listitem"><p>make sure patches apply with zero
2381               fuzz</p></li>
2382 <li class="listitem"><p>run check-shlibs to see that all
2383               binaries will find their shared libs.</p></li>
2384 </ul></div>
2385 <p>
2386         </p>
2387 </li>
2388 <li class="listitem"><p><code class="varname">PKG_DEBUG_LEVEL</code>: The level
2389         of debugging output which is displayed whilst making and
2390         installing the package.  The default value for this is 0,
2391         which will not display the commands as they are executed
2392         (normal, default, quiet operation); the value 1 will display
2393         all shell commands before their invocation, and the value 2
2394         will display both the shell commands before their invocation,
2395         and their actual execution progress with <span class="command"><strong>set
2396         -x</strong></span> will be displayed.</p></li>
2397 </ul></div>
2398 <p>
2399     </p>
2400 </div>
2401 <div class="sect1">
2402 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2403 <a name="selecting-build-options"></a>5.6. Selecting Build Options</h2></div></div></div>
2404 <p>Some packages have build time options, usually to select
2405     between different dependencies, enable optional support for big
2406     dependencies or enable experimental features.</p>
2407 <p>To see which options, if any, a package supports, and which
2408     options are mutually exclusive, run <span class="command"><strong>make
2409     show-options</strong></span>, for example:</p>
2410 <pre class="programlisting">
2411     The following options are supported by this package:
2412         ssl      Enable SSL support.
2413     Exactly one of the following gecko options is required:
2414         firefox  Use firefox as gecko rendering engine.
2415         mozilla  Use mozilla as gecko rendering engine.
2416     At most one of the following database options may be selected:
2417         mysql    Enable support for MySQL database.
2418         pgsql    Enable support for PostgreSQL database.
2419
2420     These options are enabled by default: firefox
2421     These options are currently enabled: mozilla ssl
2422 </pre>
2423 <p>The following variables can be defined in
2424     <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to select which options to
2425     enable for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>,
2426     which can be used to select or disable options for all packages
2427     that support them, and
2428     <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
2429     which can be used to select or disable options specifically for
2430     package <em class="replaceable"><code>pkgbase</code></em>.  Options listed in
2431     these variables are selected, options preceded by <span class="quote">&#8220;<span class="quote">-</span>&#8221;</span>
2432     are disabled. A few examples:</p>
2433 <pre class="screen">
2434 <code class="prompt">$</code> <span class="command"><strong>grep "PKG.*OPTION" <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a></strong></span>
2435 PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
2436 PKG_OPTIONS.kdebase=    debug -sasl
2437 PKG_OPTIONS.apache=     suexec </pre>
2438 <p>It is important to note that options that were specifically
2439     suggested by the package maintainer must be explicitly removed if
2440     you do not wish to include the option.  If you are unsure you can view
2441     the current state with <span class="command"><strong>make show-options</strong></span>.</p>
2442 <p>The following settings are consulted in the order given, and
2443     the last setting that selects or disables an option is
2444     used:</p>
2445 <div class="orderedlist"><ol class="orderedlist" type="1">
2446 <li class="listitem"><p>the default options as suggested by the package
2447       maintainer</p></li>
2448 <li class="listitem"><p>the options implied by the settings of legacy
2449       variables (see below)</p></li>
2450 <li class="listitem"><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
2451 <li class="listitem"><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
2452 </ol></div>
2453 <p>For groups of mutually exclusive options, the last option
2454     selected is used, all others are automatically disabled.  If an
2455     option of the group is explicitly disabled, the previously
2456     selected option, if any, is used.  It is an error if no option
2457     from a required group of options is selected, and building the
2458     package will fail.</p>
2459 <p>Before the options framework was introduced, build options
2460     were selected by setting a variable (often named
2461     <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
2462     <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> for each option.  To ease
2463     transition to the options framework for the user, these legacy
2464     variables are converted to the appropriate options setting
2465     (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
2466     automatically.  A warning is issued to prompt the user to update
2467     <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to use the options framework
2468     directly.  Support for the legacy variables will be removed
2469     eventually.</p>
2470 </div>
2471 </div>
2472 <div class="chapter">
2473 <div class="titlepage"><div><div><h2 class="title">
2474 <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
2475 <div class="toc">
2476 <p><b>Table of Contents</b></p>
2477 <dl>
2478 <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
2479 <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
2480 </dl>
2481 </div>
2482 <div class="sect1">
2483 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2484 <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
2485 <p>Once you have built and installed a package, you can create
2486     a <span class="emphasis"><em>binary package</em></span> which can be installed on
2487     another system with <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>. This saves having to build
2488     the same package on a group of hosts and wasting CPU time. It also
2489     provides a simple means for others to install your package, should
2490     you distribute it.</p>
2491 <p>To create a binary package, change into the appropriate
2492     directory in pkgsrc, and run <span class="command"><strong>make
2493     package</strong></span>:</p>
2494 <pre class="screen">
2495 <code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2496 <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
2497     </pre>
2498 <p>This will build and install your package (if not already done),
2499     and then build a binary package from what was installed. You can
2500     then use the <span class="command"><strong>pkg_*</strong></span> tools to manipulate
2501     it. Binary packages are created by default in
2502     <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
2503     gzipped tar file. See <a class="xref" href="#logs.package" title="B.2. Packaging figlet">Section B.2, &#8220;Packaging figlet&#8221;</a> for a
2504     continuation of the above <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/misc/figlet/README.html" target="_top"><code class="filename">misc/figlet</code></a> example.</p>
2505 <p>See <a class="xref" href="#submit" title="Chapter 21. Submitting and Committing">Chapter 21, <i>Submitting and Committing</i></a> for information on how to submit
2506     such a binary package.</p>
2507 </div>
2508 <div class="sect1">
2509 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2510 <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
2511 <p>See <a class="xref" href="#build.helpful-targets" title="17.17. Other helpful targets">Section 17.17, &#8220;Other helpful targets&#8221;</a>.</p>
2512 </div>
2513 </div>
2514 <div class="chapter">
2515 <div class="titlepage"><div><div><h2 class="title">
2516 <a name="bulk"></a>Chapter 7. Creating binary packages for everything in pkgsrc (bulk
2517 builds)</h2></div></div></div>
2518 <div class="toc">
2519 <p><b>Table of Contents</b></p>
2520 <dl>
2521 <dt><span class="sect1"><a href="#bulk.pre">7.1. Think first, build later</a></span></dt>
2522 <dt><span class="sect1"><a href="#bulk.req">7.2. Requirements of a bulk build</a></span></dt>
2523 <dt><span class="sect1"><a href="#bulk.old">7.3. Running an old-style bulk build</a></span></dt>
2524 <dd><dl>
2525 <dt><span class="sect2"><a href="#binary.configuration">7.3.1. Configuration</a></span></dt>
2526 <dt><span class="sect2"><a href="#other-environmental-considerations">7.3.2. Other environmental considerations</a></span></dt>
2527 <dt><span class="sect2"><a href="#operation">7.3.3. Operation</a></span></dt>
2528 <dt><span class="sect2"><a href="#what-it-does">7.3.4. What it does</a></span></dt>
2529 <dt><span class="sect2"><a href="#disk-space-requirements">7.3.5. Disk space requirements</a></span></dt>
2530 <dt><span class="sect2"><a href="#setting-up-a-sandbox">7.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
2531 <dt><span class="sect2"><a href="#building-a-partial-set">7.3.7. Building a partial set of packages</a></span></dt>
2532 <dt><span class="sect2"><a href="#bulk-upload">7.3.8. Uploading results of a bulk build</a></span></dt>
2533 </dl></dd>
2534 <dt><span class="sect1"><a href="#bulk.pbulk">7.4. Running a pbulk-style bulk build</a></span></dt>
2535 <dd><dl>
2536 <dt><span class="sect2"><a href="#bulk.pbulk.prepare">7.4.1. Preparation</a></span></dt>
2537 <dt><span class="sect2"><a href="#bulk.pbulk.conf">7.4.2. Configuration</a></span></dt>
2538 </dl></dd>
2539 <dt><span class="sect1"><a href="#creating-cdroms">7.5. Creating a multiple CD-ROM packages collection</a></span></dt>
2540 <dd><dl><dt><span class="sect2"><a href="#cdpack-example">7.5.1. Example of cdpack</a></span></dt></dl></dd>
2541 </dl>
2542 </div>
2543 <p>When you have multiple machines that should run the same packages,
2544 it is wasted time if they all build their packages themselves from
2545 source. There are two ways of getting a set of binary packages: The old
2546 bulk build system, or the new (as of 2007) parallel bulk build (pbulk)
2547 system. This chapter describes how to set them up so that the packages
2548 are most likely to be usable later.</p>
2549 <div class="sect1">
2550 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2551 <a name="bulk.pre"></a>7.1. Think first, build later</h2></div></div></div>
2552 <p>Since a bulk build takes several days or even weeks to finish, you
2553 should think about the setup before you start everything. Pay attention
2554 to at least the following points:</p>
2555 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
2556 <li class="listitem">
2557 <p>If you want to upload the binary packages to
2558 ftp.NetBSD.org, make sure the setup complies to the requirements for binary
2559 packages:</p>
2560 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
2561 <li class="listitem"><p>To end up on ftp.NetBSD.org, the packages must be built
2562 by a NetBSD developer on a trusted machine (that is, where you and only
2563 you have root access).</p></li>
2564 <li class="listitem"><p>Packages on ftp.NetBSD.org should only be created from
2565 the stable branches (like 2009Q1), so that users browsing the available
2566 collections can see at a glance how old the packages
2567 are.</p></li>
2568 <li class="listitem"><p>The packages must be built as root, since some packages
2569 require set-uid binaries at runtime, and creating those packages as
2570 unprivileged user doesn't work well at the moment.</p></li>
2571 </ul></div>
2572 </li>
2573 <li class="listitem"><p>Make sure that the bulk build cannot break anything in
2574 your system. Most bulk builds run as root, so they should be run at least
2575 in a chroot environment or something even more restrictive, depending on
2576 what the operating system provides. There have been numerous cases where
2577 certain packages tried to install files outside the
2578 <code class="filename">LOCALBASE</code> or wanted to edit some files in
2579 <code class="filename">/etc</code>. Furthermore, the bulk builds install and
2580 deinstall packages in <code class="filename">/usr/pkg</code> (or whatever
2581 <code class="filename">LOCALBASE</code> is) during their operation, so be sure
2582 that you don't need any package during the build.</p></li>
2583 </ul></div>
2584 </div>
2585 <div class="sect1">
2586 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2587 <a name="bulk.req"></a>7.2. Requirements of a bulk build</h2></div></div></div>
2588 <p>A complete bulk build requires lots of disk space. Some of the
2589 disk space can be read-only, some other must be writable. Some can be on
2590 remote filesystems (such as NFS) and some should be local. Some can be
2591 temporary filesystems, others must survive a sudden reboot.</p>
2592 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
2593 <li class="listitem"><p>10 GB for the distfiles (read-write, remote, temporary)</p></li>
2594 <li class="listitem"><p>10 GB for the binary packages (read-write, remote, permanent)</p></li>
2595 <li class="listitem"><p>400 MB for the pkgsrc tree (read-only, remote, permanent)</p></li>
2596 <li class="listitem"><p>5 GB for <code class="filename">LOCALBASE</code> (read-write, local, temporary for pbulk, permanent for old-bulk)</p></li>
2597 <li class="listitem"><p>5 GB for the log files (read-write, remote, permanent)</p></li>
2598 <li class="listitem"><p>5 GB for temporary files (read-write, local, temporary)</p></li>
2599 </ul></div>
2600 </div>
2601 <div class="sect1">
2602 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2603 <a name="bulk.old"></a>7.3. Running an old-style bulk build</h2></div></div></div>
2604 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
2605 <h3 class="title">Note</h3>
2606 <p>There are two ways of doing a bulk build. The old-style
2607 one and the new-style <span class="quote">&#8220;<span class="quote">pbulk</span>&#8221;</span>. The latter is the recommended
2608 way.</p>
2609 </div>
2610 <div class="sect2">
2611 <div class="titlepage"><div><div><h3 class="title">
2612 <a name="binary.configuration"></a>7.3.1. Configuration</h3></div></div></div>
2613 <div class="sect3">
2614 <div class="titlepage"><div><div><h4 class="title">
2615 <a name="binary.bulk.build.conf"></a>7.3.1.1. <code class="filename">build.conf</code>
2616 </h4></div></div></div>
2617 <p>The <code class="filename">build.conf</code> file is the main
2618         configuration file for bulk builds. You can configure how your
2619         copy of pkgsrc is kept up to date, how the distfiles are
2620         downloaded, how the packages are built and how the report is
2621         generated. You can find an annotated example file in
2622         <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
2623         it, copy <code class="filename">build.conf-example</code> to
2624         <code class="filename">build.conf</code> and edit it, following the
2625         comments in that file.</p>
2626 </div>
2627 <div class="sect3">
2628 <div class="titlepage"><div><div><h4 class="title">
2629 <a name="binary.mk.conf"></a>7.3.1.2. <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>
2630 </h4></div></div></div>
2631 <p>You may want to set variables in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.
2632         Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
2633         details of the default settings. You will want to ensure that
2634         <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
2635         As used in this example, <code class="varname">SKIP_LICENSE_CHECK=yes</code>
2636         completely bypasses the license check.</p>
2637 <pre class="programlisting">
2638 PACKAGES?=      ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
2639 WRKOBJDIR?=     /usr/tmp/pkgsrc   # build here instead of in pkgsrc
2640 BSDSRCDIR=      /usr/src
2641 BSDXSRCDIR=     /usr/xsrc         # for x11/xservers
2642 OBJHOSTNAME?=   yes               # use work.`hostname`
2643 FAILOVER_FETCH= yes               # insist on the correct checksum
2644 PKG_DEVELOPER?= yes
2645 SKIP_LICENSE_CHECK=    yes
2646 </pre>
2647 <p>Some options that are especially useful for bulk builds
2648         can be found at the top lines of the file
2649         <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
2650         options of these are briefly described here.</p>
2651 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
2652 <li class="listitem"><p>If you are on a slow machine, you may want to
2653           set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
2654           <span class="quote">&#8220;<span class="quote">no</span>&#8221;</span>.</p></li>
2655 <li class="listitem"><p>If you are doing bulk builds from a read-only
2656           copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
2657           to the directory where all log files are created. Otherwise the
2658           log files are created in the pkgsrc directory.</p></li>
2659 <li class="listitem"><p>Another important variable is
2660           <code class="varname">BULK_PREREQ</code>, which is a list of packages that
2661           should be always available while building other
2662           packages.</p></li>
2663 </ul></div>
2664 <p>Some other options are scattered in the pkgsrc
2665         infrastructure:</p>
2666 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
2667 <li class="listitem"><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
2668           should be set to <code class="literal">yes</code>. The purpose of the
2669           bulk builds is creating binary packages, no matter if they
2670           are vulnerable or not. Leaving this variable unset would
2671           prevent the bulk build system from even trying to build
2672           them, so possible building errors would not show
2673           up.</p></li>
2674 <li class="listitem"><p><code class="varname">CHECK_FILES</code>
2675           (<code class="filename">pkgsrc/mk/check/check-files.mk</code>) can be set to
2676           <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span> to check that the installed set of files
2677           matches the <code class="filename">PLIST</code>.</p></li>
2678 <li class="listitem"><p><code class="varname">CHECK_INTERPRETER</code>
2679           (<code class="filename">pkgsrc/mk/check/check-interpreter.mk</code>) can be set to
2680           <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span> to check that the installed
2681           <span class="quote">&#8220;<span class="quote">#!</span>&#8221;</span>-scripts will find their
2682           interpreter.</p></li>
2683 <li class="listitem"><p><code class="varname">PKGSRC_RUN_TEST</code> can be
2684           set to <span class="quote">&#8220;<span class="quote"><code class="literal">yes</code></span>&#8221;</span> to run each
2685           package's self-test before installing it. Note that some
2686           packages make heavy use of <span class="quote">&#8220;<span class="quote">good</span>&#8221;</span> random
2687           numbers, so you need to assure that the machine on which you
2688           are doing the bulk builds is not completely idle. Otherwise
2689           some test programs will seem to hang, while they are just
2690           waiting for new random data to be
2691           available.</p></li>
2692 </ul></div>
2693 </div>
2694 <div class="sect3">
2695 <div class="titlepage"><div><div><h4 class="title">
2696 <a name="pre-build.local"></a>7.3.1.3. <code class="filename">pre-build.local</code>
2697 </h4></div></div></div>
2698 <p>It is possible to configure the bulk build to perform
2699         certain site-specific tasks at the end of the pre-build
2700         stage.  If the file
2701         <code class="filename">pre-build.local</code> exists in
2702         <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
2703         (as a <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?sh+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">sh</span>(1)</span></a> script) at the end of the usual pre-build
2704         stage.  An example use of
2705         <code class="filename">pre-build.local</code> is to have the line:</p>
2706 <pre class="screen">echo "I do not have enough disk space to build this pig." \
2707         &gt; misc/openoffice/$BROKENF</pre>
2708 <p>to prevent the system from trying to build a particular package
2709         which requires nearly 3 GB of disk space.</p>
2710 </div>
2711 </div>
2712 <div class="sect2">
2713 <div class="titlepage"><div><div><h3 class="title">
2714 <a name="other-environmental-considerations"></a>7.3.2. Other environmental considerations</h3></div></div></div>
2715 <p>As <code class="filename">/usr/pkg</code> will be completely
2716       deleted at the start of bulk builds, make sure your login
2717       shell is placed somewhere else. Either drop it into
2718       <code class="filename">/usr/local/bin</code> (and adjust your login
2719       shell in the passwd file), or (re-)install it via
2720       <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> from <code class="filename">/etc/rc.local</code>, so
2721       you can login after a reboot (remember that your current
2722       process won't die if the package is removed, you just can't
2723       start any new instances of the shell any more).  Also, if you
2724       use NetBSD earlier than 1.5, or you still want to use the pkgsrc
2725       version of ssh for some reason, be sure to install ssh before
2726       starting it from <code class="filename">rc.local</code>:</p>
2727 <pre class="programlisting">
2728 (cd /usr/pkgsrc/security/ssh &amp;&amp; make bulk-install)
2729 if [ -f /usr/pkg/etc/rc.d/sshd ]; then
2730   /usr/pkg/etc/rc.d/sshd
2731 fi
2732 </pre>
2733 <p>Not doing so will result in you being not able to log in
2734       via ssh after the bulk build is finished or if the machine
2735       gets rebooted or crashes. You have been warned! :)</p>
2736 </div>
2737 <div class="sect2">
2738 <div class="titlepage"><div><div><h3 class="title">
2739 <a name="operation"></a>7.3.3. Operation</h3></div></div></div>
2740 <p>Make sure you don't need any of the packages still
2741       installed.</p>
2742 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
2743 <h3 class="title">Warning</h3>
2744 <p>During the bulk build, <span class="emphasis"><em>all packages, their
2745         configuration files and some more files from
2746         <code class="filename">/var</code>, <code class="filename">/home</code> and
2747         possibly other locations will be removed! So don't run a bulk
2748         build with privileges that might harm your
2749         system.</em></span></p>
2750 </div>
2751 <p>Be sure to remove all other things that might
2752       interfere with builds, like some libs installed in
2753       <code class="filename">/usr/local</code>, etc. then become root and type:</p>
2754 <pre class="screen">
2755 <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2756 <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong>
2757       </pre>
2758 <p>If for some reason your last build didn't complete (power
2759       failure, system panic, ...), you can continue it by
2760       running:</p>
2761 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
2762 <p>At the end of the bulk build, you will get a summary via mail,
2763       and find build logs in the directory specified by
2764       <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
2765       file.</p>
2766 </div>
2767 <div class="sect2">
2768 <div class="titlepage"><div><div><h3 class="title">
2769 <a name="what-it-does"></a>7.3.4. What it does</h3></div></div></div>
2770 <p>The bulk builds consist of three steps:</p>
2771 <div class="variablelist"><dl class="variablelist">
2772 <dt><span class="term">1. pre-build</span></dt>
2773 <dd><p>The script updates your pkgsrc tree via (anon)cvs, then
2774             cleans out any broken distfiles, and removes all
2775             packages installed.</p></dd>
2776 <dt><span class="term">2. the bulk build</span></dt>
2777 <dd><p>This is basically <span class="quote">&#8220;<span class="quote">make bulk-package</span>&#8221;</span> with
2778             an optimised order in which packages will be
2779             built. Packages that don't require other packages will
2780             be built first, and packages with many dependencies will
2781             be built later.</p></dd>
2782 <dt><span class="term">3. post-build</span></dt>
2783 <dd><p>Generates a report that's placed in the directory
2784             specified in the <code class="filename">build.conf</code> file
2785             named <code class="filename">broken.html</code>, a short version
2786             of that report will also be mailed to the build's
2787             admin.</p></dd>
2788 </dl></div>
2789 <p>During the build, a list of broken packages will be compiled
2790       in <code class="filename">/usr/pkgsrc/.broken</code> (or
2791       <code class="filename">.../.broken.${MACHINE}</code> if
2792       <code class="varname">OBJMACHINE</code> is set), individual build logs
2793       of broken builds can be found in the package's
2794       directory. These files are used by the bulk-targets to mark
2795       broken builds to not waste time trying to rebuild them, and
2796       they can be used to debug these broken package builds
2797       later.</p>
2798 </div>
2799 <div class="sect2">
2800 <div class="titlepage"><div><div><h3 class="title">
2801 <a name="disk-space-requirements"></a>7.3.5. Disk space requirements</h3></div></div></div>
2802 <p>Currently, roughly the following requirements are valid for
2803       NetBSD 2.0/i386:</p>
2804 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
2805 <li class="listitem"><p>10 GB - distfiles (NFS ok)</p></li>
2806 <li class="listitem"><p>8 GB - full set of all binaries (NFS ok)</p></li>
2807 <li class="listitem"><p>5 GB - temp space for compiling (local disk recommended)</p></li>
2808 </ul></div>
2809 <p>Note that all pkgs will be de-installed as soon as they are
2810       turned into a binary package, and that sources are removed,
2811       so there is no excessively huge demand to disk
2812       space. Afterwards, if the package is needed again, it will
2813       be installed via <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> instead of building again, so
2814       there are no cycles wasted by recompiling.</p>
2815 </div>
2816 <div class="sect2">
2817 <div class="titlepage"><div><div><h3 class="title">
2818 <a name="setting-up-a-sandbox"></a>7.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
2819 <p>If you don't want all the packages nuked from a machine
2820       (rendering it useless for anything but pkg compiling), there
2821       is the possibility of doing the package bulk build inside a
2822       chroot environment.</p>
2823 <p>The first step is to set up a chroot sandbox,
2824       e.g. <code class="filename">/usr/sandbox</code>.  This can be done by
2825       using null mounts, or manually.</p>
2826 <p>There is a shell script called
2827       <code class="filename">mksandbox</code> installed by the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/mksandbox/README.html" target="_top"><code class="filename">pkgtools/mksandbox</code></a> package, which will set
2828       up the sandbox environment using null mounts. It will also
2829       create a script called <code class="filename">sandbox</code> in the
2830       root of the sandbox environment, which will allow the null
2831       mounts to be activated using the <span class="command"><strong>sandbox
2832       mount</strong></span> command and deactivated using the
2833       <span class="command"><strong>sandbox umount</strong></span> command.</p>
2834 <p>To set up a sandbox environment by hand, after extracting all
2835       the sets from a NetBSD installation or doing a <span class="command"><strong>make
2836       distribution DESTDIR=/usr/sandbox</strong></span> in
2837       <code class="filename">/usr/src/etc</code>, be sure the following items
2838       are present and properly configured:</p>
2839 <div class="procedure"><ol class="procedure" type="1">
2840 <li class="step">
2841 <p>Kernel</p>
2842 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
2843 </li>
2844 <li class="step">
2845 <p><code class="filename">/dev/*</code></p>
2846 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
2847 </li>
2848 <li class="step">
2849 <p><code class="filename">/etc/resolv.conf</code> (for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a> and mail):</p>
2850 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
2851 </li>
2852 <li class="step">
2853 <p>Working(!) mail config (hostname, sendmail.cf):</p>
2854 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
2855 </li>
2856 <li class="step">
2857 <p><code class="filename">/etc/localtime</code> (for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a>):</p>
2858 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
2859 </li>
2860 <li class="step">
2861 <p><code class="filename">/usr/src</code> (system sources,
2862           e.&nbsp;g. for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/sysutils/aperture/README.html" target="_top"><code class="filename">sysutils/aperture</code></a>):</p>
2863 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
2864           <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
2865 </li>
2866 <li class="step">
2867 <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
2868 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
2869 </li>
2870 <li class="step">
2871 <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
2872 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
2873 </li>
2874 <li class="step">
2875 <p>Checkout pkgsrc via cvs into
2876           <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
2877 <pre class="screen">
2878 <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
2879 <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong>
2880           </pre>
2881 <p>Do not mount/link this to the copy of your pkgsrc tree
2882           you do development in, as this will likely cause problems!</p>
2883 </li>
2884 <li class="step"><p>Make
2885           <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
2886           <code class="filename">.../distfiles</code> point somewhere
2887           appropriate. NFS- and/or nullfs-mounts may come in handy!</p></li>
2888 <li class="step"><p>Edit <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, see <a class="xref" href="#binary.mk.conf" title="7.3.1.2. mk.conf">Section 7.3.1.2, &#8220;<code class="filename">mk.conf</code>&#8221;</a>.</p></li>
2889 <li class="step"><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
2890 </ol></div>
2891 <p>When the chroot sandbox is set up, you can start
2892       the build with the following steps:</p>
2893 <pre class="screen">
2894 <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2895 <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong>
2896       </pre>
2897 <p>This will just jump inside the sandbox and start building.  At
2898         the end of the build, mail will be sent with the results of
2899         the build. Created binary pkgs will be in
2900         <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
2901       (wherever that points/mounts to/from).</p>
2902 </div>
2903 <div class="sect2">
2904 <div class="titlepage"><div><div><h3 class="title">
2905 <a name="building-a-partial-set"></a>7.3.7. Building a partial set of packages</h3></div></div></div>
2906 <p>In addition to building a complete set of all packages in
2907       pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
2908       may be used to build a subset of the packages contained in
2909       pkgsrc.  By setting <code class="varname">SPECIFIC_PKGS</code>
2910       in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, the variables</p>
2911 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
2912 <li class="listitem"><p>SITE_SPECIFIC_PKGS</p></li>
2913 <li class="listitem"><p>HOST_SPECIFIC_PKGS</p></li>
2914 <li class="listitem"><p>GROUP_SPECIFIC_PKGS</p></li>
2915 <li class="listitem"><p>USER_SPECIFIC_PKGS</p></li>
2916 </ul></div>
2917 <p>will define the set of packages which should be built.
2918       The bulk build code will also include any packages which are
2919       needed as dependencies for the explicitly listed packages.</p>
2920 <p>One use of this is to do a bulk build with
2921       <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
2922       periodically to have a complete set of the binary packages
2923       needed for your site available without the overhead of
2924       building extra packages that are not needed.</p>
2925 </div>
2926 <div class="sect2">
2927 <div class="titlepage"><div><div><h3 class="title">
2928 <a name="bulk-upload"></a>7.3.8. Uploading results of a bulk build</h3></div></div></div>
2929 <p>This section describes how pkgsrc developers can upload binary
2930       pkgs built by bulk builds to ftp.NetBSD.org.</p>
2931 <p>If you would like to automatically create checksum files for the
2932       binary packages you intend to upload, remember to set
2933       <code class="varname">MKSUMS=yes</code> in your
2934       <code class="filename">mk/bulk/build.conf</code>.</p>
2935 <p>If you would like to PGP sign the checksum files (highly
2936       recommended!), remember to set
2937       <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
2938       <code class="filename">mk/bulk/build.conf</code>.  This will prompt you for
2939       your GPG password to sign the files before uploading everything.</p>
2940 <p>Then, make sure that you have <code class="varname">RSYNC_DST</code>
2941       set properly in your <code class="filename">mk/bulk/build.conf</code>
2942       file, i.e. adjust it to something like one of the following:</p>
2943 <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/pkgsrc/packages/NetBSD/arch/a.b.c-20xxQy/upload</pre>
2944 <p>Please use appropriate values for "20xxQy" (the branch),
2945       "a.b.c" (the OS version) and "arch" here. If your login on ftp.NetBSD.org
2946       is different from your local login, write your login directly
2947       into the variable, e.g. my local account is "feyrer", but for my
2948       login "hubertf", I use:</p>
2949 <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/pkgsrc/packages/NetBSD/arch/a.b.c-20xxQy/upload</pre>
2950 <p>A separate <code class="filename">upload</code> directory is used
2951       here to allow "closing" the directory during upload. To do
2952       so, run the following command on ftp.NetBSD.org next:</p>
2953 <pre class="screen">nbftp% <strong class="userinput"><code>mkdir -p -m 750 /pub/pkgsrc/packages/NetBSD/arch/a.b.c-20xxQy/upload</code></strong></pre>
2954 <p>Before uploading the binary pkgs, ssh authentication needs
2955       to be set up. This example shows how to set up temporary keys
2956       for the root account <span class="emphasis"><em>inside the sandbox</em></span>
2957       (assuming that no keys should be present there usually):</p>
2958 <pre class="screen">
2959 <code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
2960 chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
2961 chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t rsa</code></strong>
2962 chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-rsa.pub</code></strong>
2963       </pre>
2964 <p>Now take the output of <code class="filename">id-rsa.pub</code> and
2965       append it to your <code class="filename">~/.ssh/authorized_keys</code>
2966       file on ftp.NetBSD.org. You should remove the key after the
2967       upload is done!</p>
2968 <p>Next, test if your ssh connection really works:</p>
2969 <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
2970 <p>Use "-l yourNetBSDlogin" here as appropriate!</p>
2971 <p>Now after all this works, you can exit the sandbox and start
2972       the upload:</p>
2973 <pre class="screen">
2974 chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
2975 <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2976 <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong>
2977       </pre>
2978 <p>The upload process may take quite some time. Use <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?ls+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">ls</span>(1)</span></a> or
2979       <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?du+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">du</span>(1)</span></a> on the FTP server to monitor progress of the
2980       upload. The upload script will take care of not uploading
2981       restricted packages.</p>
2982 <p>After the upload has ended, first thing is to revoke ssh access:</p>
2983 <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
2984       Gdd:x! </pre>
2985 <p>Use whatever is needed to remove the key you've entered
2986       before! Last, move the uploaded packages out of the
2987       <code class="filename">upload</code> directory to have them accessible
2988       to everyone:</p>
2989 <pre class="screen">
2990 nbftp% <strong class="userinput"><code>cd /pub/pkgsrc/packages/NetBSD/arch/a.b.c-20xxQy</code></strong>
2991 nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
2992 nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
2993 nbftp% <strong class="userinput"><code>chgrp -R netbsd .</code></strong>
2994 nbftp% <strong class="userinput"><code>find . -type d | xargs chmod 775</code></strong>
2995       </pre>
2996 </div>
2997 </div>
2998 <div class="sect1">
2999 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3000 <a name="bulk.pbulk"></a>7.4. Running a pbulk-style bulk build</h2></div></div></div>
3001 <p>Running a pbulk-style bulk build works roughly as follows:</p>
3002 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
3003 <li class="listitem"><p>First, build the pbulk infrastructure in a fresh pkgsrc location.</p></li>
3004 <li class="listitem"><p>Then, build each of the packages from a clean installation directory using the infrastructure.</p></li>
3005 </ul></div>
3006 <div class="sect2">
3007 <div class="titlepage"><div><div><h3 class="title">
3008 <a name="bulk.pbulk.prepare"></a>7.4.1. Preparation</h3></div></div></div>
3009 <p>First, you need to create a pkgsrc installation for the pbulk infrastructure. No matter on which platform you are (even on NetBSD), you should bootstrap into its own directory. Let's take the directory <code class="filename">/usr/pbulk</code> or <code class="filename">$HOME/pbulk</code> for it. This installation will be bootstrapped and all the tools that are required for the bulk build will be installed there.</p>
3010 <pre class="screen">
3011 $ <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
3012 $ <strong class="userinput"><code>./bootstrap/bootstrap --prefix=/usr/pbulk --varbase=/usr/pbulk/var --workdir=/tmp/pbulk-bootstrap</code></strong>
3013 $ <strong class="userinput"><code>rm -rf /tmp/pbulk-bootstrap</code></strong>
3014 </pre>
3015 <p>Now the basic environment for the pbulk infrastructure is installed. The specific tools are still missing. This is a good time to edit the pkgsrc configuration file <code class="filename">/usr/pbulk/etc/mk.conf</code> to fit your needs. Typical things you might set now are:</p>
3016 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
3017 <li class="listitem"><p><code class="literal"><code class="varname">PKG_DEVELOPER</code>=yes</code>, to enable many consistency checks,</p></li>
3018 <li class="listitem"><p><code class="literal"><code class="varname">WRKOBJDIR</code>=/tmp/pbulk-outer</code>, to keep <code class="filename">/usr/pkgsrc</code> free from any modifications,</p></li>
3019 <li class="listitem"><p><code class="literal"><code class="varname">DISTDIR</code>=/distfiles</code>, to have only one directory in which all distfiles (for the infrastructure and for the actual packages) are downloaded,</p></li>
3020 <li class="listitem"><p><code class="literal"><code class="varname">ACCEPTABLE_LICENSES</code>+=...</code>, to select some licenses additional to the usual Free/Open Source licenses that are acceptable to you,</p></li>
3021 <li class="listitem"><p><code class="literal"><code class="varname">SKIP_LICENSE_CHECK</code>=yes</code>, to bypass the license checks.</p></li>
3022 </ul></div>
3023 <p>Now you are ready to build the rest of the pbulk infrastructure.</p>
3024 <pre class="screen">
3025 $ <strong class="userinput"><code>cd pkgtools/pbulk</code></strong>
3026 $ <strong class="userinput"><code>/usr/pbulk/bin/bmake install</code></strong>
3027 $ <strong class="userinput"><code>rm -rf /tmp/pbulk-outer</code></strong>
3028 </pre>
3029 <p>Now the pbulk infrastructure is built and installed. It still needs to be configured, and after some more preparation, we will be able to start the real bulk build.</p>
3030 </div>
3031 <div class="sect2">
3032 <div class="titlepage"><div><div><h3 class="title">
3033 <a name="bulk.pbulk.conf"></a>7.4.2. Configuration</h3></div></div></div>
3034 <p>TODO; see pkgsrc/doc/HOWTO-pbulk for more information.</p>
3035 <p>TODO: continue writing</p>
3036 </div>
3037 </div>
3038 <div class="sect1">
3039 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3040 <a name="creating-cdroms"></a>7.5. Creating a multiple CD-ROM packages collection</h2></div></div></div>
3041 <p>After your pkgsrc bulk-build has completed, you may wish to
3042     create a CD-ROM set of the resulting binary packages to assist
3043     in installing packages on other machines.  The
3044     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/cdpack/README.html" target="_top"><code class="filename">pkgtools/cdpack</code></a> package provides
3045     a simple tool for creating the ISO 9660 images.
3046     <span class="command"><strong>cdpack</strong></span> arranges the packages on the CD-ROMs in a
3047     way that keeps all the dependencies for a given package on the same
3048     CD as that package.</p>
3049 <div class="sect2">
3050 <div class="titlepage"><div><div><h3 class="title">
3051 <a name="cdpack-example"></a>7.5.1. Example of cdpack</h3></div></div></div>
3052 <p>Complete documentation for cdpack is found in the cdpack(1)
3053       man page. The following short example assumes that the binary
3054       packages are left in
3055       <code class="filename">/usr/pkgsrc/packages/All</code> and that
3056       sufficient disk space exists in <code class="filename">/u2</code> to
3057       hold the ISO 9660 images.</p>
3058 <pre class="screen">
3059 <code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
3060 <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
3061 <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong>
3062       </pre>
3063 <p>If you wish to include a common set of files
3064       (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
3065       etc.) on each CD in the collection, then you need to create a
3066       directory which contains these files. e.g.</p>
3067 <pre class="screen">
3068 <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
3069 <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" &gt; /tmp/common/README</code></strong>
3070 <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" &gt; /tmp/common/COPYING</code></strong>
3071 <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
3072 <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" &gt; /tmp/common/bin/myscript</code></strong>
3073 <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" &gt;&gt; /tmp/common/bin/myscript</code></strong>
3074 <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong>
3075       </pre>
3076 <p>Now create the images:</p>
3077 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
3078 <p>Each image will contain <code class="filename">README</code>,
3079       <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
3080       in their root directories.</p>
3081 </div>
3082 </div>
3083 </div>
3084 <div class="chapter">
3085 <div class="titlepage"><div><div><h2 class="title">
3086 <a name="files"></a>Chapter 8. Directory layout of the installed files</h2></div></div></div>
3087 <div class="toc">
3088 <p><b>Table of Contents</b></p>
3089 <dl>
3090 <dt><span class="sect1"><a href="#files.localbase">8.1. File system layout in <code class="literal">${LOCALBASE}</code></a></span></dt>
3091 <dt><span class="sect1"><a href="#files.varbase">8.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
3092 </dl>
3093 </div>
3094 <p>The files that are installed by pkgsrc are organized in a way that
3095 is similar to what you find in the <code class="filename">/usr</code> directory
3096 of the base system. But some details are different. This is because
3097 pkgsrc initially came from FreeBSD and had adopted its file system
3098 hierarchy. Later it was largely influenced by NetBSD. But no matter
3099 which operating system you are using pkgsrc with, you can expect the
3100 same layout for pkgsrc.</p>
3101 <p>There are mainly four root directories for pkgsrc, which are all
3102 configurable in the <code class="filename">bootstrap/bootstrap</code> script.
3103 When pkgsrc has been installed as root, the default locations
3104 are:</p>
3105 <pre class="programlisting">
3106 LOCALBASE=              /usr/pkg
3107 PKG_SYSCONFBASE=        /usr/pkg/etc
3108 VARBASE=                /var
3109 PKG_DBDIR=              /var/db/pkg
3110 </pre>
3111 <p>In unprivileged mode (when pkgsrc has been installed as any other
3112 user), the default locations are:</p>
3113 <pre class="programlisting">
3114 LOCALBASE=              ${HOME}/pkg
3115 PKG_SYSCONFBASE=        ${HOME}/pkg/etc
3116 VARBASE=                ${HOME}/pkg/var
3117 PKG_DBDIR=              ${HOME}/pkg/var/db/pkg
3118 </pre>
3119 <p>What these four directories are for, and what they look like is
3120 explained below.</p>
3121 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
3122 <li class="listitem"><p><code class="varname">LOCALBASE</code> corresponds to the
3123 <code class="filename">/usr</code> directory in the base system. It is the
3124 <span class="quote">&#8220;<span class="quote">main</span>&#8221;</span> directory where the files are installed and contains
3125 the well-known subdirectories like <code class="filename">bin</code>,
3126 <code class="filename">include</code>, <code class="filename">lib</code>,
3127 <code class="filename">share</code> and
3128 <code class="filename">sbin</code>.</p></li>
3129 <li class="listitem"><p><code class="varname">VARBASE</code> corresponds to
3130 <code class="filename">/var</code> in the base system. Some programs (especially
3131 games, network daemons) need write access to it during normal
3132 operation.</p></li>
3133 <li class="listitem"><p><code class="varname">PKG_SYSCONFDIR</code> corresponds to
3134 <code class="filename">/etc</code> in the base system. It contains configuration
3135 files of the packages, as well as pkgsrc's <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>
3136 itself.</p></li>
3137 </ul></div>
3138 <div class="sect1">
3139 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3140 <a name="files.localbase"></a>8.1. File system layout in <code class="literal">${LOCALBASE}</code>
3141 </h2></div></div></div>
3142 <p>The following directories exist in a typical pkgsrc installation
3143 in <code class="filename">${LOCALBASE}</code>.</p>
3144 <div class="variablelist"><dl class="variablelist">
3145 <dt><span class="term"><code class="filename">bin</code></span></dt>
3146 <dd><p>Contains executable programs that are intended to be
3147 directly used by the end user.</p></dd>
3148 <dt><span class="term"><code class="filename">emul</code></span></dt>
3149 <dd><p>Contains files for the emulation layers of various other
3150 operating systems, especially for
3151 NetBSD.</p></dd>
3152 <dt><span class="term"><code class="filename">etc</code> (the usual location of
3153 <code class="filename">${PKG_SYSCONFDIR}</code>)</span></dt>
3154 <dd><p>Contains
3155 the configuration files.</p></dd>
3156 <dt><span class="term"><code class="filename">include</code></span></dt>
3157 <dd><p>Contains headers for the C and C++ programming
3158 languages.</p></dd>
3159 <dt><span class="term"><code class="filename">info</code></span></dt>
3160 <dd><p>Contains GNU info files of various
3161 packages.</p></dd>
3162 <dt><span class="term"><code class="filename">lib</code></span></dt>
3163 <dd><p>Contains shared and static
3164 libraries.</p></dd>
3165 <dt><span class="term"><code class="filename">libdata</code></span></dt>
3166 <dd><p>Contains data files that don't change after
3167 installation. Other data files belong into
3168 <code class="filename">${VARBASE}</code>.</p></dd>
3169 <dt><span class="term"><code class="filename">libexec</code></span></dt>
3170 <dd><p>Contains programs that are not intended to be used by
3171 end users, such as helper programs or network
3172 daemons.</p></dd>
3173 <dt><span class="term"><code class="filename">libexec/cgi-bin</code></span></dt>
3174 <dd><p>Contains programs that are intended to be executed as
3175 CGI scripts by a web server.</p></dd>
3176 <dt><span class="term"><code class="filename">man</code> (the usual value of
3177 <code class="filename">${PKGMANDIR}</code>)</span></dt>
3178 <dd><p>Contains brief
3179 documentation in form of manual pages.</p></dd>
3180 <dt><span class="term"><code class="filename">sbin</code></span></dt>
3181 <dd><p>Contains programs that are intended to be used only by
3182 the super-user.</p></dd>
3183 <dt><span class="term"><code class="filename">share</code></span></dt>
3184 <dd><p>Contains platform-independent data files that don't
3185 change after installation.</p></dd>
3186 <dt><span class="term"><code class="filename">share/doc</code></span></dt>
3187 <dd><p>Contains documentation files provided by the
3188 packages.</p></dd>
3189 <dt><span class="term"><code class="filename">share/examples</code></span></dt>
3190 <dd><p>Contains example files provided by the packages. Among
3191 others, the original configuration files are saved here and copied to
3192 <code class="filename">${PKG_SYSCONFDIR}</code> during
3193 installation.</p></dd>
3194 <dt><span class="term"><code class="filename">share/examples/rc.d</code></span></dt>
3195 <dd><p>Contains the original files for rc.d
3196 scripts.</p></dd>
3197 <dt><span class="term"><code class="filename">var</code> (the usual location of
3198 <code class="filename">${VARBASE}</code>)</span></dt>
3199 <dd><p>Contains files
3200 that may be modified after
3201 installation.</p></dd>
3202 </dl></div>
3203 </div>
3204 <div class="sect1">
3205 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3206 <a name="files.varbase"></a>8.2. File system layout in <code class="literal">${VARBASE}</code>
3207 </h2></div></div></div>
3208 <div class="variablelist"><dl class="variablelist">
3209 <dt><span class="term"><code class="filename">db/pkg</code> (the usual location of
3210 <code class="filename">${PKG_DBDIR}</code>)</span></dt>
3211 <dd><p>Contains
3212 information about the currently installed
3213 packages.</p></dd>
3214 <dt><span class="term"><code class="filename">games</code></span></dt>
3215 <dd><p>Contains highscore
3216 files.</p></dd>
3217 <dt><span class="term"><code class="filename">log</code></span></dt>
3218 <dd><p>Contains log files.</p></dd>
3219 <dt><span class="term"><code class="filename">run</code></span></dt>
3220 <dd><p>Contains informational files about daemons that are
3221 currently running.</p></dd>
3222 </dl></div>
3223 </div>
3224 </div>
3225 <div class="chapter">
3226 <div class="titlepage"><div><div><h2 class="title">
3227 <a name="faq"></a>Chapter 9. Frequently Asked Questions</h2></div></div></div>
3228 <div class="toc">
3229 <p><b>Table of Contents</b></p>
3230 <dl>
3231 <dt><span class="sect1"><a href="#mailing-list-pointers">9.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
3232 <dt><span class="sect1"><a href="#pkgviews-docs">9.2. Where's the pkgviews documentation?</a></span></dt>
3233 <dt><span class="sect1"><a href="#faq-pkgtools">9.3. Utilities for package management (pkgtools)</a></span></dt>
3234 <dt><span class="sect1"><a href="#non-root-pkgsrc">9.4. How to use pkgsrc as non-root</a></span></dt>
3235 <dt><span class="sect1"><a href="#resume-transfers">9.5. How to resume transfers when fetching distfiles?</a></span></dt>
3236 <dt><span class="sect1"><a href="#x.org-from-pkgsrc">9.6. How can I install/use modular X.org from pkgsrc?</a></span></dt>
3237 <dt><span class="sect1"><a href="#fetch-behind-firewall">9.7. How to fetch files from behind a firewall</a></span></dt>
3238 <dt><span class="sect1"><a href="#passive-ftp">9.8. How do I tell <span class="command"><strong>make fetch</strong></span> to do passive FTP?</a></span></dt>
3239 <dt><span class="sect1"><a href="#fetching-all-distfiles">9.9. How to fetch all distfiles at once</a></span></dt>
3240 <dt><span class="sect1"><a href="#tmac.andoc-missing">9.10. What does <span class="quote">&#8220;<span class="quote">Don't know how to make
3241 /usr/share/tmac/tmac.andoc</span>&#8221;</span> mean?</a></span></dt>
3242 <dt><span class="sect1"><a href="#bsd.own.mk-missing">9.11. What does <span class="quote">&#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221;</span> mean?</a></span></dt>
3243 <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">9.12. Using 'sudo' with pkgsrc</a></span></dt>
3244 <dt><span class="sect1"><a href="#faq.conf">9.13. How do I change the location of configuration files?</a></span></dt>
3245 <dt><span class="sect1"><a href="#audit-packages">9.14. Automated security checks</a></span></dt>
3246 <dt><span class="sect1"><a href="#ufaq-cflags">9.15. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
3247 <dt><span class="sect1"><a href="#ufaq-fail">9.16. A package does not build.  What shall I do?</a></span></dt>
3248 <dt><span class="sect1"><a href="#faq.rcs-conflicts">9.17. What does <span class="quote">&#8220;<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>&#8221;</span> mean?</a></span></dt>
3249 </dl>
3250 </div>
3251 <p>This section contains hints, tips &amp; tricks on special things in
3252 pkgsrc that we didn't find a better place for in the previous chapters, and
3253 it contains items for both pkgsrc users and developers.</p>
3254 <div class="sect1">
3255 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3256 <a name="mailing-list-pointers"></a>9.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
3257 <p>The following mailing lists may be of interest to pkgsrc users:</p>
3258 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
3259 <li class="listitem"><p><a class="ulink" href="http://www.NetBSD.org/mailinglists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
3260           This is a general purpose list for most issues regarding
3261           pkgsrc, regardless of platform, e.g. soliciting user help
3262           for pkgsrc configuration, unexpected build failures, using
3263           particular packages, upgrading pkgsrc installations,
3264           questions regarding the pkgsrc release branches, etc.  General announcements or
3265           proposals for changes that impact the pkgsrc user community,
3266           e.g. major infrastructure changes, new features, package
3267           removals, etc., may also be posted.</p></li>
3268 <li class="listitem"><p><a class="ulink" href="http://www.NetBSD.org/mailinglists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
3269           A list where the results of pkgsrc bulk builds are sent and
3270           discussed.</p></li>
3271 <li class="listitem"><p><a class="ulink" href="http://www.NetBSD.org/mailinglists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
3272           This list is for those who are interested in getting a
3273           commit message for every change committed to pkgsrc. It is
3274           also available in digest form, meaning one daily message
3275           containing all commit messages for changes to the package
3276           source tree in that 24 hour period.</p></li>
3277 </ul></div>
3278 <p>To subscribe, do:</p>
3279 <pre class="programlisting">
3280 <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
3281 </pre>
3282 <p>Archives for all these mailing lists are available from
3283 <a class="ulink" href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
3284 </div>
3285 <div class="sect1">
3286 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3287 <a name="pkgviews-docs"></a>9.2. Where's the pkgviews documentation?</h2></div></div></div>
3288 <p>Pkgviews is tightly integrated with buildlink.  You can find a
3289 pkgviews User's guide in
3290 <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
3291 </div>
3292 <div class="sect1">
3293 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3294 <a name="faq-pkgtools"></a>9.3. Utilities for package management (pkgtools)</h2></div></div></div>
3295 <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
3296 a number of useful utilities for both users and developers of pkgsrc.  This
3297 section attempts only to make the reader aware of the utilities and when
3298 they might be useful, and not to duplicate the documentation that comes
3299 with each package.</p>
3300 <p>Utilities used by pkgsrc (automatically installed when needed):</p>
3301 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/x11-links/README.html" target="_top"><code class="filename">pkgtools/x11-links</code></a>:
3302       Symlinks for use by buildlink.</p></li></ul></div>
3303 <p>OS tool augmentation (automatically installed when needed):</p>
3304 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
3305 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/digest/README.html" target="_top"><code class="filename">pkgtools/digest</code></a>:
3306       Calculates various kinds of checksums (including SHA1).</p></li>
3307 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/libnbcompat/README.html" target="_top"><code class="filename">pkgtools/libnbcompat</code></a>:
3308       Compatibility library for pkgsrc tools.</p></li>
3309 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/mtree/README.html" target="_top"><code class="filename">pkgtools/mtree</code></a>: Installed on
3310       non-BSD systems due to lack of native mtree.</p></li>
3311 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>:
3312       Up-to-date replacement for
3313       <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
3314       systems where pkg_install is not present.</p></li>
3315 </ul></div>
3316 <p>Utilities used by pkgsrc (not automatically installed):</p>
3317 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
3318 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgtools/pkg_tarup</code></a>:
3319       Create a binary package from an
3320       already-installed package.  Used by <span class="command"><strong>make replace</strong></span> to
3321       save the old package.</p></li>
3322 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/dfdisk/README.html" target="_top"><code class="filename">pkgtools/dfdisk</code></a>:
3323       Adds extra functionality to pkgsrc, allowing it to fetch distfiles
3324       from multiple locations. It currently supports the following
3325       methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
3326 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a>: Put X11
3327       packages someplace else (enabled by default).</p></li>
3328 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a>: Determine
3329       the best compiler flags to optimise code for your current
3330       CPU and compiler. </p></li>
3331 </ul></div>
3332 <p>Utilities for keeping track of installed packages, being up to date,
3333 etc:</p>
3334 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
3335 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_chk/README.html" target="_top"><code class="filename">pkgtools/pkg_chk</code></a>: Reports on
3336       packages whose installed versions do not match the latest pkgsrc
3337       entries.</p></li>
3338 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a>: Makes
3339       dependency graphs of packages, to aid in choosing a strategy for
3340       updating.</p></li>
3341 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdepgraph/README.html" target="_top"><code class="filename">pkgtools/pkgdepgraph</code></a>: Makes
3342       graphs from the output of <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a> (uses graphviz).</p></li>
3343 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>: The
3344       pkglint(1) program checks a pkgsrc entry for errors.</p></li>
3345 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/lintpkgsrc/README.html" target="_top"><code class="filename">pkgtools/lintpkgsrc</code></a>: The lintpkgsrc(1) program
3346       does various checks on the complete pkgsrc system.</p></li>
3347 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgsurvey/README.html" target="_top"><code class="filename">pkgtools/pkgsurvey</code></a>: Report what
3348       packages you have installed.</p></li>
3349 </ul></div>
3350 <p>Utilities for people maintaining or creating individual packages:</p>
3351 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
3352 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>: Automate
3353       making and maintaining patches for a package (includes pkgdiff,
3354       pkgvi, mkpatches, etc.).</p></li>
3355 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>,
3356       <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>: Aids in
3357       converting to pkgsrc.</p></li>
3358 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>: Convert
3359       pkgsrc to a Solaris package.</p></li>
3360 </ul></div>
3361 <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
3362 utilities)</p>
3363 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
3364 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_comp/README.html" target="_top"><code class="filename">pkgtools/pkg_comp</code></a>: Build
3365       packages in a chrooted area.</p></li>
3366 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/libkver/README.html" target="_top"><code class="filename">pkgtools/libkver</code></a>: Spoof
3367       kernel version for chrooted cross builds.</p></li>
3368 </ul></div>
3369 </div>
3370 <div class="sect1">
3371 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3372 <a name="non-root-pkgsrc"></a>9.4. How to use pkgsrc as non-root</h2></div></div></div>
3373 <p>If you want to use pkgsrc as non-root user, you can set some
3374 variables to make pkgsrc work under these conditions.  At the very least,
3375 you need to set <code class="varname">UNPRIVILEGED</code> to <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>; this
3376 will turn on unprivileged mode and set multiple related variables to allow
3377 installation of packages as non-root.</p>
3378 <p>In case the defaults are not enough, you may want to tune some other
3379 variables used.  For example, if the automatic user/group detection leads
3380 to incorrect values (or not the ones you would like to use), you can change
3381 them by setting <code class="varname">UNPRIVILEGED_USER</code> and
3382 <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
3383 <p>As regards bootstrapping, please note that the
3384 <span class="command"><strong>bootstrap</strong></span> script will ease non-root configuration when
3385 given the <span class="quote">&#8220;<span class="quote">--ignore-user-check</span>&#8221;</span> flag, as it will choose and
3386 use multiple default directories under <code class="filename">~/pkg</code> as the
3387 installation targets.  These directories can be overridden by the
3388 <span class="quote">&#8220;<span class="quote">--prefix</span>&#8221;</span> flag provided by the script, as well as some others
3389 that allow finer tuning of the tree layout.</p>
3390 </div>
3391 <div class="sect1">
3392 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3393 <a name="resume-transfers"></a>9.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
3394 <p>By default, resuming transfers in pkgsrc is disabled, but you can
3395 enable this feature by adding the option
3396 <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
3397 <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.  If, during a fetch step, an incomplete
3398 distfile is found, pkgsrc will try to resume it.</p>
3399 <p>You can also
3400 use a different program than the default <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?ftp+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">ftp</span>(1)</span></a> by changing the
3401 <code class="varname">FETCH_USING</code> variable.  You can specify the program by
3402 using of ftp, fetch, wget or curl.  Alternatively, fetching can be disabled
3403 by using the value manual.  A value of custom disables the system defaults
3404 and dependency tracking for the fetch program.  In that case you have to
3405 provide <code class="varname">FETCH_CMD</code>, <code class="varname">FETCH_BEFORE_ARGS</code>,
3406 <code class="varname">FETCH_RESUME_ARGS</code>, <code class="varname">FETCH_OUTPUT_ARGS</code>,
3407 <code class="varname">FETCH_AFTER_ARGS</code>.</p>
3408 <p>For example, if you want to use
3409 <code class="filename">wget</code> to download, you'll have to use something
3410 like:</p>
3411 <pre class="programlisting">
3412 FETCH_USING=    wget
3413 </pre>
3414 </div>
3415 <div class="sect1">
3416 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3417 <a name="x.org-from-pkgsrc"></a>9.6. How can I install/use modular X.org from pkgsrc?</h2></div></div></div>
3418 <p>If you want to use modular X.org from pkgsrc instead of your system's own X11
3419 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
3420 you will have to add the following line into
3421 <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>:</p>
3422 <pre class="programlisting">
3423 X11_TYPE=modular
3424 </pre>
3425 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
3426 <h3 class="title">Note</h3>
3427 <p>The DragonFly operating system defaults to using modular X.org from pkgsrc.
3428 </p>
3429 </div>
3430 </div>
3431 <div class="sect1">
3432 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3433 <a name="fetch-behind-firewall"></a>9.7. How to fetch files from behind a firewall</h2></div></div></div>
3434 <p>If you are sitting behind a firewall which does not allow direct
3435 connections to Internet hosts (i.e. non-NAT), you may specify the
3436 relevant proxy hosts.  This is done using an environment variable in the
3437 form of a URL, e.g. in Amdahl, the machine
3438 <span class="quote">&#8220;<span class="quote">orpheus.amdahl.com</span>&#8221;</span> is one of the firewalls, and it uses
3439 port 80 as the proxy port number.  So the proxy environment variables
3440 are:</p>
3441 <pre class="programlisting">
3442 ftp_proxy=ftp://orpheus.amdahl.com:80/
3443 http_proxy=http://orpheus.amdahl.com:80/
3444 </pre>
3445 </div>
3446 <div class="sect1">
3447 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3448 <a name="passive-ftp"></a>9.8. How do I tell <span class="command"><strong>make fetch</strong></span> to do passive FTP?</h2></div></div></div>
3449 <p>This depends on which utility is used to retrieve distfiles.  From
3450 <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
3451 the first available command from the following list:</p>
3452 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
3453 <li class="listitem"><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
3454 <li class="listitem"><p><code class="filename">/usr/bin/ftp</code></p></li>
3455 </ul></div>
3456 <p>On a default NetBSD installation, this will be
3457 <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
3458 connections first, and falls back to active connections if the server
3459 refuses to do passive.  For the other tools, add the following to your
3460 <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file:
3461 <code class="varname">PASSIVE_FETCH=1</code>.</p>
3462 <p>Having that option present will prevent
3463 <code class="filename">/usr/bin/ftp</code> from falling back to active
3464 transfers.</p>
3465 </div>
3466 <div class="sect1">
3467 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3468 <a name="fetching-all-distfiles"></a>9.9. How to fetch all distfiles at once</h2></div></div></div>
3469 <p>You would like to download all the distfiles in a single batch
3470 from work or university, where you can't run a <span class="command"><strong>make
3471 fetch</strong></span>.  There is an archive of distfiles on <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/" target="_top">ftp.NetBSD.org</a>,
3472 but downloading the entire directory may not be appropriate.</p>
3473 <p>The answer here is to do a <span class="command"><strong>make fetch-list</strong></span> in
3474 <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
3475 resulting list to your machine at work/school and use it there.  If you
3476 don't have a NetBSD-compatible <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?ftp+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">ftp</span>(1)</span></a> (like tnftp) at work, don't
3477 forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
3478 URL:</p>
3479 <p>At home:</p>
3480 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
3481 <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles &gt;/tmp/fetch.sh</code></strong>
3482 <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
3483 <p>At work:</p>
3484 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
3485 <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
3486 home.</p>
3487 <p>If you have a machine running NetBSD, and you want to get
3488 <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your
3489 machine architecture), you can do so by using the above-mentioned
3490 <span class="command"><strong>make fetch-list</strong></span> approach, or fetch the distfiles
3491 directly by running:</p>
3492 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
3493 <p>If you even decide to ignore
3494 <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
3495 by running:</p>
3496 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
3497 </div>
3498 <div class="sect1">
3499 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3500 <a name="tmac.andoc-missing"></a>9.10. What does <span class="quote">&#8220;<span class="quote">Don't know how to make
3501 /usr/share/tmac/tmac.andoc</span>&#8221;</span> mean?</h2></div></div></div>
3502 <p>When compiling the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>
3503 package, you get the error from make that it doesn't know how to make
3504 <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
3505 you don't have installed the <span class="quote">&#8220;<span class="quote">text</span>&#8221;</span> set (nroff, ...) from
3506 the NetBSD base distribution on your machine.  It is recommended to do
3507 that to format man pages.</p>
3508 <p>In the case of the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a> package, you
3509 can get away with setting <code class="varname">NOMAN=YES</code> either in the
3510 environment or in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.</p>
3511 </div>
3512 <div class="sect1">
3513 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3514 <a name="bsd.own.mk-missing"></a>9.11. What does <span class="quote">&#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221;</span> mean?</h2></div></div></div>
3515 <p>You didn't install the compiler set, <code class="filename">comp.tgz</code>,
3516 when you installed your NetBSD machine.  Please get and install it, by
3517 extracting it in <code class="filename">/</code>:</p>
3518 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
3519 <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
3520 <p><code class="filename">comp.tgz</code> is part of every NetBSD release.  Get
3521 the one that corresponds to your release (determine via <span class="command"><strong>uname
3522 -r</strong></span>).</p>
3523 </div>
3524 <div class="sect1">
3525 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3526 <a name="using-sudo-with-pkgsrc"></a>9.12. Using 'sudo' with pkgsrc</h2></div></div></div>
3527 <p>When installing packages as non-root user and using the just-in-time
3528 <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?su+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">su</span>(1)</span></a> feature of pkgsrc, it can become annoying to type in the root
3529 password for each required package installed.  To avoid this, the sudo
3530 package can be used, which does password caching over a limited time.  To
3531 use it, install sudo (either as binary package or from
3532 <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/sudo/README.html" target="_top"><code class="filename">security/sudo</code></a>) and then put the
3533 following into your <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, somewhere
3534 <span class="emphasis"><em>after</em></span> the definition of the
3535 <code class="varname">LOCALBASE</code> variable:</p>
3536 <pre class="programlisting">
3537 .if exists(${LOCALBASE}/bin/sudo)
3538 SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
3539 .endif
3540 </pre>
3541 </div>
3542 <div class="sect1">
3543 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3544 <a name="faq.conf"></a>9.13. How do I change the location of configuration files?</h2></div></div></div>
3545 <p>As the system administrator, you can choose where configuration files
3546 are installed.  The default settings make all these files go into
3547 <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
3548 be suboptimal depending on your expectations (e.g., a read-only,
3549 NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
3550 configuration of the provided packages).</p>
3551 <p>In order to change the defaults, you can modify the
3552 <code class="varname">PKG_SYSCONFBASE</code> variable (in
3553 <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>) to point to your preferred configuration
3554 directory; some common examples include <code class="filename">/etc</code> or
3555 <code class="filename">/etc/pkg</code>.</p>
3556 <p>Furthermore, you can change this value on a per-package basis by
3557 setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
3558 <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
3559 package you would like to modify, that is, the contents of
3560 <code class="varname">PKGBASE</code>.</p>
3561 <p>Note that after changing these settings, you must rebuild and
3562 reinstall any affected packages.</p>
3563 </div>
3564 <div class="sect1">
3565 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3566 <a name="audit-packages"></a>9.14. Automated security checks</h2></div></div></div>
3567 <p>Please be aware that there can often be bugs in third-party software,
3568 and some of these bugs can leave a machine vulnerable to exploitation by
3569 attackers.  In an effort to lessen the exposure, the NetBSD packages team
3570 maintains a database of known-exploits to packages which have at one time
3571 been included in pkgsrc.  The database can be downloaded automatically, and
3572 a security audit of all packages installed on a system can take place.  To
3573 do this, refer to the following two tools (installed as part of the
3574 <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a> package):</p>
3575 <div class="orderedlist"><ol class="orderedlist" type="1">
3576 <li class="listitem">
3577 <p><span class="command"><strong>pkg_admin fetch-pkg-vulnerabilities</strong></span>, an easy way to
3578     download a list of the security vulnerabilities information.  This list
3579     is kept up to date by the pkgsrc security team, and is distributed
3580     from the NetBSD ftp server:</p>
3581 <p><a class="ulink" href="ftp://ftp.NetBSD.org/pkgsrc/distfiles/pkg-vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pkgsrc/distfiles/pkg-vulnerabilities</a></p>
3582 </li>
3583 <li class="listitem"><p><span class="command"><strong>pkg_admin audit</strong></span>, an easy way to audit the
3584     current machine, checking each known vulnerability.  If a
3585     vulnerable package is installed, it will be shown by output to stdout,
3586     including a description of the type of vulnerability, and a URL
3587     containing more information.</p></li>
3588 </ol></div>
3589 <p>Use of these tools is strongly recommended!  After
3590 <span class="quote">&#8220;<span class="quote">pkg_install</span>&#8221;</span> is installed, please read
3591 the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
3592 pkg_install</code></strong>.</p>
3593 <p>If this package is installed, pkgsrc builds will use it to
3594 perform a security check before building any package.  See <a class="xref" href="#variables-affecting-build" title="5.2. Variables affecting the build process">Section 5.2, &#8220;Variables affecting the build process&#8221;</a> for ways to control this
3595 check.</p>
3596 </div>
3597 <div class="sect1">
3598 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3599 <a name="ufaq-cflags"></a>9.15. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
3600 <p>When you add your own preferences to the
3601         <code class="varname">CFLAGS</code> variable in your
3602         <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, these flags are passed in
3603         environment variables to the <code class="filename">./configure</code>
3604         scripts and to <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>. Some package authors ignore the
3605         <code class="varname">CFLAGS</code> from the environment variable by
3606         overriding them in the <code class="filename">Makefile</code>s of their
3607         package.</p>
3608 <p>Currently there is no solution to this problem. If you
3609         really need the package to use your <code class="varname">CFLAGS</code>
3610         you should run <span class="command"><strong>make patch</strong></span> in the package
3611         directory and then inspect any <code class="filename">Makefile</code> and
3612         <code class="filename">Makefile.in</code> for whether they define
3613         <code class="varname">CFLAGS</code> explicitly. Usually you can remove
3614         these lines. But be aware that some <span class="quote">&#8220;<span class="quote">smart</span>&#8221;</span>
3615         programmers write so bad code that it only works for the
3616         specific combination of <code class="varname">CFLAGS</code> they have
3617         chosen.</p>
3618 </div>
3619 <div class="sect1">
3620 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3621 <a name="ufaq-fail"></a>9.16. A package does not build.  What shall I do?</h2></div></div></div>
3622 <div class="procedure"><ol class="procedure" type="1">
3623 <li class="step"><p>Make sure that your copy of pkgsrc is consistent. A
3624         case that occurs often is that people only update pkgsrc in
3625         parts, because of performance reasons. Since pkgsrc is one large
3626         system, not a collection of many small systems, there are
3627         sometimes changes that only work when the whole pkgsrc tree is
3628         updated.</p></li>
3629 <li class="step"><p>Make sure that you don't have any CVS conflicts.
3630         Search for <span class="quote">&#8220;<span class="quote">&lt;&lt;&lt;&lt;&lt;&lt;</span>&#8221;</span> or
3631         <span class="quote">&#8220;<span class="quote">&gt;&gt;&gt;&gt;&gt;&gt;</span>&#8221;</span> in all your pkgsrc
3632         files.</p></li>
3633 <li class="step"><p>Make sure that you don't have old copies of the packages
3634         extracted. Run <span class="command"><strong>make clean clean-depends</strong></span> to
3635         verify this.</p></li>
3636 <li class="step"><p>If the problem still exists, write a mail to the
3637         <code class="literal">pkgsrc-users</code> mailing list.</p></li>
3638 </ol></div>
3639 </div>
3640 <div class="sect1">
3641 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3642 <a name="faq.rcs-conflicts"></a>9.17. What does <span class="quote">&#8220;<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>&#8221;</span> mean?</h2></div></div></div>
3643 <p>You have modified a file from pkgsrc, and someone else has
3644 modified that same file afterwards in the CVS repository. Both changes
3645 are in the same region of the file, so when you updated pkgsrc, the
3646 <code class="literal">cvs</code> command marked the conflicting changes in the
3647 file. Because of these markers, the file is no longer a valid
3648 <code class="filename">Makefile</code>.</p>
3649 <p>Have a look at that file, and if you don't need your local changes
3650 anymore, you can remove that file and run <span class="command"><strong>cvs -q update
3651 -dP</strong></span> in that directory to download the current version.</p>
3652 </div>
3653 </div>
3654 </div>
3655 <div class="part">
3656 <div class="titlepage"><div><div><h1 class="title">
3657 <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
3658 <div class="partintro">
3659 <div></div>
3660 <p>This part of the book deals with creating and
3661         modifying packages. It starts with a <span class="quote">&#8220;<span class="quote">HOWTO</span>&#8221;</span>-like
3662         guide on creating a new package. The remaining chapters are more
3663         like a reference manual for pkgsrc.</p>
3664 <div class="toc">
3665 <p><b>Table of Contents</b></p>
3666 <dl>
3667 <dt><span class="chapter"><a href="#creating">10. Creating a new pkgsrc package from scratch</a></span></dt>
3668 <dd><dl>
3669 <dt><span class="sect1"><a href="#creating.common">10.1. Common types of packages</a></span></dt>
3670 <dd><dl>
3671 <dt><span class="sect2"><a href="#creating.perl-module">10.1.1. Perl modules</a></span></dt>
3672 <dt><span class="sect2"><a href="#creating.kde-app">10.1.2. KDE applications</a></span></dt>
3673 <dt><span class="sect2"><a href="#creating.python-module">10.1.3. Python modules and programs</a></span></dt>
3674 </dl></dd>
3675 <dt><span class="sect1"><a href="#creating.examples">10.2. Examples</a></span></dt>
3676 <dd><dl><dt><span class="sect2"><a href="#creating.nvu">10.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
3677 </dl></dd>
3678 <dt><span class="chapter"><a href="#components">11. Package components - files, directories and contents</a></span></dt>
3679 <dd><dl>
3680 <dt><span class="sect1"><a href="#components.Makefile">11.1. <code class="filename">Makefile</code></a></span></dt>
3681 <dt><span class="sect1"><a href="#components.distinfo">11.2. <code class="filename">distinfo</code></a></span></dt>
3682 <dt><span class="sect1"><a href="#components.patches">11.3. patches/*</a></span></dt>
3683 <dd><dl>
3684 <dt><span class="sect2"><a href="#components.patch.structure">11.3.1. Structure of a single patch file</a></span></dt>
3685 <dt><span class="sect2"><a href="#components.patches.caveats">11.3.2. Creating patch files</a></span></dt>
3686 <dt><span class="sect2"><a href="#components.patches.sources">11.3.3. Sources where the patch files come from</a></span></dt>
3687 <dt><span class="sect2"><a href="#components.patches.guidelines">11.3.4. Patching guidelines</a></span></dt>
3688 <dt><span class="sect2"><a href="#components.patches.feedback">11.3.5. Feedback to the author</a></span></dt>
3689 </dl></dd>
3690 <dt><span class="sect1"><a href="#other-mandatory-files">11.4. Other mandatory files</a></span></dt>
3691 <dt><span class="sect1"><a href="#components.optional">11.5. Optional files</a></span></dt>
3692 <dd><dl>
3693 <dt><span class="sect2"><a href="#components.optional.bin">11.5.1. Files affecting the binary package</a></span></dt>
3694 <dt><span class="sect2"><a href="#components.optional.build">11.5.2. Files affecting the build process</a></span></dt>
3695 <dt><span class="sect2"><a href="#components.optional.none">11.5.3. Files affecting nothing at all</a></span></dt>
3696 </dl></dd>
3697 <dt><span class="sect1"><a href="#work-dir">11.6. <code class="filename">work*</code></a></span></dt>
3698 <dt><span class="sect1"><a href="#files-dir">11.7. <code class="filename">files/*</code></a></span></dt>
3699 </dl></dd>
3700 <dt><span class="chapter"><a href="#makefile">12. Programming in <code class="filename">Makefile</code>s</a></span></dt>
3701 <dd><dl>
3702 <dt><span class="sect1"><a href="#makefile.style">12.1. Caveats</a></span></dt>
3703 <dt><span class="sect1"><a href="#makefile.variables">12.2. <code class="filename">Makefile</code> variables</a></span></dt>
3704 <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">12.2.1. Naming conventions</a></span></dt></dl></dd>
3705 <dt><span class="sect1"><a href="#makefile.code">12.3. Code snippets</a></span></dt>
3706 <dd><dl>
3707 <dt><span class="sect2"><a href="#adding-to-list">12.3.1. Adding things to a list</a></span></dt>
3708 <dt><span class="sect2"><a href="#converting-internal-to-external">12.3.2. Converting an internal list into an external list</a></span></dt>
3709 <dt><span class="sect2"><a href="#passing-variable-to-shell">12.3.3. Passing variables to a shell command</a></span></dt>
3710 <dt><span class="sect2"><a href="#quoting-guideline">12.3.4. Quoting guideline</a></span></dt>
3711 <dt><span class="sect2"><a href="#bsd-make-bug-workaround">12.3.5. Workaround for a bug in BSD Make</a></span></dt>
3712 </dl></dd>
3713 </dl></dd>
3714 <dt><span class="chapter"><a href="#plist">13. PLIST issues</a></span></dt>
3715 <dd><dl>
3716 <dt><span class="sect1"><a href="#rcs-id">13.1. RCS ID</a></span></dt>
3717 <dt><span class="sect1"><a href="#automatic-plist-generation">13.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
3718 <dt><span class="sect1"><a href="#print-PLIST">13.3. Tweaking output of <span class="command"><strong>make print-PLIST</strong></span></a></span></dt>
3719 <dt><span class="sect1"><a href="#plist.misc">13.4. Variable substitution in PLIST</a></span></dt>
3720 <dt><span class="sect1"><a href="#manpage-compression">13.5. Man page compression</a></span></dt>
3721 <dt><span class="sect1"><a href="#using-PLIST_SRC">13.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3722 <dt><span class="sect1"><a href="#platform-specific-plist">13.7. Platform-specific and differing PLISTs</a></span></dt>
3723 <dt><span class="sect1"><a href="#faq.common-dirs">13.8. Sharing directories between packages</a></span></dt>
3724 </dl></dd>
3725 <dt><span class="chapter"><a href="#buildlink">14. Buildlink methodology</a></span></dt>
3726 <dd><dl>
3727 <dt><span class="sect1"><a href="#converting-to-buildlink3">14.1. Converting packages to use buildlink3</a></span></dt>
3728 <dt><span class="sect1"><a href="#creating-buildlink3.mk">14.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
3729 <dd><dl>
3730 <dt><span class="sect2"><a href="#anatomy-of-bl3">14.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
3731 <dt><span class="sect2"><a href="#updating-buildlink-depends">14.2.2. Updating
3732       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
3733       and
3734       <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
3735       in <code class="filename">buildlink3.mk</code> files</a></span></dt>
3736 </dl></dd>
3737 <dt><span class="sect1"><a href="#writing-builtin.mk">14.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
3738 <dd><dl>
3739 <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">14.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
3740 <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">14.3.2. Global preferences for native or pkgsrc software</a></span></dt>
3741 </dl></dd>
3742 </dl></dd>
3743 <dt><span class="chapter"><a href="#pkginstall">15. The pkginstall framework</a></span></dt>
3744 <dd><dl>
3745 <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">15.1. Files and directories outside the installation prefix</a></span></dt>
3746 <dd><dl>
3747 <dt><span class="sect2"><a href="#dirs-outside-prefix">15.1.1. Directory manipulation</a></span></dt>
3748 <dt><span class="sect2"><a href="#files-outside-prefix">15.1.2. File manipulation</a></span></dt>
3749 </dl></dd>
3750 <dt><span class="sect1"><a href="#conf-files">15.2. Configuration files</a></span></dt>
3751 <dd><dl>
3752 <dt><span class="sect2"><a href="#conf-files-sysconfdir">15.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
3753 <dt><span class="sect2"><a href="#conf-files-configure">15.2.2. Telling the software where configuration files are</a></span></dt>
3754 <dt><span class="sect2"><a href="#conf-files-patching">15.2.3. Patching installations</a></span></dt>
3755 <dt><span class="sect2"><a href="#conf-files-disable">15.2.4. Disabling handling of configuration files</a></span></dt>
3756 </dl></dd>
3757 <dt><span class="sect1"><a href="#rcd-scripts">15.3. System startup scripts</a></span></dt>
3758 <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">15.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
3759 <dt><span class="sect1"><a href="#users-and-groups">15.4. System users and groups</a></span></dt>
3760 <dt><span class="sect1"><a href="#shells">15.5. System shells</a></span></dt>
3761 <dd><dl><dt><span class="sect2"><a href="#shells-disable">15.5.1. Disabling shell registration</a></span></dt></dl></dd>
3762 <dt><span class="sect1"><a href="#fonts">15.6. Fonts</a></span></dt>
3763 <dd><dl><dt><span class="sect2"><a href="#fonts-disable">15.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
3764 </dl></dd>
3765 <dt><span class="chapter"><a href="#options">16. Options handling</a></span></dt>
3766 <dd><dl>
3767 <dt><span class="sect1"><a href="#global-default-options">16.1. Global default options</a></span></dt>
3768 <dt><span class="sect1"><a href="#converting-to-options">16.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
3769 <dt><span class="sect1"><a href="#option-names">16.3. Option Names</a></span></dt>
3770 <dt><span class="sect1"><a href="#option-build">16.4. Determining the options of dependencies</a></span></dt>
3771 </dl></dd>
3772 <dt><span class="chapter"><a href="#build">17. The build process</a></span></dt>
3773 <dd><dl>
3774 <dt><span class="sect1"><a href="#build.intro">17.1. Introduction</a></span></dt>
3775 <dt><span class="sect1"><a href="#build.prefix">17.2. Program location</a></span></dt>
3776 <dt><span class="sect1"><a href="#build.builddirs">17.3. Directories used during the build process</a></span></dt>
3777 <dt><span class="sect1"><a href="#build.running">17.4. Running a phase</a></span></dt>
3778 <dt><span class="sect1"><a href="#build.fetch">17.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
3779 <dd><dl>
3780 <dt><span class="sect2"><a href="#build.fetch.what">17.5.1. What to fetch and where to get it from</a></span></dt>
3781 <dt><span class="sect2"><a href="#build.fetch.how">17.5.2. How are the files fetched?</a></span></dt>
3782 </dl></dd>
3783 <dt><span class="sect1"><a href="#build.checksum">17.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
3784 <dt><span class="sect1"><a href="#build.extract">17.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
3785 <dt><span class="sect1"><a href="#build.patch">17.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
3786 <dt><span class="sect1"><a href="#build.tools">17.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
3787 <dt><span class="sect1"><a href="#build.wrapper">17.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
3788 <dt><span class="sect1"><a href="#build.configure">17.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3789 <dt><span class="sect1"><a href="#build.build">17.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3790 <dt><span class="sect1"><a href="#build.test">17.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
3791 <dt><span class="sect1"><a href="#build.install">17.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3792 <dt><span class="sect1"><a href="#build.package">17.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
3793 <dt><span class="sect1"><a href="#build.clean">17.16. Cleaning up</a></span></dt>
3794 <dt><span class="sect1"><a href="#build.helpful-targets">17.17. Other helpful targets</a></span></dt>
3795 </dl></dd>
3796 <dt><span class="chapter"><a href="#tools">18. Tools needed for building or running</a></span></dt>
3797 <dd><dl>
3798 <dt><span class="sect1"><a href="#pkgsrc-tools">18.1. Tools for pkgsrc builds</a></span></dt>
3799 <dt><span class="sect1"><a href="#package-tools">18.2. Tools needed by packages</a></span></dt>
3800 <dt><span class="sect1"><a href="#platform-tools">18.3. Tools provided by platforms</a></span></dt>
3801 <dt><span class="sect1"><a href="#tools.questions">18.4. Questions regarding the tools</a></span></dt>
3802 </dl></dd>
3803 <dt><span class="chapter"><a href="#fixes">19. Making your package work</a></span></dt>
3804 <dd><dl>
3805 <dt><span class="sect1"><a href="#general-operation">19.1. General operation</a></span></dt>
3806 <dd><dl>
3807 <dt><span class="sect2"><a href="#portability-of-packages">19.1.1. Portability of packages</a></span></dt>
3808 <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">19.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
3809 <dt><span class="sect2"><a href="#user-interaction">19.1.3. User interaction</a></span></dt>
3810 <dt><span class="sect2"><a href="#handling-licenses">19.1.4. Handling licenses</a></span></dt>
3811 <dt><span class="sect2"><a href="#restricted-packages">19.1.5. Restricted packages</a></span></dt>
3812 <dt><span class="sect2"><a href="#dependencies">19.1.6. Handling dependencies</a></span></dt>
3813 <dt><span class="sect2"><a href="#conflicts">19.1.7. Handling conflicts with other packages</a></span></dt>
3814 <dt><span class="sect2"><a href="#not-building-packages">19.1.8. Packages that cannot or should not be built</a></span></dt>
3815 <dt><span class="sect2"><a href="#undeletable-packages">19.1.9. Packages which should not be deleted, once installed</a></span></dt>
3816 <dt><span class="sect2"><a href="#security-handling">19.1.10. Handling packages with security problems</a></span></dt>
3817 <dt><span class="sect2"><a href="#bumping-pkgrevision">19.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
3818 <dt><span class="sect2"><a href="#fixes.subst">19.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
3819 </dl></dd>
3820 <dt><span class="sect1"><a href="#fixes.fetch">19.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
3821 <dd><dl>
3822 <dt><span class="sect2"><a href="#no-plain-download">19.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
3823 <dt><span class="sect2"><a href="#modified-distfiles-same-name">19.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
3824 </dl></dd>
3825 <dt><span class="sect1"><a href="#fixes.configure">19.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3826 <dd><dl>
3827 <dt><span class="sect2"><a href="#fixes.libtool">19.3.1. Shared libraries - libtool</a></span></dt>
3828 <dt><span class="sect2"><a href="#using-libtool">19.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
3829 <dt><span class="sect2"><a href="#autoconf-automake">19.3.3. GNU Autoconf/Automake</a></span></dt>
3830 </dl></dd>
3831 <dt><span class="sect1"><a href="#programming-languages">19.4. Programming languages</a></span></dt>
3832 <dd><dl>
3833 <dt><span class="sect2"><a href="#basic-programming-languages">19.4.1. C, C++, and Fortran</a></span></dt>
3834 <dt><span class="sect2"><a href="#java-programming-language">19.4.2. Java</a></span></dt>
3835 <dt><span class="sect2"><a href="#perl-scripts">19.4.3. Packages containing perl scripts</a></span></dt>
3836 <dt><span class="sect2"><a href="#shell-scripts">19.4.4. Packages containing shell scripts</a></span></dt>
3837 <dt><span class="sect2"><a href="#other-programming-languages">19.4.5. Other programming languages</a></span></dt>
3838 </dl></dd>
3839 <dt><span class="sect1"><a href="#fixes.build">19.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3840 <dd><dl>
3841 <dt><span class="sect2"><a href="#fixes.build.cpp">19.5.1. Compiling C and C++ code conditionally</a></span></dt>
3842 <dt><span class="sect2"><a href="#compiler-bugs">19.5.2. How to handle compiler bugs</a></span></dt>
3843 <dt><span class="sect2"><a href="#undefined-reference">19.5.3. Undefined reference to <span class="quote">&#8220;<span class="quote">...</span>&#8221;</span></a></span></dt>
3844 <dt><span class="sect2"><a href="#out-of-memory">19.5.4. Running out of memory</a></span></dt>
3845 </dl></dd>
3846 <dt><span class="sect1"><a href="#fixes.install">19.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3847 <dd><dl>
3848 <dt><span class="sect2"><a href="#install-scripts">19.6.1. Creating needed directories</a></span></dt>
3849 <dt><span class="sect2"><a href="#where-to-install-documentation">19.6.2. Where to install documentation</a></span></dt>
3850 <dt><span class="sect2"><a href="#installing-score-files">19.6.3. Installing highscore files</a></span></dt>
3851 <dt><span class="sect2"><a href="#destdir-support">19.6.4. Adding DESTDIR support to packages</a></span></dt>
3852 <dt><span class="sect2"><a href="#hardcoded-paths">19.6.5. Packages with hardcoded paths to other interpreters</a></span></dt>
3853 <dt><span class="sect2"><a href="#perl-modules">19.6.6. Packages installing perl modules</a></span></dt>
3854 <dt><span class="sect2"><a href="#faq.info-files">19.6.7. Packages installing info files</a></span></dt>
3855 <dt><span class="sect2"><a href="#manpages">19.6.8. Packages installing man pages</a></span></dt>
3856 <dt><span class="sect2"><a href="#gconf-data-files">19.6.9. Packages installing GConf data files</a></span></dt>
3857 <dt><span class="sect2"><a href="#scrollkeeper-data-files">19.6.10. Packages installing scrollkeeper/rarian data files</a></span></dt>
3858 <dt><span class="sect2"><a href="#x11-fonts">19.6.11. Packages installing X11 fonts</a></span></dt>
3859 <dt><span class="sect2"><a href="#gtk2-modules">19.6.12. Packages installing GTK2 modules</a></span></dt>
3860 <dt><span class="sect2"><a href="#sgml-xml-data">19.6.13. Packages installing SGML or XML data</a></span></dt>
3861 <dt><span class="sect2"><a href="#mime-database">19.6.14. Packages installing extensions to the MIME database</a></span></dt>
3862 <dt><span class="sect2"><a href="#intltool">19.6.15. Packages using intltool</a></span></dt>
3863 <dt><span class="sect2"><a href="#startup-scripts">19.6.16. Packages installing startup scripts</a></span></dt>
3864 <dt><span class="sect2"><a href="#tex-packages">19.6.17. Packages installing TeX modules</a></span></dt>
3865 <dt><span class="sect2"><a href="#emulation-packages">19.6.18. Packages supporting running binaries in
3866     emulation</a></span></dt>
3867 <dt><span class="sect2"><a href="#hicolor-theme">19.6.19. Packages installing hicolor theme icons</a></span></dt>
3868 <dt><span class="sect2"><a href="#desktop-files">19.6.20. Packages installing desktop files</a></span></dt>
3869 </dl></dd>
3870 <dt><span class="sect1"><a href="#punting">19.7. Marking packages as having problems</a></span></dt>
3871 </dl></dd>
3872 <dt><span class="chapter"><a href="#debug">20. Debugging</a></span></dt>
3873 <dt><span class="chapter"><a href="#submit">21. Submitting and Committing</a></span></dt>
3874 <dd><dl>
3875 <dt><span class="sect1"><a href="#submitting-binary-packages">21.1. Submitting binary packages</a></span></dt>
3876 <dt><span class="sect1"><a href="#submitting-your-package">21.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
3877 <dt><span class="sect1"><a href="#general-notes-for-changes">21.3. General notes when adding, updating, or removing packages</a></span></dt>
3878 <dt><span class="sect1"><a href="#committing-importing">21.4. Committing: Adding a package to CVS</a></span></dt>
3879 <dt><span class="sect1"><a href="#updating-package">21.5. Updating a package to a newer version</a></span></dt>
3880 <dt><span class="sect1"><a href="#renaming-package">21.6. Renaming a package in pkgsrc</a></span></dt>
3881 <dt><span class="sect1"><a href="#moving-package">21.7. Moving a package in pkgsrc</a></span></dt>
3882 </dl></dd>
3883 <dt><span class="chapter"><a href="#devfaq">22. Frequently Asked Questions</a></span></dt>
3884 <dt><span class="chapter"><a href="#gnome">23. GNOME packaging and porting</a></span></dt>
3885 <dd><dl>
3886 <dt><span class="sect1"><a href="#meta-packages">23.1. Meta packages</a></span></dt>
3887 <dt><span class="sect1"><a href="#new-package">23.2. Packaging a GNOME application</a></span></dt>
3888 <dt><span class="sect1"><a href="#full-update">23.3. Updating GNOME to a newer version</a></span></dt>
3889 <dt><span class="sect1"><a href="#patching">23.4. Patching guidelines</a></span></dt>
3890 </dl></dd>
3891 </dl>
3892 </div>
3893 </div>
3894 <div class="chapter">
3895 <div class="titlepage"><div><div><h2 class="title">
3896 <a name="creating"></a>Chapter 10. Creating a new pkgsrc package from scratch</h2></div></div></div>
3897 <div class="toc">
3898 <p><b>Table of Contents</b></p>
3899 <dl>
3900 <dt><span class="sect1"><a href="#creating.common">10.1. Common types of packages</a></span></dt>
3901 <dd><dl>
3902 <dt><span class="sect2"><a href="#creating.perl-module">10.1.1. Perl modules</a></span></dt>
3903 <dt><span class="sect2"><a href="#creating.kde-app">10.1.2. KDE applications</a></span></dt>
3904 <dt><span class="sect2"><a href="#creating.python-module">10.1.3. Python modules and programs</a></span></dt>
3905 </dl></dd>
3906 <dt><span class="sect1"><a href="#creating.examples">10.2. Examples</a></span></dt>
3907 <dd><dl><dt><span class="sect2"><a href="#creating.nvu">10.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
3908 </dl>
3909 </div>
3910 <p>When you find a package that is not yet in pkgsrc, you
3911 most likely have a URL from where you can download the source
3912 code. Starting with this URL, creating a package involves only a
3913 few steps.</p>
3914 <div class="procedure"><ol class="procedure" type="1">
3915 <li class="step"><p>First, install the packages <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a> and <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>.</p></li>
3916 <li class="step"><p>Then, choose one of the top-level directories as the
3917 category in which you want to place your package. You can also create a
3918 directory of your own (maybe called <code class="filename">local</code>). In that
3919 category directory, create another directory for your package and change
3920 into it.</p></li>
3921 <li class="step"><p>Run the program <span class="command"><strong>url2pkg</strong></span>, which will ask
3922 you for a URL. Enter the URL of the distribution file (in most cases a
3923 <code class="filename">.tar.gz</code> file) and watch how the basic ingredients
3924 of your package are created automatically. The distribution file is
3925 extracted automatically to fill in some details in the
3926 <code class="filename">Makefile</code> that would otherwise have to be done
3927 manually.</p></li>
3928 <li class="step">
3929 <p>Examine the extracted files to determine the dependencies of
3930 your package. Ideally, this is mentioned in some
3931 <code class="filename">README</code> file, but things may differ. For each of
3932 these dependencies, look where it exists in pkgsrc, and if there is a
3933 file called <code class="filename">buildlink3.mk</code> in that directory, add a
3934 line to your package <code class="filename">Makefile</code> which includes that
3935 file just before the last line. If the
3936 <code class="filename">buildlink3.mk</code> file does not exist, it must be
3937 created first. The <code class="filename">buildlink3.mk</code> file makes sure that the package's include files and libraries are provided.</p>
3938 <p>If you just need binaries from a package, add a
3939 <code class="varname">DEPENDS</code> line to the Makefile, which specifies the
3940 version of the dependency and where it can be found in pkgsrc. This line
3941 should be placed in the third paragraph. If the dependency is only
3942 needed for building the package, but not when using it, use
3943 <code class="varname">BUILD_DEPENDS</code> instead of <code class="varname">DEPENDS</code>.
3944 Your package may then look like this:</p>
3945 <pre class="programlisting">
3946 [...]
3947
3948 BUILD_DEPENDS+= lua&gt;=5.0:../../lang/lua
3949 DEPENDS+=       screen-[0-9]*:../../misc/screen
3950 DEPENDS+=       screen&gt;=4.0:../../misc/screen
3951
3952 [...]
3953
3954 .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
3955 .include "../../devel/glib2/buildlink3.mk"
3956 .include "../../mk/bsd.pkg.mk"
3957 </pre>
3958 </li>
3959 <li class="step"><p>Run <span class="command"><strong>pkglint</strong></span> to see what things still need
3960 to be done to make your package a <span class="quote">&#8220;<span class="quote">good</span>&#8221;</span> one. If you don't
3961 know what pkglint's warnings want to tell you, try <span class="command"><strong>pkglint
3962 --explain</strong></span> or <span class="command"><strong>pkglint
3963 -e</strong></span>, which outputs additional
3964 explanations.</p></li>
3965 <li class="step"><p>In many cases the package is not yet ready to build. You can
3966 find instructions for the most common cases in the next section, <a class="xref" href="#creating.common" title="10.1. Common types of packages">Section 10.1, &#8220;Common types of packages&#8221;</a>. After you have followed the instructions
3967 over there, you can hopefully continue here.</p></li>
3968 <li class="step"><p>Run <span class="command"><strong>bmake clean</strong></span> to clean the working
3969 directory from the extracted files. Besides these files, a lot of cache
3970 files and other system information has been saved in the working
3971 directory, which may become wrong after you edited the
3972 <code class="filename">Makefile</code>.</p></li>
3973 <li class="step"><p>Now, run <span class="command"><strong>bmake</strong></span> to build the package. For
3974 the various things that can go wrong in this phase, consult <a class="xref" href="#fixes" title="Chapter 19. Making your package work">Chapter 19, <i>Making your package work</i></a>.</p></li>
3975 <li class="step"><p>When the package builds fine, the next step is to install
3976 the package. Run <span class="command"><strong>bmake install</strong></span> and hope that
3977 everything works.</p></li>
3978 <li class="step"><p>Up to now, the file <code class="filename">PLIST</code>, which
3979 contains a list of the files that are installed by the package, is
3980 nearly empty. Run <span class="command"><strong>bmake print-PLIST
3981 &gt;PLIST</strong></span> to generate a probably correct list. Check
3982 the file using your preferred text editor to see if the list of
3983 files looks plausible.</p></li>
3984 <li class="step"><p>Run <span class="command"><strong>pkglint</strong></span> again to see if the generated
3985 <code class="filename">PLIST</code> contains garbage or not.</p></li>
3986 <li class="step"><p>When you ran <span class="command"><strong>bmake install</strong></span>, the package
3987 has been registered in the database of installed files, but with an
3988 empty list of files. To fix this, run <span class="command"><strong>bmake deinstall</strong></span>
3989 and <span class="command"><strong>bmake install</strong></span> again. Now the package is
3990 registered with the list of files from
3991 <code class="filename">PLIST</code>.</p></li>
3992 <li class="step"><p>Run <span class="command"><strong>bmake package</strong></span> to create a binary
3993 package from the set of installed files.</p></li>
3994 </ol></div>
3995 <div class="sect1">
3996 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3997 <a name="creating.common"></a>10.1. Common types of packages</h2></div></div></div>
3998 <div class="sect2">
3999 <div class="titlepage"><div><div><h3 class="title">
4000 <a name="creating.perl-module"></a>10.1.1. Perl modules</h3></div></div></div>
4001 <p>Simple Perl modules are handled automatically by
4002 <span class="command"><strong>url2pkg</strong></span>, including dependencies.</p>
4003 </div>
4004 <div class="sect2">
4005 <div class="titlepage"><div><div><h3 class="title">
4006 <a name="creating.kde-app"></a>10.1.2. KDE applications</h3></div></div></div>
4007 <p>KDE applications should always include
4008 <code class="filename">meta-pkgs/kde3/kde3.mk</code>, which contains numerous
4009 settings that are typical of KDE packages.</p>
4010 </div>
4011 <div class="sect2">
4012 <div class="titlepage"><div><div><h3 class="title">
4013 <a name="creating.python-module"></a>10.1.3. Python modules and programs</h3></div></div></div>
4014 <p>Python modules and programs packages are easily created using a
4015 set of predefined variables.</p>
4016 <p>Most Python packages use either <span class="quote">&#8220;<span class="quote">distutils</span>&#8221;</span> or
4017 easy-setup (<span class="quote">&#8220;<span class="quote">eggs</span>&#8221;</span>).
4018 If the software uses <span class="quote">&#8220;<span class="quote">distutils</span>&#8221;</span>, set the
4019 <code class="varname">PYDISTUTILSPKG</code> variable to <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span> so
4020 pkgsrc will make use of this framework.
4021 <span class="quote">&#8220;<span class="quote">distutils</span>&#8221;</span> uses a script called <code class="filename">setup.py</code>,
4022 if the <span class="quote">&#8220;<span class="quote">distutils</span>&#8221;</span> driver is not called
4023 <code class="filename">setup.py</code>, set the <code class="varname">PYSETUP</code> variable
4024 to the name of the script.</p>
4025 <p>
4026 If the default Python versions are not supported by the software, set the
4027 <code class="varname">PYTHON_VERSIONS_ACCEPTED</code> variable to the Python versions
4028 the software is known to work with, from the most recent to the older
4029 one, e.g.
4030 </p>
4031 <pre class="programlisting">
4032 PYTHON_VERSIONS_ACCEPTED=       31 27 26
4033 </pre>
4034 <p>
4035 If the packaged software is a Python module, include
4036 <span class="quote">&#8220;<span class="quote"><code class="filename">../../lang/python/extension.mk</code></span>&#8221;</span>.
4037 In this case, the package directory should be called
4038 <span class="quote">&#8220;<span class="quote">py-software</span>&#8221;</span> and <code class="varname">PKGNAME</code> should be set to
4039 <span class="quote">&#8220;<span class="quote">${PYPKGPREFIX}-${DISTNAME}</span>&#8221;</span>, e.g.
4040 </p>
4041 <pre class="programlisting">
4042 DISTNAME=   foopymodule-1.2.10
4043 PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
4044 </pre>
4045 <p>If it is an application, also include
4046 <span class="quote">&#8220;<span class="quote"><code class="filename">../../lang/python/application.mk</code></span>&#8221;</span>
4047 before <span class="quote">&#8220;<span class="quote">extension.mk</span>&#8221;</span>.</p>
4048 <p>If the packaged software, either it is an application or a module, is
4049 egg-aware, you only need to include
4050 <span class="quote">&#8220;<span class="quote"><code class="filename">../../lang/python/egg.mk</code></span>&#8221;</span>.</p>
4051 <p>In order to correctly set the path to the Python interpreter, use the
4052 <code class="varname">REPLACE_PYTHON</code> variable and set it to the list of files
4053 (paths relative to <code class="varname">WRKSRC</code>) that must be corrected.
4054 For example :
4055 </p>
4056 <pre class="programlisting">
4057 REPLACE_PYTHON=   *.py
4058 </pre>
4059 </div>
4060 </div>
4061 <div class="sect1">
4062 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4063 <a name="creating.examples"></a>10.2. Examples</h2></div></div></div>
4064 <div class="sect2">
4065 <div class="titlepage"><div><div><h3 class="title">
4066 <a name="creating.nvu"></a>10.2.1. How the www/nvu package came into pkgsrc</h3></div></div></div>
4067 <div class="sect3">
4068 <div class="titlepage"><div><div><h4 class="title">
4069 <a name="creating.nvu.init"></a>10.2.1.1. The initial package</h4></div></div></div>
4070 <p>Looking at the file <code class="filename">pkgsrc/doc/TODO</code>, I saw
4071 that the <span class="quote">&#8220;<span class="quote">nvu</span>&#8221;</span> package has not yet been imported into
4072 pkgsrc. As the description says it has to do with the web, the obvious
4073 choice for the category is <span class="quote">&#8220;<span class="quote">www</span>&#8221;</span>.</p>
4074 <pre class="programlisting">
4075 <code class="prompt">$</code> mkdir www/nvu
4076 <code class="prompt">$</code> cd www/nvu
4077 </pre>
4078 <p>The web site says that the sources are available as a tar file, so
4079 I fed that URL to the <span class="command"><strong>url2pkg</strong></span> program:</p>
4080 <pre class="programlisting">
4081 <code class="prompt">$</code> url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
4082 </pre>
4083 <p>My editor popped up, and I added a <code class="varname">PKGNAME</code> line
4084 below the <code class="varname">DISTNAME</code> line, as the package name should
4085 not have the word <span class="quote">&#8220;<span class="quote">sources</span>&#8221;</span> in it. I also filled in the
4086 <code class="varname">MAINTAINER</code>, <code class="varname">HOMEPAGE</code> and
4087 <code class="varname">COMMENT</code> fields. Then the package
4088 <code class="filename">Makefile</code> looked like that:</p>
4089 <pre class="programlisting">
4090 # $NetBSD$
4091 #
4092
4093 DISTNAME=       nvu-1.0-sources
4094 PKGNAME=        nvu-1.0
4095 CATEGORIES=     www
4096 MASTER_SITES=   http://cvs.nvu.com/download/
4097 EXTRACT_SUFX=   .tar.bz2
4098
4099 MAINTAINER=     rillig@NetBSD.org
4100 HOMEPAGE=       http://cvs.nvu.com/
4101 COMMENT=        Web Authoring System
4102
4103 # url2pkg-marker (please do not remove this line.)
4104 .include "../../mk/bsd.pkg.mk"
4105 </pre>
4106 <p>Then, I quit the editor and watched pkgsrc downloading a large
4107 source archive:</p>
4108 <pre class="programlisting">
4109 url2pkg&gt; Running "make makesum" ...
4110 =&gt; Required installed package digest&gt;=20010302: digest-20060826 found
4111 =&gt; Fetching nvu-1.0-sources.tar.bz2
4112 Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
4113 100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
4114 29687976 bytes retrieved in 03:12 (150.77 KB/s)
4115 url2pkg&gt; Running "make extract" ...
4116 =&gt; Required installed package digest&gt;=20010302: digest-20060826 found
4117 =&gt; Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4118 =&gt; Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4119 work.bacc -&gt; /tmp/roland/pkgsrc/www/nvu/work.bacc
4120 ===&gt; Installing dependencies for nvu-1.0
4121 ===&gt; Overriding tools for nvu-1.0
4122 ===&gt; Extracting for nvu-1.0
4123 url2pkg&gt; Adjusting the Makefile.
4124
4125 Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
4126
4127 Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
4128 </pre>
4129 </div>
4130 <div class="sect3">
4131 <div class="titlepage"><div><div><h4 class="title">
4132 <a name="creating.nvu.problems"></a>10.2.1.2. Fixing all kinds of problems to make the package work</h4></div></div></div>
4133 <p>Now that the package has been extracted, let's see what's inside
4134 it. The package has a <code class="filename">README.txt</code>, but that only
4135 says something about mozilla, so it's probably useless for seeing what
4136 dependencies this package has. But since there is a GNU configure script
4137 in the package, let's hope that it will complain about everything it
4138 needs.</p>
4139 <pre class="programlisting">
4140 <code class="prompt">$</code> bmake
4141 =&gt; Required installed package digest&gt;=20010302: digest-20060826 found
4142 =&gt; Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4143 =&gt; Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4144 ===&gt; Patching for nvu-1.0
4145 ===&gt; Creating toolchain wrappers for nvu-1.0
4146 ===&gt; Configuring for nvu-1.0
4147 [...]
4148 configure: error: Perl 5.004 or higher is required.
4149 [...]
4150 WARNING: Please add USE_TOOLS+=perl to the package Makefile.
4151 [...]
4152 </pre>
4153 <p>That worked quite well. So I opened the package Makefile in my
4154 editor, and since it already has a <code class="varname">USE_TOOLS</code> line, I
4155 just appended <span class="quote">&#8220;<span class="quote">perl</span>&#8221;</span> to it. Since the dependencies of the
4156 package have changed now, and since a perl wrapper is automatically
4157 installed in the <span class="quote">&#8220;<span class="quote">tools</span>&#8221;</span> phase, I need to build the package
4158 from scratch.</p>
4159 <pre class="programlisting">
4160 <code class="prompt">$</code> bmake clean
4161 ===&gt; Cleaning for nvu-1.0
4162 <code class="prompt">$</code> bmake
4163 [...]
4164 *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
4165 GNU Make.  You will not be able to build Mozilla without GNU Make.
4166 [...]
4167 </pre>
4168 <p>So I added <span class="quote">&#8220;<span class="quote">gmake</span>&#8221;</span> to the
4169 <code class="varname">USE_TOOLS</code> line and tried again (from scratch).</p>
4170 <pre class="programlisting">
4171 [...]
4172 checking for GTK - version &gt;= 1.2.0... no
4173 *** Could not run GTK test program, checking why...
4174 [...]
4175 </pre>
4176 <p>Now to the other dependencies. The first question is: Where is the
4177 GTK package hidden in pkgsrc?</p>
4178 <pre class="programlisting">
4179 <code class="prompt">$</code> echo ../../*/gtk*
4180 [many packages ...]
4181 <code class="prompt">$</code> echo ../../*/gtk
4182 ../../x11/gtk
4183 <code class="prompt">$</code> echo ../../*/gtk2
4184 ../../x11/gtk2
4185 <code class="prompt">$</code> echo ../../*/gtk2/bui*
4186 ../../x11/gtk2/buildlink3.mk
4187 </pre>
4188 <p>The first try was definitely too broad. The second one had exactly
4189 one result, which is very good. But there is one pitfall with GNOME
4190 packages. Before GNOME 2 had been released, there were already many
4191 GNOME 1 packages in pkgsrc. To be able to continue to use these
4192 packages, the GNOME 2 packages were imported as separate packages, and
4193 their names usually have a <span class="quote">&#8220;<span class="quote">2</span>&#8221;</span> appended. So I checked
4194 whether this was the case here, and indeed it was.</p>
4195 <p>Since the GTK2 package has a <code class="filename">buildlink3.mk</code>
4196 file, adding the dependency is very easy. I just inserted an
4197 <code class="literal">.include</code> line before the last line of the package
4198 <code class="filename">Makefile</code>, so that it now looks like this:</p>
4199 <pre class="programlisting">
4200 [...]
4201 .include "../../x11/gtk2/buildlink3.mk"
4202 .include "../../mk/bsd.pkg.mk
4203 </pre>
4204 <p>After another <span class="command"><strong>bmake clean &amp;&amp; bmake</strong></span>, the answer
4205 was:</p>
4206 <pre class="programlisting">
4207 [...]
4208 checking for gtk-config... /home/roland/pkg/bin/gtk-config
4209 checking for GTK - version &gt;= 1.2.0... no
4210 *** Could not run GTK test program, checking why...
4211 *** The test program failed to compile or link. See the file config.log for the
4212 *** exact error that occured. This usually means GTK was incorrectly installed
4213 *** or that you have moved GTK since it was installed. In the latter case, you
4214 *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
4215 configure: error: Test for GTK failed.
4216 [...]
4217 </pre>
4218 <p>In this particular case, the assumption that <span class="quote">&#8220;<span class="quote">every package
4219 prefers GNOME 2</span>&#8221;</span> had been wrong. The first of the lines above
4220 told me that this package really wanted to have the GNOME 1 version of
4221 GTK. If the package had looked for GTK2, it would have looked for
4222 <span class="command"><strong>pkg-config</strong></span> instead of <span class="command"><strong>gtk-config</strong></span>.
4223 So I changed the <code class="literal">x11/gtk2</code> to
4224 <code class="literal">x11/gtk</code> in the package <code class="filename">Makefile</code>,
4225 and tried again.</p>
4226 <pre class="programlisting">
4227 [...]
4228 cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"   -I../../../dist/include/xpcom -I../../../dist/include -I/tmp/roland/pkgsrc/www/nvu/work.bacc/mozilla/dist/include/nspr -I/usr/X11R6/include   -fPIC -DPIC -I/home/roland/pkg/include -I/usr/include  -I/usr/X11R6/include -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -Wno-long-long -pedantic -O2 -I/home/roland/pkg/include -I/usr/include -Dunix -pthread -pipe  -DDEBUG -D_DEBUG -DDEBUG_roland -DTRACING -g -I/home/roland/pkg/include/glib/glib-1.2 -I/home/roland/pkg/lib/glib/include -I/usr/pkg/include/orbit-1.0   -I/home/roland/pkg/include -I/usr/include  -I/usr/X11R6/include -include ../../../mozilla-config.h -DMOZILLA_CLIENT -Wp,-MD,.deps/xpidl.pp xpidl.c
4229 In file included from xpidl.c:42:
4230 xpidl.h:53:24: libIDL/IDL.h: No such file or directory
4231 In file included from xpidl.c:42:
4232 xpidl.h:132: error: parse error before "IDL_ns"
4233 [...]
4234 </pre>
4235 <p>The package still does not find all of its dependencies. Now the
4236 question is: Which package provides the
4237 <code class="filename">libIDL/IDL.h</code> header file?</p>
4238 <pre class="programlisting">
4239 <code class="prompt">$</code> echo ../../*/*idl*
4240 ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
4241 <code class="prompt">$</code> echo ../../*/*IDL*
4242 ../../net/libIDL
4243 </pre>
4244 <p>Let's take the one from the second try. So I included the
4245 <code class="filename">../../net/libIDL/buildlink3.mk</code> file and tried
4246 again. But the error didn't change. After digging through some of the
4247 code, I concluded that the build process of the package was broken and
4248 couldn't have ever worked, but since the Mozilla source tree is quite
4249 large, I didn't want to fix it. So I added the following to the package
4250 <code class="filename">Makefile</code> and tried again:</p>
4251 <pre class="programlisting">
4252 CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
4253 BUILDLINK_TRANSFORM+=   -l:IDL:IDL-2
4254 </pre>
4255 <p>The latter line is needed because the package expects the library
4256 <code class="filename">libIDL.so</code>, but only
4257 <code class="filename">libIDL-2.so</code> is available. So I told the compiler
4258 wrapper to rewrite that on the fly.</p>
4259 <p>The next problem was related to a recent change of the FreeType
4260 interface. I looked up in <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/seamonkey/README.html" target="_top"><code class="filename">www/seamonkey</code></a>
4261 which patch files were relevant for this issue and copied them to the
4262 <code class="filename">patches</code> directory. Then I retried, fixed the
4263 patches so that they applied cleanly and retried again. This time,
4264 everything worked.</p>
4265 </div>
4266 <div class="sect3">
4267 <div class="titlepage"><div><div><h4 class="title">
4268 <a name="creating.nvu.inst"></a>10.2.1.3. Installing the package</h4></div></div></div>
4269 <pre class="programlisting">
4270 <code class="prompt">$</code> bmake CHECK_FILES=no install
4271 [...]
4272 <code class="prompt">$</code> bmake print-PLIST &gt;PLIST
4273 <code class="prompt">$</code> bmake deinstall
4274 <code class="prompt">$</code> bmake install
4275 </pre>
4276 </div>
4277 </div>
4278 </div>
4279 </div>
4280 <div class="chapter">
4281 <div class="titlepage"><div><div><h2 class="title">
4282 <a name="components"></a>Chapter 11. Package components - files, directories and contents</h2></div></div></div>
4283 <div class="toc">
4284 <p><b>Table of Contents</b></p>
4285 <dl>
4286 <dt><span class="sect1"><a href="#components.Makefile">11.1. <code class="filename">Makefile</code></a></span></dt>
4287 <dt><span class="sect1"><a href="#components.distinfo">11.2. <code class="filename">distinfo</code></a></span></dt>
4288 <dt><span class="sect1"><a href="#components.patches">11.3. patches/*</a></span></dt>
4289 <dd><dl>
4290 <dt><span class="sect2"><a href="#components.patch.structure">11.3.1. Structure of a single patch file</a></span></dt>
4291 <dt><span class="sect2"><a href="#components.patches.caveats">11.3.2. Creating patch files</a></span></dt>
4292 <dt><span class="sect2"><a href="#components.patches.sources">11.3.3. Sources where the patch files come from</a></span></dt>
4293 <dt><span class="sect2"><a href="#components.patches.guidelines">11.3.4. Patching guidelines</a></span></dt>
4294 <dt><span class="sect2"><a href="#components.patches.feedback">11.3.5. Feedback to the author</a></span></dt>
4295 </dl></dd>
4296 <dt><span class="sect1"><a href="#other-mandatory-files">11.4. Other mandatory files</a></span></dt>
4297 <dt><span class="sect1"><a href="#components.optional">11.5. Optional files</a></span></dt>
4298 <dd><dl>
4299 <dt><span class="sect2"><a href="#components.optional.bin">11.5.1. Files affecting the binary package</a></span></dt>
4300 <dt><span class="sect2"><a href="#components.optional.build">11.5.2. Files affecting the build process</a></span></dt>
4301 <dt><span class="sect2"><a href="#components.optional.none">11.5.3. Files affecting nothing at all</a></span></dt>
4302 </dl></dd>
4303 <dt><span class="sect1"><a href="#work-dir">11.6. <code class="filename">work*</code></a></span></dt>
4304 <dt><span class="sect1"><a href="#files-dir">11.7. <code class="filename">files/*</code></a></span></dt>
4305 </dl>
4306 </div>
4307 <p>Whenever you're preparing a package, there are a number of
4308 files involved which are described in the following
4309 sections.</p>
4310 <div class="sect1">
4311 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4312 <a name="components.Makefile"></a>11.1. <code class="filename">Makefile</code>
4313 </h2></div></div></div>
4314 <p>Building, installation and creation of a binary package are all
4315   controlled by the package's <code class="filename">Makefile</code>.
4316   The <code class="filename">Makefile</code> describes various things about
4317   a package, for example from where to get it, how to configure,
4318   build, and install it.</p>
4319 <p>A package <code class="filename">Makefile</code> contains several
4320   sections that describe the package.</p>
4321 <p>In the first section there are the following variables, which
4322   should appear exactly in the order given here.  The order and
4323   grouping of the variables is mostly historical and has no further
4324   meaning.</p>
4325 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
4326 <li class="listitem"><p><code class="varname">DISTNAME</code> is the basename of the
4327     distribution file to be downloaded from the package's
4328     website.</p></li>
4329 <li class="listitem"><p><code class="varname">PKGNAME</code> is the name of the
4330     package, as used by pkgsrc. You only need to provide it if
4331     <code class="varname">DISTNAME</code> (which is the default) is not a good
4332     name for the package in pkgsrc.  Usually it is the pkgsrc
4333     directory name together with the version number. It must match the
4334     regular expression
4335     <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
4336     starts with a letter or digit, and contains only letters, digits,
4337     dashes, underscores, dots and plus signs.</p></li>
4338 <li class="listitem"><p><code class="varname">SVR4_PKGNAME</code> is the name of
4339     the package file to create if the <code class="varname">PKGNAME</code>
4340     isn't unique on a SVR4 system. The default is
4341     <code class="varname">PKGNAME</code>, which may be shortened when you use
4342     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>. Only add
4343     <code class="varname">SVR4_PKGNAME</code> if <code class="varname">PKGNAME</code>
4344     does not produce an unique package name on a SVR4 system.
4345     The length of <code class="varname">SVR4_PKGNAME</code> is limited to 5
4346     characters.</p></li>
4347 <li class="listitem">
4348 <p><code class="varname">CATEGORIES</code> is a list of categories
4349     which the package fits in. You can choose any of the top-level
4350     directories of pkgsrc for it.</p>
4351 <p>Currently the following values are available for
4352     <code class="varname">CATEGORIES</code>. If more than
4353     one is used, they need to be separated by spaces:</p>
4354 <pre class="programlisting">
4355 archivers     cross         geography     meta-pkgs     security
4356 audio         databases     graphics      misc          shells
4357 benchmarks    devel         ham           multimedia    sysutils
4358 biology       editors       inputmethod   net           textproc
4359 cad           emulators     lang          news          time
4360 chat          finance       mail          parallel      wm
4361 comms         fonts         math          pkgtools      www
4362 converters    games         mbone         print         x11
4363 </pre>
4364 </li>
4365 <li class="listitem"><p><code class="varname">MASTER_SITES</code>,
4366     <code class="varname">DYNAMIC_MASTER_SITES</code>,
4367     <code class="varname">DIST_SUBDIR</code>, <code class="varname">EXTRACT_SUFX</code>
4368     and <code class="varname">DISTFILES</code> are discussed in detail in
4369     <a class="xref" href="#build.fetch" title="17.5. The fetch phase">Section 17.5, &#8220;The <span class="emphasis"><em>fetch</em></span> phase&#8221;</a>.</p></li>
4370 </ul></div>
4371 <p>The second section contains information about separately
4372   downloaded patches, if any.
4373   </p>
4374 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
4375 <li class="listitem"><p><code class="varname">PATCHFILES:</code>
4376     Name(s) of additional files that contain distribution patches.
4377     There is no default. pkgsrc will look for them at
4378     <code class="varname">PATCH_SITES</code>.
4379     They will automatically be uncompressed before patching if
4380     the names end with <code class="filename">.gz</code> or
4381     <code class="filename">.Z</code>.</p></li>
4382 <li class="listitem"><p><code class="varname">PATCH_SITES</code>:
4383     Primary location(s) for distribution patch files (see
4384     <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
4385 </ul></div>
4386 <p>The third section contains the following variables.
4387   </p>
4388 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
4389 <li class="listitem"><p><code class="varname">MAINTAINER</code> is the email
4390     address of the person who feels responsible for this package,
4391     and who is most likely to look at problems or questions regarding
4392     this package which have been reported with <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">send-pr</span>(1)</span></a>.
4393     Other developers may contact the <code class="varname">MAINTAINER</code>
4394     before making changes to the package, but are not required to
4395     do so. When packaging a new program, set <code class="varname">MAINTAINER</code>
4396     to yourself. If you really can't maintain the package for future
4397     updates, set it to
4398     <code class="email">&lt;<a class="email" href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>&gt;</code>.</p></li>
4399 <li class="listitem"><p><code class="varname">OWNER</code> should be used instead
4400     of <code class="varname">MAINTAINER</code> when you do not want other
4401     developers to update or change the package without contacting
4402     you first. A package Makefile should contain one of
4403     <code class="varname">MAINTAINER</code> or <code class="varname">OWNER</code>, but
4404     not both.  </p></li>
4405 <li class="listitem"><p><code class="varname">HOMEPAGE</code> is a URL where users can
4406     find more information about the package.</p></li>
4407 <li class="listitem"><p><code class="varname">COMMENT</code> is a one-line
4408     description of the package (should not include the package
4409     name).</p></li>
4410 </ul></div>
4411 <p>Other variables that affect the build:
4412   </p>
4413 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
4414 <p><code class="varname">WRKSRC</code>: The directory where the
4415       interesting distribution files of the package are found. The
4416       default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
4417       works for most packages.</p>
4418 <p>If a package doesn't create a subdirectory for itself
4419       (most GNU software does, for instance), but extracts itself in
4420       the current directory, you should set
4421       <code class="varname">WRKSRC=${WRKDIR}</code>.</p>
4422 <p>If a package doesn't create a subdirectory with the
4423       name of <code class="varname">DISTNAME</code> but some different name,
4424       set <code class="varname">WRKSRC</code> to point to the proper name in
4425       <code class="filename">${WRKDIR}</code>, for example
4426       <code class="varname">WRKSRC=${WRKDIR}/${DISTNAME}/unix</code>. See
4427       <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/lang/tcl/README.html" target="_top"><code class="filename">lang/tcl</code></a> and <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/tk/README.html" target="_top"><code class="filename">x11/tk</code></a> for other examples.</p>
4428 <p>The name of the working directory created by pkgsrc is
4429       taken from the <code class="varname">WRKDIR_BASENAME</code>
4430       variable. By default, its value is
4431       <code class="filename">work</code>. If you want to use the same
4432       pkgsrc tree for building different kinds of binary packages,
4433       you can change the variable according to your needs. Two
4434       other variables handle common cases of setting
4435       <code class="varname">WRKDIR_BASENAME</code> individually. If
4436       <code class="varname">OBJHOSTNAME</code> is defined in
4437       <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, the first component of
4438       the host's name is attached to the directory name. If
4439       <code class="varname">OBJMACHINE</code> is defined, the platform name
4440       is attached, which might look like
4441       <code class="filename">work.i386</code> or
4442       <code class="filename">work.sparc</code>.</p>
4443 </li></ul></div>
4444 <p>Please pay attention to the following gotchas:</p>
4445 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
4446 <li class="listitem"><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are
4447       installed in compressed form by the package.  For packages using
4448       BSD-style makefiles which honor MANZ, there is
4449       <code class="varname">MANCOMPRESSED_IF_MANZ</code>.</p></li>
4450 <li class="listitem"><p>Replace <code class="filename">/usr/local</code> with
4451       <span class="quote">&#8220;<span class="quote">${PREFIX}</span>&#8221;</span> in all files (see patches,
4452       below).</p></li>
4453 <li class="listitem"><p>If the package installs any info files, see <a class="xref" href="#faq.info-files" title="19.6.7. Packages installing info files">Section 19.6.7, &#8220;Packages installing info files&#8221;</a>.</p></li>
4454 </ul></div>
4455 </div>
4456 <div class="sect1">
4457 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4458 <a name="components.distinfo"></a>11.2. <code class="filename">distinfo</code>
4459 </h2></div></div></div>
4460 <p>The <code class="filename">distinfo</code> file contains the message
4461   digest, or checksum, of each distfile needed for the package. This
4462   ensures that the distfiles retrieved from the Internet have not been
4463   corrupted during transfer or altered by a malign force to introduce
4464   a security hole. Due to recent rumor about weaknesses of digest
4465   algorithms, all distfiles are protected using both SHA1 and RMD160
4466   message digests, as well as the file size.</p>
4467 <p>The <code class="filename">distinfo</code> file also contains the
4468   checksums for all the patches found in the
4469   <code class="filename">patches</code> directory (see <a class="xref" href="#components.patches" title="11.3. patches/*">Section 11.3, &#8220;patches/*&#8221;</a>).</p>
4470 <p>To regenerate the <code class="filename">distinfo</code> file, use the
4471   <span class="command"><strong>make makedistinfo</strong></span> or <span class="command"><strong>make mdi</strong></span>
4472   command.</p>
4473 <p>Some packages have different sets of distfiles depending on
4474   the platform, for example <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/lang/openjdk7/README.html" target="_top"><code class="filename">lang/openjdk7</code></a>. These are kept in the same
4475   <code class="filename">distinfo</code> file and care should be taken when
4476   upgrading such a package to ensure distfile information is not
4477   lost.</p>
4478 </div>
4479 <div class="sect1">
4480 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4481 <a name="components.patches"></a>11.3. patches/*</h2></div></div></div>
4482 <p>Many packages still don't work out-of-the box on the various
4483   platforms that are supported by pkgsrc. Therefore, a number of custom
4484   patch files are needed to make the package work. These patch files are
4485   found in the <code class="filename">patches/</code> directory.</p>
4486 <p>In the <span class="emphasis"><em>patch</em></span> phase, these patches are
4487   applied to the files in <code class="varname">WRKSRC</code> directory after
4488   extracting them, in <a class="ulink" href="http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_13_03" target="_top">alphabetic
4489   order</a>.</p>
4490 <div class="sect2">
4491 <div class="titlepage"><div><div><h3 class="title">
4492 <a name="components.patch.structure"></a>11.3.1. Structure of a single patch file</h3></div></div></div>
4493 <p>The <code class="filename">patch-*</code> files should be in
4494   <span class="command"><strong>diff -bu</strong></span> format, and apply without a fuzz to avoid
4495   problems. (To force patches to apply with fuzz you can set
4496   <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>). Furthermore, each patch
4497   should contain only changes for a single file, and no file should be
4498   patched by more than one patch file. This helps to keep future
4499   modifications simple.</p>
4500 <p>Each patch file is structured as follows: In the first line,
4501   there is the RCS Id of the patch itself. The second line should be
4502   empty for aesthetic reasons. After that, there should be a comment for
4503   each change that the patch does. There are a number of standard
4504   cases:</p>
4505 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
4506 <li class="listitem"><p>Patches for commonly known vulnerabilities should
4507   mention the vulnerability ID (CAN, CVE).</p></li>
4508 <li class="listitem"><p>Patches that change source code should mention the
4509   platform and other environment (for example, the compiler) that the
4510   patch is needed for.</p></li>
4511 </ul></div>
4512 <p>In all, the patch should be commented so that any
4513   developer who knows the code of the application can make some use of
4514   the patch. Special care should be taken for the upstream developers,
4515   since we generally want that they accept our patches, so we have less
4516   work in the future.</p>
4517 </div>
4518 <div class="sect2">
4519 <div class="titlepage"><div><div><h3 class="title">
4520 <a name="components.patches.caveats"></a>11.3.2. Creating patch files</h3></div></div></div>
4521 <p>One important thing to mention is to pay attention that no RCS
4522   IDs get stored in the patch files, as these will cause problems when
4523   later checked into the NetBSD CVS tree. Use the
4524   <span class="command"><strong>pkgdiff</strong></span> command from the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a> package to avoid these
4525   problems.</p>
4526 <p>For even more automation, we recommend using
4527   <span class="command"><strong>mkpatches</strong></span> from the same package to make a
4528   whole set of patches. You just have to backup files before you
4529   edit them to <code class="filename">filename.orig</code>, e.g. with
4530   <span class="command"><strong>cp -p filename filename.orig</strong></span> or, easier, by
4531   using <span class="command"><strong>pkgvi</strong></span> again from the same package. If
4532   you upgrade a package this way, you can easily compare the new
4533   set of patches with the previously existing one with
4534   <span class="command"><strong>patchdiff</strong></span>. The files in <code class="filename">patches</code>
4535   are replaced by new files, so carefully check if you want to take all
4536   the changes.</p>
4537 <p>When you have finished a package, remember to generate
4538   the checksums for the patch files by using the <span class="command"><strong>make
4539   makepatchsum</strong></span> command, see <a class="xref" href="#components.distinfo" title="11.2. distinfo">Section 11.2, &#8220;<code class="filename">distinfo</code>&#8221;</a>.</p>
4540 <p>When adding a patch that corrects a problem in the
4541   distfile (rather than e.g. enforcing pkgsrc's view of where
4542   man pages should go), send the patch as a bug report to the
4543   maintainer.  This benefits non-pkgsrc users of the package,
4544   and usually makes it possible to remove the patch in future
4545   version.</p>
4546 <p>The file names of the patch files are usually of the form
4547   <code class="filename">patch-<em class="replaceable"><code>path_to_file__with__underscores.c</code></em></code>.
4548   Many packages still use the previous convention
4549   <code class="filename">patch-<em class="replaceable"><code>[a-z][a-z]</code></em></code>,
4550   but new patches should be of the form containing the filename.
4551   <span class="command"><strong>mkpatches</strong></span> included in <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a> takes care of the name
4552   automatically.</p>
4553 </div>
4554 <div class="sect2">
4555 <div class="titlepage"><div><div><h3 class="title">
4556 <a name="components.patches.sources"></a>11.3.3. Sources where the patch files come from</h3></div></div></div>
4557 <p>If you want to share patches between multiple packages
4558   in pkgsrc, e.g. because they use the same distfiles, set
4559   <code class="varname">PATCHDIR</code> to the path where the patch files
4560   can be found, e.g.:</p>
4561 <pre class="programlisting">
4562 PATCHDIR= ${.CURDIR}/../xemacs/patches
4563 </pre>
4564 <p>Patch files that are distributed by the author or other
4565     maintainers can be listed in
4566     <code class="varname">PATCHFILES</code>.</p>
4567 <p>If it is desired to store any patches that should not be
4568     committed into pkgsrc, they can be kept outside the pkgsrc
4569     tree in the <code class="filename">$LOCALPATCHES</code> directory. The
4570     directory tree there is expected to have the same
4571     <span class="quote">&#8220;<span class="quote">category/package</span>&#8221;</span> structure as pkgsrc, and
4572     patches are expected to be stored inside these dirs (also
4573     known as <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
4574     example, if you want to keep a private patch for
4575     <code class="filename">pkgsrc/graphics/png</code>, keep it in
4576     <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
4577     files in the named directory are expected to be patch files,
4578     and <span class="emphasis"><em>they are applied after pkgsrc patches are
4579     applied</em></span>.</p>
4580 </div>
4581 <div class="sect2">
4582 <div class="titlepage"><div><div><h3 class="title">
4583 <a name="components.patches.guidelines"></a>11.3.4. Patching guidelines</h3></div></div></div>
4584 <p>When fixing a portability issue in the code do not use
4585       preprocessor magic to check for the current operating system nor
4586       platform.  Doing so hurts portability to other platforms because
4587       the OS-specific details are not abstracted appropriately.</p>
4588 <p>The general rule to follow is: instead of checking for the
4589       operating system the application is being built on, check for the
4590       specific <span class="emphasis"><em>features</em></span> you need.  For example,
4591       instead of assuming that kqueue is available under NetBSD and
4592       using the <code class="varname">__NetBSD__</code> macro to conditionalize
4593       kqueue support, add a check that detects kqueue itself &mdash;
4594       yes, this generally involves patching the
4595       <span class="command"><strong>configure</strong></span> script.  There is absolutely nothing
4596       that prevents some OSes from adopting interfaces from other OSes
4597       (e.g. Linux implementing kqueue), something that the above checks
4598       cannot take into account.</p>
4599 <p>Of course, checking for features generally involves more
4600       work on the developer's side, but the resulting changes are
4601       cleaner and there are chances they will work on many other
4602       platforms.  Not to mention that there are higher chances of being
4603       later integrated into the mainstream sources.  Remember:
4604       <span class="emphasis"><em>It doesn't work unless it is right!</em></span></p>
4605 <p>Some typical examples:</p>
4606 <div class="table">
4607 <a name="patch-examples"></a><p class="title"><b>Table 11.1. Patching examples</b></p>
4608 <div class="table-contents"><table summary="Patching examples" border="1">
4609 <colgroup>
4610 <col>
4611 <col>
4612 <col>
4613 </colgroup>
4614 <thead><tr>
4615 <th>Where</th>
4616 <th>Incorrect</th>
4617 <th>Correct</th>
4618 </tr></thead>
4619 <tbody>
4620 <tr>
4621 <td>configure script</td>
4622 <td>
4623 <pre class="programlisting">
4624 case ${target_os} in
4625 netbsd*) have_kvm=yes ;;
4626 *)       have_kvm=no  ;;
4627 esac
4628 </pre>
4629               </td>
4630 <td>
4631 <pre class="programlisting">
4632 AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)
4633 </pre>
4634               </td>
4635 </tr>
4636 <tr>
4637 <td>C source file</td>
4638 <td>
4639 <pre class="programlisting">
4640 #if defined(__NetBSD__)
4641 #  include &lt;sys/event.h&gt;
4642 #endif
4643 </pre>
4644               </td>
4645 <td>
4646 <pre class="programlisting">
4647 #if defined(HAVE_SYS_EVENT_H)
4648 #  include &lt;sys/event.h&gt;
4649 #endif
4650 </pre>
4651               </td>
4652 </tr>
4653 <tr>
4654 <td>C source file</td>
4655 <td>
4656 <pre class="programlisting">
4657 int
4658 monitor_file(...)
4659 {
4660 #if defined(__NetBSD__)
4661         int fd = kqueue();
4662         ...
4663 #else
4664         ...
4665 #endif
4666 }
4667 </pre>
4668               </td>
4669 <td>
4670 <pre class="programlisting">
4671 int
4672 monitor_file(...)
4673 {
4674 #if defined(HAVE_KQUEUE)
4675         int fd = kqueue();
4676         ...
4677 #else
4678         ...
4679 #endif
4680 }
4681 </pre>
4682               </td>
4683 </tr>
4684 </tbody>
4685 </table></div>
4686 </div>
4687 <br class="table-break"><p>For more information, please read the <span class="emphasis"><em>Making
4688       packager-friendly software</em></span> article (<a class="ulink" href="http://www.onlamp.com/pub/a/onlamp/2005/03/31/packaging.html" target="_top">part
4689       1</a>, <a class="ulink" href="http://www.oreillynet.com/pub/a/onlamp/2005/04/28/packaging2.html" target="_top">part
4690       2</a>).  It summarizes multiple details on how to make
4691       software easier to package; all the suggestions in it were
4692       collected from our experience in pkgsrc work, so they are possibly
4693       helpful when creating patches too.</p>
4694 </div>
4695 <div class="sect2">
4696 <div class="titlepage"><div><div><h3 class="title">
4697 <a name="components.patches.feedback"></a>11.3.5. Feedback to the author</h3></div></div></div>
4698 <p>Always, always, <span class="strong"><strong>always</strong></span>
4699       feed back any <span class="emphasis"><em>portability fixes</em></span> or
4700       improvements you do to a package to the mainstream developers.
4701       This is the only way to get their attention on portability issues
4702       and to ensure that future versions can be built out-of-the box on
4703       NetBSD.  Furthermore, any user that gets newer distfiles will get
4704       the fixes straight from the packaged code.</p>
4705 <p>This generally involves cleaning up the patches
4706       (because sometimes the patches that are
4707       added to pkgsrc are quick hacks), filing bug reports in the
4708       appropriate trackers for the projects and working with the
4709       mainstream authors to accept your changes.  It is
4710       <span class="emphasis"><em>extremely important</em></span> that you do it so that
4711       the packages in pkgsrc are kept simple and thus further changes
4712       can be done without much hassle.</p>
4713 <p>When you have done this, please add a URL to the upstream
4714       bug report to the patch comment.</p>
4715 <p>Support the idea of free software!</p>
4716 </div>
4717 </div>
4718 <div class="sect1">
4719 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4720 <a name="other-mandatory-files"></a>11.4. Other mandatory files</h2></div></div></div>
4721 <div class="variablelist"><dl class="variablelist">
4722 <dt><span class="term"><code class="filename">DESCR</code></span></dt>
4723 <dd><p>A multi-line description of the piece of software.  This should include
4724           any credits where they are due.  Please bear in mind that others do not
4725           share your sense of humour (or spelling idiosyncrasies), and that others
4726           will read everything that you write here.</p></dd>
4727 <dt><span class="term"><code class="filename">PLIST</code></span></dt>
4728 <dd><p>This file governs the files that are installed on your
4729           system: all the binaries, manual pages, etc. There are other
4730           directives which may be entered in this file, to control the
4731           creation and deletion of directories, and the location of
4732           inserted files.  See <a class="xref" href="#plist" title="Chapter 13. PLIST issues">Chapter 13, <i>PLIST issues</i></a> for more
4733           information.</p></dd>
4734 </dl></div>
4735 </div>
4736 <div class="sect1">
4737 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4738 <a name="components.optional"></a>11.5. Optional files</h2></div></div></div>
4739 <div class="sect2">
4740 <div class="titlepage"><div><div><h3 class="title">
4741 <a name="components.optional.bin"></a>11.5.1. Files affecting the binary package</h3></div></div></div>
4742 <div class="variablelist"><dl class="variablelist">
4743 <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
4744 <dd>
4745 <p>This shell script is invoked twice by <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>.
4746             First time after package extraction and before files are
4747             moved in place, the second time after the files to install
4748             are moved in place. This can be used to do any custom
4749             procedures not possible with @exec commands in
4750             <code class="filename">PLIST</code>. See <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> and
4751             <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> for more information.  See also <a class="xref" href="#files-and-dirs-outside-prefix" title="15.1. Files and directories outside the installation prefix">Section 15.1, &#8220;Files and directories outside the installation prefix&#8221;</a>.
4752             Please note that you can modify variables in it easily by using
4753             <code class="varname">FILES_SUBST</code> in the package's
4754             <code class="filename">Makefile</code>:</p>
4755 <pre class="programlisting">
4756 FILES_SUBST+=  SOMEVAR="somevalue"
4757 </pre>
4758 <p>replaces "@SOMEVAR@" with <span class="quote">&#8220;<span class="quote">somevalue</span>&#8221;</span> in the
4759             <code class="filename">INSTALL</code>.  By default, substitution is
4760             performed for <code class="varname">PREFIX</code>,
4761             <code class="varname">LOCALBASE</code>, <code class="varname">X11BASE</code>,
4762             <code class="varname">VARBASE</code>, and a few others, type
4763             <span class="command"><strong>make help topic=FILES_SUBST</strong></span> for a
4764             complete list.</p>
4765 </dd>
4766 <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
4767 <dd><p>This script is executed before and after any files are removed.  It is
4768             this script's responsibility to clean up any additional messy details
4769             around the package's installation, since all pkg_delete knows is how to
4770             delete the files created in the original distribution.
4771             See <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a>
4772             and <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> for more information.
4773             The same methods to replace variables can be used as for
4774             the <code class="filename">INSTALL</code> file.</p></dd>
4775 <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
4776 <dd>
4777 <p>This file is displayed after installation of the package.
4778             Useful for things like legal notices on almost-free
4779             software and hints for updating config files after
4780             installing modules for apache, PHP etc.
4781             Please note that you can modify variables in it easily by using
4782             <code class="varname">MESSAGE_SUBST</code> in the package's
4783             <code class="filename">Makefile</code>:</p>
4784 <pre class="programlisting">
4785 MESSAGE_SUBST+=  SOMEVAR="somevalue"
4786 </pre>
4787 <p>replaces "${SOMEVAR}" with <span class="quote">&#8220;<span class="quote">somevalue</span>&#8221;</span> in
4788             <code class="filename">MESSAGE</code>.  By default, substitution is
4789             performed for <code class="varname">PKGNAME</code>,
4790             <code class="varname">PKGBASE</code>, <code class="varname">PREFIX</code>,
4791             <code class="varname">LOCALBASE</code>, <code class="varname">X11PREFIX</code>,
4792             <code class="varname">X11BASE</code>,
4793             <code class="varname">PKG_SYSCONFDIR</code>,
4794             <code class="varname">ROOT_GROUP</code>, and
4795             <code class="varname">ROOT_USER</code>.</p>
4796 <p>You can display a different or additional files by
4797             setting the <code class="varname">MESSAGE_SRC</code> variable.  Its
4798             default is <code class="filename">MESSAGE</code>, if the file
4799             exists.</p>
4800 </dd>
4801 <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
4802 <dd><p>FIXME: There is no documentation on the
4803         alternatives framework.</p></dd>
4804 </dl></div>
4805 </div>
4806 <div class="sect2">
4807 <div class="titlepage"><div><div><h3 class="title">
4808 <a name="components.optional.build"></a>11.5.2. Files affecting the build process</h3></div></div></div>
4809 <div class="variablelist"><dl class="variablelist">
4810 <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
4811 <dd><p>This file contains arbitrary things that could
4812         also go into a <code class="filename">Makefile</code>, but its purpose is
4813         to be used by more than one package. This file should only be
4814         used when the packages that will use the file are known in
4815         advance. For other purposes it is often better to write a
4816         <code class="filename">*.mk</code> file and give it a good name that
4817         describes what it does.</p></dd>
4818 <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
4819 <dd><p>This file contains the dependency information
4820         for the buildlink3 framework (see <a class="xref" href="#buildlink" title="Chapter 14. Buildlink methodology">Chapter 14, <i>Buildlink methodology</i></a>).</p></dd>
4821 <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
4822 <dd><p>This file contains workarounds for compiler bugs
4823         and similar things. It is included automatically by the pkgsrc
4824         infrastructure, so you don't need an extra
4825         <code class="literal">.include</code> line for
4826         it.</p></dd>
4827 <dt><span class="term"><code class="filename">options.mk</code></span></dt>
4828 <dd><p>This file contains the code for the
4829         package-specific options (see <a class="xref" href="#options" title="Chapter 16. Options handling">Chapter 16, <i>Options handling</i></a>) that can be
4830         selected by the user. If a package has only one or two options,
4831         it is equally acceptable to put the code directly into the
4832         <code class="filename">Makefile</code>.</p></dd>
4833 </dl></div>
4834 </div>
4835 <div class="sect2">
4836 <div class="titlepage"><div><div><h3 class="title">
4837 <a name="components.optional.none"></a>11.5.3. Files affecting nothing at all</h3></div></div></div>
4838 <div class="variablelist"><dl class="variablelist">
4839 <dt><span class="term"><code class="filename">README*</code></span></dt>
4840 <dd><p>These files do not take place in the creation of
4841         a package and thus are purely informative to the package
4842         developer.</p></dd>
4843 <dt><span class="term"><code class="filename">TODO</code></span></dt>
4844 <dd><p>This file contains things that need to be done
4845         to make the package even
4846         better.</p></dd>
4847 </dl></div>
4848 </div>
4849 </div>
4850 <div class="sect1">
4851 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4852 <a name="work-dir"></a>11.6. <code class="filename">work*</code>
4853 </h2></div></div></div>
4854 <p>When you type <span class="command"><strong>make</strong></span>, the distribution files are
4855     unpacked into the directory denoted by
4856     <code class="varname">WRKDIR</code>. It can be removed by running
4857     <span class="command"><strong>make clean</strong></span>. Besides the sources, this
4858     directory is also used to keep various timestamp files.
4859     The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
4860     The default is <code class="filename">${.CURDIR}/work</code>
4861     or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
4862     if <code class="varname">OBJMACHINE</code> is set.</p>
4863 </div>
4864 <div class="sect1">
4865 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4866 <a name="files-dir"></a>11.7. <code class="filename">files/*</code>
4867 </h2></div></div></div>
4868 <p>If you have any files that you wish to be placed in the package prior
4869     to configuration or building, you could place these files here and use
4870     a <span class="command"><strong>${CP}</strong></span> command in the
4871     <span class="quote">&#8220;<span class="quote">pre-configure</span>&#8221;</span> target to achieve
4872     this. Alternatively, you could simply diff the file against
4873     <code class="filename">/dev/null</code> and use the patch mechanism to manage
4874     the creation of this file.</p>
4875 <p>If you want to share files in this way with other
4876     packages, set the <code class="varname">FILESDIR</code> variable to point
4877     to the other package's <code class="filename">files</code> directory,
4878     e.g.:</p>
4879 <pre class="programlisting">
4880 FILESDIR=${.CURDIR}/../xemacs/files
4881 </pre>
4882 </div>
4883 </div>
4884 <div class="chapter">
4885 <div class="titlepage"><div><div><h2 class="title">
4886 <a name="makefile"></a>Chapter 12. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
4887 <div class="toc">
4888 <p><b>Table of Contents</b></p>
4889 <dl>
4890 <dt><span class="sect1"><a href="#makefile.style">12.1. Caveats</a></span></dt>
4891 <dt><span class="sect1"><a href="#makefile.variables">12.2. <code class="filename">Makefile</code> variables</a></span></dt>
4892 <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">12.2.1. Naming conventions</a></span></dt></dl></dd>
4893 <dt><span class="sect1"><a href="#makefile.code">12.3. Code snippets</a></span></dt>
4894 <dd><dl>
4895 <dt><span class="sect2"><a href="#adding-to-list">12.3.1. Adding things to a list</a></span></dt>
4896 <dt><span class="sect2"><a href="#converting-internal-to-external">12.3.2. Converting an internal list into an external list</a></span></dt>
4897 <dt><span class="sect2"><a href="#passing-variable-to-shell">12.3.3. Passing variables to a shell command</a></span></dt>
4898 <dt><span class="sect2"><a href="#quoting-guideline">12.3.4. Quoting guideline</a></span></dt>
4899 <dt><span class="sect2"><a href="#bsd-make-bug-workaround">12.3.5. Workaround for a bug in BSD Make</a></span></dt>
4900 </dl></dd>
4901 </dl>
4902 </div>
4903 <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
4904   each of which forms a well-defined part of the pkgsrc system. Using
4905   the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> system as a programming language for a big system
4906   like pkgsrc requires some discipline to keep the code correct and
4907   understandable.</p>
4908 <p>The basic ingredients for <code class="filename">Makefile</code>
4909   programming are variables (which are actually macros) and shell
4910   commands. Among these shell commands may even be more complex ones
4911   like <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?awk+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">awk</span>(1)</span></a> programs. To make sure that every shell command runs
4912   as intended it is necessary to quote all variables correctly when they
4913   are used.</p>
4914 <p>This chapter describes some patterns, that appear quite often in
4915   <code class="filename">Makefile</code>s, including the pitfalls that come along
4916   with them.</p>
4917 <div class="sect1">
4918 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4919 <a name="makefile.style"></a>12.1. Caveats</h2></div></div></div>
4920 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
4921 <p>When you are creating a file as a
4922     target of a rule, always write the data to a temporary file first
4923     and finally rename that file. Otherwise there might occur an error
4924     in the middle of generating the file, and when the user runs
4925     <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> for the second time, the file exists and will not be
4926     regenerated properly. Example:</p>
4927 <pre class="programlisting">
4928 wrong:
4929         @echo "line 1" &gt; ${.TARGET}
4930         @echo "line 2" &gt;&gt; ${.TARGET}
4931         @false
4932
4933 correct:
4934         @echo "line 1" &gt; ${.TARGET}.tmp
4935         @echo "line 2" &gt;&gt; ${.TARGET}.tmp
4936         @false
4937         @mv ${.TARGET}.tmp ${.TARGET}
4938 </pre>
4939 <p>When you run <span class="command"><strong>make wrong</strong></span> twice, the file
4940     <code class="filename">wrong</code> will exist, although there was an error
4941     message in the first run. On the other hand, running <span class="command"><strong>make
4942     correct</strong></span> gives an error message twice, as expected.</p>
4943 <p>You might remember that <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> sometimes removes
4944     <code class="literal">${.TARGET}</code> in case of error, but this only
4945     happens when it is interrupted, for example by pressing
4946     <code class="literal">^C</code>. This does <span class="emphasis"><em>not</em></span> happen
4947     when one of the commands fails (like <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?false+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">false</span>(1)</span></a> above).</p>
4948 </li></ul></div>
4949 </div>
4950 <div class="sect1">
4951 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
4952 <a name="makefile.variables"></a>12.2. <code class="filename">Makefile</code> variables</h2></div></div></div>
4953 <p><code class="filename">Makefile</code> variables contain strings that
4954     can be processed using the five operators ``='', ``+='', ``?='',
4955     ``:='', and ``!='', which are described in the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> man
4956     page.</p>
4957 <p>When a variable's value is parsed from a
4958     <code class="filename">Makefile</code>, the hash character ``#'' and the
4959     backslash character ``\'' are handled specially. If a backslash is
4960     followed by a newline, any whitespace immediately in front of the
4961     backslash, the backslash, the newline, and any whitespace
4962     immediately behind the newline are replaced with a single space. A
4963     backslash character and an immediately following hash character are
4964     replaced with a single hash character. Otherwise, the backslash is
4965     passed as is. In a variable assignment, any hash character that is
4966     not preceded by a backslash starts a comment that continues upto the
4967     end of the logical line.</p>
4968 <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
4969     the only way to create a variable consisting of a single backslash
4970     is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
4971 <p>So far for defining variables. The other thing you can do with
4972     variables is evaluating them. A variable is evaluated when it is
4973     part of the right side of the ``:='' or the ``!='' operator, or
4974     directly before executing a shell command which the variable is part
4975     of. In all other cases, <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> performs lazy evaluation, that
4976     is, variables are not evaluated until there's no other way. The
4977     ``modifiers'' mentioned in the man page also evaluate the
4978     variable.</p>
4979 <p>Some of the modifiers split the string into words and then
4980     operate on the words, others operate on the string as a whole. When
4981     a string is split into words, it is split as you would expect
4982     it from <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?sh+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">sh</span>(1)</span></a>.</p>
4983 <p>No rule without exception&mdash;the <span class="command"><strong>.for</strong></span>
4984     loop does not follow the shell quoting rules but splits at sequences
4985     of whitespace.</p>
4986 <p>There are several types of variables that should be handled
4987     differently. Strings and two types of lists.</p>
4988 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
4989 <li class="listitem"><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
4990       characters. Nevertheless, you should restrict yourself to only
4991       using printable characters. Examples are
4992       <code class="varname">PREFIX</code> and
4993       <code class="varname">COMMENT</code>.</p></li>
4994 <li class="listitem"><p><span class="emphasis"><em>Internal lists</em></span> are lists that
4995       are never exported to any shell command. Their elements are
4996       separated by whitespace. Therefore, the elements themselves cannot
4997       have embedded whitespace. Any other characters are allowed.
4998       Internal lists can be used in <span class="command"><strong>.for</strong></span> loops.
4999       Examples are <code class="varname">DEPENDS</code> and
5000       <code class="varname">BUILD_DEPENDS</code>.</p></li>
5001 <li class="listitem"><p><span class="emphasis"><em>External lists</em></span> are lists that
5002       may be exported to a shell command. Their elements can contain any
5003       characters, including whitespace. That's why they cannot be used
5004       in <span class="command"><strong>.for</strong></span> loops. Examples are
5005       <code class="varname">DISTFILES</code> and
5006       <code class="varname">MASTER_SITES</code>.</p></li>
5007 </ul></div>
5008 <div class="sect2">
5009 <div class="titlepage"><div><div><h3 class="title">
5010 <a name="makefile.variables.names"></a>12.2.1. Naming conventions</h3></div></div></div>
5011 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
5012 <li class="listitem"><p>All variable names starting with an underscore
5013         are reserved for use by the pkgsrc infrastructure. They shall
5014         not be used by package
5015         <code class="filename">Makefile</code>s.</p></li>
5016 <li class="listitem"><p>In <span class="command"><strong>.for</strong></span> loops you should use
5017         lowercase variable names for the iteration
5018         variables.</p></li>
5019 <li class="listitem"><p>All list variables should have a ``plural''
5020         name, e.g. <code class="varname">PKG_OPTIONS</code> or
5021         <code class="varname">DISTFILES</code>.</p></li>
5022 </ul></div>
5023 </div>
5024 </div>
5025 <div class="sect1">
5026 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5027 <a name="makefile.code"></a>12.3. Code snippets</h2></div></div></div>
5028 <p>This section presents you with some code snippets you should
5029     use in your own code. If you don't find anything appropriate here,
5030     you should test your code and add it here.</p>
5031 <div class="sect2">
5032 <div class="titlepage"><div><div><h3 class="title">
5033 <a name="adding-to-list"></a>12.3.1. Adding things to a list</h3></div></div></div>
5034 <pre class="programlisting">
5035 STRING=                 foo * bar `date`
5036 INT_LIST=               # empty
5037 ANOTHER_INT_LIST=       apache-[0-9]*:../../www/apache
5038 EXT_LIST=               # empty
5039 ANOTHER_EXT_LIST=       a=b c=d
5040
5041 INT_LIST+=              ${STRING}               # 1
5042 INT_LIST+=              ${ANOTHER_INT_LIST}     # 2
5043 EXT_LIST+=              ${STRING:Q}             # 3
5044 EXT_LIST+=              ${ANOTHER_EXT_LIST}     # 4
5045 </pre>
5046 <p>When you add a string to an external list (example 3), it
5047       must be quoted. In all other cases, you must not add a quoting
5048       level. You must not merge internal and external lists, unless you
5049       are sure that all entries are correctly interpreted in both
5050       lists.</p>
5051 </div>
5052 <div class="sect2">
5053 <div class="titlepage"><div><div><h3 class="title">
5054 <a name="converting-internal-to-external"></a>12.3.2. Converting an internal list into an external list</h3></div></div></div>
5055 <pre class="programlisting">
5056 EXT_LIST=       # empty
5057 .for i in ${INT_LIST}
5058 EXT_LIST+=      ${i:Q}""
5059 .endfor
5060 </pre>
5061 <p>This code converts the internal list
5062       <code class="varname">INT_LIST</code> into the external list
5063       <code class="varname">EXT_LIST</code>. As the elements of an internal list
5064       are unquoted they must be quoted here. The reason for appending
5065       <code class="varname">""</code> is explained below.</p>
5066 </div>
5067 <div class="sect2">
5068 <div class="titlepage"><div><div><h3 class="title">
5069 <a name="passing-variable-to-shell"></a>12.3.3. Passing variables to a shell command</h3></div></div></div>
5070 <p>Sometimes you may want to print an arbitrary string. There
5071         are many ways to get it wrong and only few that can handle every
5072         nastiness.</p>
5073 <pre class="programlisting">
5074 STRING=         foo bar &lt;    &gt; * `date` $$HOME ' "
5075 EXT_LIST=       string=${STRING:Q} x=second\ item
5076
5077 all:
5078         echo ${STRING}                  # 1
5079         echo "${STRING}"                # 2
5080         echo "${STRING:Q}"              # 3
5081         echo ${STRING:Q}                # 4
5082         echo x${STRING:Q} | sed 1s,.,,  # 5
5083         printf "%s\\n" ${STRING:Q}""    # 6
5084         env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
5085 </pre>
5086 <p>Example 1 leads to a syntax error in the shell, as the
5087       characters are just copied.</p>
5088 <p>Example 2 leads to a syntax error too, and if you leave out
5089       the last " character from <code class="varname">${STRING}</code>,
5090       <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?date+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">date</span>(1)</span></a> will be executed. The <code class="varname">$HOME</code> shell
5091       variable would be evaluated, too.</p>
5092 <p>Example 3 outputs each space character preceded by a
5093       backslash (or not), depending on the implementation of the
5094       <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command.</p>
5095 <p>Example 4 handles correctly every string that does not start
5096       with a dash. In that case, the result depends on the
5097       implementation of the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command. As long as you can
5098       guarantee that your input does not start with a dash, this form is
5099       appropriate.</p>
5100 <p>Example 5 handles even the case of a leading dash
5101       correctly.</p>
5102 <p>Example 6 also works with every string and is the
5103       light-weight solution, since it does not involve a pipe, which has
5104       its own problems.</p>
5105 <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
5106       because the quoting has already been done when adding elements to
5107       the list.</p>
5108 <p>As internal lists shall not be passed to the shell, there is
5109       no example for it.</p>
5110 </div>
5111 <div class="sect2">
5112 <div class="titlepage"><div><div><h3 class="title">
5113 <a name="quoting-guideline"></a>12.3.4. Quoting guideline</h3></div></div></div>
5114 <p>There are many possible sources of wrongly quoted variables.
5115       This section lists some of the commonly known ones.</p>
5116 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
5117 <li class="listitem">
5118 <p>Whenever you use the value of a list, think
5119         about what happens to leading or trailing whitespace. If the
5120         list is a well-formed shell expression, you can apply the
5121         <code class="varname">:M*</code> modifier to strip leading and trailing
5122         whitespace from each word. The <code class="varname">:M</code> operator
5123         first splits its argument according to the rules of the shell,
5124         and then creates a new list consisting of all words that match
5125         the shell glob expression <code class="varname">*</code>, that is: all.
5126         One class of situations where this is needed is when adding a
5127         variable like <code class="varname">CPPFLAGS</code> to
5128         <code class="varname">CONFIGURE_ARGS</code>. If the configure script
5129         invokes other configure scripts, it strips the leading and
5130         trailing whitespace from the variable and then passes it to the
5131         other configure scripts. But these configure scripts expect the
5132         (child) <code class="varname">CPPFLAGS</code> variable to be the same as
5133         the parent <code class="varname">CPPFLAGS</code>. That's why we better
5134         pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
5135         here is how we do it:</p>
5136 <pre class="programlisting">
5137 CPPFLAGS=               # empty
5138 CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX:Q}\"
5139 CPPFLAGS+=              ${MY_CPPFLAGS}
5140
5141 CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
5142
5143 all:
5144         echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
5145         echo x${CONFIGURE_ARGS}x        # properly trimmed
5146 </pre>
5147 </li>
5148 <li class="listitem"><p>The example above contains one bug: The
5149         <code class="varname">${PREFIX}</code> is a properly quoted shell
5150         expression, but there is the C compiler after it, which also
5151         expects a properly quoted string (this time in C syntax). The
5152         version above is therefore only correct if
5153         <code class="varname">${PREFIX}</code> does not have embedded backslashes
5154         or double quotes. If you want to allow these, you have to add
5155         another layer of quoting to each variable that is used as a C
5156         string literal. You cannot use the <code class="varname">:Q</code>
5157         operator for it, as this operator only works for the
5158         shell.</p></li>
5159 <li class="listitem">
5160 <p>Whenever a variable can be empty, the
5161         <code class="varname">:Q</code> operator can have surprising results. Here
5162         are two completely different cases which can be solved with the
5163         same trick.</p>
5164 <pre class="programlisting">
5165 EMPTY=                  # empty
5166 empty_test:
5167         for i in a ${EMPTY:Q} c; do \
5168             echo "$$i"; \
5169         done
5170
5171 for_test:
5172 .for i in a:\ a:\test.txt
5173         echo ${i:Q}
5174         echo "foo"
5175 .endfor
5176 </pre>
5177 <p>The first example will only print two of the three lines
5178         we might have expected. This is because
5179         <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
5180         the shell cannot see. The workaround is to write
5181         <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
5182         as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
5183         -f ${FNAME:Q}</code> (both of these are wrong).</p>
5184 <p>The second example will only print three lines instead of
5185         four. The first line looks like <code class="varname">a:\ echo foo</code>.
5186         This is because the backslash of the value
5187         <code class="varname">a:\</code> is interpreted as a line-continuation by
5188         <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>, which makes the second line the arguments of the
5189         <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command from the first line. To avoid this, write
5190         <code class="varname">${i:Q}""</code>.</p>
5191 </li>
5192 </ul></div>
5193 </div>
5194 <div class="sect2">
5195 <div class="titlepage"><div><div><h3 class="title">
5196 <a name="bsd-make-bug-workaround"></a>12.3.5. Workaround for a bug in BSD Make</h3></div></div></div>
5197 <p>The pkgsrc bmake program does not handle the following
5198       assignment correctly. In case <code class="varname">_othervar_</code>
5199       contains a ``-'' character, one of the closing braces is included
5200       in <code class="varname">${VAR}</code> after this code executes.</p>
5201 <pre class="programlisting">
5202 VAR:=   ${VAR:N${_othervar_:C/-//}}
5203 </pre>
5204 <p>For a more complex code snippet and a workaround, see the
5205       package <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/regress/make-quoting/README.html" target="_top"><code class="filename">regress/make-quoting</code></a>, testcase
5206       <code class="varname">bug1</code>.</p>
5207 </div>
5208 </div>
5209 </div>
5210 <div class="chapter">
5211 <div class="titlepage"><div><div><h2 class="title">
5212 <a name="plist"></a>Chapter 13. PLIST issues</h2></div></div></div>
5213 <div class="toc">
5214 <p><b>Table of Contents</b></p>
5215 <dl>
5216 <dt><span class="sect1"><a href="#rcs-id">13.1. RCS ID</a></span></dt>
5217 <dt><span class="sect1"><a href="#automatic-plist-generation">13.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
5218 <dt><span class="sect1"><a href="#print-PLIST">13.3. Tweaking output of <span class="command"><strong>make print-PLIST</strong></span></a></span></dt>
5219 <dt><span class="sect1"><a href="#plist.misc">13.4. Variable substitution in PLIST</a></span></dt>
5220 <dt><span class="sect1"><a href="#manpage-compression">13.5. Man page compression</a></span></dt>
5221 <dt><span class="sect1"><a href="#using-PLIST_SRC">13.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
5222 <dt><span class="sect1"><a href="#platform-specific-plist">13.7. Platform-specific and differing PLISTs</a></span></dt>
5223 <dt><span class="sect1"><a href="#faq.common-dirs">13.8. Sharing directories between packages</a></span></dt>
5224 </dl>
5225 </div>
5226 <p>The <code class="filename">PLIST</code> file contains a package's
5227   <span class="quote">&#8220;<span class="quote">packing list</span>&#8221;</span>, i.e. a list of files that belong to
5228   the package (relative to the <code class="filename">${PREFIX}</code>
5229   directory it's been installed in) plus some additional statements
5230   - see the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> man page for a full list.
5231   This chapter addresses some issues that need attention when
5232   dealing with the <code class="filename">PLIST</code> file (or files, see
5233   below!).</p>
5234 <div class="sect1">
5235 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5236 <a name="rcs-id"></a>13.1. RCS ID</h2></div></div></div>
5237 <p>Be sure to add a RCS ID line as the first thing in any
5238     <code class="filename">PLIST</code> file you write:</p>
5239 <pre class="programlisting">
5240 @comment $NetBSD$
5241     </pre>
5242 </div>
5243 <div class="sect1">
5244 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5245 <a name="automatic-plist-generation"></a>13.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
5246 <p>You can use the <span class="command"><strong>make print-PLIST</strong></span> command
5247     to output a PLIST that matches any new files since the package
5248     was extracted.  See <a class="xref" href="#build.helpful-targets" title="17.17. Other helpful targets">Section 17.17, &#8220;Other helpful targets&#8221;</a> for
5249     more information on this target.</p>
5250 </div>
5251 <div class="sect1">
5252 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5253 <a name="print-PLIST"></a>13.3. Tweaking output of <span class="command"><strong>make print-PLIST</strong></span>
5254 </h2></div></div></div>
5255 <p>If you have used any of the *-dirs packages, as explained in
5256     <a class="xref" href="#faq.common-dirs" title="13.8. Sharing directories between packages">Section 13.8, &#8220;Sharing directories between packages&#8221;</a>, you may have noticed that
5257     <span class="command"><strong>make print-PLIST</strong></span> outputs a set of
5258     <code class="varname">@comment</code>s instead of real
5259     <code class="varname">@dirrm</code> lines.  You can also do this for
5260     specific directories and files, so that the results of that
5261     command are very close to reality. This helps <span class="emphasis"><em>a
5262     lot</em></span> during the update of packages.</p>
5263 <p>The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
5264     of AWK patterns and actions that are used to filter the output of
5265     print-PLIST.  You can <span class="emphasis"><em>append</em></span> any chunk of AWK
5266     scripting you like to it, but be careful with quoting.</p>
5267 <p>For example, to get all files inside the
5268     <code class="filename">libdata/foo</code> directory removed from the
5269     resulting PLIST:</p>
5270 <pre class="programlisting">
5271 PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
5272     </pre>
5273 <p>And to get all the <code class="varname">@dirrm</code> lines referring
5274     to a specific (shared) directory converted to
5275     <code class="varname">@comment</code>s:</p>
5276 <pre class="programlisting">
5277 PRINT_PLIST_AWK+=       /^@dirrm share\/specific/ { print "@comment " $$0; next; }
5278     </pre>
5279 </div>
5280 <div class="sect1">
5281 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5282 <a name="plist.misc"></a>13.4. Variable substitution in PLIST</h2></div></div></div>
5283 <p>A number of variables are substituted automatically in
5284     PLISTs when a package is installed on a system. This includes the
5285     following variables:</p>
5286 <div class="variablelist"><dl class="variablelist">
5287 <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
5288 <dd>
5289 <p>Some packages like emacs and perl embed information
5290           about which architecture they were built on into the
5291           pathnames where they install their files. To handle this
5292           case, PLIST will be preprocessed before actually used, and
5293           the symbol
5294           <span class="quote">&#8220;<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>&#8221;</span> will be
5295           replaced by what <span class="command"><strong>uname -p</strong></span> gives. The
5296           same is done if the string
5297           <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
5298           PLIST somewhere - use this on packages that have GNU
5299           autoconf-created configure scripts.</p>
5300 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
5301 <h3 class="title">Legacy note</h3>
5302 <p>There used to be a symbol
5303             <span class="quote">&#8220;<span class="quote"><code class="varname">$ARCH</code></span>&#8221;</span> that
5304             was replaced by the output of <span class="command"><strong>uname
5305             -m</strong></span>, but that's no longer supported and has
5306             been removed.</p>
5307 </div>
5308 </dd>
5309 <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
5310 <dd>
5311 <p>Some packages want to embed the OS name and version
5312           into some paths.  To do this, use these variables in the
5313           <code class="filename">PLIST</code>:
5314           </p>
5315 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
5316 <li class="listitem"><p><code class="varname">${OPSYS}</code> - output of <span class="quote">&#8220;<span class="quote"><span class="command"><strong>uname -s</strong></span></span>&#8221;</span></p></li>
5317 <li class="listitem"><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. <span class="quote">&#8220;<span class="quote">solaris</span>&#8221;</span>)</p></li>
5318 <li class="listitem"><p><code class="varname">${OS_VERSION}</code> - <span class="quote">&#8220;<span class="quote"><span class="command"><strong>uname -r</strong></span></span>&#8221;</span></p></li>
5319 </ul></div>
5320 </dd>
5321 </dl></div>
5322 <p>For a complete list of values which are replaced by
5323     default, please look in <code class="filename">bsd.pkg.mk</code> (and
5324     search for <code class="varname">PLIST_SUBST</code>).</p>
5325 <p>If you want to change other variables not listed above, you
5326     can add variables and their expansions to this variable in the
5327     following way, similar to <code class="varname">MESSAGE_SUBST</code> (see <a class="xref" href="#components.optional" title="11.5. Optional files">Section 11.5, &#8220;Optional files&#8221;</a>):</p>
5328 <pre class="programlisting">
5329 PLIST_SUBST+=   SOMEVAR="somevalue"
5330     </pre>
5331 <p>This replaces all occurrences of <span class="quote">&#8220;<span class="quote">${SOMEVAR}</span>&#8221;</span>
5332     in the <code class="filename">PLIST</code> with
5333     <span class="quote">&#8220;<span class="quote">somevalue</span>&#8221;</span>.</p>
5334 <p>The <code class="varname">PLIST_VARS</code> variable can be used to simplify
5335     the common case of conditionally including some
5336     <code class="filename">PLIST</code> entries. It can be done by adding
5337     <code class="literal"><code class="varname">PLIST_VARS</code>+=foo</code> and
5338     setting the corresponding <code class="varname">PLIST.foo</code> variable
5339     to <code class="literal">yes</code> if the entry should be included.
5340     This will substitute <span class="quote">&#8220;<span class="quote"><code class="varname">${PLIST.foo}</code></span>&#8221;</span>
5341     in the <code class="filename">PLIST</code> with either
5342     <span class="quote">&#8220;<span class="quote"><code class="literal">""</code></span>&#8221;</span> or
5343     <span class="quote">&#8220;<span class="quote"><code class="literal">"@comment "</code></span>&#8221;</span>.
5344     For example, in <code class="filename">Makefile</code>:</p>
5345 <pre class="programlisting">
5346 PLIST_VARS+=    foo
5347 .if <em class="replaceable"><code>condition</code></em>
5348 PLIST.foo=      yes
5349 .else
5350     </pre>
5351 <p>And then in <code class="filename">PLIST</code>:</p>
5352 <pre class="programlisting">
5353 @comment $NetBSD$
5354 bin/bar
5355 man/man1/bar.1
5356 ${PLIST.foo}bin/foo
5357 ${PLIST.foo}man/man1/foo.1
5358 ${PLIST.foo}share/bar/foo.data
5359 ${PLIST.foo}@dirrm share/bar
5360     </pre>
5361 </div>
5362 <div class="sect1">
5363 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5364 <a name="manpage-compression"></a>13.5. Man page compression</h2></div></div></div>
5365 <p>Man pages should be installed in compressed form if
5366     <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
5367     and uncompressed otherwise. To handle this in the
5368     <code class="filename">PLIST</code> file, the suffix <span class="quote">&#8220;<span class="quote">.gz</span>&#8221;</span> is
5369     appended/removed automatically for man pages according to
5370     <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
5371     or not, see above for details. This modification of the
5372     <code class="filename">PLIST</code> file is done on a copy of it, not
5373     <code class="filename">PLIST</code> itself.</p>
5374 </div>
5375 <div class="sect1">
5376 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5377 <a name="using-PLIST_SRC"></a>13.6. Changing PLIST source with <code class="varname">PLIST_SRC</code>
5378 </h2></div></div></div>
5379 <p>To use one or more files as source for the <code class="filename">PLIST</code> used
5380     in generating the binary package, set the variable
5381     <code class="varname">PLIST_SRC</code> to the names of that file(s).
5382     The files are later concatenated using <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?cat+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">cat</span>(1)</span></a>, and the order of things is
5383     important. The default for <code class="varname">PLIST_SRC</code> is
5384     <code class="filename">${PKGDIR}/PLIST</code>.</p>
5385 </div>
5386 <div class="sect1">
5387 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5388 <a name="platform-specific-plist"></a>13.7. Platform-specific and differing PLISTs</h2></div></div></div>
5389 <p>Some packages decide to install a different set of files based on
5390     the operating system being used. These differences can be
5391     automatically handled by using the following files:</p>
5392 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
5393 <li class="listitem"><p><code class="filename">PLIST.common</code></p></li>
5394 <li class="listitem"><p><code class="filename">PLIST.${OPSYS}</code></p></li>
5395 <li class="listitem"><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
5396 <li class="listitem"><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
5397 <li class="listitem"><p><code class="filename">PLIST.common_end</code></p></li>
5398 </ul></div>
5399 </div>
5400 <div class="sect1">
5401 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5402 <a name="faq.common-dirs"></a>13.8. Sharing directories between packages</h2></div></div></div>
5403 <p>A <span class="quote">&#8220;<span class="quote">shared directory</span>&#8221;</span> is a directory where
5404     multiple (and unrelated) packages install files.  These
5405     directories were problematic because you had to add special
5406     tricks in the PLIST to conditionally remove them, or have some
5407     centralized package handle them.</p>
5408 <p>In pkgsrc, it is now easy: Each package should create
5409     directories and install files as needed; <span class="command"><strong>pkg_delete</strong></span>
5410     will remove any directories left empty after uninstalling a
5411     package.</p>
5412 <p>If a package needs an empty directory to work, create
5413     the directory during installation as usual, and also add an
5414     entry to the PLIST:
5415     </p>
5416 <pre class="programlisting">
5417 @pkgdir path/to/empty/directory
5418     </pre>
5419 <p>
5420     </p>
5421 </div>
5422 </div>
5423 <div class="chapter">
5424 <div class="titlepage"><div><div><h2 class="title">
5425 <a name="buildlink"></a>Chapter 14. Buildlink methodology</h2></div></div></div>
5426 <div class="toc">
5427 <p><b>Table of Contents</b></p>
5428 <dl>
5429 <dt><span class="sect1"><a href="#converting-to-buildlink3">14.1. Converting packages to use buildlink3</a></span></dt>
5430 <dt><span class="sect1"><a href="#creating-buildlink3.mk">14.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
5431 <dd><dl>
5432 <dt><span class="sect2"><a href="#anatomy-of-bl3">14.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
5433 <dt><span class="sect2"><a href="#updating-buildlink-depends">14.2.2. Updating
5434       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5435       and
5436       <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5437       in <code class="filename">buildlink3.mk</code> files</a></span></dt>
5438 </dl></dd>
5439 <dt><span class="sect1"><a href="#writing-builtin.mk">14.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
5440 <dd><dl>
5441 <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">14.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
5442 <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">14.3.2. Global preferences for native or pkgsrc software</a></span></dt>
5443 </dl></dd>
5444 </dl>
5445 </div>
5446 <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
5447   are seen by a package's configure and build processes.  This is implemented
5448   in a two step process:</p>
5449 <div class="orderedlist"><ol class="orderedlist" type="1">
5450 <li class="listitem"><p>Symlink headers and libraries for dependencies into
5451       <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
5452       of <code class="varname">WRKDIR</code>.</p></li>
5453 <li class="listitem"><p>Create wrapper scripts that are used in place of the normal compiler
5454       tools that translate <code class="option">-I${LOCALBASE}/include</code> and
5455       <code class="option">-L${LOCALBASE}/lib</code> into references to
5456       <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
5457       native compiler on some operating systems look like GCC, so that
5458       packages that expect GCC won't require modifications to build with
5459       those native compilers.</p></li>
5460 </ol></div>
5461 <p>This normalizes the environment in which a package is built so that the
5462   package may be built consistently despite what other software may be
5463   installed. Please note that the normal system header and library paths,
5464   e.g. <code class="filename">/usr/include</code>,
5465   <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
5466   designed to insulate the package build from non-system-supplied
5467   software.</p>
5468 <div class="sect1">
5469 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5470 <a name="converting-to-buildlink3"></a>14.1. Converting packages to use buildlink3</h2></div></div></div>
5471 <p>The process of converting packages to use the buildlink3
5472     framework (<span class="quote">&#8220;<span class="quote">bl3ifying</span>&#8221;</span>) is fairly straightforward.
5473     The things to keep in mind are:</p>
5474 <div class="orderedlist"><ol class="orderedlist" type="1">
5475 <li class="listitem"><p>Ensure that the build always calls the wrapper scripts
5476         instead of the actual toolchain.  Some packages are tricky,
5477         and the only way to know for sure is the check
5478         <code class="filename">${WRKDIR}/.work.log</code> to see if the
5479         wrappers are being invoked.</p></li>
5480 <li class="listitem"><p>Don't override <code class="varname">PREFIX</code> from within
5481         the package Makefile, e.g. Java VMs, standalone shells,
5482         etc., because the code to symlink files into
5483         <code class="filename">${BUILDLINK_DIR}</code> looks for files
5484         relative to <span class="quote">&#8220;<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>&#8221;</span>.
5485         </p></li>
5486 <li class="listitem"><p>Remember that <span class="emphasis"><em>only</em></span> the
5487         <code class="filename">buildlink3.mk</code> files that you list in a
5488         package's Makefile are added as dependencies for that package.
5489         </p></li>
5490 </ol></div>
5491 <p>If a dependency on a particular package is required for its libraries and
5492     headers, then we replace:</p>
5493 <pre class="programlisting">
5494 DEPENDS+=       foo&gt;=1.1.0:../../category/foo
5495 </pre>
5496 <p>with</p>
5497 <pre class="programlisting">
5498 .include "../../category/foo/buildlink3.mk"
5499 </pre>
5500 <p>The buildlink3.mk files usually define the required dependencies.
5501     If you need a newer version of the dependency when using buildlink3.mk
5502     files, then you can define it in your Makefile; for example:</p>
5503 <pre class="programlisting">
5504 BUILDLINK_API_DEPENDS.foo+=   foo&gt;=1.1.0
5505 .include "../../category/foo/buildlink3.mk"
5506 </pre>
5507 <p>There are several <code class="filename">buildlink3.mk</code>
5508     files in <code class="filename">pkgsrc/mk</code>
5509     that handle special package issues:</p>
5510 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
5511 <li class="listitem"><p><code class="filename">bdb.buildlink3.mk</code> chooses either
5512         the native or a pkgsrc Berkeley DB implementation based on
5513         the values of <code class="varname">BDB_ACCEPTED</code> and
5514         <code class="varname">BDB_DEFAULT</code>.</p></li>
5515 <li class="listitem"><p><code class="filename">curses.buildlink3.mk</code>: If the system
5516         comes with neither Curses nor NCurses, this will take care
5517         to install the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/ncurses/README.html" target="_top"><code class="filename">devel/ncurses</code></a> package.</p></li>
5518 <li class="listitem"><p><code class="filename">krb5.buildlink3.mk</code> uses the value
5519         of <code class="varname">KRB5_ACCEPTED</code> to choose between
5520         adding a dependency on Heimdal or MIT-krb5 for packages that
5521         require a Kerberos 5 implementation.</p></li>
5522 <li class="listitem"><p><code class="filename">motif.buildlink3.mk</code> checks for a
5523         system-provided Motif installation or adds a dependency on
5524         <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/lesstif/README.html" target="_top"><code class="filename">x11/lesstif</code></a>, <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/motif/README.html" target="_top"><code class="filename">x11/motif</code></a> or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/openmotif/README.html" target="_top"><code class="filename">x11/openmotif</code></a>.  The user can set
5525         <code class="varname">MOTIF_TYPE</code> to <span class="quote">&#8220;<span class="quote">dt</span>&#8221;</span>,
5526         <span class="quote">&#8220;<span class="quote">lesstif</span>&#8221;</span>, <span class="quote">&#8220;<span class="quote">motif</span>&#8221;</span> or
5527         <span class="quote">&#8220;<span class="quote">openmotif</span>&#8221;</span> to choose
5528         which Motif version will be used.</p></li>
5529 <li class="listitem"><p><code class="filename">oss.buildlink3.mk</code> defines several
5530         variables that may be used by packages that use the
5531         Open Sound System (OSS) API.</p></li>
5532 <li class="listitem"><p><code class="filename">pgsql.buildlink3.mk</code> will accept
5533         any of the Postgres versions in the variable
5534         <code class="varname">PGSQL_VERSIONS_ACCEPTED</code> and default to
5535         the version <code class="varname">PGSQL_VERSION_DEFAULT</code>. See
5536         the file for more information.</p></li>
5537 <li class="listitem"><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
5538         <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
5539         a dependency on <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/pth/README.html" target="_top"><code class="filename">devel/pth</code></a> as needed.</p></li>
5540 <li class="listitem"><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
5541         <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
5542         library.</p></li>
5543 </ul></div>
5544 <p>The comments in those <code class="filename">buildlink3.mk</code>
5545     files provide a more complete
5546     description of how to use them properly.</p>
5547 </div>
5548 <div class="sect1">
5549 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5550 <a name="creating-buildlink3.mk"></a>14.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
5551 <a name="buildlink3.mk"></a><p>A package's <code class="filename">buildlink3.mk</code> file is
5552     included by Makefiles to indicate the need to compile and link
5553     against header files and libraries provided by the package.  A
5554     <code class="filename">buildlink3.mk</code> file should always provide
5555     enough information to add the correct type of dependency
5556     relationship and include any other
5557     <code class="filename">buildlink3.mk</code> files that it needs to find
5558     headers and libraries that it needs in turn.</p>
5559 <p>To generate an initial <code class="filename">buildlink3.mk</code>
5560     file for further editing, Rene Hexel's <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/createbuildlink/README.html" target="_top"><code class="filename">pkgtools/createbuildlink</code></a>
5561     package is highly recommended.  For most packages, the following
5562     command will generate a good starting point for
5563     <code class="filename">buildlink3.mk</code> files:</p>
5564 <pre class="screen">
5565 <code class="prompt">%</code> <strong class="userinput"><code>cd pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>pkgdir</code></em>
5566 <code class="prompt">%</code> createbuildlink &gt;buildlink3.mk</code></strong>
5567     </pre>
5568 <div class="sect2">
5569 <div class="titlepage"><div><div><h3 class="title">
5570 <a name="anatomy-of-bl3"></a>14.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
5571 <p>The following real-life example
5572       <code class="filename">buildlink3.mk</code> is taken
5573       from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
5574 <pre class="programlisting">
5575 # $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
5576
5577 BUILDLINK_TREE+=        tiff
5578
5579 .if !defined(TIFF_BUILDLINK3_MK)
5580 TIFF_BUILDLINK3_MK:=
5581
5582 BUILDLINK_API_DEPENDS.tiff+=    tiff&gt;=3.6.1
5583 BUILDLINK_ABI_DEPENDS.tiff+=    tiff&gt;=3.7.2nb1
5584 BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
5585
5586 .include "../../devel/zlib/buildlink3.mk"
5587 .include "../../graphics/jpeg/buildlink3.mk"
5588 .endif # TIFF_BUILDLINK3_MK
5589
5590 BUILDLINK_TREE+=        -tiff
5591 </pre>
5592 <p>The header and footer manipulate
5593       <code class="varname">BUILDLINK_TREE</code>, which is common across all
5594       <code class="filename">buildlink3.mk</code> files and is used to track
5595       the dependency tree.</p>
5596 <p>The main section is protected from multiple inclusion
5597       and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
5598       added.  Several important variables are set in the section:</p>
5599 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
5600 <li class="listitem"><p><code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5601           is the actual dependency recorded in the installed
5602           package; this should always be set using
5603           <span class="command"><strong>+=</strong></span> to ensure that
5604           we're appending to any pre-existing list of values.  This
5605           variable should be set to the first version of the
5606           package that had an backwards-incompatible API change.
5607           </p></li>
5608 <li class="listitem"><p><code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
5609           is the location of the <em class="replaceable"><code>pkg</code></em>
5610           pkgsrc directory.</p></li>
5611 <li class="listitem"><p><code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
5612           (not shown above) controls whether we use
5613           <code class="varname">BUILD_DEPENDS</code> or
5614           <code class="varname">DEPENDS</code> to add the dependency on
5615           <em class="replaceable"><code>pkg</code></em>.  The build dependency is
5616           selected by setting
5617           <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
5618           to <span class="quote">&#8220;<span class="quote">build</span>&#8221;</span>.  By default, the full dependency is
5619           used.</p></li>
5620 <li class="listitem"><p><code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
5621             and
5622             <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
5623             (not shown above) are lists of subdirectories of
5624             <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
5625             to add to the header and library search paths.  These
5626             default to <span class="quote">&#8220;<span class="quote">include</span>&#8221;</span> and <span class="quote">&#8220;<span class="quote">lib</span>&#8221;</span>
5627           respectively.</p></li>
5628 <li class="listitem"><p><code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
5629             (not shown above) is the list of preprocessor flags to add
5630             to <code class="varname">CPPFLAGS</code>, which are passed on to the
5631             configure and build phases.  The <span class="quote">&#8220;<span class="quote">-I</span>&#8221;</span> option
5632             should be avoided and instead be handled using
5633             <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
5634           above.</p></li>
5635 </ul></div>
5636 <p>The following variables are all optionally defined within
5637       this second section (protected against multiple inclusion) and
5638       control which package files are symlinked into
5639       <code class="filename">${BUILDLINK_DIR}</code> and how their names are
5640       transformed during the symlinking:</p>
5641 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
5642 <li class="listitem"><p><code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
5643             (not shown above) is a shell glob pattern relative to
5644             <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
5645             to be symlinked into
5646             <code class="filename">${BUILDLINK_DIR}</code>,
5647           e.g. <code class="filename">include/*.h</code>.</p></li>
5648 <li class="listitem"><p><code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
5649             (not shown above) is a shell pipeline that
5650             outputs to stdout a list of files relative to
5651             <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
5652             The resulting files are to be symlinked
5653             into <code class="filename">${BUILDLINK_DIR}</code>.  By default,
5654             this takes the <code class="filename">+CONTENTS</code> of a
5655             <em class="replaceable"><code>pkg</code></em> and filters it through
5656             <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.</p></li>
5657 <li class="listitem"><p><code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
5658             (not shown above) is a filter command that filters
5659             <code class="filename">+CONTENTS</code> input into a list of files
5660             relative to
5661             <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
5662             on stdout.  By default for overwrite packages,
5663             <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
5664             outputs the contents of the <code class="filename">include</code>
5665             and <code class="filename">lib</code> directories in the package
5666             <code class="filename">+CONTENTS</code>, and for pkgviews packages,
5667             it outputs any libtool archives in
5668             <code class="filename">lib</code> directories.</p></li>
5669 <li class="listitem"><p><code class="varname">BUILDLINK_FNAME_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
5670             (not shown above) is a list of sed arguments used to
5671             transform the name of the source filename into a
5672             destination filename, e.g. <span class="command"><strong>-e
5673             "s|/curses.h|/ncurses.h|g"</strong></span>.</p></li>
5674 </ul></div>
5675 <p>This section can additionally include any
5676       <code class="filename">buildlink3.mk</code> needed for
5677       <em class="replaceable"><code>pkg</code></em>'s library dependencies.
5678       Including these <code class="filename">buildlink3.mk</code> files
5679       means that the headers and libraries for these
5680       dependencies are also symlinked into
5681       <code class="filename">${BUILDLINK_DIR}</code>
5682       whenever the <em class="replaceable"><code>pkg</code></em>
5683       <code class="filename">buildlink3.mk</code>
5684       file is included. Dependencies are only added for directly
5685       include <code class="filename">buildlink3.mk</code> files.</p>
5686 <p>When providing a <code class="filename">buildlink3.mk</code> and
5687       including other <code class="filename">buildlink3.mk</code> files in it,
5688       please only add necessary ones, i.e., those whose libraries or
5689       header files are automatically exposed when the package is
5690       use.</p>
5691 <p>In particular, if only an executable
5692       (<code class="filename">bin/foo</code>) is linked against a library, that
5693       library does not need to be propagated in the
5694       <code class="filename">buildlink3.mk</code> file.</p>
5695 <p>The following steps should help you decide if a
5696       <code class="filename">buildlink3.mk</code> file needs to be included:
5697       </p>
5698 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
5699 <li class="listitem"><p>Look at the installed header files: What
5700         headers do they include? The packages providing these files
5701         must be buildlinked.</p></li>
5702 <li class="listitem"><p>Run <code class="filename">ldd</code> on all installed
5703         libraries and look against what other libraries they link.
5704         Some of the packages providing these probably need to be
5705         buildlinked; however, it's not automatic, since e.g. GTK on
5706         some systems pulls in the X libraries, so they will show up in
5707         the <code class="filename">ldd</code> output, while on others (like OS
5708         X) it won't. <code class="filename">ldd</code> output can thus only be
5709         used as a hint.</p></li>
5710 </ul></div>
5711 <p>
5712       </p>
5713 </div>
5714 <div class="sect2">
5715 <div class="titlepage"><div><div><h3 class="title">
5716 <a name="updating-buildlink-depends"></a>14.2.2. Updating
5717       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5718       and
5719       <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5720       in <code class="filename">buildlink3.mk</code> files</h3></div></div></div>
5721 <p>These two variables differ in that one describes source
5722       compatibility (API) and the other binary compatibility (ABI).
5723       The difference is that a change in the API breaks compilation of
5724       programs while changes in the ABI stop compiled programs from
5725       running.</p>
5726 <p>Changes to the
5727       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5728       variable in a <code class="filename">buildlink3.mk</code> file happen
5729       very rarely. One possible reason is that all packages depending
5730       on this already need a newer version. In case it is bumped see
5731       the description below.</p>
5732 <p>The most common example of an ABI change is that the major
5733       version of a shared library is increased. In this case,
5734       <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5735       should be adjusted to require at least the new package version.
5736       Then the packages that depend on this package need their
5737       <code class="varname">PKGREVISION</code>s increased and, if they have
5738       <code class="filename">buildlink3.mk</code> files, their
5739       <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5740       adjusted, too. This is needed so pkgsrc will require the correct
5741       package dependency and not settle for an older one when building
5742       the source.</p>
5743 <p>See <a class="xref" href="#dependencies" title="19.1.6. Handling dependencies">Section 19.1.6, &#8220;Handling dependencies&#8221;</a> for
5744       more information about dependencies on other packages,
5745       including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
5746       <code class="varname">ABI_DEPENDS</code> definitions.</p>
5747 <p>Please take careful consideration before adjusting
5748       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5749       or
5750       <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5751       as we don't want to cause unneeded package deletions and
5752       rebuilds.  In many cases, new versions of packages work just
5753       fine with older dependencies.</p>
5754 <p>Also it is not needed to set
5755       <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5756       when it is identical to
5757       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>. </p>
5758 </div>
5759 </div>
5760 <div class="sect1">
5761 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5762 <a name="writing-builtin.mk"></a>14.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
5763 <p>Some packages in pkgsrc install headers and libraries that
5764       coincide with headers and libraries present in the base system.
5765       Aside from a <code class="filename">buildlink3.mk</code> file, these
5766       packages should also include a <code class="filename">builtin.mk</code>
5767       file that includes the necessary checks to decide whether using
5768       the built-in software or the pkgsrc software is
5769     appropriate.</p>
5770 <p>The only requirements of a builtin.mk file for
5771     <em class="replaceable"><code>pkg</code></em> are:</p>
5772 <div class="orderedlist"><ol class="orderedlist" type="1">
5773 <li class="listitem"><p>It should set
5774         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5775         to either <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span> or <span class="quote">&#8220;<span class="quote">no</span>&#8221;</span>
5776         after it is included.</p></li>
5777 <li class="listitem"><p>It should <span class="emphasis"><em>not</em></span> override any
5778         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5779         which is already set before the
5780         <code class="filename">builtin.mk</code> file is included.</p></li>
5781 <li class="listitem"><p>It should be written to allow multiple inclusion.  This
5782         is <span class="emphasis"><em>very</em></span> important and takes careful
5783         attention to <code class="filename">Makefile</code> coding.</p></li>
5784 </ol></div>
5785 <div class="sect2">
5786 <div class="titlepage"><div><div><h3 class="title">
5787 <a name="anatomy-of-builtin.mk"></a>14.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</h3></div></div></div>
5788 <p>The following is the recommended template for builtin.mk
5789       files:</p>
5790 <pre class="programlisting">
5791 .if !defined(IS_BUILTIN.foo)
5792 #
5793 # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
5794 # genuinely exists in the system or not.
5795 #
5796 IS_BUILTIN.foo?=        no
5797
5798 # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
5799 # version can be determined.
5800 #
5801 .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
5802 BUILTIN_PKG.foo?=       foo-1.0
5803 .  endif
5804 .endif  # IS_BUILTIN.foo
5805
5806 .if !defined(USE_BUILTIN.foo)
5807 USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
5808 .  if defined(BUILTIN_PKG.foo)
5809 .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
5810 .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
5811 USE_BUILTIN.foo!=                                                       \
5812         ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
5813         &amp;&amp; ${ECHO} "yes" || ${ECHO} "no"
5814 .      endif
5815 .    endfor
5816 .  endif
5817 .endif  # USE_BUILTIN.foo
5818
5819 CHECK_BUILTIN.foo?=     no
5820 .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
5821 #
5822 # Here we place code that depends on whether USE_BUILTIN.foo is set to
5823 # "yes" or "no".
5824 #
5825 .endif  # CHECK_BUILTIN.foo
5826 </pre>
5827 <p>The first section sets
5828       <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5829       depending on if <em class="replaceable"><code>pkg</code></em> really exists
5830       in the base system.  This should not be a base system software
5831       with similar functionality to <em class="replaceable"><code>pkg</code></em>;
5832       it should only be <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span> if the actual package is
5833       included as part of the base system.  This variable is only
5834       used internally within the <code class="filename">builtin.mk</code>
5835       file.</p>
5836 <p>The second section sets
5837       <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5838       to the version of <em class="replaceable"><code>pkg</code></em> in the base
5839       system if it exists (if
5840       <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5841       is <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>).  This variable is only used internally
5842       within the <code class="filename">builtin.mk</code> file.</p>
5843 <p>The third section sets
5844       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5845       and is <span class="emphasis"><em>required</em></span> in all
5846       <code class="filename">builtin.mk</code> files.  The code in this
5847       section must make the determination whether the built-in
5848       software is adequate to satisfy the dependencies listed in
5849       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5850       This is typically done by comparing
5851       <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5852       against each of the dependencies in
5853       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5854       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5855       <span class="emphasis"><em>must</em></span> be set to the correct value by the
5856       end of the <code class="filename">builtin.mk</code> file.  Note that
5857       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5858       may be <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span> even if
5859       <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5860       is <span class="quote">&#8220;<span class="quote">no</span>&#8221;</span> because we may make the determination
5861       that the built-in version of the software is similar enough to
5862       be used as a replacement.</p>
5863 <p>The last section is guarded by
5864       <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
5865       and includes code that uses the value of
5866       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5867       set in the previous section.  This typically includes, e.g.,
5868       adding additional dependency restrictions and listing additional
5869       files to symlink into <code class="filename">${BUILDLINK_DIR}</code> (via
5870       <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).</p>
5871 </div>
5872 <div class="sect2">
5873 <div class="titlepage"><div><div><h3 class="title">
5874 <a name="native-or-pkgsrc-preference"></a>14.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
5875 <p>When building packages, it's possible to choose whether to set
5876         a global preference for using either the built-in (native)
5877         version or the pkgsrc version of software to satisfy a
5878         dependency.  This is controlled by setting
5879         <code class="varname">PREFER_PKGSRC</code> and
5880         <code class="varname">PREFER_NATIVE</code>.  These variables take values
5881         of either <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>, <span class="quote">&#8220;<span class="quote">no</span>&#8221;</span>, or a list of
5882         packages.  <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
5883         use the pkgsrc versions of software, while
5884         <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
5885         built-in versions.  Preferences are determined by the most
5886         specific instance of the package in either
5887         <code class="varname">PREFER_PKGSRC</code> or
5888         <code class="varname">PREFER_NATIVE</code>.  If a package is specified
5889         in neither or in both variables, then
5890         <code class="varname">PREFER_PKGSRC</code> has precedence over
5891         <code class="varname">PREFER_NATIVE</code>.  For example, to require
5892         using pkgsrc versions of software for all but the most basic
5893       bits on a NetBSD system, you can set:</p>
5894 <pre class="programlisting">
5895 PREFER_PKGSRC=  yes
5896 PREFER_NATIVE=  getopt skey tcp_wrappers
5897 </pre>
5898 <p>A package <span class="emphasis"><em>must</em></span> have a
5899       <code class="filename">builtin.mk</code>
5900       file to be listed in <code class="varname">PREFER_NATIVE</code>,
5901       otherwise it is simply ignored in that list.</p>
5902 </div>
5903 </div>
5904 </div>
5905 <div class="chapter">
5906 <div class="titlepage"><div><div><h2 class="title">
5907 <a name="pkginstall"></a>Chapter 15. The pkginstall framework</h2></div></div></div>
5908 <div class="toc">
5909 <p><b>Table of Contents</b></p>
5910 <dl>
5911 <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">15.1. Files and directories outside the installation prefix</a></span></dt>
5912 <dd><dl>
5913 <dt><span class="sect2"><a href="#dirs-outside-prefix">15.1.1. Directory manipulation</a></span></dt>
5914 <dt><span class="sect2"><a href="#files-outside-prefix">15.1.2. File manipulation</a></span></dt>
5915 </dl></dd>
5916 <dt><span class="sect1"><a href="#conf-files">15.2. Configuration files</a></span></dt>
5917 <dd><dl>
5918 <dt><span class="sect2"><a href="#conf-files-sysconfdir">15.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
5919 <dt><span class="sect2"><a href="#conf-files-configure">15.2.2. Telling the software where configuration files are</a></span></dt>
5920 <dt><span class="sect2"><a href="#conf-files-patching">15.2.3. Patching installations</a></span></dt>
5921 <dt><span class="sect2"><a href="#conf-files-disable">15.2.4. Disabling handling of configuration files</a></span></dt>
5922 </dl></dd>
5923 <dt><span class="sect1"><a href="#rcd-scripts">15.3. System startup scripts</a></span></dt>
5924 <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">15.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
5925 <dt><span class="sect1"><a href="#users-and-groups">15.4. System users and groups</a></span></dt>
5926 <dt><span class="sect1"><a href="#shells">15.5. System shells</a></span></dt>
5927 <dd><dl><dt><span class="sect2"><a href="#shells-disable">15.5.1. Disabling shell registration</a></span></dt></dl></dd>
5928 <dt><span class="sect1"><a href="#fonts">15.6. Fonts</a></span></dt>
5929 <dd><dl><dt><span class="sect2"><a href="#fonts-disable">15.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
5930 </dl>
5931 </div>
5932 <p>This chapter describes the framework known as
5933 <code class="literal">pkginstall</code>, whose key features are:</p>
5934 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
5935 <li class="listitem"><p>Generic installation and manipulation of directories and files
5936     outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
5937 <li class="listitem"><p>Automatic handling of configuration files during installation,
5938     provided that packages are correctly designed.</p></li>
5939 <li class="listitem"><p>Generation and installation of system startup scripts.</p></li>
5940 <li class="listitem"><p>Registration of system users and groups.</p></li>
5941 <li class="listitem"><p>Registration of system shells.</p></li>
5942 <li class="listitem"><p>Automatic updating of fonts databases.</p></li>
5943 </ul></div>
5944 <p>The following sections inspect each of the above points in detail.</p>
5945 <p>You may be thinking that many of the things described here could be
5946 easily done with simple code in the package's post-installation target
5947 (<code class="literal">post-install</code>).  <span class="emphasis"><em>This is incorrect</em></span>,
5948 as the code in them is only executed when building from source.  Machines
5949 using binary packages could not benefit from it at all (as the code itself
5950 could be unavailable).  Therefore, the only way to achieve any of the items
5951 described above is by means of the installation scripts, which are
5952 automatically generated by pkginstall.</p>
5953 <div class="sect1">
5954 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
5955 <a name="files-and-dirs-outside-prefix"></a>15.1. Files and directories outside the installation prefix</h2></div></div></div>
5956 <p>As you already know, the <code class="filename">PLIST</code> file holds a list
5957 of files and directories that belong to a package.  The names used in it
5958 are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
5959 which means that it cannot register files outside this directory (absolute
5960 path names are not allowed).  Despite this restriction, some packages need
5961 to install files outside this location; e.g., under
5962 <code class="filename">${VARBASE}</code> or
5963 <code class="filename">${PKG_SYSCONFDIR}</code>.  The only way to achieve this
5964 is to create such files during installation time by using
5965 installation scripts.</p>
5966 <p>The generic installation scripts are shell scripts that can
5967 contain arbitrary code.  The list of scripts to execute is taken from
5968 the <code class="varname">INSTALL_FILE</code> variable, which defaults to
5969 <code class="filename">INSTALL</code>.  A similar variable exists for package
5970 removal (<code class="varname">DEINSTALL_FILE</code>, whose default is
5971 <code class="filename">DEINSTALL</code>).  These scripts can run arbitrary
5972 commands, so they have the potential to create and manage files
5973 anywhere in the file system.</p>
5974 <p>Using these general installation files is not recommended, but
5975 may be needed in some special cases.  One reason for avoiding them is
5976 that the user has to trust the packager that there is no unwanted or
5977 simply erroneous code included in the installation script. Also,
5978 previously there were many similar scripts for the same functionality,
5979 and fixing a common error involved finding and changing all of
5980 them.</p>
5981 <p>The pkginstall framework offers another, standardized way.  It
5982 provides generic scripts to abstract the manipulation of such files
5983 and directories based on variables set in the package's
5984 <code class="filename">Makefile</code>.  The rest of this section describes
5985 these variables.</p>
5986 <div class="sect2">
5987 <div class="titlepage"><div><div><h3 class="title">
5988 <a name="dirs-outside-prefix"></a>15.1.1. Directory manipulation</h3></div></div></div>
5989 <p>The following variables can be set to request the creation of
5990 directories anywhere in the file system:</p>
5991 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
5992 <li class="listitem"><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
5993     contain a list of directories that should be created and should attempt
5994     to be destroyed by the installation scripts.  The difference between
5995     the two is that the latter prompts the administrator to remove any
5996     directories that may be left after deinstallation (because they were
5997     not empty), while the former does not.</p></li>
5998 <li class="listitem">
5999 <p><code class="varname">MAKE_DIRS_PERMS</code> and
6000     <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
6001     which directories should be created and should attempt to be destroyed
6002     by the installation scripts.  Each tuple holds the following values,
6003     separated by spaces: the directory name, its owner, its group and its
6004     numerical mode.  For example:</p>
6005 <pre class="programlisting">
6006 MAKE_DIRS_PERMS+=         ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
6007 </pre>
6008 <p>The difference between the two is exactly the same as their
6009     non-<code class="varname">PERMS</code> counterparts.</p>
6010 </li>
6011 </ul></div>
6012 </div>
6013 <div class="sect2">
6014 <div class="titlepage"><div><div><h3 class="title">
6015 <a name="files-outside-prefix"></a>15.1.2. File manipulation</h3></div></div></div>
6016 <p>Creating non-empty files outside the installation prefix is tricky
6017 because the <code class="filename">PLIST</code> forces all files to be inside it.
6018 To overcome this problem, the only solution is to extract the file in the
6019 known place (i.e., inside the installation prefix) and copy it to the
6020 appropriate location during installation (done by the installation scripts
6021 generated by pkginstall).  We will call the former the <span class="emphasis"><em>master
6022 file</em></span> in the following paragraphs, which describe the variables
6023 that can be used to automatically and consistently handle files outside the
6024 installation prefix:</p>
6025 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
6026 <li class="listitem">
6027 <p><code class="varname">CONF_FILES</code> and
6028     <code class="varname">REQD_FILES</code> are pairs of master and target files.
6029     During installation time, the master file is copied to the target one
6030     if and only if the latter does not exist.  Upon deinstallation, the
6031     target file is removed provided that it was not modified by the
6032     installation.</p>
6033 <p>The difference between the two is that the latter prompts the
6034     administrator to remove any files that may be left after
6035     deinstallation (because they were not empty), while the former does
6036     not.</p>
6037 </li>
6038 <li class="listitem">
6039 <p><code class="varname">CONF_FILES_PERMS</code> and
6040     <code class="varname">REQD_FILES_PERMS</code> contain tuples describing master
6041     files as well as their target locations.  For each of them, it also
6042     specifies their owner, their group and their numeric permissions, in
6043     this order.  For example:</p>
6044 <pre class="programlisting">
6045 REQD_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
6046 </pre>
6047 <p>The difference between the two is exactly the same as their
6048     non-<code class="varname">PERMS</code> counterparts.</p>
6049 </li>
6050 </ul></div>
6051 </div>
6052 </div>
6053 <div class="sect1">
6054 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6055 <a name="conf-files"></a>15.2. Configuration files</h2></div></div></div>
6056 <p>Configuration files are special in the sense that they are installed
6057 in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
6058 need special treatment during installation (most of which is automated by
6059 pkginstall).  The main concept you must bear in mind is that files marked
6060 as configuration files are automatically copied to the right place (somewhere
6061 inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
6062 and only if</em></span> they didn't exist before.  Similarly, they will not
6063 be removed if they have local modifications.  This ensures that
6064 administrators never lose any custom changes they may have made.</p>
6065 <div class="sect2">
6066 <div class="titlepage"><div><div><h3 class="title">
6067 <a name="conf-files-sysconfdir"></a>15.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</h3></div></div></div>
6068 <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
6069 specifies where configuration files shall be installed.  Its contents are
6070 set based upon the following variables:</p>
6071 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
6072 <li class="listitem"><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
6073     directory.  Defaults to <code class="filename">${PREFIX}/etc</code> although it may
6074     be overridden by the user to point to his preferred location (e.g.,
6075     <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
6076     Packages must not use it directly.</p></li>
6077 <li class="listitem">
6078 <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
6079     <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
6080     for the package being built shall be installed.  The definition of this
6081     variable only makes sense in the package's
6082     <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
6083 <p>As an example, consider the Apache package,
6084     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/apache2/README.html" target="_top"><code class="filename">www/apache2</code></a>, which places its
6085     configuration files under the
6086     <code class="filename">httpd/</code> subdirectory of
6087     <code class="varname">PKG_SYSCONFBASE</code>.  This should be set in the package
6088     Makefile.</p>
6089 </li>
6090 <li class="listitem"><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
6091     variable that holds this package's configuration directory (if
6092     different from <code class="varname">PKG_SYSCONFBASE</code>).  It defaults to
6093     <code class="varname">PKGBASE</code>'s value, and is always prefixed with
6094     <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
6095 <li class="listitem"><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
6096     directory where the configuration files for the package identified by
6097     <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
6098 </ul></div>
6099 <p>Based on the above variables, pkginstall determines the value of
6100 <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
6101 variable that can be used within a package to refer to its configuration
6102 directory.  The algorithm used to set its value is basically the
6103 following:</p>
6104 <div class="orderedlist"><ol class="orderedlist" type="1">
6105 <li class="listitem"><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
6106     its value is used.</p></li>
6107 <li class="listitem"><p>If the previous variable is not defined but
6108     <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
6109     <code class="filename">Makefile</code>, the resulting value is
6110     <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
6111 <li class="listitem"><p>Otherwise, it is set to
6112     <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
6113 </ol></div>
6114 <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
6115 automatically added to <code class="filename">OWN_DIRS</code>.  See <a class="xref" href="#dirs-outside-prefix" title="15.1.1. Directory manipulation">Section 15.1.1, &#8220;Directory manipulation&#8221;</a> what this means.  This does not apply to
6116 subdirectories of <code class="filename">${PKG_SYSCONFDIR}</code>, they still have to
6117 be created with OWN_DIRS or MAKE_DIRS.</p>
6118 </div>
6119 <div class="sect2">
6120 <div class="titlepage"><div><div><h3 class="title">
6121 <a name="conf-files-configure"></a>15.2.2. Telling the software where configuration files are</h3></div></div></div>
6122 <p>Given that pkgsrc (and users!) expect configuration files to be in a
6123 known place, you need to teach each package where it shall install its
6124 files.  In some cases you will have to patch the package Makefiles to
6125 achieve it.  If you are lucky, though, it may be as easy as passing an
6126 extra flag to the configuration script; this is the case of GNU Autoconf-
6127 generated files:</p>
6128 <pre class="programlisting">
6129 CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
6130 </pre>
6131 <p>Note that this specifies where the package has to <span class="emphasis"><em>look
6132 for</em></span> its configuration files, not where they will be originally
6133 installed (although the difference is never explicit,
6134 unfortunately).</p>
6135 </div>
6136 <div class="sect2">
6137 <div class="titlepage"><div><div><h3 class="title">
6138 <a name="conf-files-patching"></a>15.2.3. Patching installations</h3></div></div></div>
6139 <p>As said before, pkginstall automatically handles configuration files.
6140 This means that <span class="strong"><strong>the packages themselves must not
6141 touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
6142 directly</strong></span>.  Bad news is that many software installation scripts
6143 will, out of the box, mess with the contents of that directory.  So what is
6144 the correct procedure to fix this issue?</p>
6145 <p>You must teach the package (usually by manually patching it) to
6146 install any configuration files under the examples hierarchy,
6147 <code class="filename">share/examples/${PKGBASE}/</code>.  This way, the
6148 <code class="filename">PLIST</code> registers them and the administrator always
6149 has the original copies available.</p>
6150 <p>Once the required configuration files are in place (i.e., under the
6151 examples hierarchy), the pkginstall framework can use them as master copies
6152 during the package installation to update what is in
6153 <code class="filename">${PKG_SYSCONFDIR}</code>.  To achieve this, the variables
6154 <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
6155 used.  Check out <a class="xref" href="#files-outside-prefix" title="15.1.2. File manipulation">Section 15.1.2, &#8220;File manipulation&#8221;</a> for information
6156 about their syntax and their purpose.  Here is an example, taken from the
6157 <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/mail/mutt/README.html" target="_top"><code class="filename">mail/mutt</code></a> package:</p>
6158 <pre class="programlisting">
6159 EGDIR=        ${PREFIX}/share/doc/mutt/samples
6160 CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
6161 </pre>
6162 <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
6163 package and has no meaning outside it.</p>
6164 </div>
6165 <div class="sect2">
6166 <div class="titlepage"><div><div><h3 class="title">
6167 <a name="conf-files-disable"></a>15.2.4. Disabling handling of configuration files</h3></div></div></div>
6168 <p>The automatic copying of config files can be toggled by setting the
6169 environment variable <code class="varname">PKG_CONFIG</code> prior to package
6170 installation.</p>
6171 </div>
6172 </div>
6173 <div class="sect1">
6174 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6175 <a name="rcd-scripts"></a>15.3. System startup scripts</h2></div></div></div>
6176 <p>System startup scripts are special files because they must be
6177 installed in a place known by the underlying OS, usually outside the
6178 installation prefix.  Therefore, the same rules described in <a class="xref" href="#files-and-dirs-outside-prefix" title="15.1. Files and directories outside the installation prefix">Section 15.1, &#8220;Files and directories outside the installation prefix&#8221;</a> apply, and the same solutions
6179 can be used.  However, pkginstall provides a special mechanism to handle
6180 these files.</p>
6181 <p>In order to provide system startup scripts, the package has
6182 to:</p>
6183 <div class="orderedlist"><ol class="orderedlist" type="1">
6184 <li class="listitem"><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
6185     the <code class="literal">.sh</code> suffix appended.  Considering the
6186     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/print/cups/README.html" target="_top"><code class="filename">print/cups</code></a> package as an example, it has a
6187     <code class="filename">cupsd.sh</code> in its files directory.</p></li>
6188 <li class="listitem">
6189 <p>Tell pkginstall to handle it, appending the name of the script,
6190     without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
6191     Continuing the previous example:</p>
6192 <pre class="programlisting">
6193 RCD_SCRIPTS+=   cupsd
6194 </pre>
6195 </li>
6196 </ol></div>
6197 <p>Once this is done, pkginstall will do the following steps for each
6198 script in an automated fashion:</p>
6199 <div class="orderedlist"><ol class="orderedlist" type="1">
6200 <li class="listitem"><p>Process the file found in the files directory applying all the
6201     substitutions described in the <code class="filename">FILES_SUBST</code>
6202     variable.</p></li>
6203 <li class="listitem"><p>Copy the script from the files directory to the examples
6204     hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>.  Note
6205     that this master file must be explicitly registered in the
6206     <code class="filename">PLIST</code>.</p></li>
6207 <li class="listitem"><p>Add code to the installation scripts to copy the startup script
6208     from the examples hierarchy into the system-wide startup scripts
6209     directory.</p></li>
6210 </ol></div>
6211 <div class="sect2">
6212 <div class="titlepage"><div><div><h3 class="title">
6213 <a name="rcd-scripts-disable"></a>15.3.1. Disabling handling of system startup scripts</h3></div></div></div>
6214 <p>The automatic copying of config files can be toggled by setting the
6215 environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
6216 installation.  Note that the scripts will be always copied inside the
6217 examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
6218 matter what the value of this variable is.</p>
6219 </div>
6220 </div>
6221 <div class="sect1">
6222 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6223 <a name="users-and-groups"></a>15.4. System users and groups</h2></div></div></div>
6224 <p>If a package needs to create special users and/or groups during
6225 installation, it can do so by using the pkginstall framework.</p>
6226 <p>Users can be created by adding entries to the
6227 <code class="varname">PKG_USERS</code> variable.  Each entry has the following
6228 syntax:</p>
6229 <pre class="programlisting">
6230 user:group
6231 </pre>
6232 <p>Further specification of user details may be done by setting
6233 per-user variables.
6234 <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the
6235 numeric UID for the user.
6236 <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the
6237 user's description or comment.
6238 <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the
6239 user's home directory, and defaults to
6240 <code class="filename">/nonexistent</code> if not specified.
6241 <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the
6242 user's shell, and defaults to <code class="filename">/sbin/nologin</code> if
6243 not specified.</p>
6244 <p>Similarly, groups can be created by adding entries to the
6245 <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
6246 <pre class="programlisting">
6247 group
6248 </pre>
6249 <p>The numeric GID of the group may be set by defining
6250 <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
6251 <p>If a package needs to create the users and groups at an earlier
6252 stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
6253 either <code class="literal">configure</code> or <code class="literal">build</code> to
6254 indicate the phase before which the users and groups are created.  In
6255 this case, the numeric UIDs and GIDs of the created users and groups
6256 are automatically hardcoded into the final installation scripts.</p>
6257 </div>
6258 <div class="sect1">
6259 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6260 <a name="shells"></a>15.5. System shells</h2></div></div></div>
6261 <p>Packages that install system shells should register them in the shell
6262 database, <code class="filename">/etc/shells</code>, to make things easier to the
6263 administrator.  This must be done from the installation scripts to keep
6264 binary packages working on any system.  pkginstall provides an easy way to
6265 accomplish this task.</p>
6266 <p>When a package provides a shell interpreter, it has to set the
6267 <code class="varname">PKG_SHELL</code> variable to its absolute file name.  This will
6268 add some hooks to the installation scripts to handle it.  Consider the
6269 following example, taken from <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/shells/zsh/README.html" target="_top"><code class="filename">shells/zsh</code></a>:</p>
6270 <pre class="programlisting">
6271 PKG_SHELL=      ${PREFIX}/bin/zsh
6272 </pre>
6273 <div class="sect2">
6274 <div class="titlepage"><div><div><h3 class="title">
6275 <a name="shells-disable"></a>15.5.1. Disabling shell registration</h3></div></div></div>
6276 <p>The automatic registration of shell interpreters can be disabled by
6277 the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
6278 environment variable to <code class="literal">NO</code>.</p>
6279 </div>
6280 </div>
6281 <div class="sect1">
6282 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6283 <a name="fonts"></a>15.6. Fonts</h2></div></div></div>
6284 <p>Packages that install X11 fonts should update the database files
6285 that index the fonts within each fonts directory.  This can easily be
6286 accomplished within the pkginstall framework.</p>
6287 <p>When a package installs X11 fonts, it must list the directories in
6288 which fonts are installed in the
6289 <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
6290 where <em class="replaceable"><code>type</code></em> can be one of <span class="quote">&#8220;<span class="quote">ttf</span>&#8221;</span>,
6291 <span class="quote">&#8220;<span class="quote">type1</span>&#8221;</span> or <span class="quote">&#8220;<span class="quote">x11</span>&#8221;</span>.  This will add hooks to the
6292 installation scripts to run the appropriate commands to update the fonts
6293 database files within each of those directories.  For convenience, if the
6294 directory path is relative, it is taken to be relative to the package's
6295 installation prefix.  Consider the following example, taken from <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/fonts/dbz-ttf/README.html" target="_top"><code class="filename">fonts/dbz-ttf</code></a>:</p>
6296 <pre class="programlisting">
6297 FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
6298 </pre>
6299 <div class="sect2">
6300 <div class="titlepage"><div><div><h3 class="title">
6301 <a name="fonts-disable"></a>15.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
6302 <p>The automatic update of fonts databases can be disabled by
6303 the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
6304 environment variable to <code class="literal">NO</code>.</p>
6305 </div>
6306 </div>
6307 </div>
6308 <div class="chapter">
6309 <div class="titlepage"><div><div><h2 class="title">
6310 <a name="options"></a>Chapter 16. Options handling</h2></div></div></div>
6311 <div class="toc">
6312 <p><b>Table of Contents</b></p>
6313 <dl>
6314 <dt><span class="sect1"><a href="#global-default-options">16.1. Global default options</a></span></dt>
6315 <dt><span class="sect1"><a href="#converting-to-options">16.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
6316 <dt><span class="sect1"><a href="#option-names">16.3. Option Names</a></span></dt>
6317 <dt><span class="sect1"><a href="#option-build">16.4. Determining the options of dependencies</a></span></dt>
6318 </dl>
6319 </div>
6320 <p>Many packages have the ability to be built to support different
6321 sets of features.  <code class="filename">bsd.options.mk</code> is a framework
6322 in pkgsrc that provides generic handling of those options that
6323 determine different ways in which the packages can be built.  It's
6324 possible for the user to specify exactly which sets of options will be
6325 built into a package or to allow a set of global default options
6326 apply.</p>
6327 <p>There are two broad classes of behaviors that one might want to
6328 control via options.  One is whether some particular feature is
6329 enabled in a program that will be built anyway, often by including or
6330 not including a dependency on some other package.  The other is
6331 whether or not an additional program will be built as part of the
6332 package.  Generally, it is better to make a split package for such
6333 additional programs instead of using options, because it enables
6334 binary packages to be built which can then be added separately.  For
6335 example, the foo package might have minimal dependencies (those
6336 packages without which foo doesn't make sense), and then the foo-gfoo
6337 package might include the GTK frontend program gfoo.  This is better
6338 than including a gtk option to foo that adds gfoo, because either that
6339 option is default, in which case binary users can't get foo without
6340 gfoo, or not default, in which case they can't get gfoo.  With split
6341 packages, they can install foo without having GTK, and later decide to
6342 install gfoo (pulling in GTK at that time).  This is an advantage to
6343 source users too, avoiding the need for rebuilds.</p>
6344 <p>Plugins with widely varying dependencies should usually be split
6345 instead of options.</p>
6346 <p>It is often more work to maintain split packages, especially if
6347 the upstream package does not support this.  The decision of split
6348 vs. option should be made based on the likelihood that users will want
6349 or object to the various pieces, the size of the dependencies that are
6350 included, and the amount of work.</p>
6351 <p>A further consideration is licensing.  Non-free parts, or parts
6352 that depend on non-free dependencies (especially plugins) should
6353 almost always be split if feasible.</p>
6354 <div class="sect1">
6355 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6356 <a name="global-default-options"></a>16.1. Global default options</h2></div></div></div>
6357 <p>Global default options are listed in
6358 <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
6359 that should be built into every package if that option is supported.
6360 This variable should be set in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.</p>
6361 </div>
6362 <div class="sect1">
6363 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6364 <a name="converting-to-options"></a>16.2. Converting packages to use <code class="filename">bsd.options.mk</code>
6365 </h2></div></div></div>
6366 <p>The following example shows how
6367 <code class="filename">bsd.options.mk</code> should be used
6368 by the hypothetical ``wibble'' package, either in the package
6369 <code class="filename">Makefile</code>, or in a file,
6370 e.g. <code class="filename">options.mk</code>, that is included by the
6371 main package <code class="filename">Makefile</code>.</p>
6372 <pre class="programlisting">
6373 PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
6374 PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
6375 PKG_OPTIONS_OPTIONAL_GROUPS=    database
6376 PKG_OPTIONS_GROUP.database=     mysql pgsql
6377 PKG_SUGGESTED_OPTIONS=          wibble-foo
6378 PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
6379 PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
6380
6381 .include "../../mk/bsd.prefs.mk"
6382
6383 # this package was previously named wibble2
6384 .if defined(PKG_OPTIONS.wibble2)
6385 PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
6386 PKG_OPTIONS_DEPRECATED_WARNINGS+= \
6387         "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
6388 .endif
6389
6390 .include "../../mk/bsd.options.mk"
6391
6392 # Package-specific option-handling
6393
6394 ###
6395 ### FOO support
6396 ###
6397 .if !empty(PKG_OPTIONS:Mwibble-foo)
6398 CONFIGURE_ARGS+=    --enable-foo
6399 .endif
6400
6401 ###
6402 ### LDAP support
6403 ###
6404 .if !empty(PKG_OPTIONS:Mldap)
6405 .  include "../../databases/openldap-client/buildlink3.mk"
6406 CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
6407 .endif
6408
6409 ###
6410 ### database support
6411 ###
6412 .if !empty(PKG_OPTIONS:Mmysql)
6413 .  include "../../mk/mysql.buildlink3.mk"
6414 .endif
6415 .if !empty(PKG_OPTIONS:Mpgsql)
6416 .  include "../../mk/pgsql.buildlink3.mk"
6417 .endif
6418 </pre>
6419 <p>The first section contains the information about which build
6420 options are supported by the package, and any default options settings
6421 if needed.</p>
6422 <div class="orderedlist"><ol class="orderedlist" type="1">
6423 <li class="listitem"><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
6424 <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> variable that the user can set to override the default
6425 options.  It should be set to
6426 PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
6427 PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
6428 at the point where the options are processed.</p></li>
6429 <li class="listitem"><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
6430 build options supported by the package.</p></li>
6431 <li class="listitem"><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
6432 list of names of groups of mutually exclusive options.  The options in
6433 each group are listed in
6434 <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
6435 The most specific setting of any option from the group takes
6436 precedence over all other options in the group.  Options from the
6437 groups will be automatically added to
6438 <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
6439 <li class="listitem"><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
6440 <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
6441 packages will fail if no option from the group is
6442 selected.</p></li>
6443 <li class="listitem"><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
6444 of names of sets of options.  At least one option from each set must
6445 be selected.  The options in each set are listed in
6446 <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
6447 Options from the sets will be automatically added to
6448 <code class="varname">PKG_SUPPORTED_OPTIONS</code>.  Building the package will
6449 fail if no option from the set is selected.</p></li>
6450 <li class="listitem"><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
6451 build options which are enabled by default.</p></li>
6452 <li class="listitem"><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
6453 of
6454 <span class="quote">&#8220;<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>&#8221;</span>
6455 pairs that map legacy <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> variables to
6456 their option counterparts.  Pairs should be added with
6457 <span class="quote">&#8220;<span class="quote">+=</span>&#8221;</span> to keep the listing of global legacy variables.  A
6458 warning will be issued if the user uses a legacy
6459 variable.</p></li>
6460 <li class="listitem"><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
6461 of
6462 <span class="quote">&#8220;<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>&#8221;</span>
6463 pairs that map options that have been renamed to their new
6464 counterparts.  Pairs should be added with <span class="quote">&#8220;<span class="quote">+=</span>&#8221;</span> to keep
6465 the listing of global legacy options.  A warning will be issued if
6466 the user uses a legacy option.</p></li>
6467 <li class="listitem"><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
6468 options implied by deprecated variables used.  This can be used for
6469 cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
6470 <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
6471 <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
6472 <li class="listitem"><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
6473 a list of warnings about deprecated variables or options used, and
6474 what to use instead.</p></li>
6475 </ol></div>
6476 <p>A package should never modify
6477 <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
6478 <code class="varname">PKG_OPTIONS_VAR</code>.  These are strictly user-settable.
6479 To suggest a default set of options, use
6480 <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
6481 <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
6482 including <code class="filename">bsd.options.mk</code>.  If none of
6483 <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
6484 <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
6485 <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
6486 happen with platform-specific options if none of them is supported on
6487 the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
6488 empty list and the package is otherwise treated as not using the
6489 options framework.</p>
6490 <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
6491 variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
6492 build options, properly filtered to remove unsupported and duplicate
6493 options.</p>
6494 <p>The remaining sections contain the logic that is specific to
6495 each option.  The correct way to check for an option is to check
6496 whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
6497 <pre class="programlisting">
6498 .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
6499 </pre>
6500 </div>
6501 <div class="sect1">
6502 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6503 <a name="option-names"></a>16.3. Option Names</h2></div></div></div>
6504 <p>Options that enable similar features in different packages (like
6505 optional support for a library) should use a common name in all
6506 packages that support it (like the name of the library).  If another
6507 package already has an option with the same meaning, use the same
6508 name.</p>
6509 <p>Options that enable features specific to one package, where it's
6510 unlikely that another (unrelated) package has the same (or a similar)
6511 optional feature, should use a name prefixed with
6512 <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
6513 <p>If a group of related packages share an optional feature
6514 specific to that group, prefix it with the name of the
6515 <span class="quote">&#8220;<span class="quote">main</span>&#8221;</span> package
6516 (e. g. <code class="varname">djbware-errno-hack</code>).</p>
6517 <p>For new options, add a line to
6518 <code class="filename">mk/defaults/options.description</code>.  Lines have two
6519 fields, separated by tab.  The first field is the option name, the
6520 second its description.  The description should be a whole sentence
6521 (starting with an uppercase letter and ending with a period) that
6522 describes what enabling the option does.  E. g. <span class="quote">&#8220;<span class="quote">Enable ispell
6523 support.</span>&#8221;</span> The file is sorted by option names.</p>
6524 </div>
6525 <div class="sect1">
6526 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6527 <a name="option-build"></a>16.4. Determining the options of dependencies</h2></div></div></div>
6528 <p>When writing <a class="link" href="#buildlink3.mk"><code class="filename">buildlink3.mk</code></a> files, it is often necessary to list
6529 different dependencies based on the options with which the package was
6530 built. For querying these options, the file
6531 <code class="filename">pkgsrc/mk/pkg-build-options.mk</code> should be used. A
6532 typical example looks like this:</p>
6533 <pre class="programlisting">
6534 pkgbase := libpurple
6535 .include "../../mk/pkg-build-options.mk"
6536
6537 .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
6538 ...
6539 .endif
6540 </pre>
6541 <p>Including <code class="filename">pkg-build-options.mk</code> here will set
6542 the variable <code class="varname">PKG_BUILD_OPTIONS.libpurple</code> to the build
6543 options of the libpurple package, which can then be queried like
6544 <code class="varname">PKG_OPTIONS</code> in the <code class="filename">options.mk</code>
6545 file. See the file <code class="filename">pkg-build-options.mk</code> for more
6546 details.</p>
6547 </div>
6548 </div>
6549 <div class="chapter">
6550 <div class="titlepage"><div><div><h2 class="title">
6551 <a name="build"></a>Chapter 17. The build process</h2></div></div></div>
6552 <div class="toc">
6553 <p><b>Table of Contents</b></p>
6554 <dl>
6555 <dt><span class="sect1"><a href="#build.intro">17.1. Introduction</a></span></dt>
6556 <dt><span class="sect1"><a href="#build.prefix">17.2. Program location</a></span></dt>
6557 <dt><span class="sect1"><a href="#build.builddirs">17.3. Directories used during the build process</a></span></dt>
6558 <dt><span class="sect1"><a href="#build.running">17.4. Running a phase</a></span></dt>
6559 <dt><span class="sect1"><a href="#build.fetch">17.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
6560 <dd><dl>
6561 <dt><span class="sect2"><a href="#build.fetch.what">17.5.1. What to fetch and where to get it from</a></span></dt>
6562 <dt><span class="sect2"><a href="#build.fetch.how">17.5.2. How are the files fetched?</a></span></dt>
6563 </dl></dd>
6564 <dt><span class="sect1"><a href="#build.checksum">17.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
6565 <dt><span class="sect1"><a href="#build.extract">17.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
6566 <dt><span class="sect1"><a href="#build.patch">17.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
6567 <dt><span class="sect1"><a href="#build.tools">17.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
6568 <dt><span class="sect1"><a href="#build.wrapper">17.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
6569 <dt><span class="sect1"><a href="#build.configure">17.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
6570 <dt><span class="sect1"><a href="#build.build">17.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
6571 <dt><span class="sect1"><a href="#build.test">17.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
6572 <dt><span class="sect1"><a href="#build.install">17.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
6573 <dt><span class="sect1"><a href="#build.package">17.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
6574 <dt><span class="sect1"><a href="#build.clean">17.16. Cleaning up</a></span></dt>
6575 <dt><span class="sect1"><a href="#build.helpful-targets">17.17. Other helpful targets</a></span></dt>
6576 </dl>
6577 </div>
6578 <div class="sect1">
6579 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6580 <a name="build.intro"></a>17.1. Introduction</h2></div></div></div>
6581 <p>This chapter gives a detailed description on how a package is
6582     built. Building a package is separated into different
6583     <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
6584     <code class="varname">build</code>, <code class="varname">install</code>), all of which are
6585     described in the following sections. Each phase is split into
6586     so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
6587     containing phase, prefixed by one of <code class="varname">pre-</code>,
6588     <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
6589     <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
6590     of the actual work is done in the <code class="varname">do-*</code> stages.</p>
6591 <p>Never override the regular targets (like
6592     <code class="varname">fetch</code>), if you have to, override the
6593     <code class="varname">do-*</code> ones instead.</p>
6594 <p>The basic steps for building a program are always the same.  First
6595     the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
6596     the local system and then extracted. After any pkgsrc-specific patches
6597     to compile properly are applied, the software can be configured, then
6598     built (usually by compiling), and finally the generated binaries, etc.
6599     can be put into place on the system.</p>
6600 <p>To get more details about what is happening at each step,
6601     you can set the <code class="varname">PKG_VERBOSE</code> variable, or the
6602     <code class="varname">PATCH_DEBUG</code> variable if you are just interested
6603     in more details about the <span class="emphasis"><em>patch</em></span> step.</p>
6604 </div>
6605 <div class="sect1">
6606 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6607 <a name="build.prefix"></a>17.2. Program location</h2></div></div></div>
6608 <p>Before outlining the process performed by the NetBSD package system in
6609     the next section, here's a brief discussion on where programs are
6610     installed, and which variables influence this.</p>
6611 <p>The automatic variable <code class="varname">PREFIX</code> indicates
6612     where all files of the final program shall be installed. It is
6613     usually set to <code class="varname">LOCALBASE</code>
6614     (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
6615     for pkgs in the <code class="filename">cross</code> category.  The value of
6616     <code class="varname">PREFIX</code> needs to be put
6617     into the various places in the program's source where paths to
6618     these files are encoded.  See <a class="xref" href="#components.patches" title="11.3. patches/*">Section 11.3, &#8220;patches/*&#8221;</a> and <a class="xref" href="#fixes.libtool" title="19.3.1. Shared libraries - libtool">Section 19.3.1, &#8220;Shared libraries - libtool&#8221;</a> for more details.</p>
6619 <p>When choosing which of these variables to use,
6620     follow the following rules:</p>
6621 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
6622 <li class="listitem"><p><code class="varname">PREFIX</code> always points to the location
6623         where the current pkg will be installed.  When referring to a
6624         pkg's own installation path, use
6625         <span class="quote">&#8220;<span class="quote">${PREFIX}</span>&#8221;</span>.</p></li>
6626 <li class="listitem"><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs
6627         are installed.  If you need to construct a -I or -L argument
6628         to the compiler to find includes and libraries installed by
6629         another non-X11 pkg, use <span class="quote">&#8220;<span class="quote">${LOCALBASE}</span>&#8221;</span>. The name
6630         <code class="varname">LOCALBASE</code> stems from FreeBSD, which
6631         installed all packages in <code class="filename">/usr/local</code>. As
6632         pkgsrc leaves <code class="filename">/usr/local</code> for the system
6633         administrator, this variable is a misnomer.</p></li>
6634 <li class="listitem"><p><code class="varname">X11BASE</code> is where the actual X11
6635         distribution (from xsrc, etc.) is installed. When looking for
6636         <span class="emphasis"><em>standard</em></span> X11 includes (not those
6637         installed by a package), use <span class="quote">&#8220;<span class="quote">${X11BASE}</span>&#8221;</span>.</p></li>
6638 <li class="listitem">
6639 <p>X11-based packages are special in that they may be
6640         installed in either <code class="varname">X11BASE</code> or
6641         <code class="varname">LOCALBASE</code>.</p>
6642 <p>Usually, X11 packages should be installed under
6643         <code class="varname">LOCALBASE</code> whenever possible.  Note that you
6644         will need to include
6645         <code class="filename">../../mk/x11.buildlink3.mk</code> in them to
6646         request the presence of X11 and to get the right compilation
6647         flags.</p>
6648 <p>Even though, there are some packages that cannot be installed
6649         under <code class="varname">LOCALBASE</code>: those that come with app-defaults
6650         files. These packages are special and they must be placed under
6651         <code class="varname">X11BASE</code>. To accomplish this, set either
6652         <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
6653         your package.</p>
6654 <p>Some notes: If you need
6655         to find includes or libraries installed by a pkg that has
6656         <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
6657         its pkg <code class="filename">Makefile</code>, you need to look in
6658         <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
6659         <code class="filename">${LOCALBASE}</code>. To force installation of
6660         all X11 packages in <code class="varname">LOCALBASE</code>, the
6661         <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a> package
6662         is enabled by default.</p>
6663 </li>
6664 <li class="listitem"><p><code class="varname">X11PREFIX</code> should be used to refer to
6665         the installed location of an X11
6666         package. <code class="varname">X11PREFIX</code> will be set to
6667         <code class="varname">X11BASE</code> if xpkgwedge is not installed, and
6668         to <code class="varname">LOCALBASE</code> if xpkgwedge is
6669         installed.</p></li>
6670 <li class="listitem">
6671 <p>If xpkgwedge is installed, it is possible to have some
6672         packages installed in <code class="varname">X11BASE</code> and some in
6673         <code class="varname">LOCALBASE</code>.  To determine the prefix of an
6674         installed package, the <code class="varname">EVAL_PREFIX</code>
6675         definition can be used. It takes pairs in the format
6676         <span class="quote">&#8220;<span class="quote">DIRNAME=&lt;package&gt;</span>&#8221;</span>, and the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
6677         variable <code class="varname">DIRNAME</code> will be set to the prefix
6678         of the installed package &lt;package&gt;, or
6679         <span class="quote">&#8220;<span class="quote">${X11PREFIX}</span>&#8221;</span> if the package is not
6680         installed.</p>
6681 <p>This is best illustrated by example.</p>
6682 <p>The following lines are taken from
6683         <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
6684 <pre class="programlisting">
6685 EVAL_PREFIX+=           GTKDIR=gtk+
6686 CONFIGURE_ARGS+=        --with-guile-prefix=${LOCALBASE:Q}
6687 CONFIGURE_ARGS+=        --with-gtk-prefix=${GTKDIR:Q}
6688 CONFIGURE_ARGS+=        --enable-multibyte
6689 </pre>
6690 <p>Specific defaults can be defined for the packages
6691         evaluated using <code class="varname">EVAL_PREFIX</code>, by using a
6692         definition of the form:</p>
6693 <pre class="programlisting">
6694 GTKDIR_DEFAULT= ${LOCALBASE}
6695 </pre>
6696 <p>where <code class="varname">GTKDIR</code> corresponds
6697         to the first definition in
6698         the <code class="varname">EVAL_PREFIX</code> pair.</p>
6699 </li>
6700 <li class="listitem"><p>Within <code class="filename">${PREFIX}</code>, packages should
6701         install files according to <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?hier+7+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">hier</span>(7)</span></a>, with the exception that
6702         manual pages go into <code class="filename">${PREFIX}/man</code>, not
6703         <code class="filename">${PREFIX}/share/man</code>.</p></li>
6704 </ul></div>
6705 </div>
6706 <div class="sect1">
6707 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6708 <a name="build.builddirs"></a>17.3. Directories used during the build process</h2></div></div></div>
6709 <p>When building a package, various directories are used to store
6710     source files, temporary files, pkgsrc-internal files, and so on. These
6711     directories are explained here.</p>
6712 <p>Some of the directory variables contain relative pathnames. There
6713     are two common base directories for these relative directories:
6714     <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
6715     pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
6716     inside the package itself.</p>
6717 <div class="variablelist"><dl class="variablelist">
6718 <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
6719 <dd><p>This is an absolute pathname that points to the pkgsrc
6720       root directory. Generally, you don't need
6721       it.</p></dd>
6722 <dt><span class="term"><code class="varname">PKGDIR</code></span></dt>
6723 <dd><p>This is an absolute pathname that points to the
6724       current package.</p></dd>
6725 <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
6726 <dd><p>This is a pathname relative to
6727       <code class="varname">PKGSRCDIR</code> that points to the current
6728       package.</p></dd>
6729 <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
6730 <dd><p>This is an absolute pathname pointing to the directory
6731       where all work takes place. The distfiles are extracted to this
6732       directory. It also contains temporary directories and log files used by
6733       the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
6734       the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
6735 <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
6736 <dd><p>This is an absolute pathname pointing to the directory
6737       where the distfiles are extracted. It is usually a direct subdirectory
6738       of <code class="varname">WRKDIR</code>, and often it's the only directory entry
6739       that isn't hidden. This variable may be changed by a package
6740       <code class="filename">Makefile</code>.</p></dd>
6741 </dl></div>
6742 <p>The <code class="varname">CREATE_WRKDIR_SYMLINK</code> definition takes either
6743     the value <span class="emphasis"><em>yes</em></span> or <span class="emphasis"><em>no</em></span> and defaults
6744     to <span class="emphasis"><em>no</em></span>. It indicates whether a symbolic link to the
6745     <code class="varname">WRKDIR</code> is to be created in the pkgsrc entry's directory.
6746     If users would like to have their pkgsrc trees behave in a
6747     read-only manner, then the value of
6748     <code class="varname">CREATE_WRKDIR_SYMLINK</code> should be set to
6749     <span class="emphasis"><em>no</em></span>.</p>
6750 </div>
6751 <div class="sect1">
6752 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6753 <a name="build.running"></a>17.4. Running a phase</h2></div></div></div>
6754 <p>You can run a particular phase by typing <span class="command"><strong>make
6755     phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
6756     phase. This will automatically run all phases that are required for this
6757     phase. The default phase is <code class="varname">build</code>, that is, when you
6758     run <span class="command"><strong>make</strong></span> without parameters in a package directory,
6759     the package will be built, but not installed.</p>
6760 </div>
6761 <div class="sect1">
6762 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6763 <a name="build.fetch"></a>17.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
6764 <p>The first step in building a package is to fetch the
6765     distribution files (distfiles) from the sites that are providing
6766     them. This is the task of the <span class="emphasis"><em>fetch</em></span>
6767     phase.</p>
6768 <div class="sect2">
6769 <div class="titlepage"><div><div><h3 class="title">
6770 <a name="build.fetch.what"></a>17.5.1. What to fetch and where to get it from</h3></div></div></div>
6771 <p>In simple cases, <code class="varname">MASTER_SITES</code>
6772       defines all URLs from where the distfile, whose name is
6773       derived from the <code class="varname">DISTNAME</code> variable, is
6774       fetched. The more complicated cases are described
6775       below.</p>
6776 <p>The variable <code class="varname">DISTFILES</code> specifies
6777       the list of distfiles that have to be fetched. Its value
6778       defaults to <code class="literal">${DISTNAME}${EXTRACT_SUFX}</code>,
6779       so that most packages don't need to define it at all.
6780       <code class="varname">EXTRACT_SUFX</code> is
6781       <code class="literal">.tar.gz</code> by default, but can be changed
6782       freely. Note that if your package requires additional
6783       distfiles to the default one, you cannot just append the
6784       additional filenames using the <code class="literal">+=</code>
6785       operator, but you have write for example:</p>
6786 <pre class="programlisting">
6787 DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
6788 </pre>
6789 <p>Each distfile is fetched from a list of sites, usually
6790       <code class="varname">MASTER_SITES</code>. If the package has multiple
6791       <code class="varname">DISTFILES</code> or multiple
6792       <code class="varname">PATCHFILES</code> from different sites, you can
6793       set
6794       <code class="varname">SITES.<em class="replaceable"><code>distfile</code></em></code>
6795       to the list of URLs where the file
6796       <code class="filename"><em class="replaceable"><code>distfile</code></em></code>
6797       (including the suffix) can be found.</p>
6798 <pre class="programlisting">
6799 DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
6800 DISTFILES+=     foo-file.tar.gz
6801 SITES.foo-file.tar.gz= \
6802 http://www.somewhere.com/somehow/ \
6803 http://www.somewhereelse.com/mirror/somehow/
6804 </pre>
6805 <p>When actually fetching the distfiles, each item from
6806       <code class="varname">MASTER_SITES</code> or
6807       <code class="varname">SITES.*</code> gets the name of each distfile
6808       appended to it, without an intermediate slash. Therefore,
6809       all site values have to end with a slash or other separator
6810       character. This allows for example to set
6811       <code class="varname">MASTER_SITES</code> to a URL of a CGI script
6812       that gets the name of the distfile as a parameter. In this
6813       case, the definition would look like:</p>
6814 <pre class="programlisting">
6815 MASTER_SITES=   http://www.example.com/download.cgi?file=
6816 </pre>
6817 <p> The exception to this rule are URLs starting with a dash.
6818       In that case the URL is taken as is, fetched and the result stored
6819       under the name of the distfile.</p>
6820 <p>There are some predefined values for
6821       <code class="varname">MASTER_SITES</code>, which can be used in
6822       packages.  The names of the variables should speak for
6823       themselves.</p>
6824 <pre class="programlisting">
6825 ${MASTER_SITE_APACHE}
6826 ${MASTER_SITE_BACKUP}
6827 ${MASTER_SITE_CYGWIN}
6828 ${MASTER_SITE_DEBIAN}
6829 ${MASTER_SITE_FREEBSD}
6830 ${MASTER_SITE_FREEBSD_LOCAL}
6831 ${MASTER_SITE_GENTOO}
6832 ${MASTER_SITE_GNOME}
6833 ${MASTER_SITE_GNU}
6834 ${MASTER_SITE_GNUSTEP}
6835 ${MASTER_SITE_IFARCHIVE}
6836 ${MASTER_SITE_KDE}
6837 ${MASTER_SITE_MOZILLA}
6838 ${MASTER_SITE_MYSQL}
6839 ${MASTER_SITE_OPENOFFICE}
6840 ${MASTER_SITE_PERL_CPAN}
6841 ${MASTER_SITE_PGSQL}
6842 ${MASTER_SITE_R_CRAN}
6843 ${MASTER_SITE_SOURCEFORGE}
6844 ${MASTER_SITE_SOURCEFORGE_JP}
6845 ${MASTER_SITE_SUNSITE}
6846 ${MASTER_SITE_SUSE}
6847 ${MASTER_SITE_TEX_CTAN}
6848 ${MASTER_SITE_XCONTRIB}
6849 ${MASTER_SITE_XEMACS}
6850 </pre>
6851 <p>Some explanations for the less self-explaining ones:
6852       <code class="varname">MASTER_SITE_BACKUP</code> contains backup sites
6853       for packages that are maintained in <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/%24%7BDIST_SUBDIR%7D" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/${DIST_SUBDIR}</a>.  <code class="varname">MASTER_SITE_LOCAL</code> contains local
6854       package source distributions that are maintained in <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/LOCAL_PORTS/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/LOCAL_PORTS/</a>.</p>
6855 <p>If you choose one of these predefined sites, you may
6856       want to specify a subdirectory of that site. Since these
6857       macros may expand to more than one actual site, you
6858       <span class="emphasis"><em>must</em></span> use the following construct to
6859       specify a subdirectory:</p>
6860 <pre class="programlisting">
6861 MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
6862 MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
6863 </pre>
6864 <p>Note the trailing slash after the subdirectory
6865       name.</p>
6866 </div>
6867 <div class="sect2">
6868 <div class="titlepage"><div><div><h3 class="title">
6869 <a name="build.fetch.how"></a>17.5.2. How are the files fetched?</h3></div></div></div>
6870 <p>The <span class="emphasis"><em>fetch</em></span> phase makes sure that
6871       all the distfiles exist in a local directory
6872       (<code class="varname">DISTDIR</code>, which can be set by the pkgsrc
6873       user). If the files do not exist, they are fetched using
6874       commands of the form</p>
6875 <pre class="programlisting">
6876 ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
6877 </pre>
6878 <p>where <code class="literal">${site}</code> varies through
6879       several possibilities in turn: first,
6880       <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the
6881       sites specified in either <code class="varname">SITES.file</code> if
6882       defined, else <code class="varname">MASTER_SITES</code> or
6883       <code class="varname">PATCH_SITES</code>, as applies, then finally the
6884       value of <code class="varname">MASTER_SITE_BACKUP</code>. The order of
6885       all except the first and the last can be optionally sorted
6886       by the user, via setting either
6887       <code class="varname">MASTER_SORT_RANDOM</code>, and
6888       <code class="varname">MASTER_SORT_AWK</code> or
6889       <code class="varname">MASTER_SORT_REGEX</code>.</p>
6890 <p> The specific command and arguments used depend on the
6891       <code class="varname">FETCH_USING</code> parameter. The example above is
6892       for <code class="literal">FETCH_USING=custom</code>.</p>
6893 <p>The distfiles mirror run by the NetBSD Foundation uses the
6894       <span class="emphasis"><em>mirror-distfiles</em></span> target to mirror the
6895       distfiles, if they are freely distributable.  Packages setting
6896       <code class="varname">NO_SRC_ON_FTP</code> (usually to
6897       <span class="quote">&#8220;<span class="quote">${RESTRICTED}</span>&#8221;</span>) will not have their distfiles
6898       mirrored.</p>
6899 </div>
6900 </div>
6901 <div class="sect1">
6902 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6903 <a name="build.checksum"></a>17.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
6904 <p>After the distfile(s) are fetched, their checksum is
6905     generated and compared with the checksums stored in the
6906     distinfo file. If the checksums don't match, the build is
6907     aborted. This is to ensure the same distfile is used for
6908     building, and that the distfile wasn't changed, e.g. by some
6909     malign force, deliberately changed distfiles on the master
6910     distribution site or network lossage.</p>
6911 </div>
6912 <div class="sect1">
6913 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6914 <a name="build.extract"></a>17.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
6915 <p>When the distfiles are present on the local system, they
6916     need to be extracted, as they usually come in the form of some
6917     compressed archive format.</p>
6918 <p>By default, all <code class="varname">DISTFILES</code> are
6919     extracted. If you only need some of them, you can set the
6920     <code class="varname">EXTRACT_ONLY</code> variable to the list of those
6921     files.</p>
6922 <p>Extracting the files is usually done by a little
6923     program, <code class="filename">mk/extract/extract</code>, which
6924     already knows how to extract various archive formats, so most
6925     likely you will not need to change anything here. But if you
6926     need, the following variables may help you:</p>
6927 <div class="variablelist"><dl class="variablelist">
6928 <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
6929 <dd><p>Use these variables to override the default
6930       options for an extract command, which are defined in
6931       <code class="filename">mk/extract/extract</code>.</p></dd>
6932 <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
6933 <dd><p>This variable can be set to
6934       <code class="literal">bsdtar</code>, <code class="literal">gtar</code>, <code class="literal">nbtar</code>
6935       (which is the default value), <code class="literal">pax</code>, or an
6936       absolute pathname pointing to the command with which tar
6937       archives should be extracted.  It is preferred to choose bsdtar over gtar
6938       if NetBSD's pax-as-tar is not good enough.</p></dd>
6939 </dl></div>
6940 <p>If the <code class="filename">extract</code> program doesn't
6941     serve your needs, you can also override the
6942     <code class="varname">EXTRACT_CMD</code> variable, which holds the
6943     command used for extracting the files. This command is
6944     executed in the <code class="filename">${WRKSRC}</code>
6945     directory. During execution of this command, the shell
6946     variable <code class="varname">extract_file</code> holds the absolute
6947     pathname of the file that is going to be extracted.</p>
6948 <p>And if that still does not suffice, you can override the
6949     <code class="varname">do-extract</code> target in the package
6950     Makefile.</p>
6951 </div>
6952 <div class="sect1">
6953 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6954 <a name="build.patch"></a>17.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
6955 <p>After extraction, all the patches named by the
6956     <code class="varname">PATCHFILES</code>, those present in the patches
6957     subdirectory of the package as well as in
6958     $LOCALPATCHES/$PKGPATH (e.g.
6959     <code class="filename">/usr/local/patches/graphics/png</code>) are
6960     applied.  Patchfiles ending in <code class="filename">.Z</code> or
6961     <code class="filename">.gz</code> are uncompressed before they are
6962     applied, files ending in <code class="filename">.orig</code> or
6963     <code class="filename">.rej</code> are ignored. Any special options to
6964     <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span></a> can be handed in
6965     <code class="varname">PATCH_DIST_ARGS</code>.  See <a class="xref" href="#components.patches" title="11.3. patches/*">Section 11.3, &#8220;patches/*&#8221;</a> for more details.</p>
6966 <p>By default <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span></a> is given special args to make
6967     it fail if the patches apply with some lines of fuzz. Please
6968     fix (regen) the patches so that they apply cleanly. The
6969     rationale behind this is that patches that don't apply cleanly
6970     may end up being applied in the wrong place, and cause severe
6971     harm there.</p>
6972 </div>
6973 <div class="sect1">
6974 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6975 <a name="build.tools"></a>17.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
6976 <p>This is covered in <a class="xref" href="#tools" title="Chapter 18. Tools needed for building or running">Chapter 18, <i>Tools needed for building or running</i></a>.
6977     </p>
6978 </div>
6979 <div class="sect1">
6980 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6981 <a name="build.wrapper"></a>17.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
6982 <p>This phase creates wrapper programs for the compilers and
6983     linkers. The following variables can be used to tweak the
6984     wrappers.</p>
6985 <div class="variablelist"><dl class="variablelist">
6986 <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
6987 <dd><p>The command used to print progress
6988       messages. Does nothing by default. Set to
6989       <code class="literal">${ECHO}</code> to see the progress
6990       messages.</p></dd>
6991 <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
6992 <dd><p>This variable can be set to
6993       <code class="literal">yes</code> (default) or <code class="literal">no</code>,
6994       depending on whether you want additional information in the
6995       wrapper log file.</p></dd>
6996 <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
6997 <dd><p>This variable can be set to
6998       <code class="literal">yes</code> or <code class="literal">no</code>, depending
6999       on whether the wrapper should use its cache, which will
7000       improve the speed. The default value is
7001       <code class="literal">yes</code>, but is forced to
7002       <code class="literal">no</code> if the platform does not support
7003       it.</p></dd>
7004 <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
7005 <dd><p>A list of reordering commands. A reordering
7006       command has the form
7007       <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
7008       It ensures that that
7009       <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code> occurs
7010       before <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
7011       </p></dd>
7012 <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
7013 <dd><p>A list of transformation commands. [TODO:
7014       investigate further]</p></dd>
7015 </dl></div>
7016 </div>
7017 <div class="sect1">
7018 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7019 <a name="build.configure"></a>17.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
7020 <p>Most pieces of software need information on the header
7021     files, system calls, and library routines which are available
7022     on the platform they run on. The process of determining this
7023     information is known as configuration, and is usually
7024     automated. In most cases, a script is supplied with the
7025     distfiles, and its invocation results in generation of header
7026     files, Makefiles, etc.</p>
7027 <p>If the package contains a configure script, this can be
7028     invoked by setting <code class="varname">HAS_CONFIGURE</code> to
7029     <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>. If the configure script is a GNU autoconf
7030     script, you should set <code class="varname">GNU_CONFIGURE</code> to
7031     <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span> instead. What happens in the
7032     <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
7033 <pre class="programlisting">
7034 .for d in ${CONFIGURE_DIRS}
7035         cd ${WRKSRC} \
7036         &amp;&amp; cd ${d} \
7037         &amp;&amp; env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
7038 .endfor
7039 </pre>
7040 <p><code class="varname">CONFIGURE_DIRS</code> (default:
7041     <span class="quote">&#8220;<span class="quote">.</span>&#8221;</span>) is a list of pathnames relative to
7042     <code class="varname">WRKSRC</code>. In each of these directories, the
7043     configure script is run with the environment
7044     <code class="varname">CONFIGURE_ENV</code> and arguments
7045     <code class="varname">CONFIGURE_ARGS</code>. The variables
7046     <code class="varname">CONFIGURE_ENV</code>,
7047     <code class="varname">CONFIGURE_SCRIPT</code> (default:
7048     <span class="quote">&#8220;<span class="quote">./configure</span>&#8221;</span>) and
7049     <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
7050     package.</p>
7051 <p>If the program uses the Perl way of configuration (mainly Perl
7052     modules, but not only), i.e. a file called
7053     <code class="filename">Makefile.PL</code>, it should include
7054     <code class="filename">../../lang/perl5/module.mk</code>. To set any parameter for
7055     <code class="filename">Makefile.PL</code> use the <code class="varname">MAKE_PARAMS</code>
7056     variable (e.g., <code class="literal">MAKE_PARAMS+=foo=bar</code></p>
7057 <p>If the program uses an <code class="filename">Imakefile</code>
7058     for configuration, the appropriate steps can be invoked by
7059     setting <code class="varname">USE_IMAKE</code> to
7060     <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>. (If you only want the package installed in
7061     <code class="varname">${X11PREFIX}</code> but xmkmf not being run, set
7062     <code class="varname">USE_X11BASE</code> instead.)  You can add variables to
7063     xmkmf's environment by adding them to the
7064     <code class="varname">SCRIPTS_ENV</code> variable.</p>
7065 <p>If the program uses <code class="filename">cmake</code>
7066     for configuration, the appropriate steps can be invoked by
7067     setting <code class="varname">USE_CMAKE</code> to <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>.
7068     You can add variables to cmake's environment by adding them to the
7069     <code class="varname">CONFIGURE_ENV</code> variable and arguments to cmake
7070     by adding them to the <code class="varname">CMAKE_ARGS</code> variable.
7071     The top directory argument is given by the
7072     <code class="varname">CMAKE_ARG_PATH</code> variable, that defaults to
7073     <span class="quote">&#8220;<span class="quote">.</span>&#8221;</span> (relative to <code class="varname">CONFIGURE_DIRS</code>)</p>
7074 <p>If there is no configure step at all, set
7075     <code class="varname">NO_CONFIGURE</code> to <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>.</p>
7076 </div>
7077 <div class="sect1">
7078 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7079 <a name="build.build"></a>17.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
7080 <p>For building a package, a rough equivalent of the
7081     following code is executed.</p>
7082 <pre class="programlisting">
7083 .for d in ${BUILD_DIRS}
7084         cd ${WRKSRC} \
7085         &amp;&amp; cd ${d} \
7086         &amp;&amp; env ${MAKE_ENV} \
7087             ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
7088                 -f ${MAKE_FILE} \
7089                 ${BUILD_TARGET}
7090 .endfor
7091 </pre>
7092 <p><code class="varname">BUILD_DIRS</code> (default:
7093     <span class="quote">&#8220;<span class="quote">.</span>&#8221;</span>) is a list of pathnames relative to
7094     <code class="varname">WRKSRC</code>. In each of these directories,
7095     <code class="varname">MAKE_PROGRAM</code> is run with the environment
7096     <code class="varname">MAKE_ENV</code> and arguments
7097     <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
7098     <code class="varname">MAKE_ENV</code>,
7099     <code class="varname">BUILD_MAKE_FLAGS</code>,
7100     <code class="varname">MAKE_FILE</code> and
7101     <code class="varname">BUILD_TARGET</code> may all be changed by the
7102     package.</p>
7103 <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
7104     <span class="quote">&#8220;<span class="quote">gmake</span>&#8221;</span> if <code class="varname">USE_TOOLS</code> contains
7105     <span class="quote">&#8220;<span class="quote">gmake</span>&#8221;</span>, <span class="quote">&#8220;<span class="quote">make</span>&#8221;</span> otherwise. The
7106     default value of <code class="varname">MAKE_FILE</code> is
7107     <span class="quote">&#8220;<span class="quote">Makefile</span>&#8221;</span>, and <code class="varname">BUILD_TARGET</code>
7108     defaults to <span class="quote">&#8220;<span class="quote">all</span>&#8221;</span>.</p>
7109 <p>If there is no build step at all, set
7110     <code class="varname">NO_BUILD</code> to <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>.</p>
7111 </div>
7112 <div class="sect1">
7113 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7114 <a name="build.test"></a>17.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
7115 <p>[TODO]</p>
7116 </div>
7117 <div class="sect1">
7118 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7119 <a name="build.install"></a>17.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
7120 <p>Once the build stage has completed, the final step is to
7121     install the software in public directories, so users can
7122     access the programs and files.</p>
7123 <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
7124     equivalent of the following code is executed. Additionally,
7125     before and after this code, much magic is performed to do
7126     consistency checks, registering the package, and so on.</p>
7127 <pre class="programlisting">
7128 .for d in ${INSTALL_DIRS}
7129         cd ${WRKSRC} \
7130         &amp;&amp; cd ${d} \
7131         &amp;&amp; env ${MAKE_ENV} \
7132             ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
7133                 -f ${MAKE_FILE} \
7134                 ${INSTALL_TARGET}
7135 .endfor
7136 </pre>
7137 <p>The variable's meanings are analogous to the ones in the
7138     <span class="emphasis"><em>build</em></span> phase.
7139     <code class="varname">INSTALL_DIRS</code> defaults to
7140     <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
7141     is <span class="quote">&#8220;<span class="quote">install</span>&#8221;</span> by default, plus
7142     <span class="quote">&#8220;<span class="quote">install.man</span>&#8221;</span> if <code class="varname">USE_IMAKE</code> is
7143     defined and <code class="varname">NO_INSTALL_MANPAGES</code> is not
7144     defined.</p>
7145 <p>In the <span class="emphasis"><em>install</em></span> phase, the following
7146     variables are useful. They are all variations of the
7147     <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?install+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">install</span>(1)</span></a> command that have the owner, group and
7148     permissions preset. <code class="varname">INSTALL</code> is the plain
7149     install command. The specialized variants, together with their
7150     intended use, are:</p>
7151 <div class="variablelist"><dl class="variablelist">
7152 <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
7153 <dd><p>directories that contain
7154       binaries</p></dd>
7155 <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
7156 <dd><p>directories that contain
7157       scripts</p></dd>
7158 <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
7159 <dd><p>directories that contain shared and static
7160       libraries</p></dd>
7161 <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
7162 <dd><p>directories that contain data
7163       files</p></dd>
7164 <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
7165 <dd><p>directories that contain man
7166       pages</p></dd>
7167 <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
7168 <dd><p>binaries that can be stripped from debugging
7169       symbols</p></dd>
7170 <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
7171 <dd><p>binaries that cannot be
7172       stripped</p></dd>
7173 <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
7174 <dd><p>game
7175       binaries</p></dd>
7176 <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
7177 <dd><p>shared and static
7178       libraries</p></dd>
7179 <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
7180 <dd><p>data files</p></dd>
7181 <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
7182 <dd><p>data files for
7183       games</p></dd>
7184 <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
7185 <dd><p>man pages</p></dd>
7186 </dl></div>
7187 <p>Some other variables are:</p>
7188 <div class="variablelist"><dl class="variablelist">
7189 <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
7190 <dd><p>A list of directories relative to
7191       <code class="varname">PREFIX</code> that are created by pkgsrc at the
7192       beginning of the <span class="emphasis"><em>install</em></span> phase.
7193       The package is supposed to create all needed directories itself
7194       before installing files to it and list all other directories here.
7195       </p></dd>
7196 </dl></div>
7197 <p>In the rare cases that a package shouldn't install anything,
7198     set <code class="varname">NO_INSTALL</code> to <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>. This is
7199     mostly relevant for packages in the <code class="filename">regress</code>
7200     category.</p>
7201 </div>
7202 <div class="sect1">
7203 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7204 <a name="build.package"></a>17.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
7205 <p>Once the install stage has completed, a binary package of
7206     the installed files can be built.  These binary packages can be
7207     used for quick installation without previous compilation, e.g. by
7208     the <span class="command"><strong>make bin-install</strong></span> or by using
7209     <span class="command"><strong>pkg_add</strong></span>.</p>
7210 <p>By default, the binary packages are created in
7211     <code class="filename">${PACKAGES}/All</code> and symlinks are created in
7212     <code class="filename">${PACKAGES}/<em class="replaceable"><code>category</code></em></code>,
7213     one for each category in the <code class="varname">CATEGORIES</code>
7214     variable.  <code class="varname">PACKAGES</code> defaults to
7215     <code class="filename">pkgsrc/packages</code>.</p>
7216 </div>
7217 <div class="sect1">
7218 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7219 <a name="build.clean"></a>17.16. Cleaning up</h2></div></div></div>
7220 <p>Once you're finished with a package, you can clean the work
7221     directory by running <span class="command"><strong>make clean</strong></span>.  If you want
7222     to clean the work directories of all dependencies too, use
7223     <span class="command"><strong>make clean-depends</strong></span>.</p>
7224 </div>
7225 <div class="sect1">
7226 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7227 <a name="build.helpful-targets"></a>17.17. Other helpful targets</h2></div></div></div>
7228 <div class="variablelist"><dl class="variablelist">
7229 <dt><span class="term">pre/post-*</span></dt>
7230 <dd><p>For any of the main targets described in the
7231           previous section, two auxiliary targets exist with
7232           <span class="quote">&#8220;<span class="quote">pre-</span>&#8221;</span> and <span class="quote">&#8220;<span class="quote">post-</span>&#8221;</span> used as a
7233           prefix for the main target's name.  These targets are
7234           invoked before and after the main target is called,
7235           allowing extra configuration or installation steps be
7236           performed from a package's Makefile, for example, which
7237           a program's configure script or install target
7238           omitted.</p></dd>
7239 <dt><span class="term">do-*</span></dt>
7240 <dd><p>Should one of the main targets do the wrong thing,
7241           and should there be no variable to fix this, you can
7242           redefine it with the do-* target.  (Note that redefining
7243           the target itself instead of the do-* target is a bad
7244           idea, as the pre-* and post-* targets won't be called
7245           anymore, etc.) You will not usually need to do
7246           this.</p></dd>
7247 <dt><span class="term">reinstall</span></dt>
7248 <dd>
7249 <p>If you did a <span class="command"><strong>make install</strong></span> and
7250           you noticed some file was not installed properly, you
7251           can repeat the installation with this target, which will
7252           ignore the <span class="quote">&#8220;<span class="quote">already installed</span>&#8221;</span> flag.</p>
7253 <p>This is the default value of
7254           <code class="varname">DEPENDS_TARGET</code> except in the case of
7255           <span class="command"><strong>make update</strong></span> and <span class="command"><strong>make
7256           package</strong></span>, where the defaults are
7257           <span class="quote">&#8220;<span class="quote">package</span>&#8221;</span> and <span class="quote">&#8220;<span class="quote">update</span>&#8221;</span>,
7258           respectively.</p>
7259 </dd>
7260 <dt><span class="term">deinstall</span></dt>
7261 <dd>
7262 <p>This target does a <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> in the
7263           current directory, effectively de-installing the
7264           package. The following variables can be used to tune the
7265           behaviour:</p>
7266 <div class="variablelist"><dl class="variablelist">
7267 <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
7268 <dd><p>Add a "-v" to the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> command.</p></dd>
7269 <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
7270 <dd><p>Remove all packages that require (depend on)
7271                 the given package.  This can be used to remove any
7272                 packages that may have been pulled in by a given
7273                 package, e.g. if <span class="command"><strong>make deinstall
7274                 DEINSTALLDEPENDS=1</strong></span> is done in
7275                 <code class="filename">pkgsrc/x11/kde</code>, this is
7276                 likely to remove whole KDE. Works by adding
7277                 <span class="quote">&#8220;<span class="quote">-R</span>&#8221;</span> to the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a>
7278                 command line.</p></dd>
7279 </dl></div>
7280 </dd>
7281 <dt><span class="term">bin-install</span></dt>
7282 <dd><p>Install a binary package from local disk and via FTP
7283           from a list of sites (see the
7284           <code class="varname">BINPKG_SITES</code> variable), and do a
7285           <span class="command"><strong>make package</strong></span> if no binary package is
7286           available anywhere.  The arguments given to
7287           <span class="command"><strong>pkg_add</strong></span> can be set via
7288           <code class="varname">BIN_INSTALL_FLAGS</code> e.g., to do verbose
7289           operation, etc.</p></dd>
7290 <dt><span class="term">update</span></dt>
7291 <dd>
7292 <p>This target causes the current package to be
7293           updated to the latest version.  The package and all
7294           depending packages first get de-installed, then current
7295           versions of the corresponding packages get compiled and
7296           installed.  This is similar to manually noting which
7297           packages are currently installed, then performing a
7298           series of <span class="command"><strong>make deinstall</strong></span> and
7299           <span class="command"><strong>make install</strong></span> (or whatever
7300           <code class="varname">UPDATE_TARGET</code> is set to) for these
7301           packages.</p>
7302 <p>You can use the <span class="quote">&#8220;<span class="quote">update</span>&#8221;</span> target to
7303           resume package updating in case a previous <span class="command"><strong>make
7304           update</strong></span> was interrupted for some reason.
7305           However, in this case, make sure you don't call
7306           <span class="command"><strong>make clean</strong></span> or otherwise remove the
7307           list of dependent packages in <code class="varname">WRKDIR</code>.
7308           Otherwise, you lose the ability to automatically update
7309           the current package along with the dependent packages
7310           you have installed.</p>
7311 <p>Resuming an interrupted <span class="command"><strong>make
7312           update</strong></span> will only work as long as the package
7313           tree remains unchanged.  If the source code for one of
7314           the packages to be updated has been changed, resuming
7315           <span class="command"><strong>make update</strong></span> will most certainly
7316           fail!</p>
7317 <p>The following variables can be used either on the
7318           command line or in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to
7319           alter the behaviour of <span class="command"><strong>make
7320           update</strong></span>:</p>
7321 <div class="variablelist"><dl class="variablelist">
7322 <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
7323 <dd><p>Install target to recursively use for the
7324                 updated package and the dependent packages.
7325                 Defaults to <code class="varname">DEPENDS_TARGET</code> if
7326                 set, <span class="quote">&#8220;<span class="quote">install</span>&#8221;</span> otherwise for
7327                 <span class="command"><strong>make update</strong></span>.  Other good
7328                 targets are <span class="quote">&#8220;<span class="quote">package</span>&#8221;</span> or
7329                 <span class="quote">&#8220;<span class="quote">bin-install</span>&#8221;</span>.  Do not set this to
7330                 <span class="quote">&#8220;<span class="quote">update</span>&#8221;</span> or you will get stuck in an
7331                 endless loop!</p></dd>
7332 <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
7333 <dd><p>Don't clean up after updating.  Useful if
7334                 you want to leave the work sources of the updated
7335                 packages around for inspection or other purposes.
7336                 Be sure you eventually clean up the source tree
7337                 (see the <span class="quote">&#8220;<span class="quote">clean-update</span>&#8221;</span> target below)
7338                 or you may run into troubles with old source code
7339                 still lying around on your next
7340                 <span class="command"><strong>make</strong></span> or <span class="command"><strong>make
7341                 update</strong></span>.</p></dd>
7342 <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
7343 <dd><p>Deinstall each package before installing
7344                 (making <code class="varname">DEPENDS_TARGET</code>). This
7345                 may be necessary if the
7346                 <span class="quote">&#8220;<span class="quote">clean-update</span>&#8221;</span> target (see below) was
7347                 called after interrupting a running <span class="command"><strong>make
7348                 update</strong></span>.</p></dd>
7349 <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
7350 <dd><p>Allows you to disable recursion and hardcode
7351                 the target for packages.  The default is
7352                 <span class="quote">&#8220;<span class="quote">update</span>&#8221;</span> for the update target,
7353                 facilitating a recursive update of prerequisite
7354                 packages.  Only set
7355                 <code class="varname">DEPENDS_TARGET</code> if you want to
7356                 disable recursive updates. Use
7357                 <code class="varname">UPDATE_TARGET</code> instead to just
7358                 set a specific target for each package to be
7359                 installed during <span class="command"><strong>make update</strong></span>
7360                 (see above).</p></dd>
7361 </dl></div>
7362 </dd>
7363 <dt><span class="term">clean-update</span></dt>
7364 <dd>
7365 <p>Clean the source tree for all packages that would
7366           get updated if <span class="command"><strong>make update</strong></span> was called
7367           from the current directory.  This target should not be
7368           used if the current package (or any of its depending
7369           packages) have already been de-installed (e.g., after
7370           calling <span class="command"><strong>make update</strong></span>) or you may lose
7371           some packages you intended to update. As a rule of
7372           thumb: only use this target <span class="emphasis"><em>before</em></span>
7373           the first time you run <span class="command"><strong>make update</strong></span>
7374           and only if you have a dirty package tree (e.g., if you
7375           used <code class="varname">NOCLEAN</code>).</p>
7376 <p>If you are unsure about whether your tree is
7377           clean, you can either perform a <span class="command"><strong>make
7378           clean</strong></span> at the top of the tree, or use the
7379           following sequence of commands from the directory of the
7380           package you want to update (<span class="emphasis"><em>before</em></span>
7381           running <span class="command"><strong>make update</strong></span> for the first
7382           time, otherwise you lose all the packages you wanted to
7383           update!):</p>
7384 <pre class="screen">
7385 <code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
7386 <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
7387 <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong>
7388           </pre>
7389 <p>The following variables can be used either on the
7390           command line or in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to alter the behaviour of
7391           <span class="command"><strong>make clean-update</strong></span>:</p>
7392 <div class="variablelist"><dl class="variablelist">
7393 <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
7394 <dd><p>After <span class="command"><strong>make clean</strong></span>, do not
7395                 reconstruct the list of directories to update for
7396                 this package.  Only use this if <span class="command"><strong>make
7397                 update</strong></span> successfully installed all
7398                 packages you wanted to update.  Normally, this is
7399                 done automatically on <span class="command"><strong>make
7400                 update</strong></span>, but may have been suppressed by
7401                 the <code class="varname">NOCLEAN</code> variable (see
7402                 above).</p></dd>
7403 </dl></div>
7404 </dd>
7405 <dt><span class="term">replace</span></dt>
7406 <dd>
7407 <p>Update the installation of the current package.  This
7408           differs from update in that it does not replace dependent
7409           packages.  You will need to install <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgtools/pkg_tarup</code></a> for this
7410           target to work.</p>
7411 <p><span class="emphasis"><em>Be careful when using this
7412           target!</em></span> There are no guarantees that dependent
7413           packages will still work, in particular they will most
7414           certainly break if you <span class="command"><strong>make replace</strong></span> a
7415           library package whose shared library major version changed
7416           between your installed version and the new one.  For this
7417           reason, this target is not officially supported and only
7418           recommended for advanced users.</p>
7419 </dd>
7420 <dt><span class="term">info</span></dt>
7421 <dd><p>This target invokes <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_info+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_info</span>(1)</span></a> for the current
7422           package. You can use this to check which version of a
7423           package is installed.</p></dd>
7424 <dt><span class="term">index</span></dt>
7425 <dd>
7426 <p>This is a top-level command, i.e. it should be used in
7427           the <code class="filename">pkgsrc</code> directory.  It creates a
7428           database of all packages in the local pkgsrc tree, including
7429           dependencies, comment, maintainer, and some other useful
7430           information.  Individual entries are created by running
7431           <span class="command"><strong>make describe</strong></span> in the packages'
7432           directories.  This index file is saved as
7433           <code class="filename">pkgsrc/INDEX</code>.  It can be displayed in
7434           verbose format by running <span class="command"><strong>make
7435           print-index</strong></span>.  You can search in it with
7436           <span class="command"><strong>make search
7437           key=<em class="replaceable"><code>something</code></em></strong></span>.  You can
7438           extract a list of all packages that depend on a particular
7439           one by running <span class="command"><strong>make show-deps
7440           PKG=<em class="replaceable"><code>somepackage</code></em></strong></span>.</p>
7441 <p>Running this command takes a very long time, some
7442           hours even on fast machines!</p>
7443 </dd>
7444 <dt><span class="term">readme</span></dt>
7445 <dd>
7446 <p>This target generates a
7447           <code class="filename">README.html</code> file, which can be
7448           viewed using a browser such as <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/links/README.html" target="_top"><code class="filename">www/links</code></a>.  The generated files
7449           contain references to any packages which are in the
7450           <code class="varname">PACKAGES</code> directory on the local
7451           host. The generated files can be made to refer to URLs
7452           based on <code class="varname">FTP_PKG_URL_HOST</code> and
7453           <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I
7454           wanted to generate <code class="filename">README.html</code>
7455           files which pointed to binary packages on the local
7456           machine, in the directory
7457           <code class="filename">/usr/packages</code>, set
7458           <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
7459           <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
7460           <code class="varname">${PACKAGES}</code> directory and its
7461           subdirectories will be searched for all the binary
7462           packages.</p>
7463 <p>The target can be run at the toplevel or in category
7464           directories, in which case it descends recursively.</p>
7465 </dd>
7466 <dt><span class="term">readme-all</span></dt>
7467 <dd><p>This is a top-level command, run it in
7468           <code class="filename">pkgsrc</code>.  Use this target to create a
7469           file <code class="filename">README-all.html</code> which contains a
7470           list of all packages currently available in the NetBSD
7471           Packages Collection, together with the category they belong
7472           to and a short description. This file is compiled from the
7473           <code class="filename">pkgsrc/*/README.html</code> files, so be sure
7474           to run this <span class="emphasis"><em>after</em></span> a <span class="command"><strong>make
7475           readme</strong></span>.</p></dd>
7476 <dt><span class="term">cdrom-readme</span></dt>
7477 <dd><p>This is very much the same as the
7478           <span class="quote">&#8220;<span class="quote">readme</span>&#8221;</span> target (see above), but is to be
7479           used when generating a pkgsrc tree to be written to a
7480           CD-ROM.  This target also produces
7481           <code class="filename">README.html</code> files, and can be made
7482           to refer to URLs based on
7483           <code class="varname">CDROM_PKG_URL_HOST</code> and
7484           <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
7485 <dt><span class="term">show-distfiles</span></dt>
7486 <dd><p>This target shows which distfiles and patchfiles
7487           are needed to build the package
7488           (<code class="varname">ALLFILES</code>, which contains all
7489           <code class="varname">DISTFILES</code> and
7490           <code class="varname">PATCHFILES</code>, but not
7491           <code class="filename">patches/*</code>).</p></dd>
7492 <dt><span class="term">show-downlevel</span></dt>
7493 <dd><p>This target shows nothing if the package is not
7494           installed. If a version of this package is installed,
7495           but is not the version provided in this version of
7496           pkgsrc, then a warning message is displayed. This target
7497           can be used to show which of your installed packages are
7498           downlevel, and so the old versions can be deleted, and
7499           the current ones added.</p></dd>
7500 <dt><span class="term">show-pkgsrc-dir</span></dt>
7501 <dd><p>This target shows the directory in the pkgsrc
7502           hierarchy from which the package can be built and
7503           installed. This may not be the same directory as the one
7504           from which the package was installed. This target is
7505           intended to be used by people who may wish to upgrade
7506           many packages on a single host, and can be invoked from
7507           the top-level pkgsrc Makefile by using the
7508           <span class="quote">&#8220;<span class="quote">show-host-specific-pkgs</span>&#8221;</span> target.</p></dd>
7509 <dt><span class="term">show-installed-depends</span></dt>
7510 <dd><p>This target shows which installed packages match
7511           the current package's <code class="varname">DEPENDS</code>. Useful
7512           if out of date dependencies are causing build
7513           problems.</p></dd>
7514 <dt><span class="term">check-shlibs</span></dt>
7515 <dd><p>After a package is installed, check all its
7516           binaries and (on ELF platforms) shared libraries to see
7517           if they find the shared libs they need.  Run by default
7518           if <code class="varname">PKG_DEVELOPER</code> is set in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.</p></dd>
7519 <dt><span class="term">print-PLIST</span></dt>
7520 <dd>
7521 <p>After a <span class="quote">&#8220;<span class="quote">make install</span>&#8221;</span> from a new or
7522           upgraded pkg, this prints out an attempt to generate a
7523           new <code class="filename">PLIST</code> from a <span class="command"><strong>find
7524           -newer work/.extract_done</strong></span>.  An attempt is made
7525           to care for shared libs etc., but it is
7526           <span class="emphasis"><em>strongly</em></span> recommended to review the
7527           result before putting it into
7528           <code class="filename">PLIST</code>. On upgrades, it's useful to
7529           diff the output of this command against an already
7530           existing <code class="filename">PLIST</code> file.</p>
7531 <p>If the package installs files via <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?tar+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span></a> or
7532           other methods that don't update file access times, be
7533           sure to add these files manually to your
7534           <code class="filename">PLIST</code>, as the <span class="quote">&#8220;<span class="quote">find
7535           -newer</span>&#8221;</span> command used by this target won't catch
7536           them!</p>
7537 <p>See <a class="xref" href="#print-PLIST" title="13.3. Tweaking output of make print-PLIST">Section 13.3, &#8220;Tweaking output of <span class="command"><strong>make print-PLIST</strong></span>&#8221;</a> for more
7538           information on this target.</p>
7539 </dd>
7540 <dt><span class="term">bulk-package</span></dt>
7541 <dd>
7542 <p>Used to do bulk builds. If an appropriate binary
7543           package already exists, no action is taken. If not, this
7544           target will compile, install and package it (and its
7545           depends, if <code class="varname">PKG_DEPENDS</code> is set
7546           properly. See <a class="xref" href="#binary.configuration" title="7.3.1. Configuration">Section 7.3.1, &#8220;Configuration&#8221;</a>).
7547           After creating the binary package, the sources, the
7548           just-installed package and its required packages are
7549           removed, preserving free disk space.</p>
7550 <p><span class="emphasis"><em>Beware that this target may deinstall
7551           all packages installed on a system!</em></span></p>
7552 </dd>
7553 <dt><span class="term">bulk-install</span></dt>
7554 <dd>
7555 <p>Used during bulk-installs to install required
7556           packages. If an up-to-date binary package is available,
7557           it will be installed via <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>. If not,
7558           <span class="command"><strong>make bulk-package</strong></span> will be executed,
7559           but the installed binary won't be removed.</p>
7560 <p>A binary package is considered
7561           <span class="quote">&#8220;<span class="quote">up-to-date</span>&#8221;</span> to be installed via
7562           <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> if:</p>
7563 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
7564 <li class="listitem"><p>None of the package's files
7565               (<code class="filename">Makefile</code>, ...) were modified
7566               since it was built.</p></li>
7567 <li class="listitem"><p>None of the package's required (binary)
7568               packages were modified since it was built.</p></li>
7569 </ul></div>
7570 <p><span class="emphasis"><em>Beware that this target may deinstall
7571           all packages installed on a system!</em></span></p>
7572 </dd>
7573 </dl></div>
7574 </div>
7575 </div>
7576 <div class="chapter">
7577 <div class="titlepage"><div><div><h2 class="title">
7578 <a name="tools"></a>Chapter 18. Tools needed for building or running</h2></div></div></div>
7579 <div class="toc">
7580 <p><b>Table of Contents</b></p>
7581 <dl>
7582 <dt><span class="sect1"><a href="#pkgsrc-tools">18.1. Tools for pkgsrc builds</a></span></dt>
7583 <dt><span class="sect1"><a href="#package-tools">18.2. Tools needed by packages</a></span></dt>
7584 <dt><span class="sect1"><a href="#platform-tools">18.3. Tools provided by platforms</a></span></dt>
7585 <dt><span class="sect1"><a href="#tools.questions">18.4. Questions regarding the tools</a></span></dt>
7586 </dl>
7587 </div>
7588 <p>The <code class="varname">USE_TOOLS</code> definition is used both internally
7589 by pkgsrc and also for individual packages to define what commands
7590 are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
7591 or for later run-time of an installed packaged (such as
7592 <code class="varname">DEPENDS</code>).
7593 If the native system provides an adequate tool, then in many cases, a pkgsrc
7594 package will not be used.</p>
7595 <p>When building a package, the replacement tools are
7596 made available in a directory (as symlinks or wrapper scripts)
7597 that is early in the executable search path. Just like the buildlink
7598 system, this helps with consistent builds.</p>
7599 <p>A tool may be needed to help build a specific package. For example,
7600 perl, GNU make (gmake) or yacc may be needed.</p>
7601 <p>Also a tool may be needed, for example, because the native system's supplied
7602 tool may be inefficient for building a package with pkgsrc.
7603 For example, a package may need GNU awk, bison (instead of
7604 yacc) or a better sed.</p>
7605 <p>The tools used by a package can be listed by running
7606 <span class="command"><strong>make show-tools</strong></span>.</p>
7607 <div class="sect1">
7608 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7609 <a name="pkgsrc-tools"></a>18.1. Tools for pkgsrc builds</h2></div></div></div>
7610 <p>The default set of tools used by pkgsrc is defined in
7611 <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
7612 such as: <span class="command"><strong>cat</strong></span>, <span class="command"><strong>awk</strong></span>,
7613 <span class="command"><strong>chmod</strong></span>, <span class="command"><strong>test</strong></span>, and so on.
7614 These can be seen by running:
7615 <span class="command"><strong>make show-var VARNAME=USE_TOOLS</strong></span>.</p>
7616 <p>If a package needs a specific program to build
7617 then the <code class="varname">USE_TOOLS</code> variable can be used
7618 to define the tools needed.</p>
7619 </div>
7620 <div class="sect1">
7621 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7622 <a name="package-tools"></a>18.2. Tools needed by packages</h2></div></div></div>
7623 <p>In the following examples, the :run means that it is needed at
7624 run-time (and becomes a DEPENDS).
7625 The default is a build dependency which can be set with
7626 :build. (So in this example, it is the same as gmake:build
7627 and pkg-config:build.)</p>
7628 <pre class="programlisting">
7629 USE_TOOLS+=     gmake perl:run pkg-config
7630 </pre>
7631 <p>When using the tools framework, a
7632 <code class="varname">TOOLS_PATH.foo</code> variable is defined
7633 which contains the full path to the appropriate tool. For example,
7634 <code class="varname">TOOLS_PATH.bash</code> could be <span class="quote">&#8220;<span class="quote">/bin/bash</span>&#8221;</span>
7635 on Linux systems.</p>
7636 <p>If you always need a pkgsrc version of the
7637 tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
7638 </p>
7639 </div>
7640 <div class="sect1">
7641 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7642 <a name="platform-tools"></a>18.3. Tools provided by platforms</h2></div></div></div>
7643 <p>When improving or porting pkgsrc to a new platform, have a look
7644 at (or create) the corresponding platform specific make file fragment under
7645 <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
7646 the name of the common tools. For example:</p>
7647 <pre class="programlisting">
7648 .if exists(/usr/bin/bzcat)
7649 TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
7650 .elif exists(/usr/bin/bzip2)
7651 TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
7652 .endif
7653
7654 TOOLS_PLATFORM.true?=           true                    # shell builtin
7655 </pre>
7656 </div>
7657 <div class="sect1">
7658 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7659 <a name="tools.questions"></a>18.4. Questions regarding the tools</h2></div></div></div>
7660 <div class="qandaset">
7661 <a name="idm76168656"></a><dl>
7662 <dt>18.4.1. <a href="#tools.new">How do I add a new tool?</a>
7663 </dt>
7664 <dt>18.4.2. <a href="#tools.listall">How do I get a list of all available
7665         tools?</a>
7666 </dt>
7667 <dt>18.4.3. <a href="#tools.used">How can I get a list of all the tools that a
7668         package is using while being built? I want to know whether it
7669         uses sed or not.</a>
7670 </dt>
7671 </dl>
7672 <table border="0" style="width: 100%;">
7673 <colgroup>
7674 <col align="left" width="1%">
7675 <col>
7676 </colgroup>
7677 <tbody>
7678 <tr class="question">
7679 <td align="left" valign="top">
7680 <a name="tools.new"></a><a name="idm76168272"></a><p><b>18.4.1.</b></p>
7681 </td>
7682 <td align="left" valign="top"><p>How do I add a new tool?</p></td>
7683 </tr>
7684 <tr class="answer">
7685 <td align="left" valign="top"></td>
7686 <td align="left" valign="top"><p>TODO</p></td>
7687 </tr>
7688 <tr class="question">
7689 <td align="left" valign="top">
7690 <a name="tools.listall"></a><a name="idm76167248"></a><p><b>18.4.2.</b></p>
7691 </td>
7692 <td align="left" valign="top"><p>How do I get a list of all available
7693         tools?</p></td>
7694 </tr>
7695 <tr class="answer">
7696 <td align="left" valign="top"></td>
7697 <td align="left" valign="top"><p>TODO</p></td>
7698 </tr>
7699 <tr class="question">
7700 <td align="left" valign="top">
7701 <a name="tools.used"></a><a name="idm76166224"></a><p><b>18.4.3.</b></p>
7702 </td>
7703 <td align="left" valign="top"><p>How can I get a list of all the tools that a
7704         package is using while being built? I want to know whether it
7705         uses sed or not.</p></td>
7706 </tr>
7707 <tr class="answer">
7708 <td align="left" valign="top"></td>
7709 <td align="left" valign="top"><p>Currently, you can't. (TODO: But I want to be able
7710         to do it.)</p></td>
7711 </tr>
7712 </tbody>
7713 </table>
7714 </div>
7715 </div>
7716 </div>
7717 <div class="chapter">
7718 <div class="titlepage"><div><div><h2 class="title">
7719 <a name="fixes"></a>Chapter 19. Making your package work</h2></div></div></div>
7720 <div class="toc">
7721 <p><b>Table of Contents</b></p>
7722 <dl>
7723 <dt><span class="sect1"><a href="#general-operation">19.1. General operation</a></span></dt>
7724 <dd><dl>
7725 <dt><span class="sect2"><a href="#portability-of-packages">19.1.1. Portability of packages</a></span></dt>
7726 <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">19.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
7727 <dt><span class="sect2"><a href="#user-interaction">19.1.3. User interaction</a></span></dt>
7728 <dt><span class="sect2"><a href="#handling-licenses">19.1.4. Handling licenses</a></span></dt>
7729 <dt><span class="sect2"><a href="#restricted-packages">19.1.5. Restricted packages</a></span></dt>
7730 <dt><span class="sect2"><a href="#dependencies">19.1.6. Handling dependencies</a></span></dt>
7731 <dt><span class="sect2"><a href="#conflicts">19.1.7. Handling conflicts with other packages</a></span></dt>
7732 <dt><span class="sect2"><a href="#not-building-packages">19.1.8. Packages that cannot or should not be built</a></span></dt>
7733 <dt><span class="sect2"><a href="#undeletable-packages">19.1.9. Packages which should not be deleted, once installed</a></span></dt>
7734 <dt><span class="sect2"><a href="#security-handling">19.1.10. Handling packages with security problems</a></span></dt>
7735 <dt><span class="sect2"><a href="#bumping-pkgrevision">19.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
7736 <dt><span class="sect2"><a href="#fixes.subst">19.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
7737 </dl></dd>
7738 <dt><span class="sect1"><a href="#fixes.fetch">19.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
7739 <dd><dl>
7740 <dt><span class="sect2"><a href="#no-plain-download">19.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
7741 <dt><span class="sect2"><a href="#modified-distfiles-same-name">19.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
7742 </dl></dd>
7743 <dt><span class="sect1"><a href="#fixes.configure">19.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
7744 <dd><dl>
7745 <dt><span class="sect2"><a href="#fixes.libtool">19.3.1. Shared libraries - libtool</a></span></dt>
7746 <dt><span class="sect2"><a href="#using-libtool">19.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
7747 <dt><span class="sect2"><a href="#autoconf-automake">19.3.3. GNU Autoconf/Automake</a></span></dt>
7748 </dl></dd>
7749 <dt><span class="sect1"><a href="#programming-languages">19.4. Programming languages</a></span></dt>
7750 <dd><dl>
7751 <dt><span class="sect2"><a href="#basic-programming-languages">19.4.1. C, C++, and Fortran</a></span></dt>
7752 <dt><span class="sect2"><a href="#java-programming-language">19.4.2. Java</a></span></dt>
7753 <dt><span class="sect2"><a href="#perl-scripts">19.4.3. Packages containing perl scripts</a></span></dt>
7754 <dt><span class="sect2"><a href="#shell-scripts">19.4.4. Packages containing shell scripts</a></span></dt>
7755 <dt><span class="sect2"><a href="#other-programming-languages">19.4.5. Other programming languages</a></span></dt>
7756 </dl></dd>
7757 <dt><span class="sect1"><a href="#fixes.build">19.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
7758 <dd><dl>
7759 <dt><span class="sect2"><a href="#fixes.build.cpp">19.5.1. Compiling C and C++ code conditionally</a></span></dt>
7760 <dt><span class="sect2"><a href="#compiler-bugs">19.5.2. How to handle compiler bugs</a></span></dt>
7761 <dt><span class="sect2"><a href="#undefined-reference">19.5.3. Undefined reference to <span class="quote">&#8220;<span class="quote">...</span>&#8221;</span></a></span></dt>
7762 <dt><span class="sect2"><a href="#out-of-memory">19.5.4. Running out of memory</a></span></dt>
7763 </dl></dd>
7764 <dt><span class="sect1"><a href="#fixes.install">19.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
7765 <dd><dl>
7766 <dt><span class="sect2"><a href="#install-scripts">19.6.1. Creating needed directories</a></span></dt>
7767 <dt><span class="sect2"><a href="#where-to-install-documentation">19.6.2. Where to install documentation</a></span></dt>
7768 <dt><span class="sect2"><a href="#installing-score-files">19.6.3. Installing highscore files</a></span></dt>
7769 <dt><span class="sect2"><a href="#destdir-support">19.6.4. Adding DESTDIR support to packages</a></span></dt>
7770 <dt><span class="sect2"><a href="#hardcoded-paths">19.6.5. Packages with hardcoded paths to other interpreters</a></span></dt>
7771 <dt><span class="sect2"><a href="#perl-modules">19.6.6. Packages installing perl modules</a></span></dt>
7772 <dt><span class="sect2"><a href="#faq.info-files">19.6.7. Packages installing info files</a></span></dt>
7773 <dt><span class="sect2"><a href="#manpages">19.6.8. Packages installing man pages</a></span></dt>
7774 <dt><span class="sect2"><a href="#gconf-data-files">19.6.9. Packages installing GConf data files</a></span></dt>
7775 <dt><span class="sect2"><a href="#scrollkeeper-data-files">19.6.10. Packages installing scrollkeeper/rarian data files</a></span></dt>
7776 <dt><span class="sect2"><a href="#x11-fonts">19.6.11. Packages installing X11 fonts</a></span></dt>
7777 <dt><span class="sect2"><a href="#gtk2-modules">19.6.12. Packages installing GTK2 modules</a></span></dt>
7778 <dt><span class="sect2"><a href="#sgml-xml-data">19.6.13. Packages installing SGML or XML data</a></span></dt>
7779 <dt><span class="sect2"><a href="#mime-database">19.6.14. Packages installing extensions to the MIME database</a></span></dt>
7780 <dt><span class="sect2"><a href="#intltool">19.6.15. Packages using intltool</a></span></dt>
7781 <dt><span class="sect2"><a href="#startup-scripts">19.6.16. Packages installing startup scripts</a></span></dt>
7782 <dt><span class="sect2"><a href="#tex-packages">19.6.17. Packages installing TeX modules</a></span></dt>
7783 <dt><span class="sect2"><a href="#emulation-packages">19.6.18. Packages supporting running binaries in
7784     emulation</a></span></dt>
7785 <dt><span class="sect2"><a href="#hicolor-theme">19.6.19. Packages installing hicolor theme icons</a></span></dt>
7786 <dt><span class="sect2"><a href="#desktop-files">19.6.20. Packages installing desktop files</a></span></dt>
7787 </dl></dd>
7788 <dt><span class="sect1"><a href="#punting">19.7. Marking packages as having problems</a></span></dt>
7789 </dl>
7790 </div>
7791 <div class="sect1">
7792 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
7793 <a name="general-operation"></a>19.1. General operation</h2></div></div></div>
7794 <div class="sect2">
7795 <div class="titlepage"><div><div><h3 class="title">
7796 <a name="portability-of-packages"></a>19.1.1. Portability of packages</h3></div></div></div>
7797 <p>One appealing feature of pkgsrc is that it runs on many
7798     different platforms. As a result, it is important to ensure,
7799     where possible, that packages in pkgsrc are portable. This
7800     chapter mentions some particular details you should pay
7801     attention to while working on pkgsrc.</p>
7802 </div>
7803 <div class="sect2">
7804 <div class="titlepage"><div><div><h3 class="title">
7805 <a name="pulling-vars-from-etc-mk.conf"></a>19.1.2. How to pull in user-settable variables from <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>
7806 </h3></div></div></div>
7807 <p>The pkgsrc user can configure pkgsrc by overriding several
7808     variables in the file pointed to by <code class="varname">MAKECONF</code>,
7809     which is <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> by default. When you
7810     want to use those variables in the preprocessor directives of
7811     <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> (for example <code class="literal">.if</code> or
7812     <code class="literal">.for</code>), you need to include the file
7813     <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
7814     loads the user preferences.</p>
7815 <p>But note that some variables may not be completely defined
7816     after <code class="filename">../../mk/bsd.prefs.mk</code> has been
7817     included, as they may contain references to variables that are
7818     not yet defined. In shell commands this is no problem, since
7819     variables are actually macros, which are only expanded when they
7820     are used. But in the preprocessor directives mentioned above and
7821     in dependency lines (of the form <code class="literal">target:
7822     dependencies</code>) the variables are expanded at load
7823     time.</p>
7824 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7825 <h3 class="title">Note</h3>
7826 <p>Currently there is no exhaustive list of all
7827     variables that tells you whether they can be used at load time
7828     or only at run time, but it is in preparation.</p>
7829 </div>
7830 </div>
7831 <div class="sect2">
7832 <div class="titlepage"><div><div><h3 class="title">
7833 <a name="user-interaction"></a>19.1.3. User interaction</h3></div></div></div>
7834 <p>Occasionally, packages require interaction from the user,
7835     and this can be in a number of ways:</p>
7836 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
7837 <li class="listitem"><p>When fetching the distfiles, some packages require user
7838         interaction such as entering username/password or accepting a
7839         license on a web page.</p></li>
7840 <li class="listitem"><p>When extracting the distfiles, some packages may ask for
7841         passwords.</p></li>
7842 <li class="listitem"><p>help to configure the package before it is built</p></li>
7843 <li class="listitem"><p>help during the build process</p></li>
7844 <li class="listitem"><p>help during the installation of a package</p></li>
7845 </ul></div>
7846 <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is
7847     provided to notify the pkgsrc mechanism of an interactive stage
7848     which will be needed, and this should be set in the package's
7849     <code class="filename">Makefile</code>, e.g.:</p>
7850 <pre class="programlisting">
7851 INTERACTIVE_STAGE=      build
7852     </pre>
7853 <p>Multiple interactive stages can be specified:</p>
7854 <pre class="programlisting">
7855 INTERACTIVE_STAGE=      configure install
7856     </pre>
7857 <p>The user can then decide to skip this package by setting the
7858     <code class="varname">BATCH</code> variable.</p>
7859 </div>
7860 <div class="sect2">
7861 <div class="titlepage"><div><div><h3 class="title">
7862 <a name="handling-licenses"></a>19.1.4. Handling licenses</h3></div></div></div>
7863 <p>Authors of software can choose the licence under which
7864     software can be copied.  This is due to copyright law, and reasons
7865     for license choices are outside the scope of pkgsrc.  The pkgsrc
7866     system recognizes that there are a number of licenses which some
7867     users may find objectionable or difficult or impossible to comply
7868     with.  The Free Software Foundation has declared some licenses
7869     "Free", and the Open Source Initiative has a definition of "Open
7870     Source".  The pkgsrc system, as a policy choice, does not label
7871     packages which have licenses that are Free or Open Source.
7872     However, packages without a license meeting either of those tests
7873     are labeled with a license tag denoting the license.  Note that a
7874     package with no license to copy trivially does not meet either the
7875     Free or Open Source test.</p>
7876 <p>For packages which are not Free or Open Source, pkgsrc will
7877     not build the package unless the user has indicated to pkgsrc that
7878     packages with that particular license may be built.  Note that
7879     this documentation avoids the term "accepted the license".  The
7880     pkgsrc system is merely providing a mechanism to avoid
7881     accidentally building a package with a non-free license;
7882     judgement and responsibility remain with the user.  (Installation
7883     of binary packages are not currently subject to this mechanism;
7884     this is a bug.)</p>
7885 <p>One might want to only install packages with a BSD license,
7886     or the GPL, and not the other.  The free licenses are added to the 
7887     default <code class="varname">ACCEPTABLE_LICENSES</code> variable.  The
7888     user can override the default by setting the
7889     <code class="varname">ACCEPTABLE_LICENSES</code> variable with "=" instead
7890     of "+=".  The licenses accepted by default are:
7891     </p>
7892 <pre class="programlisting">
7893         apache-1.1 apache-2.0
7894         arphic-public
7895         artistic artistic-2.0
7896         boost-license
7897         cc-by-sa-v3.0
7898         cddl-1.0
7899         cpl-1.0
7900         epl-v1.0
7901         gnu-fdl-v1.1 gnu-fdl-v1.2 gnu-fdl-v1.3
7902         gnu-gpl-v1
7903         gnu-gpl-v2 gnu-lgpl-v2 gnu-lgpl-v2.1
7904         gnu-gpl-v3 gnu-lgpl-v3
7905         ibm-public-license-1.0
7906         ipafont
7907         isc
7908         lppl-1.3c
7909         lucent
7910         miros
7911         mit
7912         mpl-1.0 mpl-1.1 mpl-2.0
7913         mplusfont
7914         ofl-v1.0 ofl-v1.1
7915         original-bsd modified-bsd 2-clause-bsd
7916         php
7917         png-license
7918         postgresql-license
7919         public-domain
7920         python-software-foundation
7921         qpl-v1.0
7922         sgi-free-software-b-v2.0
7923         sleepycat-public
7924         unlicense
7925         x11
7926         zlib
7927         zpl
7928     </pre>
7929 <p>
7930     </p>
7931 <p>The license tag mechanism is intended to address
7932     copyright-related issues surrounding building, installing and
7933     using a package, and not to address redistribution issues (see
7934     <code class="varname">RESTRICTED</code> and
7935     <code class="varname">NO_SRC_ON_FTP</code>, etc.).  
7936     Packages with redistribution restrictions should set these
7937     tags.</p>
7938 <p>Denoting that a package may be copied according to a
7939     particular license is done by placing the license in
7940     <code class="filename">pkgsrc/licenses</code> and setting the
7941     <code class="varname">LICENSE</code> variable to a string identifying the
7942     license, e.g. in <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>:</p>
7943 <pre class="programlisting">
7944 LICENSE=        xv-license
7945     </pre>
7946 <p>When trying to build, the user will get a notice that the
7947     package is covered by a license which has not been placed in the
7948     <code class="varname">ACCEPTABLE_LICENSES</code> variable:</p>
7949 <pre class="programlisting">
7950 <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
7951 ===&gt; xv-3.10anb9 has an unacceptable license: xv-license.
7952 ===&gt;     To view the license, enter "/usr/bin/make show-license".
7953 ===&gt;     To indicate acceptance, add this line to your /etc/mk.conf:
7954 ===&gt;     ACCEPTABLE_LICENSES+=xv-license
7955 *** Error code 1
7956     </pre>
7957 <p>The license can be viewed with <span class="command"><strong>make
7958     show-license</strong></span>, and if the user so chooses, the line
7959     printed above can be added to <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to
7960     convey to pkgsrc that it should not in the future fail because of
7961     that license:</p>
7962 <pre class="programlisting">
7963 ACCEPTABLE_LICENSES+=xv-license
7964     </pre>
7965 <p>When adding a package with a new license, the following steps
7966     are required:</p>
7967 <div class="orderedlist"><ol class="orderedlist" type="1">
7968 <li class="listitem">
7969 <p>Check if the file can avoid the -license filename tag as described above by referencing <a class="ulink" href="http://www.gnu.org/licenses/license-list.html" target="_top">Various Licenses and Comments about Them</a> and <a class="ulink" href="http://opensource.org/licenses/alphabetical" target="_top">Licenses by Name | Open Source Initiative</a>.  If this is the case, additionally add the license filename to:</p>
7970 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
7971 <li class="listitem"><p>DEFAULT_ACCEPTABLE_LICENSES in <code class="filename">pkgsrc/mk/license.mk</code></p></li>
7972 <li class="listitem"><p>default_acceptable_licenses in <code class="filename">pkgsrc/pkgtools/pkg_install/files/lib/license.c</code></p></li>
7973 <li class="listitem"><p>the ACCEPTABLE_LICENSES list in <code class="filename">pkgsrc/doc/guide/files/fixes.xml</code></p></li>
7974 </ul></div>
7975 <p>with the proper syntax as demonstrated in those files, respectively.</p>
7976 </li>
7977 <li class="listitem"><p>The license text should be added to <code class="filename">pkgsrc/licenses</code> for displaying.  A list of known licenses can be seen in this directory.</p></li>
7978 </ol></div>
7979 <p>When the license changes (in a way other than formatting),
7980     please make sure that the new license has a different name (e.g.,
7981     append the version number if it exists, or the date).  Just
7982     because a user told pkgsrc to build programs under a previous
7983     version of a license does not mean that pkgsrc should build
7984     programs under the new licenses.  The higher-level point is that
7985     pkgsrc does not evaluate licenses for reasonableness; the only
7986     test is a mechanistic test of whether a particular text has been
7987     approved by either of two bodies.</p>
7988 <p>The use of <code class="varname">LICENSE=shareware</code>,
7989     <code class="varname">LICENSE=no-commercial-use</code>, and similar language
7990     is deprecated because it does not crisply refer to a particular
7991     license text.  Another problem with such usage is that it does not
7992     enable a user to tell pkgsrc to proceed for a single package
7993     without also telling pkgsrc to proceed for all packages with that
7994     tag.</p>
7995 </div>
7996 <div class="sect2">
7997 <div class="titlepage"><div><div><h3 class="title">
7998 <a name="restricted-packages"></a>19.1.5. Restricted packages</h3></div></div></div>
7999 <p>Some licenses restrict how software may be re-distributed.
8000     Because a license tag is required unless the package is Free or
8001     Open Source, all packages with restrictions should have license
8002     tags.  By declaring the restrictions, package tools can
8003     automatically refrain from e.g. placing binary packages on FTP
8004     sites.</p>
8005 <p>There are four restrictions that may be encoded, which are
8006     the cross product of sources (distfiles) and binaries not being
8007     placed on FTP sites and CD-ROMs.  Because this is rarely the exact
8008     language in any license, and because non-Free licenses tend to be
8009     different from each other, pkgsrc adopts a definition of FTP and
8010     CD-ROM.  Pkgsrc uses "FTP" to mean that the source or binary file
8011     should not be made available over the Internet at no charge.
8012     Pkgsrc uses "CD-ROM" to mean that the source or binary may not be
8013     made available on some kind of media, together with other source
8014     and binary packages, and which is sold for a distribution charge.
8015     </p>
8016 <p>In order to encode these restrictions, the package system
8017     defines five make variables that can be set to note these
8018     restrictions:</p>
8019 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
8020 <li class="listitem">
8021 <p><code class="varname">RESTRICTED</code></p>
8022 <p>This variable should be set whenever a restriction
8023         exists (regardless of its kind).  Set this variable to a
8024         string containing the reason for the restriction.  It should
8025         be understood that those wanting to understand the restriction
8026         will have to read the license, and perhaps seek advice of
8027         counsel.</p>
8028 </li>
8029 <li class="listitem">
8030 <p><code class="varname">NO_BIN_ON_CDROM</code></p>
8031 <p>Binaries may not be placed on CD-ROM containing other
8032         binary packages, for which a distribution charge may be made.
8033         In this case, set this variable to
8034         <code class="varname">${RESTRICTED}</code>.</p>
8035 </li>
8036 <li class="listitem">
8037 <p><code class="varname">NO_BIN_ON_FTP</code></p>
8038 <p>Binaries may not made available on the Internet without
8039         charge.  In this case, set this variable to
8040         <code class="varname">${RESTRICTED}</code>.  If this variable is set,
8041         binary packages will not be included on ftp.NetBSD.org.</p>
8042 </li>
8043 <li class="listitem">
8044 <p><code class="varname">NO_SRC_ON_CDROM</code></p>
8045 <p>Distfiles may not be placed on CD-ROM, together with
8046         other distfiles, for which a fee may be charged.  In this
8047         case, set this variable to <code class="varname">${RESTRICTED}</code>.
8048         </p>
8049 </li>
8050 <li class="listitem">
8051 <p><code class="varname">NO_SRC_ON_FTP</code></p>
8052 <p>Distfiles may not made available via FTP at no charge.
8053         In this case, set this variable to
8054         <code class="varname">${RESTRICTED}</code>.  If this variable is set,
8055         the distfile(s) will not be mirrored on ftp.NetBSD.org.</p>
8056 </li>
8057 </ul></div>
8058 <p>Please note that packages will to be removed from pkgsrc
8059     when the distfiles are not distributable and cannot be obtained
8060     for a period of one full quarter branch. Packages with manual /
8061     interactive fetch must have a maintainer and it is his/her
8062     responsibility to ensure this.</p>
8063 </div>
8064 <div class="sect2">
8065 <div class="titlepage"><div><div><h3 class="title">
8066 <a name="dependencies"></a>19.1.6. Handling dependencies</h3></div></div></div>
8067 <p>Your package may depend on some other package being present
8068     - and there are various ways of expressing this dependency.
8069     pkgsrc supports the <code class="varname">BUILD_DEPENDS</code> and
8070     <code class="varname">DEPENDS</code> definitions, the
8071     <code class="varname">USE_TOOLS</code> definition, as well as dependencies
8072     via <code class="filename">buildlink3.mk</code>, which is the preferred way
8073     to handle dependencies, and which uses the variables named above.
8074     See <a class="xref" href="#buildlink" title="Chapter 14. Buildlink methodology">Chapter 14, <i>Buildlink methodology</i></a> for more information.</p>
8075 <p>The basic difference between the two variables is as
8076     follows: The <code class="varname">DEPENDS</code> definition registers
8077     that pre-requisite in the binary package so it will be pulled in
8078     when the binary package is later installed, whilst the
8079     <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
8080     dependency that is only needed for building the package.</p>
8081 <p>This means that if you only need a package present whilst
8082     you are building, it should be noted as a
8083     <code class="varname">BUILD_DEPENDS</code>.</p>
8084 <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
8085     <code class="varname">DEPENDS</code> definition is:</p>
8086 <pre class="programlisting">
8087 &lt;pre-req-package-name&gt;:../../&lt;category&gt;/&lt;pre-req-package&gt;
8088     </pre>
8089 <p>Please note that the <span class="quote">&#8220;<span class="quote">pre-req-package-name</span>&#8221;</span>
8090     may include any of the wildcard version numbers recognized by
8091     <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_info+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_info</span>(1)</span></a>.</p>
8092 <div class="orderedlist"><ol class="orderedlist" type="1">
8093 <li class="listitem">
8094 <p>If your package needs another package's binaries or
8095         libraries to build and run, and if that package has a
8096         <code class="filename">buildlink3.mk</code> file available, use it:</p>
8097 <pre class="programlisting">
8098 .include "../../graphics/jpeg/buildlink3.mk"
8099         </pre>
8100 </li>
8101 <li class="listitem">
8102 <p>If your package needs another package's binaries or
8103         libraries only for building, and if that package has a
8104         <code class="filename">buildlink3.mk</code> file available, use it:</p>
8105 <pre class="programlisting">
8106 .include "../../graphics/jpeg/buildlink3.mk"
8107         </pre>
8108 <p>but set
8109         <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>jpeg</code></em>?=build</code>
8110         to make it a build dependency only. This case is rather
8111         rare.</p>
8112 </li>
8113 <li class="listitem">
8114 <p>If your package needs binaries from another package to build,
8115         use the <code class="varname">BUILD_DEPENDS</code> definition:</p>
8116 <pre class="programlisting">
8117 BUILD_DEPENDS+= scons-[0-9]*:../../devel/scons
8118         </pre>
8119 </li>
8120 <li class="listitem"><p>If your package needs a library with which to link and
8121         there is no <code class="filename">buildlink3.mk</code> file
8122         available, create one. Using
8123         <code class="varname">DEPENDS</code> won't be sufficient because the
8124         include files and libraries will be hidden from the compiler.</p></li>
8125 <li class="listitem">
8126 <p>If your package needs some executable to be able to run
8127         correctly and if there's no
8128         <code class="filename">buildlink3.mk</code> file, this is specified
8129         using the <code class="varname">DEPENDS</code> variable. The
8130         <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/print/lyx/README.html" target="_top"><code class="filename">print/lyx</code></a> package needs to
8131         be able to execute the latex binary from the teTeX package
8132         when it runs, and that is specified:</p>
8133 <pre class="programlisting">
8134 DEPENDS+=        teTeX-[0-9]*:../../print/teTeX
8135         </pre>
8136 </li>
8137 <li class="listitem">
8138 <p>You can use wildcards in package dependencies. Note that
8139         such wildcard dependencies are retained when creating binary
8140         packages. The dependency is checked when installing the binary
8141         package and any package which matches the pattern will be
8142         used. Wildcard dependencies should be used with care.</p>
8143 <p>The <span class="quote">&#8220;<span class="quote">-[0-9]*</span>&#8221;</span> should be used instead of
8144         <span class="quote">&#8220;<span class="quote">-*</span>&#8221;</span> to avoid potentially ambiguous matches
8145         such as <span class="quote">&#8220;<span class="quote">tk-postgresql</span>&#8221;</span> matching a
8146         <span class="quote">&#8220;<span class="quote">tk-*</span>&#8221;</span> <code class="varname">DEPENDS</code>.</p>
8147 <p>Wildcards can also be used to specify that a package
8148         will only build against a certain minimum version of a
8149         pre-requisite:</p>
8150 <pre class="programlisting">
8151 DEPENDS+=       ImageMagick&gt;=6.0:../../graphics/ImageMagick
8152         </pre>
8153 <p>This means that the package will build using version 6.0
8154         of ImageMagick or newer. Such a dependency may be warranted
8155         if, for example, the command line options of an executable
8156         have changed.</p>
8157 <p>If you need to depend on minimum versions of libraries,
8158         see the buildlink section of the pkgsrc guide.</p>
8159 <p>For security fixes, please update the package
8160         vulnerabilities file. See <a class="xref" href="#security-handling" title="19.1.10. Handling packages with security problems">Section 19.1.10, &#8220;Handling packages with security problems&#8221;</a> for more
8161         information.</p>
8162 </li>
8163 </ol></div>
8164 <p>If your package needs files from another package to build,
8165     add the relevant distribution files to
8166     <code class="varname">DISTFILES</code>, so they will be extracted
8167     automatically. See the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/print/ghostscript/README.html" target="_top"><code class="filename">print/ghostscript</code></a> package for an example.
8168     (It relies on the jpeg sources being present in source form
8169     during the build.)</p>
8170 </div>
8171 <div class="sect2">
8172 <div class="titlepage"><div><div><h3 class="title">
8173 <a name="conflicts"></a>19.1.7. Handling conflicts with other packages</h3></div></div></div>
8174 <p>Your package may conflict with other packages a user might
8175     already have installed on his system, e.g. if your package
8176     installs the same set of files as another package in the pkgsrc
8177     tree.</p>
8178 <p>In this case you can set <code class="varname">CONFLICTS</code> to a
8179     space-separated list of packages (including version string) your
8180     package conflicts with.</p>
8181 <p>For example, <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/Xaw3d/README.html" target="_top"><code class="filename">x11/Xaw3d</code></a>
8182     and <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/Xaw-Xpm/README.html" target="_top"><code class="filename">x11/Xaw-Xpm</code></a>
8183     install the same shared library, thus you set in
8184     <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
8185 <pre class="programlisting">
8186 CONFLICTS=      Xaw-Xpm-[0-9]*
8187     </pre>
8188 <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:</p>
8189 <pre class="programlisting">
8190 CONFLICTS=      Xaw3d-[0-9]*
8191     </pre>
8192 <p>Packages will automatically conflict with other packages
8193     with the name prefix and a different version
8194     string. <span class="quote">&#8220;<span class="quote">Xaw3d-1.5</span>&#8221;</span> e.g. will automatically
8195     conflict with the older version <span class="quote">&#8220;<span class="quote">Xaw3d-1.3</span>&#8221;</span>.</p>
8196 </div>
8197 <div class="sect2">
8198 <div class="titlepage"><div><div><h3 class="title">
8199 <a name="not-building-packages"></a>19.1.8. Packages that cannot or should not be built</h3></div></div></div>
8200 <p>There are several reasons why a package might be
8201     instructed to not build under certain circumstances.  If the
8202     package builds and runs on most platforms, the exceptions
8203     should be noted with <code class="varname">NOT_FOR_PLATFORM</code>.  If
8204     the package builds and runs on a small handful of platforms,
8205     set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
8206     Both <code class="varname">ONLY_FOR_PLATFORM</code> and
8207     <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
8208     (OS-version-platform) that can use glob-style
8209     wildcards.</p>
8210 <p>Some packages are tightly bound to a specific version of an
8211     operating system, e.g. LKMs or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/sysutils/lsof/README.html" target="_top"><code class="filename">sysutils/lsof</code></a>.  Such binary packages are not
8212     backwards compatible with other versions of the OS, and should be
8213     uploaded to a version specific directory on the FTP server.  Mark
8214     these packages by setting <code class="varname">OSVERSION_SPECIFIC</code> to
8215     <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>.  This variable is not currently used by any of
8216     the package system internals, but may be used in the
8217     future.</p>
8218 <p>If the package should be skipped (for example, because it
8219     provides functionality already provided by the system), set
8220     <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.  If
8221     the package should fail because some preconditions are not met,
8222     set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
8223     message.</p>
8224 </div>
8225 <div class="sect2">
8226 <div class="titlepage"><div><div><h3 class="title">
8227 <a name="undeletable-packages"></a>19.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
8228 <p>To ensure that a package may not be deleted, once it has been
8229     installed, the <code class="varname">PKG_PRESERVE</code> definition should
8230     be set in the package Makefile. This will be carried into any
8231     binary package that is made from this pkgsrc entry. A
8232     <span class="quote">&#8220;<span class="quote">preserved</span>&#8221;</span> package will
8233     not be deleted using <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> unless the
8234     <span class="quote">&#8220;<span class="quote">-f</span>&#8221;</span> option is used.</p>
8235 </div>
8236 <div class="sect2">
8237 <div class="titlepage"><div><div><h3 class="title">
8238 <a name="security-handling"></a>19.1.10. Handling packages with security problems</h3></div></div></div>
8239 <p>When a vulnerability is found, this should be noted in
8240     <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
8241     and after committing that file, ask pkgsrc-security@NetBSD.org to
8242     update the file on ftp.NetBSD.org.</p>
8243 <p>After fixing the vulnerability by a patch, its
8244     <code class="varname">PKGREVISION</code> should be increased (this is of
8245     course not necessary if the problem is fixed by using a newer
8246     release of the software), and the pattern in the
8247     pkg-vulnerabilities file must be updated.</p>
8248 <p>Also, if the fix should be applied to the stable pkgsrc
8249     branch, be sure to submit a pullup request!</p>
8250 <p>Binary packages already on ftp.NetBSD.org will be handled
8251     semi-automatically by a weekly cron job.</p>
8252 </div>
8253 <div class="sect2">
8254 <div class="titlepage"><div><div><h3 class="title">
8255 <a name="bumping-pkgrevision"></a>19.1.11. How to handle incrementing versions when fixing an existing package</h3></div></div></div>
8256 <p>When making fixes to an existing package it can be useful
8257     to change the version number in <code class="varname">PKGNAME</code>. To
8258     avoid conflicting with future versions by the original author, a
8259     <span class="quote">&#8220;<span class="quote">nb1</span>&#8221;</span>, <span class="quote">&#8220;<span class="quote">nb2</span>&#8221;</span>, ... suffix can be used
8260     on package versions by setting <code class="varname">PKGREVISION=1</code>
8261     (2, ...). The <span class="quote">&#8220;<span class="quote">nb</span>&#8221;</span> is treated like a
8262     <span class="quote">&#8220;<span class="quote">.</span>&#8221;</span> by the package tools. e.g.</p>
8263 <pre class="programlisting">
8264 DISTNAME=       foo-17.42
8265 PKGREVISION=    9
8266     </pre>
8267 <p>will result in a <code class="varname">PKGNAME</code> of
8268     <span class="quote">&#8220;<span class="quote">foo-17.42nb9</span>&#8221;</span>. If you want to use the original
8269     value of <code class="varname">PKGNAME</code> without the <span class="quote">&#8220;<span class="quote">nbX</span>&#8221;</span>
8270     suffix, e.g. for setting <code class="varname">DIST_SUBDIR</code>, use
8271     <code class="varname">PKGNAME_NOREV</code>.</p>
8272 <p>When a new release of the package is released, the
8273     <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
8274     minor release of the above package, things should be like:</p>
8275 <pre class="programlisting">
8276 DISTNAME=       foo-17.43
8277     </pre>
8278 <p><code class="varname">PKGREVISION</code> should be incremented for any
8279     non-trivial change in the resulting binary package.  Without a
8280     <code class="varname">PKGREVISION</code> bump, someone with the previous
8281     version installed has no way of knowing that their package is out
8282     of date.  Thus, changes without increasing
8283     <code class="varname">PKGREVISION</code> are essentially labeled "this is so
8284     trivial that no reasonable person would want to upgrade", and this
8285     is the rough test for when increasing
8286     <code class="varname">PKGREVISION</code> is appropriate.  Examples of
8287     changes that do not merit increasing
8288     <code class="varname">PKGREVISION</code> are:</p>
8289 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
8290 <li class="listitem"><p>Changing <code class="varname">HOMEPAGE</code>,
8291       <code class="varname">MAINTAINER</code>, <code class="varname">OWNER</code>,
8292       or comments in Makefile.</p></li>
8293 <li class="listitem"><p>
8294       Changing build variables if the resulting binary package is the same.</p></li>
8295 <li class="listitem"><p>
8296       Changing <code class="filename">DESCR</code>.</p></li>
8297 <li class="listitem"><p>
8298       Adding <code class="varname">PKG_OPTIONS</code> if the default options don't change.</p></li>
8299 </ul></div>
8300 <p>Examples of changes that do merit an increase to
8301     <code class="varname">PKGREVISION</code> include:</p>
8302 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
8303 <li class="listitem"><p>
8304       Security fixes</p></li>
8305 <li class="listitem"><p>
8306       Changes or additions to a patch file</p></li>
8307 <li class="listitem"><p>
8308       Changes to the <code class="filename">PLIST</code></p></li>
8309 <li class="listitem"><p>A dependency is changed or renamed.</p></li>
8310 </ul></div>
8311 <p>PKGREVISION must also be incremented when dependencies have ABI
8312     changes.</p>
8313 </div>
8314 <div class="sect2">
8315 <div class="titlepage"><div><div><h3 class="title">
8316 <a name="fixes.subst"></a>19.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
8317 <p>When you want to replace the same text in multiple files
8318     or when the replacement text varies, patches alone cannot help.
8319     This is where the SUBST framework comes in. It provides an
8320     easy-to-use interface for replacing text in files.
8321     Example:</p>
8322 <pre class="programlisting">
8323 SUBST_CLASSES+=                 fix-paths
8324 SUBST_STAGE.fix-paths=          pre-configure
8325 SUBST_MESSAGE.fix-paths=        Fixing absolute paths.
8326 SUBST_FILES.fix-paths=          src/*.c
8327 SUBST_FILES.fix-paths+=         scripts/*.sh
8328 SUBST_SED.fix-paths=            -e 's,"/usr/local,"${PREFIX},g'
8329 SUBST_SED.fix-paths+=           -e 's,"/var/log,"${VARBASE}/log,g'
8330     </pre>
8331 <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
8332     that are used to identify the different SUBST blocks that are
8333     defined. The SUBST framework is heavily used by pkgsrc, so it is
8334     important to always use the <code class="literal">+=</code> operator with
8335     this variable. Otherwise some substitutions may be
8336     skipped.</p>
8337 <p>The remaining variables of each SUBST block are
8338     parameterized with the identifier from the first line
8339     (<code class="literal">fix-paths</code> in this case.) They can be seen as
8340     parameters to a function call.</p>
8341 <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
8342     which the replacement will take place. All combinations of
8343     <code class="literal">pre-</code>, <code class="literal">do-</code> and
8344     <code class="literal">post-</code> together with a phase name are
8345     possible, though only few are actually used. Most commonly used
8346     are <code class="literal">post-patch</code> and
8347     <code class="literal">pre-configure</code>. Of these two,
8348     <code class="literal">pre-configure</code> should be preferred because
8349     then it is possible to run <span class="command"><strong>bmake patch</strong></span> and
8350     have the state after applying the patches but before making any
8351     other changes. This is especially useful when you are debugging
8352     a package in order to create new patches for it. Similarly,
8353     <code class="literal">post-build</code> is preferred over
8354     <code class="literal">pre-install</code>, because the install phase should
8355     generally be kept as simple as possible. When you use
8356     <code class="literal">post-build</code>, you have the same files in the
8357     working directory that will be installed later, so you can check
8358     if the substitution has succeeded.</p>
8359 <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
8360     that is printed just before the substitution is done.</p>
8361 <p><code class="varname">SUBST_FILES.*</code> is the list of shell
8362     globbing patterns that specifies the files in which the
8363     substitution will take place. The patterns are interpreted
8364     relatively to the <code class="varname">WRKSRC</code> directory.</p>
8365 <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
8366     <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?sed+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">sed</span>(1)</span></a> that specify the actual substitution. Every sed
8367     command should be prefixed with <code class="literal">-e</code>, so that
8368     all SUBST blocks look uniform.</p>
8369 <p>There are some more variables, but they are so seldomly
8370     used that they are only documented in the
8371     <code class="filename">mk/subst.mk</code> file.</p>
8372 </div>
8373 </div>
8374 <div class="sect1">
8375 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8376 <a name="fixes.fetch"></a>19.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
8377 <div class="sect2">
8378 <div class="titlepage"><div><div><h3 class="title">
8379 <a name="no-plain-download"></a>19.2.1. Packages whose distfiles aren't available for plain downloading</h3></div></div></div>
8380 <p>If you need to download from a dynamic URL you can set
8381     <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span class="command"><strong>make
8382     fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
8383     with the name of each file to download as an argument, expecting
8384     it to output the URL of the directory from which to download
8385     it. <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/graphics/ns-cult3d/README.html" target="_top"><code class="filename">graphics/ns-cult3d</code></a> is an
8386     example of this usage.</p>
8387 <p>If the download can't be automated, because the user must
8388     submit personal information to apply for a password, or must pay
8389     for the source, or whatever, you can set
8390     <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
8391     displayed to the user before aborting the build. Example:</p>
8392 <pre class="programlisting">
8393 FETCH_MESSAGE=  "Please download the files"
8394 FETCH_MESSAGE+= "    "${DISTFILES:Q}
8395 FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
8396     </pre>
8397 </div>
8398 <div class="sect2">
8399 <div class="titlepage"><div><div><h3 class="title">
8400 <a name="modified-distfiles-same-name"></a>19.2.2. How to handle modified distfiles with the 'old' name</h3></div></div></div>
8401 <p>Sometimes authors of a software package make some
8402     modifications after the software was released, and they put up a
8403     new distfile without changing the package's version number. If a
8404     package is already in pkgsrc at that time, the checksum will
8405     no longer match. The contents of the new distfile should be
8406     compared against the old one before changing anything, to make
8407     sure the distfile was really updated on purpose, and that
8408     no trojan horse or so crept in.
8409     Please mention that the distfiles were compared and what was found
8410     in your commit message.</p>
8411 <p>Then, the correct way to work around this is to
8412     set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
8413     usually based on <code class="varname">PKGNAME_NOREV</code>. All
8414     <code class="varname">DISTFILES</code> and
8415     <code class="varname">PATCHFILES</code> for this package will be put in that
8416     subdirectory of the local distfiles directory.
8417     (See <a class="xref" href="#bumping-pkgrevision" title="19.1.11. How to handle incrementing versions when fixing an existing package">Section 19.1.11, &#8220;How to handle incrementing versions when fixing an existing package&#8221;</a> for more details.)
8418     In case this
8419     happens more often, <code class="varname">PKGNAME</code> can be used (thus
8420     including the <code class="filename">nbX</code> suffix) or a date stamp
8421     can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.</p>
8422 <p><code class="varname">DIST_SUBDIR</code> is also used when a distfile's name does not contain a version and the distfile is apt to change. In cases where the likelihood of this is very small, <code class="varname">DIST_SUBDIR</code> might not be required. Additionally, <code class="varname">DIST_SUBDIR</code> must not be removed unless the distfile name changes, even if a package is being moved or renamed.</p>
8423 <p>Do not forget regenerating the <code class="filename">distinfo</code> file
8424     after that, since it contains the <code class="varname">DIST_SUBDIR</code>
8425     path in the filenames.
8426     Also, increase the PKGREVISION if the installed package is different.
8427     Furthermore, a mail to the package's authors seems appropriate
8428     telling them that changing distfiles after releases without
8429     changing the file names is not good practice.</p>
8430 </div>
8431 </div>
8432 <div class="sect1">
8433 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8434 <a name="fixes.configure"></a>19.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
8435 <div class="sect2">
8436 <div class="titlepage"><div><div><h3 class="title">
8437 <a name="fixes.libtool"></a>19.3.1. Shared libraries - libtool</h3></div></div></div>
8438 <p>pkgsrc supports many different machines, with different
8439     object formats like a.out and ELF, and varying abilities to do
8440     shared library and dynamic loading at all. To accompany this,
8441     varying commands and options have to be passed to the
8442     compiler, linker, etc. to get the Right Thing, which can be
8443     pretty annoying especially if you don't have all the machines
8444     at your hand to test things.  The
8445     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/libtool/README.html" target="_top"><code class="filename">devel/libtool</code></a> pkg
8446     can help here, as it just <span class="quote">&#8220;<span class="quote">knows</span>&#8221;</span> how to build
8447     both static and dynamic libraries from a set of source files,
8448     thus being platform-independent.</p>
8449 <p>Here's how to use libtool in a package in seven simple
8450     steps:</p>
8451 <div class="orderedlist"><ol class="orderedlist" type="1">
8452 <li class="listitem"><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
8453         Makefile.</p></li>
8454 <li class="listitem"><p>For library objects, use <span class="quote">&#8220;<span class="quote">${LIBTOOL} --mode=compile
8455         ${CC}</span>&#8221;</span> in place of <span class="quote">&#8220;<span class="quote">${CC}</span>&#8221;</span>. You could even
8456         add it to the definition of <code class="varname">CC</code>, if only
8457         libraries are being built in a given Makefile. This one command
8458         will build both PIC and non-PIC library objects, so you need not
8459         have separate shared and non-shared library rules.</p></li>
8460 <li class="listitem">
8461 <p>For the linking of the library, remove any
8462         <span class="quote">&#8220;<span class="quote">ar</span>&#8221;</span>, <span class="quote">&#8220;<span class="quote">ranlib</span>&#8221;</span>, and <span class="quote">&#8220;<span class="quote">ld
8463         -Bshareable</span>&#8221;</span> commands, and instead use:</p>
8464 <pre class="programlisting">
8465 ${LIBTOOL} --mode=link \
8466     ${CC} -o ${.TARGET:.a=.la} \
8467         ${OBJS:.o=.lo} \
8468         -rpath ${PREFIX}/lib \
8469         -version-info major:minor
8470         </pre>
8471 <p>Note that the library is changed to have a
8472         <code class="filename">.la</code> extension, and the objects are
8473         changed to have a <code class="filename">.lo</code>
8474         extension. Change <code class="varname">OBJS</code> as
8475         necessary. This automatically creates all of the
8476         <code class="filename">.a</code>,
8477         <code class="filename">.so.major.minor</code>, and ELF symlinks (if
8478         necessary) in the build directory. Be sure to include
8479         <span class="quote">&#8220;<span class="quote">-version-info</span>&#8221;</span>, especially when major and
8480         minor are zero, as libtool will otherwise strip off the
8481         shared library version.</p>
8482 <p>From the libtool manual:</p>
8483 <pre class="programlisting">
8484 So, libtool library versions are described by three integers:
8485
8486 CURRENT
8487 The most recent interface number that this library implements.
8488
8489 REVISION
8490 The implementation number of the CURRENT interface.
8491
8492 AGE
8493 The difference between the newest and oldest interfaces that
8494 this library implements.  In other words, the library implements
8495 all the interface numbers in the range from number `CURRENT -
8496 AGE' to `CURRENT'.
8497
8498 If two libraries have identical CURRENT and AGE numbers, then the
8499 dynamic linker chooses the library with the greater REVISION number.
8500         </pre>
8501 <p>The <span class="quote">&#8220;<span class="quote">-release</span>&#8221;</span> option will produce
8502         different results for a.out and ELF (excluding symlinks)
8503         in only one case. An ELF library of the form
8504         <span class="quote">&#8220;<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;</span>
8505         will have a symlink of
8506         <span class="quote">&#8220;<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;</span>
8507         on an a.out platform. This is handled
8508         automatically.</p>
8509 <p>The <span class="quote">&#8220;<span class="quote">-rpath argument</span>&#8221;</span> is the install
8510         directory of the library being built.</p>
8511 <p>In the <code class="filename">PLIST</code>, include only the
8512         <code class="filename">.la</code> file, the other files will be
8513         added automatically.</p>
8514 </li>
8515 <li class="listitem">
8516 <p>When linking shared object (<code class="filename">.so</code>)
8517         files, i.e. files that are loaded via <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?dlopen+3+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">dlopen</span>(3)</span></a>, NOT
8518         shared libraries, use <span class="quote">&#8220;<span class="quote">-module
8519         -avoid-version</span>&#8221;</span> to prevent them getting version
8520         tacked on.</p>
8521 <p>The <code class="filename">PLIST</code> file gets the
8522         <code class="filename">foo.so</code> entry.</p>
8523 </li>
8524 <li class="listitem">
8525 <p>When linking programs that depend on these libraries
8526         <span class="emphasis"><em>before</em></span> they are installed, preface
8527         the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?cc+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">cc</span>(1)</span></a> or <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?ld+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">ld</span>(1)</span></a> line with <span class="quote">&#8220;<span class="quote">${LIBTOOL}
8528         --mode=link</span>&#8221;</span>, and it will find the correct
8529         libraries (static or shared), but please be aware that
8530         libtool will not allow you to specify a relative path in
8531         -L (such as <span class="quote">&#8220;<span class="quote">-L../somelib</span>&#8221;</span>), because it
8532         expects you to change that argument to be the
8533         <code class="filename">.la</code> file. e.g.</p>
8534 <pre class="programlisting">
8535 ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
8536         </pre>
8537 <p>should be changed to:</p>
8538 <pre class="programlisting">
8539 ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
8540         </pre>
8541 <p>and it will do the right thing with the libraries.</p>
8542 </li>
8543 <li class="listitem">
8544 <p>When installing libraries, preface the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?install+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">install</span>(1)</span></a>
8545         or <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?cp+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">cp</span>(1)</span></a> command with <span class="quote">&#8220;<span class="quote">${LIBTOOL}
8546         --mode=install</span>&#8221;</span>, and change the library name to
8547         <code class="filename">.la</code>. e.g.</p>
8548 <pre class="programlisting">
8549 ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
8550         </pre>
8551 <p>This will install the static <code class="filename">.a</code>,
8552         shared library, any needed symlinks, and run
8553         <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?ldconfig+8+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">ldconfig</span>(8)</span></a>.</p>
8554 </li>
8555 <li class="listitem"><p>In your <code class="filename">PLIST</code>, include only
8556         the <code class="filename">.la</code>
8557         file (this is a change from previous behaviour).</p></li>
8558 </ol></div>
8559 </div>
8560 <div class="sect2">
8561 <div class="titlepage"><div><div><h3 class="title">
8562 <a name="using-libtool"></a>19.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
8563 <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
8564     package Makefile. This will override the package's own libtool
8565     in most cases.  For older libtool using packages,  libtool is
8566     made by ltconfig script during the do-configure step; you can
8567     check the libtool script location by doing <span class="command"><strong>make
8568     configure; find work*/ -name libtool</strong></span>.</p>
8569 <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
8570     scripts, relative to <code class="varname">WRKSRC</code>, to override.  By
8571     default, it is set to <span class="quote">&#8220;<span class="quote">libtool */libtool
8572     */*/libtool</span>&#8221;</span>.  If this does not match the location of the
8573     package's libtool script(s), set it as appropriate.</p>
8574 <p>If you do not need <code class="filename">*.a</code> static
8575     libraries built and installed, then use
8576     <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
8577 <p>If your package makes use of the platform-independent library
8578     for loading dynamic shared objects, that comes with libtool
8579     (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
8580 <p>Some packages use libtool incorrectly so that the package
8581     may not work or build in some circumstances. Some of the more
8582     common errors are:</p>
8583 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
8584 <li class="listitem">
8585 <p>The inclusion of a shared object (-module) as a dependent library in an
8586         executable or library. This in itself isn't a problem if one of two things
8587         has been done:</p>
8588 <div class="orderedlist"><ol class="orderedlist" type="1">
8589 <li class="listitem"><p>The shared object is named correctly, i.e.
8590             <code class="filename">libfoo.la</code>, not
8591             <code class="filename">foo.la</code></p></li>
8592 <li class="listitem"><p>The -dlopen option is used when linking an executable.</p></li>
8593 </ol></div>
8594 </li>
8595 <li class="listitem"><p>The use of libltdl without the correct calls to initialisation routines.
8596         The function lt_dlinit() should be called and the macro
8597         <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
8598         executables.</p></li>
8599 </ul></div>
8600 </div>
8601 <div class="sect2">
8602 <div class="titlepage"><div><div><h3 class="title">
8603 <a name="autoconf-automake"></a>19.3.3. GNU Autoconf/Automake</h3></div></div></div>
8604 <p>If a package needs GNU autoconf or automake to be executed
8605     to regenerate the configure script and Makefile.in makefile
8606     templates, then they should be executed in a pre-configure
8607     target.</p>
8608 <p>For packages that need only autoconf:</p>
8609 <pre class="programlisting">
8610 AUTOCONF_REQD=  2.50            # if default version is not good enough
8611 USE_TOOLS+=     autoconf        # use "autoconf213" for autoconf-2.13
8612 ...
8613
8614 pre-configure:
8615         cd ${WRKSRC} &amp;&amp; autoconf
8616
8617 ...
8618     </pre>
8619 <p>and for packages that need automake and autoconf:</p>
8620 <pre class="programlisting">
8621 AUTOMAKE_REQD=  1.7.1           # if default version is not good enough
8622 USE_TOOLS+=     automake        # use "automake14" for automake-1.4
8623 ...
8624
8625 pre-configure:
8626         set -e; cd ${WRKSRC}; \
8627         aclocal; autoheader; automake -a --foreign -i; autoconf
8628
8629 ...
8630     </pre>
8631 <p>Packages which use GNU Automake will almost certainly
8632     require GNU Make.</p>
8633 <p>There are times when the configure process makes
8634     additional changes to the generated files, which then causes
8635     the build process to try to re-execute the automake sequence.
8636     This is prevented by touching various files in the configure
8637     stage. If this causes problems with your package you can set
8638     <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
8639     Makefile.</p>
8640 </div>
8641 </div>
8642 <div class="sect1">
8643 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8644 <a name="programming-languages"></a>19.4. Programming languages</h2></div></div></div>
8645 <div class="sect2">
8646 <div class="titlepage"><div><div><h3 class="title">
8647 <a name="basic-programming-languages"></a>19.4.1. C, C++, and Fortran</h3></div></div></div>
8648 <p>Compilers for the C, C++, and Fortran languages comes with
8649     the NetBSD base system.  By default, pkgsrc assumes that a package
8650     is written in C and will hide all other compilers (via the wrapper
8651     framework, see <a class="xref" href="#buildlink" title="Chapter 14. Buildlink methodology">Chapter 14, <i>Buildlink methodology</i></a>).</p>
8652 <p>To declare which language's compiler a package needs, set
8653     the <code class="varname">USE_LANGUAGES</code> variable. Allowed values
8654     currently are <span class="quote">&#8220;<span class="quote">c</span>&#8221;</span>, <span class="quote">&#8220;<span class="quote">c++</span>&#8221;</span>, and
8655     <span class="quote">&#8220;<span class="quote">fortran</span>&#8221;</span> (and any combination).  The default is
8656     <span class="quote">&#8220;<span class="quote">c</span>&#8221;</span>.  Packages using GNU configure scripts, even if
8657     written in C++, usually need a C compiler for the configure
8658     phase.</p>
8659 </div>
8660 <div class="sect2">
8661 <div class="titlepage"><div><div><h3 class="title">
8662 <a name="java-programming-language"></a>19.4.2. Java</h3></div></div></div>
8663 <p>If a program is written in Java, use the Java framework in
8664     pkgsrc.  The package must include
8665     <code class="filename">../../mk/java-vm.mk</code>.  This Makefile fragment
8666     provides the following variables:</p>
8667 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
8668 <li class="listitem"><p><code class="varname">USE_JAVA</code> defines if a build
8669       dependency on the JDK is added.  If
8670       <code class="varname">USE_JAVA</code> is set to <span class="quote">&#8220;<span class="quote">run</span>&#8221;</span>, then
8671       there is only a runtime dependency on the JDK.  The default is
8672       <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>, which also adds a build dependency on the
8673       JDK.</p></li>
8674 <li class="listitem"><p>Set <code class="varname">USE_JAVA2</code> to declare that
8675       a package needs a Java2 implementation.  The supported values
8676       are <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>, <span class="quote">&#8220;<span class="quote">1.4</span>&#8221;</span>, and
8677       <span class="quote">&#8220;<span class="quote">1.5</span>&#8221;</span>.  <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span> accepts any Java2
8678       implementation, <span class="quote">&#8220;<span class="quote">1.4</span>&#8221;</span> insists on versions 1.4 or
8679       above, and <span class="quote">&#8220;<span class="quote">1.5</span>&#8221;</span> only accepts versions 1.5 or
8680       above. This variable is not set by default.</p></li>
8681 <li class="listitem"><p><code class="varname">PKG_JAVA_HOME</code> is
8682       automatically set to the runtime location of the used Java
8683       implementation dependency. It may be used to set
8684       <code class="varname">JAVA_HOME</code> to a good value if the program
8685       needs this variable to be defined.
8686       </p></li>
8687 </ul></div>
8688 </div>
8689 <div class="sect2">
8690 <div class="titlepage"><div><div><h3 class="title">
8691 <a name="perl-scripts"></a>19.4.3. Packages containing perl scripts</h3></div></div></div>
8692 <p>If your package contains interpreted perl scripts, add
8693     <span class="quote">&#8220;<span class="quote">perl</span>&#8221;</span> to the <code class="varname">USE_TOOLS</code> variable
8694     and set <code class="varname">REPLACE_PERL</code> to ensure that the proper
8695     interpreter path is set. <code class="varname">REPLACE_PERL</code> should
8696     contain a list of scripts, relative to <code class="varname">WRKSRC</code>,
8697     that you want adjusted.  Every occurrence of
8698     <code class="filename">*/bin/perl</code> will be replaced with the full
8699     path to the perl executable.</p>
8700 <p>If a particular version of perl is needed, set the
8701     <code class="varname">PERL5_REQD</code> variable to the version number.  The
8702     default is <span class="quote">&#8220;<span class="quote">5.0</span>&#8221;</span>.</p>
8703 <p>See <a class="xref" href="#perl-modules" title="19.6.6. Packages installing perl modules">Section 19.6.6, &#8220;Packages installing perl modules&#8221;</a> for information
8704     about handling perl modules.</p>
8705 </div>
8706 <div class="sect2">
8707 <div class="titlepage"><div><div><h3 class="title">
8708 <a name="shell-scripts"></a>19.4.4. Packages containing shell scripts</h3></div></div></div>
8709 <p><code class="varname">REPLACE_SH</code>,
8710     <code class="varname">REPLACE_BASH</code>, <code class="varname">REPLACE_CSH</code>,
8711     and <code class="varname">REPLACE_KSH</code> can be used to replace shell
8712     hash bangs in files. Please use the appropriate one, prefering
8713     <code class="varname">REPLACE_SH</code> in case this shell is sufficient.
8714     When using <code class="varname">REPLACE_BASH</code>, don't forget to add
8715     <code class="filename">bash</code> to <code class="varname">USE_TOOLS</code>.</p>
8716 </div>
8717 <div class="sect2">
8718 <div class="titlepage"><div><div><h3 class="title">
8719 <a name="other-programming-languages"></a>19.4.5. Other programming languages</h3></div></div></div>
8720 <p>Currently, there is no special handling for other languages
8721     in pkgsrc.  If a compiler package provides a
8722     <code class="filename">buildlink3.mk</code> file, include that, otherwise
8723     just add a (build) dependency on the appropriate compiler
8724     package.</p>
8725 </div>
8726 </div>
8727 <div class="sect1">
8728 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8729 <a name="fixes.build"></a>19.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
8730 <p>The most common failures when building a package are that
8731         some platforms do not provide certain header files, functions or
8732         libraries, or they provide the functions in a library that the
8733         original package author didn't know. To work around this, you
8734         can rewrite the source code in most cases so that it does not
8735         use the missing functions or provides a replacement function.</p>
8736 <div class="sect2">
8737 <div class="titlepage"><div><div><h3 class="title">
8738 <a name="fixes.build.cpp"></a>19.5.1. Compiling C and C++ code conditionally</h3></div></div></div>
8739 <p>If a package already comes with a GNU configure script, the
8740         preferred way to fix the build failure is to change the
8741         configure script, not the code. In the other cases, you can
8742         utilize the C preprocessor, which defines certain macros
8743         depending on the operating system and hardware architecture it
8744         compiles for. These macros can be queried using for example
8745         <code class="varname">#if defined(__i386)</code>. Almost every operating
8746         system, hardware architecture and compiler has its own macro.
8747         For example, if the macros <code class="varname">__GNUC__</code>,
8748         <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
8749         are all defined, you know that you are using NetBSD on an i386
8750         compatible CPU, and your compiler is GCC.</p>
8751 <p>The list of the following macros for hardware and
8752         operating system depends on the compiler that is used. For
8753         example, if you want to conditionally compile code on Solaris,
8754         don't use <code class="varname">__sun__</code>, as the SunPro compiler
8755         does not define it. Use <code class="varname">__sun</code> instead.</p>
8756 <div class="sect3">
8757 <div class="titlepage"><div><div><h4 class="title">
8758 <a name="fixes.build.cpp.os"></a>19.5.1.1. C preprocessor macros to identify the operating system</h4></div></div></div>
8759 <p>To distinguish between 4.4 BSD-derived systems and the
8760         rest of the world, you should use the following code.</p>
8761 <pre class="programlisting">
8762 #include &lt;sys/param.h&gt;
8763 #if (defined(BSD) &amp;&amp; BSD &gt;= 199306)
8764 /* BSD-specific code goes here */
8765 #else
8766 /* non-BSD-specific code goes here */
8767 #endif
8768 </pre>
8769 <p>If this distinction is not fine enough, you can also test
8770         for the following macros.</p>
8771 <pre class="programlisting">
8772 Cygwin      __CYGWIN__
8773 DragonFly   __DragonFly__
8774 FreeBSD     __FreeBSD__
8775 Haiku       __HAIKU__
8776 Interix     __INTERIX
8777 IRIX        __sgi (TODO: get a definite source for this)
8778 Linux       linux, __linux, __linux__
8779 MirBSD      __MirBSD__ (__OpenBSD__ is also defined)
8780 Minix3      __minix
8781 NetBSD      __NetBSD__
8782 OpenBSD     __OpenBSD__
8783 Solaris     sun, __sun
8784 </pre>
8785 </div>
8786 <div class="sect3">
8787 <div class="titlepage"><div><div><h4 class="title">
8788 <a name="fixes.build.cpp.arch"></a>19.5.1.2. C preprocessor macros to identify the hardware architecture</h4></div></div></div>
8789 <pre class="programlisting">
8790 i386        i386, __i386, __i386__
8791 MIPS        __mips
8792 SPARC       sparc, __sparc
8793 </pre>
8794 </div>
8795 <div class="sect3">
8796 <div class="titlepage"><div><div><h4 class="title">
8797 <a name="fixes.build.cpp.compiler"></a>19.5.1.3. C preprocessor macros to identify the compiler</h4></div></div></div>
8798 <pre class="programlisting">
8799 GCC         __GNUC__ (major version), __GNUC_MINOR__
8800 MIPSpro     _COMPILER_VERSION (0x741 for MIPSpro 7.41)
8801 SunPro      __SUNPRO_C (0x570 for Sun C 5.7)
8802 SunPro C++  __SUNPRO_CC (0x580 for Sun C++ 5.8)
8803 </pre>
8804 </div>
8805 </div>
8806 <div class="sect2">
8807 <div class="titlepage"><div><div><h3 class="title">
8808 <a name="compiler-bugs"></a>19.5.2. How to handle compiler bugs</h3></div></div></div>
8809 <p>Some source files trigger bugs in the compiler, based on
8810         combinations of compiler version and architecture and almost
8811         always relation to optimisation being enabled.  Common symptoms
8812         are gcc internal errors or never finishing compiling a
8813         file.</p>
8814 <p>Typically, a workaround involves testing the
8815         <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
8816         optimisation for that combination of file,
8817         <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
8818         in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
8819         number of examples.</p>
8820 </div>
8821 <div class="sect2">
8822 <div class="titlepage"><div><div><h3 class="title">
8823 <a name="undefined-reference"></a>19.5.3. Undefined reference to <span class="quote">&#8220;<span class="quote">...</span>&#8221;</span>
8824 </h3></div></div></div>
8825 <p>This error message often means that a package did not
8826         link to a shared library it needs. The following functions are
8827         known to cause this error message over and over.</p>
8828 <div class="informaltable">
8829 <a name="undefined-reference-functions"></a><table border="1">
8830 <colgroup>
8831 <col>
8832 <col>
8833 <col>
8834 </colgroup>
8835 <thead><tr>
8836 <th>Function</th>
8837 <th>Library</th>
8838 <th>Affected platforms</th>
8839 </tr></thead>
8840 <tbody>
8841 <tr>
8842 <td>accept, bind, connect</td>
8843 <td>-lsocket</td>
8844 <td>Solaris</td>
8845 </tr>
8846 <tr>
8847 <td>crypt</td>
8848 <td>-lcrypt</td>
8849 <td>DragonFly, NetBSD</td>
8850 </tr>
8851 <tr>
8852 <td>dlopen, dlsym</td>
8853 <td>-ldl</td>
8854 <td>Linux</td>
8855 </tr>
8856 <tr>
8857 <td>gethost*</td>
8858 <td>-lnsl</td>
8859 <td>Solaris</td>
8860 </tr>
8861 <tr>
8862 <td>inet_aton</td>
8863 <td>-lresolv</td>
8864 <td>Solaris</td>
8865 </tr>
8866 <tr>
8867 <td>nanosleep, sem_*, timer_*</td>
8868 <td>-lrt</td>
8869 <td>Solaris</td>
8870 </tr>
8871 <tr>
8872 <td>openpty</td>
8873 <td>-lutil</td>
8874 <td>Linux</td>
8875 </tr>
8876 </tbody>
8877 </table>
8878 </div>
8879 <p>To fix these linker errors, it is often sufficient to say
8880     <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
8881     -l<em class="replaceable"><code>foo</code></em></code> to the package
8882     <code class="filename">Makefile</code> and then say <span class="command"><strong>bmake clean;
8883     bmake</strong></span>.</p>
8884 <div class="sect3">
8885 <div class="titlepage"><div><div><h4 class="title">
8886 <a name="undefined-reference-sunpro"></a>19.5.3.1. Special issue: The SunPro compiler</h4></div></div></div>
8887 <p>When you are using the SunPro compiler, there is another
8888 possibility. That compiler cannot handle the following code:</p>
8889 <pre class="programlisting">
8890 extern int extern_func(int);
8891
8892 static inline int
8893 inline_func(int x)
8894 {
8895         return extern_func(x);
8896 }
8897
8898 int main(void)
8899 {
8900         return 0;
8901 }
8902 </pre>
8903 <p>It generates the code for <code class="function">inline_func</code> even if
8904 that function is never used. This code then refers to
8905 <code class="function">extern_func</code>, which can usually not be resolved. To
8906 solve this problem you can try to tell the package to disable inlining
8907 of functions.</p>
8908 </div>
8909 </div>
8910 <div class="sect2">
8911 <div class="titlepage"><div><div><h3 class="title">
8912 <a name="out-of-memory"></a>19.5.4. Running out of memory</h3></div></div></div>
8913 <p>Sometimes packages fail to build because the compiler runs
8914     into an operating system specific soft limit.  With the
8915     <code class="varname">UNLIMIT_RESOURCES</code> variable pkgsrc can be told
8916     to unlimit the resources.  Currently, the allowed values are
8917     <span class="quote">&#8220;<span class="quote">datasize</span>&#8221;</span> and <span class="quote">&#8220;<span class="quote">stacksize</span>&#8221;</span> (or both).
8918     Setting this variable is similar to running the shell builtin
8919     <span class="command"><strong>ulimit</strong></span> command to raise the maximum data
8920     segment size or maximum stack size of a process, respectively, to
8921     their hard limits.</p>
8922 </div>
8923 </div>
8924 <div class="sect1">
8925 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
8926 <a name="fixes.install"></a>19.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
8927 <div class="sect2">
8928 <div class="titlepage"><div><div><h3 class="title">
8929 <a name="install-scripts"></a>19.6.1. Creating needed directories</h3></div></div></div>
8930 <p>The BSD-compatible <span class="command"><strong>install</strong></span> supplied
8931     with some operating systems cannot create more than one
8932     directory at a time. As such, you should call
8933     <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
8934 <pre class="programlisting">
8935 ${INSTALL_DATA_DIR} ${PREFIX}/dir1
8936 ${INSTALL_DATA_DIR} ${PREFIX}/dir2
8937     </pre>
8938 <p>You can also just append <span class="quote">&#8220;<span class="quote"><code class="literal">dir1
8939     dir2</code></span>&#8221;</span> to the
8940     <code class="varname">INSTALLATION_DIRS</code> variable, which will
8941     automatically do the right thing.</p>
8942 </div>
8943 <div class="sect2">
8944 <div class="titlepage"><div><div><h3 class="title">
8945 <a name="where-to-install-documentation"></a>19.6.2. Where to install documentation</h3></div></div></div>
8946 <p>In general, documentation should be installed into
8947     <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
8948     <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
8949     includes the version number of the package).</p>
8950 <p>Many modern packages using GNU autoconf allow to set the
8951     directory where HTML documentation is installed with the
8952     <span class="quote">&#8220;<span class="quote">--with-html-dir</span>&#8221;</span> option. Sometimes using this flag
8953     is needed because otherwise the documentation ends up in
8954     <code class="filename">${PREFIX}/share/doc/html</code> or other
8955     places.</p>
8956 <p>An exception to the above is that library API documentation
8957     generated with the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/textproc/gtk-doc/README.html" target="_top"><code class="filename">textproc/gtk-doc</code></a> tools, for use by special
8958     browsers (devhelp) should be left at their default location, which
8959     is <code class="filename">${PREFIX}/share/gtk-doc</code>.  Such
8960     documentation can be recognized from files ending in
8961     <code class="filename">.devhelp</code> or <code class="filename">.devhelp2</code>.
8962     (It is also acceptable to install such files in
8963     <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
8964     <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code>; the
8965     <code class="filename">.devhelp*</code> file must be directly in that
8966     directory then, no additional subdirectory level is allowed in
8967     this case. This is usually achieved by using
8968     <span class="quote">&#8220;<span class="quote">--with-html-dir=${PREFIX}/share/doc</span>&#8221;</span>.
8969     <code class="filename">${PREFIX}/share/gtk-doc</code> is preferred
8970     though.)</p>
8971 </div>
8972 <div class="sect2">
8973 <div class="titlepage"><div><div><h3 class="title">
8974 <a name="installing-score-files"></a>19.6.3. Installing highscore files</h3></div></div></div>
8975 <p>Certain packages, most of them in the games category, install
8976     a score file that allows all users on the system to record their
8977     highscores.  In order for this to work, the binaries need to be
8978     installed setgid and the score files owned by the appropriate
8979     group and/or owner (traditionally the "games" user/group).  Set
8980     <code class="varname">USE_GAMESGROUP</code> to yes to support this. The
8981     following variables, documented in more detail in
8982     <code class="filename">mk/defaults/mk.conf</code>, control this
8983     behaviour: <code class="varname">GAMEDATAMODE</code>,
8984     <code class="varname">GAMEDIRMODE</code>, <code class="varname">GAMES_GROUP</code>,
8985     <code class="varname">GAMEMODE</code>, <code class="varname">GAME_USER</code>.</p>
8986 <p>A package should therefore never hard code file ownership or
8987     access permissions but rely on <code class="varname">INSTALL_GAME</code> and
8988     <code class="varname">INSTALL_GAME_DATA</code> to set these
8989     correctly.</p>
8990 </div>
8991 <div class="sect2">
8992 <div class="titlepage"><div><div><h3 class="title">
8993 <a name="destdir-support"></a>19.6.4. Adding DESTDIR support to packages</h3></div></div></div>
8994 <p><code class="varname">DESTDIR</code> support means that a package
8995     installs into a staging directory, not the final location of the
8996     files. Then a binary package is created which can be used for
8997     installation as usual. There are two ways: Either the package must
8998     install as root (<span class="quote">&#8220;<span class="quote">destdir</span>&#8221;</span>) or the package can
8999     install as non-root user (<span class="quote">&#8220;<span class="quote">user-destdir</span>&#8221;</span>).</p>
9000 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
9001 <li class="listitem"><p><code class="varname">PKG_DESTDIR_SUPPORT</code> has to be
9002       set to <span class="quote">&#8220;<span class="quote">none</span>&#8221;</span>, <span class="quote">&#8220;<span class="quote">destdir</span>&#8221;</span>, or
9003       <span class="quote">&#8220;<span class="quote">user-destdir</span>&#8221;</span>. By default <code class="varname">PKG_DESTDIR_SUPPORT</code>
9004       is set to <span class="quote">&#8220;<span class="quote">user-destdir</span>&#8221;</span> to help catching more
9005       potential packaging problems. If bsd.prefs.mk is included in the Makefile,
9006       <code class="varname">PKG_DESTDIR_SUPPORT</code> needs to be set before
9007       the inclusion.</p></li>
9008 <li class="listitem"><p>All installation operations have to be prefixed with
9009       <code class="filename">${DESTDIR}</code>.</p></li>
9010 <li class="listitem"><p>automake gets this DESTDIR mostly right
9011       automatically. Many manual rules and pre/post-install often are
9012       incorrect; fix them.</p></li>
9013 <li class="listitem"><p>If files are installed with special owner/group
9014       use <code class="varname">SPECIAL_PERMS</code>.</p></li>
9015 <li class="listitem"><p>In general, packages should support
9016       <code class="varname">UNPRIVILEGED</code> to be able to use
9017       DESTDIR.</p></li>
9018 </ul></div>
9019 </div>
9020 <div class="sect2">
9021 <div class="titlepage"><div><div><h3 class="title">
9022 <a name="hardcoded-paths"></a>19.6.5. Packages with hardcoded paths to other interpreters</h3></div></div></div>
9023 <p>Your package may also contain scripts with hardcoded paths to
9024       other interpreters besides (or as well as) perl.  To correct the
9025       full pathname to the script interpreter, you need to set the
9026       following definitions in your <code class="filename">Makefile</code> (we
9027     shall use <span class="command"><strong>tclsh</strong></span> in this example):</p>
9028 <pre class="programlisting">
9029 REPLACE_INTERPRETER+=   tcl
9030 REPLACE.tcl.old=        .*/bin/tclsh
9031 REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
9032 REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
9033 # relative to ${WRKSRC}, just as in REPLACE_PERL
9034     </pre>
9035 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
9036 <h3 class="title">Note</h3>
9037 <p>Before March 2006, these variables were called
9038     <code class="varname">_REPLACE.*</code> and
9039     <code class="varname">_REPLACE_FILES.*</code>.</p>
9040 </div>
9041 </div>
9042 <div class="sect2">
9043 <div class="titlepage"><div><div><h3 class="title">
9044 <a name="perl-modules"></a>19.6.6. Packages installing perl modules</h3></div></div></div>
9045 <p>Makefiles of packages providing perl5 modules should include
9046     the Makefile fragment
9047     <code class="filename">../../lang/perl5/module.mk</code>.  It provides a
9048     <span class="command"><strong>do-configure</strong></span> target for the standard perl
9049     configuration for such modules as well as various hooks to tune
9050     this configuration.  See comments in this file for
9051     details.</p>
9052 <p>Perl5 modules will install into different places depending
9053     on the version of perl used during the build process.  To
9054     address this, pkgsrc will append lines to the
9055     <code class="filename">PLIST</code> corresponding to the files listed in
9056     the installed <code class="filename">.packlist</code> file generated by
9057     most perl5 modules.  This is invoked by defining
9058     <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
9059     packlist files relative to <code class="varname">PERL5_PACKLIST_DIR</code>
9060     (<code class="varname">PERL5_INSTALLVENDORARCH</code> by default),
9061     e.g.:</p>
9062 <pre class="programlisting">
9063 PERL5_PACKLIST= auto/Pg/.packlist
9064     </pre>
9065 <p>The perl5 config variables
9066     <code class="varname">installarchlib</code>,
9067     <code class="varname">installscript</code>,
9068     <code class="varname">installvendorbin</code>,
9069     <code class="varname">installvendorscript</code>,
9070     <code class="varname">installvendorarch</code>,
9071     <code class="varname">installvendorlib</code>,
9072     <code class="varname">installvendorman1dir</code>, and
9073     <code class="varname">installvendorman3dir</code> represent those
9074     locations in which components of perl5 modules may be installed,
9075     provided as variable with uppercase and prefixed with
9076     <code class="varname">PERL5_</code>, e.g. <code class="varname">PERL5_INSTALLARCHLIB</code>
9077     and may be used by perl5 packages that don't have a packlist.
9078     These variables are also substituted for in the
9079     <code class="filename">PLIST</code> as uppercase prefixed with
9080     <code class="varname">PERL5_SUB_</code>.</p>
9081 </div>
9082 <div class="sect2">
9083 <div class="titlepage"><div><div><h3 class="title">
9084 <a name="faq.info-files"></a>19.6.7. Packages installing info files</h3></div></div></div>
9085 <p>Some packages install info files or use the
9086     <span class="quote">&#8220;<span class="quote">makeinfo</span>&#8221;</span>  or <span class="quote">&#8220;<span class="quote">install-info</span>&#8221;</span>
9087     commands.  <code class="varname">INFO_FILES</code> should be defined in
9088     the package Makefile so that <code class="filename">INSTALL</code> and
9089     <code class="filename">DEINSTALL</code> scripts will be generated to
9090     handle registration of the info files in the Info directory
9091     file. The <span class="quote">&#8220;<span class="quote">install-info</span>&#8221;</span> command used for the info
9092     files registration is either provided by the system, or by a
9093     special purpose package automatically added as dependency if
9094     needed.</p>
9095 <p><code class="varname">PKGINFODIR</code> is the directory under
9096     <code class="filename">${PREFIX}</code> where info files are primarily
9097     located. <code class="varname">PKGINFODIR</code> defaults to
9098     <span class="quote">&#8220;<span class="quote">info</span>&#8221;</span> and can be overridden by the user.</p>
9099 <p>The info files for the package should be listed in the
9100     package <code class="filename">PLIST</code>; however any split info files
9101     need not be listed.</p>
9102 <p>A package which needs the <span class="quote">&#8220;<span class="quote">makeinfo</span>&#8221;</span> command
9103     at build time must add <span class="quote">&#8220;<span class="quote">makeinfo</span>&#8221;</span> to
9104     <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
9105     version of the <span class="quote">&#8220;<span class="quote">makeinfo</span>&#8221;</span> command is needed it
9106     should be noted with the <code class="varname">TEXINFO_REQD</code>
9107     variable in the package <code class="filename">Makefile</code>. By
9108     default, a minimum version of 3.12 is required. If the system
9109     does not provide a <span class="command"><strong>makeinfo</strong></span> command or if it
9110     does not match the required minimum, a build dependency on the
9111     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/gtexinfo/README.html" target="_top"><code class="filename">devel/gtexinfo</code></a> package will
9112     be added automatically.</p>
9113 <p>The build and installation process of the software provided
9114     by the package should not use the
9115     <span class="command"><strong>install-info</strong></span> command as the registration of
9116     info files is the task of the package
9117     <code class="filename">INSTALL</code> script, and it must use the
9118     appropriate <span class="command"><strong>makeinfo</strong></span> command.</p>
9119 <p>To achieve this goal, the pkgsrc infrastructure creates
9120     overriding scripts for the <span class="command"><strong>install-info</strong></span> and
9121     <span class="command"><strong>makeinfo</strong></span> commands in a directory listed early
9122     in <code class="varname">PATH</code>.</p>
9123 <p>The script overriding <span class="command"><strong>install-info</strong></span> has
9124     no effect except the logging of a message. The script overriding
9125     <span class="command"><strong>makeinfo</strong></span> logs a message and according to the
9126     value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
9127     <span class="command"><strong>makeinfo</strong></span> command or exit on error.</p>
9128 </div>
9129 <div class="sect2">
9130 <div class="titlepage"><div><div><h3 class="title">
9131 <a name="manpages"></a>19.6.8. Packages installing man pages</h3></div></div></div>
9132 <p>All packages that install manual pages should install them
9133     into the same directory, so that there is one common place to look
9134     for them. In pkgsrc, this place is
9135     <code class="literal">${PREFIX}/${PKGMANDIR}</code>, and this expression
9136     should be used in packages. The default for
9137     <code class="varname">PKGMANDIR</code> is
9138     <span class="quote">&#8220;<span class="quote"><code class="filename">man</code></span>&#8221;</span>. Another often-used value
9139     is <span class="quote">&#8220;<span class="quote"><code class="filename">share/man</code></span>&#8221;</span>.</p>
9140 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
9141 <h3 class="title">Note</h3>
9142 <p>The support for a custom <code class="varname">PKGMANDIR</code>
9143     is far from complete.</p>
9144 </div>
9145 <p>The <code class="filename">PLIST</code> files can just use
9146     <code class="filename">man/</code> as the top level directory for the man
9147     page file entries, and the pkgsrc framework will convert as
9148     needed. In all other places, the correct
9149     <code class="varname">PKGMANDIR</code> must be used.</p>
9150 <p>Packages that are
9151     configured with <code class="varname">GNU_CONFIGURE</code> set as
9152     <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>, by default will use the
9153     <code class="filename">./configure</code>
9154     --mandir switch to set where the man pages should be installed.
9155     The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
9156     to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.</p>
9157 <p>Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
9158     use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
9159     to <span class="quote">&#8220;<span class="quote">no</span>&#8221;</span>.
9160     Or if the <code class="filename">./configure</code> script uses
9161     a non-standard use of --mandir, you can set
9162     <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.</p>
9163 <p>See <a class="xref" href="#manpage-compression" title="13.5. Man page compression">Section 13.5, &#8220;Man page compression&#8221;</a> for
9164     information on installation of compressed manual pages.</p>
9165 </div>
9166 <div class="sect2">
9167 <div class="titlepage"><div><div><h3 class="title">
9168 <a name="gconf-data-files"></a>19.6.9. Packages installing GConf data files</h3></div></div></div>
9169 <p>If a package installs <code class="filename">.schemas</code> or
9170     <code class="filename">.entries</code> files, used by GConf,
9171     you need to take some extra steps to make sure they get registered
9172     in the database:</p>
9173 <div class="orderedlist"><ol class="orderedlist" type="1">
9174 <li class="listitem"><p>Include <code class="filename">../../devel/GConf/schemas.mk</code>
9175         instead of its <code class="filename">buildlink3.mk</code> file.  This
9176         takes care of rebuilding the GConf database at installation and
9177         deinstallation time, and tells the package where to install
9178         GConf data files using some standard configure arguments.  It
9179         also disallows any access to the database directly from the
9180         package.</p></li>
9181 <li class="listitem"><p>Ensure that the package installs its
9182         <code class="filename">.schemas</code> files under
9183         <code class="filename">${PREFIX}/share/gconf/schemas</code>.  If they get
9184         installed under <code class="filename">${PREFIX}/etc</code>, you will
9185         need to manually patch the package.</p></li>
9186 <li class="listitem"><p>Check the PLIST and remove any entries under the etc/gconf
9187         directory, as they will be handled automatically.  See
9188         <a class="xref" href="#faq.conf" title="9.13. How do I change the location of configuration files?">Section 9.13, &#8220;How do I change the location of configuration files?&#8221;</a> for more information.</p></li>
9189 <li class="listitem"><p>Define the <code class="varname">GCONF_SCHEMAS</code> variable in
9190         your <code class="filename">Makefile</code> with a list of all
9191         <code class="filename">.schemas</code> files installed by the package, if
9192         any.  Names must not contain any directories in them.</p></li>
9193 <li class="listitem"><p>Define the <code class="varname">GCONF_ENTRIES</code> variable in
9194         your <code class="filename">Makefile</code> with a
9195         list of all <code class="filename">.entries</code> files installed by the
9196         package, if any. Names must not contain any directories in
9197         them.</p></li>
9198 </ol></div>
9199 </div>
9200 <div class="sect2">
9201 <div class="titlepage"><div><div><h3 class="title">
9202 <a name="scrollkeeper-data-files"></a>19.6.10. Packages installing scrollkeeper/rarian data files</h3></div></div></div>
9203 <p>If a package installs <code class="filename">.omf</code> files, used by
9204     scrollkeeper/rarian, you need to take some extra steps to make sure they
9205     get registered in the database:</p>
9206 <div class="orderedlist"><ol class="orderedlist" type="1">
9207 <li class="listitem"><p>Include
9208         <code class="filename">../../mk/omf-scrollkeeper.mk</code>
9209         instead of rarian's <code class="filename">buildlink3.mk</code> file.  This
9210         takes care of rebuilding the scrollkeeper database at
9211         installation and deinstallation time, and disallows any access
9212         to it directly from the package.</p></li>
9213 <li class="listitem"><p>Check the PLIST and remove any entries under the
9214         <code class="filename">libdata/scrollkeeper</code> directory, as they
9215         will be handled automatically.</p></li>
9216 <li class="listitem"><p>Remove the <code class="filename">share/omf</code> directory from
9217         the PLIST.  It will be handled by rarian. (<span class="command"><strong>make
9218         print-PLIST</strong></span> does this automatically.)</p></li>
9219 </ol></div>
9220 </div>
9221 <div class="sect2">
9222 <div class="titlepage"><div><div><h3 class="title">
9223 <a name="x11-fonts"></a>19.6.11. Packages installing X11 fonts</h3></div></div></div>
9224 <p>If a package installs font files, you will need to rebuild
9225     the fonts database in the directory where they get installed at
9226     installation and deinstallation time.  This can be automatically
9227     done by using the pkginstall framework.</p>
9228 <p>You can list the directories where fonts are installed in the
9229     <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
9230     variables, where <em class="replaceable"><code>type</code></em> can be one of
9231     <span class="quote">&#8220;<span class="quote">ttf</span>&#8221;</span>, <span class="quote">&#8220;<span class="quote">type1</span>&#8221;</span> or <span class="quote">&#8220;<span class="quote">x11</span>&#8221;</span>.
9232     Also make sure that the database file
9233     <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
9234 <p>Note that you should not create new directories for fonts;
9235     instead use the standard ones to avoid that the user needs to
9236     manually configure his X server to find them.</p>
9237 </div>
9238 <div class="sect2">
9239 <div class="titlepage"><div><div><h3 class="title">
9240 <a name="gtk2-modules"></a>19.6.12. Packages installing GTK2 modules</h3></div></div></div>
9241 <p>If a package installs GTK2 immodules or loaders, you need to
9242     take some extra steps to get them registered in the GTK2 database
9243     properly:</p>
9244 <div class="orderedlist"><ol class="orderedlist" type="1">
9245 <li class="listitem"><p>Include
9246       <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
9247       <code class="filename">buildlink3.mk</code> file.  This takes care of
9248       rebuilding the database at installation and deinstallation time.</p></li>
9249 <li class="listitem"><p>Set <code class="varname">GTK2_IMMODULES=YES</code> if
9250       your package installs GTK2 immodules.</p></li>
9251 <li class="listitem"><p>Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
9252       GTK2 loaders.</p></li>
9253 <li class="listitem">
9254 <p>Patch the package to not touch any of the GTK2
9255       databases directly.  These are:</p>
9256 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
9257 <li class="listitem"><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
9258 <li class="listitem"><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
9259 </ul></div>
9260 </li>
9261 <li class="listitem"><p>Check the <code class="filename">PLIST</code> and remove
9262       any entries under the <code class="filename">libdata/gtk-2.0</code>
9263       directory, as they will be handled automatically.</p></li>
9264 </ol></div>
9265 </div>
9266 <div class="sect2">
9267 <div class="titlepage"><div><div><h3 class="title">
9268 <a name="sgml-xml-data"></a>19.6.13. Packages installing SGML or XML data</h3></div></div></div>
9269 <p>If a package installs SGML or XML data files that need to be
9270     registered in system-wide catalogs (like DTDs, sub-catalogs,
9271     etc.), you need to take some extra steps:</p>
9272 <div class="orderedlist"><ol class="orderedlist" type="1">
9273 <li class="listitem"><p>Include
9274         <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
9275         your <code class="filename">Makefile</code>, which takes care of
9276         registering those files in system-wide catalogs at
9277         installation and deinstallation time.</p></li>
9278 <li class="listitem"><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
9279         any SGML catalogs installed by the package.</p></li>
9280 <li class="listitem"><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
9281         any XML catalogs installed by the package.</p></li>
9282 <li class="listitem"><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
9283         to be added to the SGML catalog.  These come in groups of
9284         three strings; see xmlcatmgr(1) for more information
9285         (specifically, arguments recognized by the 'add' action).
9286         Note that you will normally not use this variable.</p></li>
9287 <li class="listitem"><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
9288         to be added to the XML catalog.  These come in groups of three
9289         strings; see xmlcatmgr(1) for more information (specifically,
9290         arguments recognized by the 'add' action).  Note that you will
9291         normally not use this variable.</p></li>
9292 </ol></div>
9293 </div>
9294 <div class="sect2">
9295 <div class="titlepage"><div><div><h3 class="title">
9296 <a name="mime-database"></a>19.6.14. Packages installing extensions to the MIME database</h3></div></div></div>
9297 <p>If a package provides extensions to the MIME database by
9298     installing <code class="filename">.xml</code> files inside
9299     <code class="filename">${PREFIX}/share/mime/packages</code>, you
9300     need to take some extra steps to ensure that the database is kept
9301     consistent with respect to these new files:</p>
9302 <div class="orderedlist"><ol class="orderedlist" type="1">
9303 <li class="listitem"><p>Include
9304         <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
9305         (avoid using the <code class="filename">buildlink3.mk</code> file from
9306         this same directory, which is reserved for inclusion from
9307         other <code class="filename">buildlink3.mk</code> files).  It takes
9308         care of rebuilding the MIME database at installation and
9309         deinstallation time, and disallows any access to it directly
9310         from the package.</p></li>
9311 <li class="listitem"><p>Check the PLIST and remove any entries under the
9312         <code class="filename">share/mime</code> directory,
9313         <span class="emphasis"><em>except</em></span> for files saved under
9314         <code class="filename">share/mime/packages</code>.  The former are
9315         handled automatically by
9316         the update-mime-database program, but the latter are
9317         package-dependent and must be removed by the package that
9318         installed them in the first place.</p></li>
9319 <li class="listitem"><p>Remove any <code class="filename">share/mime/*</code> directories
9320         from the PLIST.  They will be handled by the shared-mime-info
9321         package.</p></li>
9322 </ol></div>
9323 </div>
9324 <div class="sect2">
9325 <div class="titlepage"><div><div><h3 class="title">
9326 <a name="intltool"></a>19.6.15. Packages using intltool</h3></div></div></div>
9327 <p>If a package uses intltool during its build, add
9328     <code class="literal">intltool</code> to the <code class="varname">USE_TOOLS</code>,
9329     which forces it to use the intltool package provided by pkgsrc,
9330     instead of the one bundled with the distribution file.</p>
9331 <p>This tracks intltool's build-time dependencies and uses the
9332     latest available version; this way, the package benefits of any
9333     bug fixes that may have appeared since it was released.</p>
9334 </div>
9335 <div class="sect2">
9336 <div class="titlepage"><div><div><h3 class="title">
9337 <a name="startup-scripts"></a>19.6.16. Packages installing startup scripts</h3></div></div></div>
9338 <p>If a package contains a rc.d script, it won't be copied into
9339     the startup directory by default, but you can enable it, by adding
9340     the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
9341     <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>. This option will copy the scripts
9342     into <code class="filename">/etc/rc.d</code> when a package is installed, and
9343     it will automatically remove the scripts when the package is
9344     deinstalled.</p>
9345 </div>
9346 <div class="sect2">
9347 <div class="titlepage"><div><div><h3 class="title">
9348 <a name="tex-packages"></a>19.6.17. Packages installing TeX modules</h3></div></div></div>
9349 <p>If a package installs TeX packages into the texmf tree,
9350     the <code class="filename">ls-R</code> database of the tree needs to be
9351     updated.</p>
9352 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
9353 <h3 class="title">Note</h3>
9354 <p>Except the main TeX packages such as kpathsea,
9355     packages should install files
9356     into <code class="filename">${PREFIX}/share/texmf-dist</code>,
9357     not <code class="filename">${PREFIX}/share/texmf</code>.</p>
9358 </div>
9359 <div class="orderedlist"><ol class="orderedlist" type="1">
9360 <li class="listitem"><p>Include
9361       <code class="filename">../../print/kpathsea/texmf.mk</code>.  This
9362       takes care of rebuilding the <code class="filename">ls-R</code>
9363       database at installation and deinstallation time.</p></li>
9364 <li class="listitem">
9365 <p>If your package installs files into a texmf
9366       tree other than the one
9367       at <code class="filename">${PREFIX}/share/texmf-dist</code>,
9368       set <code class="varname">TEX_TEXMF_DIRS</code> to the list of all texmf
9369       trees that need database update.</p>
9370 <p>If your package also installs font map files that need
9371       to be registered using <span class="command"><strong>updmap</strong></span>,
9372       include <code class="filename">../../print/tex-tetex/map.mk</code> and
9373       set <code class="varname">TEX_MAP_FILES</code> and/or
9374       <code class="varname">TEX_MIXEDMAP_FILES</code> to the list of all
9375       such font map files.  Then <span class="command"><strong>updmap</strong></span> will
9376       be run automatically at installation/deinstallation to
9377       enable/disable font map files for TeX output
9378       drivers.</p>
9379 </li>
9380 <li class="listitem"><p>Make sure that none of <code class="filename">ls-R</code>
9381       databases are included in <code class="filename">PLIST</code>, as
9382       they will be removed only by the kpathsea package.</p></li>
9383 </ol></div>
9384 </div>
9385 <div class="sect2">
9386 <div class="titlepage"><div><div><h3 class="title">
9387 <a name="emulation-packages"></a>19.6.18. Packages supporting running binaries in
9388     emulation</h3></div></div></div>
9389 <p>There are some packages that provide libraries and
9390     executables for running binaries from a one operating system
9391     on a different one (if the latter supports it).  One example
9392     is running Linux binaries on NetBSD.</p>
9393 <p>The <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>
9394     helps in extracting and packaging Linux rpm packages.</p>
9395 <p>The <code class="varname">CHECK_SHLIBS</code> can be set to no to
9396     avoid the <span class="command"><strong>check-shlibs</strong></span> target, which tests
9397     if all libraries for each installed executable can be found by
9398     the dynamic linker.  Since the standard dynamic linker is run,
9399     this fails for emulation packages, because the libraries used
9400     by the emulation are not in the standard directories.</p>
9401 </div>
9402 <div class="sect2">
9403 <div class="titlepage"><div><div><h3 class="title">
9404 <a name="hicolor-theme"></a>19.6.19. Packages installing hicolor theme icons</h3></div></div></div>
9405 <p>If a package installs images under the
9406     <code class="filename">share/icons/hicolor</code> and/or updates the
9407     <code class="filename">share/icons/hicolor/icon-theme.cache</code>
9408     database, you need to take some extra steps to make sure that the
9409     shared theme directory is handled appropriately and that the cache
9410     database is rebuilt:</p>
9411 <div class="orderedlist"><ol class="orderedlist" type="1">
9412 <li class="listitem"><p>Include
9413         <code class="filename">../../graphics/hicolor-icon-theme/buildlink3.mk</code>.</p></li>
9414 <li class="listitem"><p>Check the <code class="filename">PLIST</code> and remove the
9415         entry that refers to the theme cache.</p></li>
9416 <li class="listitem"><p>Ensure that the PLIST does not remove the shared icon
9417           directories from the <code class="filename">share/icons/hicolor</code>
9418           hierarchy because they will be handled automatically.</p></li>
9419 </ol></div>
9420 <p>The best way to verify that the PLIST is correct with
9421       respect to the last two points is to regenerate it using
9422       <span class="command"><strong>make print-PLIST</strong></span>.</p>
9423 </div>
9424 <div class="sect2">
9425 <div class="titlepage"><div><div><h3 class="title">
9426 <a name="desktop-files"></a>19.6.20. Packages installing desktop files</h3></div></div></div>
9427 <p>If a package installs <code class="filename">.desktop</code> files
9428       under <code class="filename">share/applications</code> and these include
9429       MIME information (MimeType key), you need to take extra steps to
9430       ensure that they are registered into the MIME database:</p>
9431 <div class="orderedlist"><ol class="orderedlist" type="1">
9432 <li class="listitem"><p>Include
9433           <code class="filename">../../sysutils/desktop-file-utils/desktopdb.mk</code>.</p></li>
9434 <li class="listitem"><p>Check the PLIST and remove the entry that refers to the
9435           <code class="filename">share/applications/mimeinfo.cache</code> file.
9436           It will be handled automatically.</p></li>
9437 </ol></div>
9438 <p>The best way to verify that the PLIST is correct with
9439       respect to the last point is to regenerate it using <span class="command"><strong>make
9440       print-PLIST</strong></span>.</p>
9441 </div>
9442 </div>
9443 <div class="sect1">
9444 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9445 <a name="punting"></a>19.7. Marking packages as having problems</h2></div></div></div>
9446 <p>In some cases one does not have the time to solve a problem
9447   immediately. In this case, one can plainly mark a package as broken.  For
9448   this, one just sets the variable <code class="varname">BROKEN</code> to the
9449   reason why the package is broken (similar to the
9450   <code class="varname">RESTRICTED</code> variable).  A user trying to build
9451   the package will immediately be shown this message, and the build
9452   will not be even tried.</p>
9453 <p><code class="varname">BROKEN</code> packages are removed from pkgsrc in irregular
9454   intervals.</p>
9455 </div>
9456 </div>
9457 <div class="chapter">
9458 <div class="titlepage"><div><div><h2 class="title">
9459 <a name="debug"></a>Chapter 20. Debugging</h2></div></div></div>
9460 <p>To check out all the gotchas when building a package, here are
9461   the steps that I do in order to get a package working.  Please note
9462   this is basically the same as what was explained in the previous
9463   sections, only with some debugging aids.</p>
9464 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
9465 <li class="listitem"><p>Be sure to set <code class="varname">PKG_DEVELOPER=yes</code> in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.</p></li>
9466 <li class="listitem">
9467 <p>Install <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>,
9468       create a directory for a new package, change into it, then run
9469       <span class="command"><strong>url2pkg</strong></span>:</p>
9470 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>mkdir /usr/pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>examplepkg</code></em></code></strong>
9471 <code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>examplepkg</code></em></code></strong>
9472 <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
9473 </li>
9474 <li class="listitem"><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
9475 <li class="listitem"><p>Fill in the <code class="filename">DESCR</code> file</p></li>
9476 <li class="listitem"><p>Run <span class="command"><strong>make configure</strong></span></p></li>
9477 <li class="listitem"><p>Add any dependencies glimpsed from documentation and the
9478       configure step to the package's
9479       <code class="filename">Makefile</code>.</p></li>
9480 <li class="listitem">
9481 <p>Make the package compile, doing multiple rounds of</p>
9482 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
9483 <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
9484 <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
9485 <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
9486 <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
9487 <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
9488 <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
9489 <p>Doing this step as non-root user will ensure that no files
9490       are modified that shouldn't be, especially during the build
9491       phase.  <span class="command"><strong>mkpatches</strong></span>,
9492       <span class="command"><strong>patchdiff</strong></span> and <span class="command"><strong>pkgvi</strong></span> are
9493       from the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>
9494       package.</p>
9495 </li>
9496 <li class="listitem"><p>Look at the <code class="filename">Makefile</code>, fix if
9497       necessary; see <a class="xref" href="#components.Makefile" title="11.1. Makefile">Section 11.1, &#8220;<code class="filename">Makefile</code>&#8221;</a>.</p></li>
9498 <li class="listitem">
9499 <p>Generate a <code class="filename">PLIST</code>:</p>
9500 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
9501 <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST &gt;PLIST</code></strong>
9502 <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
9503 <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
9504 <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
9505 <p>You usually need to be <code class="username">root</code> to do
9506       this.  Look if there are any files left:</p>
9507 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
9508 <p>If this reveals any files that are missing in
9509       <code class="filename">PLIST</code>, add them.</p>
9510 </li>
9511 <li class="listitem">
9512 <p>Now that the <code class="filename">PLIST</code> is OK, install the
9513       package again and make a binary package:</p>
9514 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
9515 <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
9516 </li>
9517 <li class="listitem">
9518 <p>Delete the installed package:</p>
9519 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete <em class="replaceable"><code>examplepkg</code></em></code></strong></pre>
9520 </li>
9521 <li class="listitem">
9522 <p>Repeat the above <span class="command"><strong>make print-PLIST</strong></span>
9523       command, which shouldn't find anything now:</p>
9524 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
9525 </li>
9526 <li class="listitem">
9527 <p>Reinstall the binary package:</p>
9528 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add .../<em class="replaceable"><code>examplepkg</code></em>.tgz</code></strong></pre>
9529 </li>
9530 <li class="listitem"><p>Play with it.  Make sure everything works.</p></li>
9531 <li class="listitem">
9532 <p>Run <span class="command"><strong>pkglint</strong></span> from <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>, and fix the problems it
9533       reports:</p>
9534 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
9535 </li>
9536 <li class="listitem"><p>Submit (or commit, if you have cvs access); see <a class="xref" href="#submit" title="Chapter 21. Submitting and Committing">Chapter 21, <i>Submitting and Committing</i></a>.</p></li>
9537 </ul></div>
9538 </div>
9539 <div class="chapter">
9540 <div class="titlepage"><div><div><h2 class="title">
9541 <a name="submit"></a>Chapter 21. Submitting and Committing</h2></div></div></div>
9542 <div class="toc">
9543 <p><b>Table of Contents</b></p>
9544 <dl>
9545 <dt><span class="sect1"><a href="#submitting-binary-packages">21.1. Submitting binary packages</a></span></dt>
9546 <dt><span class="sect1"><a href="#submitting-your-package">21.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
9547 <dt><span class="sect1"><a href="#general-notes-for-changes">21.3. General notes when adding, updating, or removing packages</a></span></dt>
9548 <dt><span class="sect1"><a href="#committing-importing">21.4. Committing: Adding a package to CVS</a></span></dt>
9549 <dt><span class="sect1"><a href="#updating-package">21.5. Updating a package to a newer version</a></span></dt>
9550 <dt><span class="sect1"><a href="#renaming-package">21.6. Renaming a package in pkgsrc</a></span></dt>
9551 <dt><span class="sect1"><a href="#moving-package">21.7. Moving a package in pkgsrc</a></span></dt>
9552 </dl>
9553 </div>
9554 <div class="sect1">
9555 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9556 <a name="submitting-binary-packages"></a>21.1. Submitting binary packages</h2></div></div></div>
9557 <p>Our policy is that we accept binaries only from pkgsrc
9558         developers to guarantee that the packages don't contain any
9559         trojan horses etc. This is not to annoy anyone but rather to
9560         protect our users! You're still free to put up your home-made
9561         binary packages and tell the world where to get them. NetBSD
9562         developers doing bulk builds and wanting to upload them please
9563         see <a class="xref" href="#bulk-upload" title="7.3.8. Uploading results of a bulk build">Section 7.3.8, &#8220;Uploading results of a bulk build&#8221;</a>.</p>
9564 </div>
9565 <div class="sect1">
9566 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9567 <a name="submitting-your-package"></a>21.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
9568 <p>First, check that your package is complete, compiles and
9569         runs well; see <a class="xref" href="#debug" title="Chapter 20. Debugging">Chapter 20, <i>Debugging</i></a> and the rest of this
9570         document. Next, generate an uuencoded gzipped <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?tar+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span></a>
9571         archive that contains all files that make up the package.
9572         Finally, send this package to the pkgsrc bug tracking system,
9573         either with the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">send-pr</span>(1)</span></a> command, or if you don't have
9574         that, go to the web page
9575         <a class="ulink" href="http://www.NetBSD.org/support/send-pr.html" target="_top">http://www.NetBSD.org/support/send-pr.html</a>,
9576         which contains some instructions and a link to a form where you
9577         can submit packages.  The
9578         <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/sysutils/gtk-send-pr/README.html" target="_top"><code class="filename">sysutils/gtk-send-pr</code></a> package is
9579         also available as a substitute for either of the above two tools.
9580         </p>
9581 <p>In the form of the problem report, the category should be
9582         <span class="quote">&#8220;<span class="quote">pkg</span>&#8221;</span>, the synopsis should include the package name
9583         and version number, and the description field should contain a
9584         short description of your package (contents of the COMMENT
9585         variable or DESCR file are OK). The uuencoded package data should
9586         go into the <span class="quote">&#8220;<span class="quote">fix</span>&#8221;</span> field.</p>
9587 <p>If you want to submit several packages, please send a
9588         separate PR for each one, it's easier for us to track things
9589         that way.</p>
9590 <p>Alternatively, you can also import new packages into
9591         pkgsrc-wip (<span class="quote">&#8220;<span class="quote">pkgsrc work-in-progress</span>&#8221;</span>); see the
9592         homepage at <a class="ulink" href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
9593         for details.</p>
9594 </div>
9595 <div class="sect1">
9596 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9597 <a name="general-notes-for-changes"></a>21.3. General notes when adding, updating, or removing packages</h2></div></div></div>
9598 <p>Please note all package additions, updates, moves, and
9599         removals in <code class="filename">pkgsrc/doc/CHANGES-<em class="replaceable"><code>YYYY</code></em></code>. It's very
9600         important to keep this file up to date and conforming to the
9601         existing format, because it will be used by scripts to
9602         automatically update pages on <a class="ulink" href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
9603         sites. Additionally, check the
9604         <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
9605         for the package you updated or removed, in case it was mentioned
9606         there.</p>
9607 <p>When the <code class="varname">PKGREVISION</code> of a package is
9608         bumped, the change should appear in
9609         <code class="filename">pkgsrc/doc/CHANGES-<em class="replaceable"><code>YYYY</code></em></code> if it is security
9610         related or otherwise relevant. Mass bumps that result from a
9611         dependency being updated should not be mentioned. In all other
9612         cases it's the developer's decision.</p>
9613 <p>There is a make target that helps in creating proper
9614   <code class="filename">CHANGES-<em class="replaceable"><code>YYYY</code></em></code> entries:  <span class="command"><strong>make
9615   changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
9616   and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
9617   usage is to first make sure that your <code class="filename">CHANGES-<em class="replaceable"><code>YYYY</code></em></code>
9618   file is up-to-date (to avoid having to resolve conflicts later-on)
9619   and then to <span class="command"><strong>cd</strong></span> to the package directory.  For
9620   package updates, <span class="command"><strong>make changes-entry</strong></span> is enough.
9621   For new packages, or package moves or removals, set the
9622   <code class="varname">CTYPE</code> variable on the command line to "Added",
9623   "Moved", or "Removed".  You can set <code class="varname">NETBSD_LOGIN_NAME</code>
9624   in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> if your local login name is
9625   not the same as your NetBSD login name. The target also automatically
9626   removes possibly existing entries for the package in the
9627   <code class="filename">TODO</code> file. Don't forget to commit
9628   the changes, e.g. by using <span class="command"><strong>make changes-entry-commit</strong></span>!
9629   If you are not using a checkout directly from cvs.NetBSD.org, but e.g.
9630   a local copy of the repository, you can set USE_NETBSD_REPO=yes. This
9631   makes the cvs commands use the main repository.
9632   </p>
9633 </div>
9634 <div class="sect1">
9635 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9636 <a name="committing-importing"></a>21.4. Committing: Adding a package to CVS</h2></div></div></div>
9637 <p>This section is only of interest for pkgsrc developers with write
9638   access to the pkgsrc repository.</p>
9639 <p>When the package is finished, <span class="quote">&#8220;<span class="quote">cvs add</span>&#8221;</span> the files.
9640 Start by adding the directory and then files in the directory. Don't
9641 forget to add the new package to the category's
9642 <code class="filename">Makefile</code>. Make sure you don't forget any files;
9643 you can check by running <span class="quote">&#8220;<span class="quote">cvs status</span>&#8221;</span>. An example:</p>
9644 <pre class="programlisting">
9645 <code class="prompt">$</code> cd .../pkgsrc/category
9646 <code class="prompt">$</code> cvs add pkgname
9647 <code class="prompt">$</code> cd pkgname
9648 <code class="prompt">$</code> cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
9649 <code class="prompt">$</code> cvs add patches/p*
9650 <code class="prompt">$</code> cvs status | less
9651 <code class="prompt">$</code> cvs commit
9652 <code class="prompt">$</code> cd ..
9653 <code class="prompt">$</code> vi Makefile # add SUBDIRS+=pkgname line
9654 <code class="prompt">$</code> cvs commit Makefile
9655 </pre>
9656 <p>The commit message of the initial import should include part of the
9657   <code class="filename">DESCR</code> file, so people reading the mailing lists know
9658   what the package is/does.</p>
9659 <p>Also mention the new package in
9660 <code class="filename">pkgsrc/doc/CHANGES-20xx</code>.</p>
9661 <p>Previously, <span class="quote">&#8220;<span class="quote">cvs import</span>&#8221;</span> was suggested, but it was
9662 much easier to get wrong than <span class="quote">&#8220;<span class="quote">cvs add</span>&#8221;</span>.</p>
9663 </div>
9664 <div class="sect1">
9665 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9666 <a name="updating-package"></a>21.5. Updating a package to a newer version</h2></div></div></div>
9667 <p>Please always put a concise, appropriate and relevant summary of the
9668   changes between old and new versions into the commit log when updating
9669   a package. There are various reasons for this:</p>
9670 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
9671 <li class="listitem"><p>A URL is volatile, and can change over time. It may go away completely
9672   or its information may be overwritten by newer information.</p></li>
9673 <li class="listitem"><p>Having the change information between old and new versions in our CVS
9674   repository is very useful for people who use either cvs or anoncvs.</p></li>
9675 <li class="listitem"><p>Having the change information between old and new versions in our CVS
9676   repository is very useful for people who read the pkgsrc-changes mailing
9677   list, so that they can make tactical decisions about when to upgrade
9678   the package.</p></li>
9679 </ul></div>
9680 <p>Please also recognize that, just because a new version of a package
9681   has been released, it should not automatically be upgraded in the CVS
9682   repository.  We prefer to be conservative in the packages that are
9683   included in pkgsrc - development or beta packages are not really the
9684   best thing for most places in which pkgsrc is used. Please use your
9685   judgement about what should go into pkgsrc, and bear in mind that
9686   stability is to be preferred above new and possibly untested features.</p>
9687 </div>
9688 <div class="sect1">
9689 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9690 <a name="renaming-package"></a>21.6. Renaming a package in pkgsrc</h2></div></div></div>
9691 <p>Renaming packages is not recommended.</p>
9692 <p>When renaming packages, be sure to fix any references to old name
9693   in other Makefiles, options, buildlink files, etc.</p>
9694 <p>Also When renaming a package, please define
9695   <code class="varname">SUPERSEDES</code> to the package name and dewey version
9696   pattern(s) of the previous package name.
9697   This may be repeated for multiple renames.
9698   The new package would be an exact replacement.
9699 </p>
9700 <p>Note that <span class="quote">&#8220;<span class="quote">successor</span>&#8221;</span> in the
9701   CHANGES-<em class="replaceable"><code>YYYY</code></em> file doesn't necessarily
9702   mean that it <span class="emphasis"><em>supersedes</em></span>, as that successor may
9703   not be an exact replacement but is a suggestion for the replaced
9704   functionality.</p>
9705 </div>
9706 <div class="sect1">
9707 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9708 <a name="moving-package"></a>21.7. Moving a package in pkgsrc</h2></div></div></div>
9709 <p>It is preferred that packages are not renamed or moved, but if needed
9710   please follow these steps.
9711 </p>
9712 <div class="orderedlist"><ol class="orderedlist" type="1">
9713 <li class="listitem"><p>Make a copy of the directory somewhere else.</p></li>
9714 <li class="listitem">
9715 <p>Remove all CVS dirs.</p>
9716 <p>Alternatively to the first two steps you can also do:</p>
9717 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package</code></strong></pre>
9718 <p>and use that for further work.</p>
9719 </li>
9720 <li class="listitem"><p>Fix <code class="varname">CATEGORIES</code> and any
9721 <code class="varname">DEPENDS</code> paths that just did <span class="quote">&#8220;<span class="quote">../package</span>&#8221;</span>
9722 instead of <span class="quote">&#8220;<span class="quote">../../category/package</span>&#8221;</span>.</p></li>
9723 <li class="listitem"><p>In the modified package's Makefile, consider setting
9724 <code class="varname">PREV_PKGPATH</code> to the previous category/package
9725 pathname.  The <code class="varname">PREV_PKGPATH</code> can be used by tools
9726 for doing an update using pkgsrc building; for example, it can
9727 search the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_summary+5+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">pkg_summary</span>(5)</span></a> database for <code class="varname">PREV_PKGPATH</code>
9728 (if no <code class="varname">SUPERSEDES</code>) and then use the corresponding
9729 new <code class="varname">PKGPATH</code> for that moved package.  Note that
9730 it may have multiple matches, so the tool should also check on the
9731 <code class="varname">PKGBASE</code> too.  The <code class="varname">PREV_PKGPATH</code>
9732 probably has no value unless <code class="varname">SUPERSEDES</code> is not
9733 set, i.e.  <code class="varname">PKGBASE</code> stays the same.  </p></li>
9734 <li class="listitem"><p><span class="command"><strong>cvs import</strong></span> the modified package in the new
9735 place.</p></li>
9736 <li class="listitem">
9737 <p>Check if any package depends on it:
9738 </p>
9739 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
9740 <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
9741 </li>
9742 <li class="listitem"><p>Fix paths in packages from step 5 to point to new location.</p></li>
9743 <li class="listitem"><p><span class="command"><strong>cvs rm (-f)</strong></span> the package at the old location.</p></li>
9744 <li class="listitem"><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
9745 <li class="listitem"><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
9746 <li class="listitem">
9747 <p>Commit the changed and removed files:</p>
9748 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
9749 <p>(and any packages from step 5, of course).</p>
9750 </li>
9751 </ol></div>
9752 </div>
9753 </div>
9754 <div class="chapter">
9755 <div class="titlepage"><div><div><h2 class="title">
9756 <a name="devfaq"></a>Chapter 22. Frequently Asked Questions</h2></div></div></div>
9757 <p>This section contains the answers to questions that may
9758         arise when you are writing a package. If you don't find your
9759         question answered here, first have a look in the other chapters,
9760         and if you still don't have the answer, ask on the
9761         <code class="literal">pkgsrc-users</code> mailing list.</p>
9762 <div class="qandaset">
9763 <a name="idm77694160"></a><dl>
9764 <dt>22.1. <a href="#devfaq.makeflags">What is the difference between
9765         MAKEFLAGS, .MAKEFLAGS and
9766         MAKE_FLAGS?</a>
9767 </dt>
9768 <dt>22.2. <a href="#devfaq.make">What is the difference between
9769         MAKE, GMAKE and
9770         MAKE_PROGRAM?</a>
9771 </dt>
9772 <dt>22.3. <a href="#devfaq.cc">What is the difference between
9773         CC, PKG_CC and
9774         PKGSRC_COMPILER?</a>
9775 </dt>
9776 <dt>22.4. <a href="#devfaq.bl3flags">What is the difference between
9777         BUILDLINK_LDFLAGS,
9778         BUILDLINK_LDADD and
9779         BUILDLINK_LIBS?</a>
9780 </dt>
9781 <dt>22.5. <a href="#devfaq.bl3prefix">Why does make show-var
9782         VARNAME=BUILDLINK_PREFIX.foo
9783         say it's empty?</a>
9784 </dt>
9785 <dt>22.6. <a href="#devfaq.master_sites">What does
9786         ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
9787         don't understand the := inside
9788         it.</a>
9789 </dt>
9790 <dt>22.7. <a href="#devfaq.mailinglists">Which mailing lists are there for package
9791         developers?</a>
9792 </dt>
9793 <dt>22.8. <a href="#devfaq.documentation">Where is the pkgsrc
9794         documentation?</a>
9795 </dt>
9796 <dt>22.9. <a href="#devfaq.too-much-time">I have a little time to kill.  What shall I
9797 do?</a>
9798 </dt>
9799 </dl>
9800 <table border="0" style="width: 100%;">
9801 <colgroup>
9802 <col align="left" width="1%">
9803 <col>
9804 </colgroup>
9805 <tbody>
9806 <tr class="question">
9807 <td align="left" valign="top">
9808 <a name="devfaq.makeflags"></a><a name="idm77693776"></a><p><b>22.1.</b></p>
9809 </td>
9810 <td align="left" valign="top"><p>What is the difference between
9811         <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
9812         <code class="varname">MAKE_FLAGS</code>?</p></td>
9813 </tr>
9814 <tr class="answer">
9815 <td align="left" valign="top"></td>
9816 <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
9817         to the pkgsrc-internal invocations of <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>, while
9818         <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
9819         the <code class="varname">MAKE_PROGRAM</code> when building the
9820         package. [FIXME: What is .MAKEFLAGS for?]</p></td>
9821 </tr>
9822 <tr class="question">
9823 <td align="left" valign="top">
9824 <a name="devfaq.make"></a><a name="idm77689808"></a><p><b>22.2.</b></p>
9825 </td>
9826 <td align="left" valign="top"><p>What is the difference between
9827         <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
9828         <code class="varname">MAKE_PROGRAM</code>?</p></td>
9829 </tr>
9830 <tr class="answer">
9831 <td align="left" valign="top"></td>
9832 <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
9833         <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> program that is used in the pkgsrc
9834         infrastructure. <code class="varname">GMAKE</code> is the path to GNU
9835         Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
9836         use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
9837         Make program that is used for building the
9838         package.</p></td>
9839 </tr>
9840 <tr class="question">
9841 <td align="left" valign="top">
9842 <a name="devfaq.cc"></a><a name="idm77685328"></a><p><b>22.3.</b></p>
9843 </td>
9844 <td align="left" valign="top"><p>What is the difference between
9845         <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
9846         <code class="varname">PKGSRC_COMPILER</code>?</p></td>
9847 </tr>
9848 <tr class="answer">
9849 <td align="left" valign="top"></td>
9850 <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
9851         compiler, which can be configured by the pkgsrc user.
9852         <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
9853         <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
9854         path to a compiler, but the type of compiler that should be
9855         used. See <code class="filename">mk/compiler.mk</code> for more
9856         information about the latter variable.</p></td>
9857 </tr>
9858 <tr class="question">
9859 <td align="left" valign="top">
9860 <a name="devfaq.bl3flags"></a><a name="idm77681232"></a><p><b>22.4.</b></p>
9861 </td>
9862 <td align="left" valign="top"><p>What is the difference between
9863         <code class="varname">BUILDLINK_LDFLAGS</code>,
9864         <code class="varname">BUILDLINK_LDADD</code> and
9865         <code class="varname">BUILDLINK_LIBS</code>?</p></td>
9866 </tr>
9867 <tr class="answer">
9868 <td align="left" valign="top"></td>
9869 <td align="left" valign="top"><p>[FIXME]</p></td>
9870 </tr>
9871 <tr class="question">
9872 <td align="left" valign="top">
9873 <a name="devfaq.bl3prefix"></a><a name="idm77678928"></a><p><b>22.5.</b></p>
9874 </td>
9875 <td align="left" valign="top"><p>Why does <span class="command"><strong>make show-var
9876         VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
9877         say it's empty?</p></td>
9878 </tr>
9879 <tr class="answer">
9880 <td align="left" valign="top"></td>
9881 <td align="left" valign="top"><p>For optimization reasons, some variables are only
9882         available in the <span class="quote">&#8220;<span class="quote">wrapper</span>&#8221;</span> phase and later. To
9883         <span class="quote">&#8220;<span class="quote">simulate</span>&#8221;</span> the wrapper phase, append
9884         <span class="command"><strong>PKG_PHASE=wrapper</strong></span> to the above
9885         command.</p></td>
9886 </tr>
9887 <tr class="question">
9888 <td align="left" valign="top">
9889 <a name="devfaq.master_sites"></a><a name="idm77675856"></a><p><b>22.6.</b></p>
9890 </td>
9891 <td align="left" valign="top"><p>What does
9892         <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
9893         don't understand the <code class="literal">:=</code> inside
9894         it.</p></td>
9895 </tr>
9896 <tr class="answer">
9897 <td align="left" valign="top"></td>
9898 <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
9899         assignment operator, like you might expect at first sight.
9900         Instead, it is a degenerate form of
9901         <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
9902         which is documented in the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> man page and which you
9903         may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
9904         case of <code class="varname">MASTER_SITE_*</code>,
9905         <em class="replaceable"><code>old_string</code></em> is the empty string and
9906         <em class="replaceable"><code>new_string</code></em> is
9907         <code class="literal">package/</code>. That's where the
9908         <code class="literal">:</code> and the <code class="literal">=</code> fall
9909         together.</p></td>
9910 </tr>
9911 <tr class="question">
9912 <td align="left" valign="top">
9913 <a name="devfaq.mailinglists"></a><a name="idm77667792"></a><p><b>22.7.</b></p>
9914 </td>
9915 <td align="left" valign="top"><p>Which mailing lists are there for package
9916         developers?</p></td>
9917 </tr>
9918 <tr class="answer">
9919 <td align="left" valign="top"></td>
9920 <td align="left" valign="top"><div class="variablelist"><dl class="variablelist">
9921 <dt><span class="term"><a class="ulink" href="http://www.NetBSD.org/mailinglists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
9922 <dd><p>This is a list for technical discussions related
9923         to pkgsrc development, e.g. soliciting feedback for changes to
9924         pkgsrc infrastructure, proposed new features, questions related
9925         to porting pkgsrc to a new platform, advice for maintaining a
9926         package, patches that affect many packages, help requests moved
9927         from pkgsrc-users when an infrastructure bug is found,
9928         etc.</p></dd>
9929 <dt><span class="term"><a class="ulink" href="http://www.NetBSD.org/mailinglists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
9930 <dd><p>All bug reports in category "pkg" sent with
9931         <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">send-pr</span>(1)</span></a> appear here. Please do not report your bugs here
9932         directly; use one of the other mailing
9933         lists.</p></dd>
9934 </dl></div></td>
9935 </tr>
9936 <tr class="question">
9937 <td align="left" valign="top">
9938 <a name="devfaq.documentation"></a><a name="idm77664080"></a><p><b>22.8.</b></p>
9939 </td>
9940 <td align="left" valign="top"><p>Where is the pkgsrc
9941         documentation?</p></td>
9942 </tr>
9943 <tr class="answer">
9944 <td align="left" valign="top"></td>
9945 <td align="left" valign="top">
9946 <p>There are many places where you can find
9947         documentation about pkgsrc:</p>
9948 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
9949 <li class="listitem"><p>The pkgsrc guide (this document) is a collection
9950         of chapters that explain large parts of pkgsrc, but some
9951         chapters tend to be outdated. Which ones they are is hard to
9952         say.</p></li>
9953 <li class="listitem"><p>On the mailing list archives (see <a class="ulink" href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>), you can find discussions
9954         about certain features, announcements of new parts of the pkgsrc
9955         infrastructure and sometimes even announcements that a certain
9956         feature has been marked as obsolete. The benefit here is that
9957         each message has a date appended to it.</p></li>
9958 <li class="listitem"><p>Many of the files in the
9959         <code class="filename">mk/</code> directory start with a comment that
9960         describes the purpose of the file and how it can be used by the
9961         pkgsrc user and package authors. An easy way to find this
9962         documentation is to run <span class="command"><strong>bmake
9963         help</strong></span>.</p></li>
9964 <li class="listitem"><p>The CVS log messages are a rich source of
9965         information, but they tend to be highly abbreviated, especially
9966         for actions that occur often. Some contain a detailed
9967         description of what has changed, but they are geared towards the
9968         other pkgsrc developers, not towards an average pkgsrc user.
9969         They also only document <span class="emphasis"><em>changes</em></span>, so if you
9970         don't know what has been before, these messages may not be worth
9971         too much to you.</p></li>
9972 <li class="listitem"><p>Some parts of pkgsrc are only <span class="quote">&#8220;<span class="quote">implicitly
9973         documented</span>&#8221;</span>, that is the documentation exists only in the
9974         mind of the developer who wrote the code. To get this
9975         information, use the <span class="command"><strong>cvs annotate</strong></span> command
9976         to see who has written it and ask on the
9977         <code class="literal">tech-pkg</code> mailing list, so that others can
9978         find your questions later (see above). To be sure that the
9979         developer in charge reads the mail, you may CC him or
9980         her.</p></li>
9981 </ul></div>
9982 </td>
9983 </tr>
9984 <tr class="question">
9985 <td align="left" valign="top">
9986 <a name="devfaq.too-much-time"></a><a name="idm77657552"></a><p><b>22.9.</b></p>
9987 </td>
9988 <td align="left" valign="top"><p>I have a little time to kill.  What shall I
9989 do?</p></td>
9990 </tr>
9991 <tr class="answer">
9992 <td align="left" valign="top"></td>
9993 <td align="left" valign="top">
9994 <p>This is not really an FAQ yet, but here's the answer
9995 anyway.</p>
9996 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
9997 <li class="listitem"><p>Run <span class="command"><strong>pkg_chk -N</strong></span> (from the
9998     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_chk/README.html" target="_top"><code class="filename">pkgtools/pkg_chk</code></a> package).  It
9999     will tell you about newer versions of installed packages that are
10000     available, but not yet updated in pkgsrc.</p></li>
10001 <li class="listitem"><p>Browse <code class="filename">pkgsrc/doc/TODO</code>
10002     &mdash; it contains a list of suggested new packages and a list of
10003     cleanups and enhancements for pkgsrc that would be nice to
10004     have.</p></li>
10005 <li class="listitem"><p>Review packages for which review was requested on
10006     the <a class="ulink" href="http://pkgsrc-wip.sourceforge.net/" target="_top">pkgsrc-wip</a> review
10007     mailing list.</p></li>
10008 </ul></div>
10009 </td>
10010 </tr>
10011 </tbody>
10012 </table>
10013 </div>
10014 </div>
10015 <div class="chapter">
10016 <div class="titlepage"><div><div><h2 class="title">
10017 <a name="gnome"></a>Chapter 23. GNOME packaging and porting</h2></div></div></div>
10018 <div class="toc">
10019 <p><b>Table of Contents</b></p>
10020 <dl>
10021 <dt><span class="sect1"><a href="#meta-packages">23.1. Meta packages</a></span></dt>
10022 <dt><span class="sect1"><a href="#new-package">23.2. Packaging a GNOME application</a></span></dt>
10023 <dt><span class="sect1"><a href="#full-update">23.3. Updating GNOME to a newer version</a></span></dt>
10024 <dt><span class="sect1"><a href="#patching">23.4. Patching guidelines</a></span></dt>
10025 </dl>
10026 </div>
10027 <p>Quoting <a class="ulink" href="http://www.gnome.org/" target="_top">GNOME's web
10028 site</a>:</p>
10029 <div class="blockquote"><blockquote class="blockquote"><p>The GNOME project provides two things: The GNOME desktop
10030   environment, an intuitive and attractive desktop for users, and the
10031   GNOME development platform, an extensive framework for building
10032   applications that integrate into the rest of the desktop.</p></blockquote></div>
10033 <p>pkgsrc provides a seamless way to automatically build and install
10034 a complete GNOME environment <span class="emphasis"><em>under many different
10035 platforms</em></span>.  We can say with confidence that pkgsrc is one of
10036 the most advanced build and packaging systems for GNOME due to its
10037 included technologies buildlink3, the wrappers and tools framework and
10038 automatic configuration file management.  Lots of efforts are put into
10039 achieving a completely clean deinstallation of installed software
10040 components.</p>
10041 <p>Given that pkgsrc is <a class="ulink" href="http://www.NetBSD.org/" target="_top">NetBSD</a>'s official packaging system,
10042 the above also means that great efforts are put into making GNOME work
10043 under this operating system.  Recently, <a class="ulink" href="http://www.dragonflybsd.org/" target="_top">DragonFly BSD</a> also adopted
10044 pkgsrc as its preferred packaging system, contributing lots of
10045 portability fixes to make GNOME build and install under it.</p>
10046 <p>This chapter is aimed at pkgsrc developers and other people
10047 interested in helping our GNOME porting and packaging efforts.  It
10048 provides instructions on how to manage the existing packages and some
10049 important information regarding their internals.</p>
10050 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
10051 <h3 class="title">We need your help!</h3>
10052 <p>Should you have some spare cycles to devote to NetBSD, pkgsrc
10053   and GNOME and are willing to learn new exciting stuff, please jump
10054   straight to the <a class="ulink" href="http://www.NetBSD.org/contrib/projects.html#gnome" target="_top">pending
10055   work</a> list!  There is still a long way to go to get a
10056   fully-functional GNOME desktop under NetBSD and we need your help to
10057   achieve it!</p>
10058 </div>
10059 <div class="sect1">
10060 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10061 <a name="meta-packages"></a>23.1. Meta packages</h2></div></div></div>
10062 <p>pkgsrc includes three GNOME-related meta packages:</p>
10063 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
10064 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>: Provides
10065     the core GNOME desktop environment.  It only includes the necessary
10066     bits to get it to boot correctly, although it may lack important
10067     functionality for daily operation.  The idea behind this package is
10068     to let end users build their own configurations on top of this one,
10069     first installing this meta package to achieve a functional setup and
10070     then adding individual applications.</p></li>
10071 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome/README.html" target="_top"><code class="filename">meta-pkgs/gnome</code></a>: Provides a
10072     complete installation of the GNOME platform and desktop as defined
10073     by the GNOME project; this is based on the components distributed in
10074     the <code class="filename">platform/x.y/x.y.z/sources</code> and
10075     <code class="filename">desktop/x.y/x.y.z/sources</code> directories of the
10076     official FTP server.  Developer-only tools found in those
10077     directories are not installed unless required by some other
10078     component to work properly.  Similarly, packages from the bindings
10079     set (<code class="filename">bindings/x.y/x.y.z/sources</code>) are not pulled
10080     in unless required as a dependency for an end-user component.  This
10081     package "extends" <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>.</p></li>
10082 <li class="listitem"><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a>:
10083     Installs all the tools required to build a GNOME component when
10084     fetched from the CVS repository.  These are required to let the
10085     <span class="command"><strong>autogen.sh</strong></span> scripts work appropriately.</p></li>
10086 </ul></div>
10087 <p>In all these packages, the <code class="varname">DEPENDS</code> lines are
10088 sorted in a way that eases updates: a package may depend on other
10089 packages listed before it but not on any listed after it.  It is very
10090 important to keep this order to ease updates so... <span class="emphasis"><em>do not
10091 change it to alphabetical sorting!</em></span></p>
10092 </div>
10093 <div class="sect1">
10094 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10095 <a name="new-package"></a>23.2. Packaging a GNOME application</h2></div></div></div>
10096 <p>Almost all GNOME applications are written in C and use a common
10097 set of tools as their build system.  Things get different with the new
10098 bindings to other languages (such as Python), but the following will
10099 give you a general idea on the minimum required tools:</p>
10100 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
10101 <li class="listitem">
10102 <p>Almost all GNOME applications use the GNU Autotools as their
10103     build system.  As a general rule you will need to tell this to your
10104     package:</p>
10105 <pre class="programlisting">
10106 GNU_CONFIGURE=yes
10107 USE_LIBTOOL=yes
10108 USE_TOOLS+=gmake
10109 </pre>
10110 </li>
10111 <li class="listitem">
10112 <p>If the package uses pkg-config to detect dependencies, add this
10113     tool to the list of required utilities:</p>
10114 <pre class="programlisting">USE_TOOLS+=pkg-config</pre>
10115 <p>Also use <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/verifypc/README.html" target="_top"><code class="filename">pkgtools/verifypc</code></a> at
10116     the end of the build process to ensure that you did not miss to
10117     specify any dependency in your package and that the version
10118     requirements are all correct.</p>
10119 </li>
10120 <li class="listitem"><p>If the package uses intltool, be sure to add
10121     <code class="literal">intltool</code> to the <code class="varname">USE_TOOLS</code>
10122     to handle dependencies and to force the package to use the latest
10123     available version.</p></li>
10124 <li class="listitem">
10125 <p>If the package uses gtk-doc (a documentation generation
10126     utility), do <span class="emphasis"><em>not</em></span> add a dependency on it.  The
10127     tool is rather big and the distfile should come with pregenerated
10128     documentation anyway; if it does not, it is a bug that you ought to
10129     report.  For such packages you should disable gtk-doc (unless it is
10130     the default):</p>
10131 <pre class="programlisting">CONFIGURE_ARGS+=--disable-gtk-doc</pre>
10132 <p>The default location of installed HTML files
10133     (<code class="filename">share/gtk-doc/&lt;package-name&gt;</code>) is correct
10134     and should not be changed unless the package insists on installing
10135     them somewhere else.  Otherwise programs as
10136     <span class="command"><strong>devhelp</strong></span> will not be able to open them.  You can
10137     do that with an entry similar to:</p>
10138 <pre class="programlisting">CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...</pre>
10139 </li>
10140 </ul></div>
10141 <p>GNOME uses multiple <span class="emphasis"><em>shared</em></span> directories and
10142 files under the installation prefix to maintain databases.  In this
10143 context, shared means that those exact same directories and files are
10144 used among several different packages, leading to conflicts in the
10145 <code class="filename">PLIST</code>.  pkgsrc currently includes functionality to
10146 handle the most common cases, so you have to forget about using
10147 <code class="literal">@unexec ${RMDIR}</code> lines in your file lists and
10148 omitting shared files from them.  If you find yourself doing those,
10149 <span class="emphasis"><em>your package is most likely incorrect</em></span>.</p>
10150 <p>The following table lists the common situations that result in
10151 using shared directories or files.  For each of them, the appropriate
10152 solution is given.  After applying the solution be sure to
10153 <span class="emphasis"><em>regenerate the package's file list</em></span> with
10154 <span class="command"><strong>make print-PLIST</strong></span> and ensure it is correct.</p>
10155 <div class="table">
10156 <a name="plist-handling"></a><p class="title"><b>Table 23.1. PLIST handling for GNOME packages</b></p>
10157 <div class="table-contents"><table summary="PLIST handling for GNOME packages" border="1">
10158 <colgroup>
10159 <col>
10160 <col>
10161 </colgroup>
10162 <thead><tr>
10163 <th>If the package...</th>
10164 <th>Then...</th>
10165 </tr></thead>
10166 <tbody>
10167 <tr>
10168 <td>Installs OMF files under <code class="filename">share/omf</code>.</td>
10169 <td>See <a class="xref" href="#scrollkeeper-data-files" title="19.6.10. Packages installing scrollkeeper/rarian data files">Section 19.6.10, &#8220;Packages installing scrollkeeper/rarian data files&#8221;</a>.</td>
10170 </tr>
10171 <tr>
10172 <td>Installs icons under the
10173         <code class="filename">share/icons/hicolor</code> hierarchy or updates
10174         <code class="filename">share/icons/hicolor/icon-theme.cache</code>.</td>
10175 <td>See <a class="xref" href="#hicolor-theme" title="19.6.19. Packages installing hicolor theme icons">Section 19.6.19, &#8220;Packages installing hicolor theme icons&#8221;</a>.</td>
10176 </tr>
10177 <tr>
10178 <td>Installs files under
10179         <code class="filename">share/mime/packages</code>.</td>
10180 <td>See <a class="xref" href="#mime-database" title="19.6.14. Packages installing extensions to the MIME database">Section 19.6.14, &#8220;Packages installing extensions to the MIME database&#8221;</a>.</td>
10181 </tr>
10182 <tr>
10183 <td>Installs <code class="filename">.desktop</code> files under
10184         <code class="filename">share/applications</code> and these include MIME
10185         information.</td>
10186 <td>See <a class="xref" href="#desktop-files" title="19.6.20. Packages installing desktop files">Section 19.6.20, &#8220;Packages installing desktop files&#8221;</a>.</td>
10187 </tr>
10188 </tbody>
10189 </table></div>
10190 </div>
10191 <br class="table-break">
10192 </div>
10193 <div class="sect1">
10194 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10195 <a name="full-update"></a>23.3. Updating GNOME to a newer version</h2></div></div></div>
10196 <p>When seeing GNOME as a whole, there are two kinds of
10197 updates:</p>
10198 <div class="variablelist"><dl class="variablelist">
10199 <dt><span class="term">Major update</span></dt>
10200 <dd>
10201 <p>Given that there is still a very long way for GNOME 3 (if it
10202       ever appears), we consider a major update one that goes from a
10203       <code class="literal">2.X</code> version to a <code class="literal">2.Y</code> one,
10204       where <code class="literal">Y</code> is even and greater than
10205       <code class="literal">X</code>.  These are hard to achieve because they
10206       introduce lots of changes in the components' code and almost all
10207       GNOME distfiles are updated to newer versions.  Some of them can
10208       even break API and ABI compatibility with the previous major
10209       version series.  As a result, the update needs to be done all at
10210       once to minimize breakage.</p>
10211 <p>A major update typically consists of around 80 package
10212       updates and the addition of some new ones.</p>
10213 </dd>
10214 <dt><span class="term">Minor update</span></dt>
10215 <dd>
10216 <p>We consider a minor update one that goes from a
10217       <code class="literal">2.A.X</code> version to a <code class="literal">2.A.Y</code>
10218       one where <code class="literal">Y</code> is greater than
10219       <code class="literal">X</code>.  These are easy to achieve because they do
10220       not update all GNOME components, can be done in an incremental way
10221       and do not break API nor ABI compatibility.</p>
10222 <p>A minor update typically consists of around 50 package
10223       updates, although the numbers here may vary a lot.</p>
10224 </dd>
10225 </dl></div>
10226 <p>In order to update the GNOME components in pkgsrc to a new stable
10227 release (either major or minor), the following steps should be
10228 followed:</p>
10229 <div class="orderedlist"><ol class="orderedlist" type="1">
10230 <li class="listitem">
10231 <p>Get a list of all the tarballs that form the new release by
10232     using the following commands.  These will leave the full list of the
10233     components' distfiles into the <code class="filename">list.txt</code>
10234     file:</p>
10235 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
10236     ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
10237     awk '{ print $9 }' &gt;list.txt</code></strong>
10238 <code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
10239     ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
10240     awk '{ print $9 }' &gt;&gt;list.txt</code></strong></pre>
10241 </li>
10242 <li class="listitem"><p>Open each meta package's <code class="filename">Makefile</code> and
10243     bump their version to the release you are updating them to.  The
10244     three meta packages should be always consistent with versioning.
10245     Obviously remove any <code class="varname">PKGREVISION</code>s that might be
10246     in them.</p></li>
10247 <li class="listitem">
10248 <p>For each meta package, update all its
10249     <code class="varname">DEPENDS</code> lines to match the latest versions as
10250     shown by the above commands.  Do <span class="emphasis"><em>not</em></span> list any
10251     newer version (even if found in the FTP) because the meta packages
10252     are supposed to list the exact versions that form a specific GNOME
10253     release.  Exceptions are permitted here if a newer version solves a
10254     serious issue in the overall desktop experience; these typically
10255     come in the form of a revision bump in pkgsrc, not in newer versions
10256     from the developers.</p>
10257 <p>Packages not listed in the <code class="filename">list.txt</code> file
10258     should be updated to the latest version available (if found in
10259     pkgsrc).  This is the case, for example, of the dependencies on the
10260     GNU Autotools in the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a> meta package.</p>
10261 </li>
10262 <li class="listitem">
10263 <p>Generate a patch from the modified meta packages and extract the
10264     list of "new" lines.  This will provide you an outline on what
10265     packages need to be updated in pkgsrc and in what order:</p>
10266 <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs diff -u gnome-devel gnome-base gnome | grep '^+D' &gt;todo.txt</code></strong></pre>
10267 </li>
10268 <li class="listitem"><p>For major desktop updates it is recommended to zap all your
10269     installed packages and start over from scratch at this point.</p></li>
10270 <li class="listitem"><p>Now comes the longest step by far: iterate over the contents
10271     of <code class="filename">todo.txt</code> and update the packages listed in
10272     it in order.  For major desktop updates none of these should be
10273     committed until the entire set is completed because there are chances
10274     of breaking not-yet-updated packages.</p></li>
10275 <li class="listitem"><p>Once the packages are up to date and working, commit them to
10276     the tree one by one with appropriate log messages.  At the end,
10277     commit the three meta package updates and all the corresponding
10278     changes to the <code class="filename">doc/CHANGES-&lt;YEAR&gt;</code> and
10279     <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/doc/TODO?rev=HEAD&amp;content-type=text/x-cvsweb-markup" target="_top"><code class="filename">pkgsrc/doc/TODO</code></a> files.</p></li>
10280 </ol></div>
10281 </div>
10282 <div class="sect1">
10283 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10284 <a name="patching"></a>23.4. Patching guidelines</h2></div></div></div>
10285 <p>GNOME is a very big component in pkgsrc which approaches 100
10286 packages.  Please, it is very important that you always, always,
10287 <span class="strong"><strong>always</strong></span> feed back any portability
10288 fixes you do to a GNOME package to the mainstream developers (see <a class="xref" href="#components.patches.feedback" title="11.3.5. Feedback to the author">Section 11.3.5, &#8220;Feedback to the author&#8221;</a>).  This is the only way to get
10289 their attention on portability issues and to ensure that future versions
10290 can be built out-of-the box on NetBSD.  The less custom patches in
10291 pkgsrc, the easier further updates are.  Those developers in charge of
10292 issuing major GNOME updates will be grateful if you do that.</p>
10293 <p>The most common places to report bugs are the <a class="ulink" href="http://bugzilla.gnome.org/" target="_top">GNOME's Bugzilla</a> and the <a class="ulink" href="http://bugzilla.freedesktop.org/" target="_top">freedesktop.org's
10294 Bugzilla</a>.  Not all components use these to track bugs, but most
10295 of them do.  Do not be short on your reports: always provide detailed
10296 explanations of the current failure, how it can be improved to achieve
10297 maximum portability and, if at all possible, provide a patch against CVS
10298 head.  The more verbose you are, the higher chances of your patch being
10299 accepted.</p>
10300 <p>Also, please avoid using preprocessor magic to fix portability
10301 issues.  While the FreeBSD GNOME people are doing a great job in porting
10302 GNOME to their operating system, the official GNOME sources are now
10303 plagued by conditionals that check for <code class="varname">__FreeBSD__</code>
10304 and similar macros.  This hurts portability.  Please see our patching
10305 guidelines (<a class="xref" href="#components.patches.guidelines" title="11.3.4. Patching guidelines">Section 11.3.4, &#8220;Patching guidelines&#8221;</a>) for more
10306 details.</p>
10307 </div>
10308 </div>
10309 </div>
10310 <div class="part">
10311 <div class="titlepage"><div><div><h1 class="title">
10312 <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
10313 <div class="partintro">
10314 <div></div>
10315 <p>This part of the guide deals with everything
10316         from the infrastructure that is behind the interfaces described
10317         in the developer's guide. A casual package maintainer should not
10318         need anything from this part.</p>
10319 <div class="toc">
10320 <p><b>Table of Contents</b></p>
10321 <dl>
10322 <dt><span class="chapter"><a href="#infr.design">24. Design of the pkgsrc infrastructure</a></span></dt>
10323 <dd><dl>
10324 <dt><span class="sect1"><a href="#infr.vardef">24.1. The meaning of variable definitions</a></span></dt>
10325 <dt><span class="sect1"><a href="#infr.vardef.problems">24.2. Avoiding problems before they arise</a></span></dt>
10326 <dt><span class="sect1"><a href="#infr.var">24.3. Variable evaluation</a></span></dt>
10327 <dd><dl>
10328 <dt><span class="sect2"><a href="#infr.var.load">24.3.1. At load time</a></span></dt>
10329 <dt><span class="sect2"><a href="#infr.var.run">24.3.2. At runtime</a></span></dt>
10330 </dl></dd>
10331 <dt><span class="sect1"><a href="#infr.varspec">24.4. How can variables be specified?</a></span></dt>
10332 <dt><span class="sect1"><a href="#infr.design.intf">24.5. Designing interfaces for Makefile fragments</a></span></dt>
10333 <dd><dl>
10334 <dt><span class="sect2"><a href="#infr.design.intf.proc">24.5.1. Procedures with parameters</a></span></dt>
10335 <dt><span class="sect2"><a href="#infr.design.intf.action">24.5.2. Actions taken on behalf of parameters</a></span></dt>
10336 </dl></dd>
10337 <dt><span class="sect1"><a href="#infr.order">24.6. The order in which files are loaded</a></span></dt>
10338 <dd><dl>
10339 <dt><span class="sect2"><a href="#infr.order.prefs">24.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
10340 <dt><span class="sect2"><a href="#infr.order.pkg">24.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
10341 </dl></dd>
10342 </dl></dd>
10343 <dt><span class="chapter"><a href="#regression">25. Regression tests</a></span></dt>
10344 <dd><dl>
10345 <dt><span class="sect1"><a href="#regression.descr">25.1. The regression tests framework</a></span></dt>
10346 <dt><span class="sect1"><a href="#regression.run">25.2. Running the regression tests</a></span></dt>
10347 <dt><span class="sect1"><a href="#regression.new">25.3. Adding a new regression test</a></span></dt>
10348 <dd><dl>
10349 <dt><span class="sect2"><a href="#regression.fun.override">25.3.1. Overridable functions</a></span></dt>
10350 <dt><span class="sect2"><a href="#regression.fun.helper">25.3.2. Helper functions</a></span></dt>
10351 </dl></dd>
10352 </dl></dd>
10353 <dt><span class="chapter"><a href="#porting">26. Porting pkgsrc</a></span></dt>
10354 <dd><dl>
10355 <dt><span class="sect1"><a href="#porting.opsys">26.1. Porting pkgsrc to a new operating system</a></span></dt>
10356 <dt><span class="sect1"><a href="#porting.compiler">26.2. Adding support for a new compiler</a></span></dt>
10357 </dl></dd>
10358 </dl>
10359 </div>
10360 </div>
10361 <div class="chapter">
10362 <div class="titlepage"><div><div><h2 class="title">
10363 <a name="infr.design"></a>Chapter 24. Design of the pkgsrc infrastructure</h2></div></div></div>
10364 <div class="toc">
10365 <p><b>Table of Contents</b></p>
10366 <dl>
10367 <dt><span class="sect1"><a href="#infr.vardef">24.1. The meaning of variable definitions</a></span></dt>
10368 <dt><span class="sect1"><a href="#infr.vardef.problems">24.2. Avoiding problems before they arise</a></span></dt>
10369 <dt><span class="sect1"><a href="#infr.var">24.3. Variable evaluation</a></span></dt>
10370 <dd><dl>
10371 <dt><span class="sect2"><a href="#infr.var.load">24.3.1. At load time</a></span></dt>
10372 <dt><span class="sect2"><a href="#infr.var.run">24.3.2. At runtime</a></span></dt>
10373 </dl></dd>
10374 <dt><span class="sect1"><a href="#infr.varspec">24.4. How can variables be specified?</a></span></dt>
10375 <dt><span class="sect1"><a href="#infr.design.intf">24.5. Designing interfaces for Makefile fragments</a></span></dt>
10376 <dd><dl>
10377 <dt><span class="sect2"><a href="#infr.design.intf.proc">24.5.1. Procedures with parameters</a></span></dt>
10378 <dt><span class="sect2"><a href="#infr.design.intf.action">24.5.2. Actions taken on behalf of parameters</a></span></dt>
10379 </dl></dd>
10380 <dt><span class="sect1"><a href="#infr.order">24.6. The order in which files are loaded</a></span></dt>
10381 <dd><dl>
10382 <dt><span class="sect2"><a href="#infr.order.prefs">24.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
10383 <dt><span class="sect2"><a href="#infr.order.pkg">24.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
10384 </dl></dd>
10385 </dl>
10386 </div>
10387 <p>The pkgsrc infrastructure consists of many small Makefile
10388         fragments. Each such fragment needs a properly specified
10389         interface. This chapter explains how such an interface looks
10390         like.</p>
10391 <div class="sect1">
10392 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10393 <a name="infr.vardef"></a>24.1. The meaning of variable definitions</h2></div></div></div>
10394 <p>Whenever a variable is defined in the pkgsrc
10395         infrastructure, the location and the way of definition provide
10396         much information about the intended use of that variable.
10397         Additionally, more documentation may be found in a header
10398         comment or in this pkgsrc guide.</p>
10399 <p>A special file is
10400         <code class="filename">mk/defaults/mk.conf</code>, which lists all
10401         variables that are intended to be user-defined. They are either
10402         defined using the <code class="literal">?=</code> operator or they are
10403         left undefined because defining them to anything would
10404         effectively mean <span class="quote">&#8220;<span class="quote">yes</span>&#8221;</span>. All these variables may be
10405         overridden by the pkgsrc user in the <code class="varname">MAKECONF</code>
10406         file.</p>
10407 <p>Outside this file, the following conventions apply:
10408         Variables that are defined using the <code class="literal">?=</code>
10409         operator may be overridden by a package.</p>
10410 <p>Variables that are defined using the <code class="literal">=</code>
10411         operator may be used read-only at run-time.</p>
10412 <p>Variables whose name starts with an underscore must not be
10413         accessed outside the pkgsrc infrastructure at all. They may
10414         change without further notice.</p>
10415 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
10416 <h3 class="title">Note</h3>
10417 <p>These conventions are currently not applied
10418         consistently to the complete pkgsrc
10419         infrastructure.</p>
10420 </div>
10421 </div>
10422 <div class="sect1">
10423 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10424 <a name="infr.vardef.problems"></a>24.2. Avoiding problems before they arise</h2></div></div></div>
10425 <p>All variables that contain lists of things should default
10426         to being empty. Two examples that do not follow this rule are
10427         <code class="varname">USE_LANGUAGES</code> and
10428         <code class="varname">DISTFILES</code>. These variables cannot simply be
10429         modified using the <code class="literal">+=</code> operator in package
10430         <code class="filename">Makefile</code>s (or other files included by
10431         them), since there is no guarantee whether the variable is
10432         already set or not, and what its value is. In the case of
10433         <code class="varname">DISTFILES</code>, the packages <span class="quote">&#8220;<span class="quote">know</span>&#8221;</span>
10434         the default value and just define it as in the following
10435         example.</p>
10436 <pre class="programlisting">
10437 DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
10438 </pre>
10439 <p>Because of the selection of this default value, the same
10440         value appears in many package Makefiles. Similarly for
10441         <code class="varname">USE_LANGUAGES</code>, but in this case the default
10442         value (<span class="quote">&#8220;<span class="quote"><code class="literal">c</code></span>&#8221;</span>) is so short that it
10443         doesn't stand out. Nevertheless it is mentioned in many
10444         files.</p>
10445 </div>
10446 <div class="sect1">
10447 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10448 <a name="infr.var"></a>24.3. Variable evaluation</h2></div></div></div>
10449 <div class="sect2">
10450 <div class="titlepage"><div><div><h3 class="title">
10451 <a name="infr.var.load"></a>24.3.1. At load time</h3></div></div></div>
10452 <p>Variable evaluation takes place either at load time or at
10453         runtime, depending on the context in which they occur. The
10454         contexts where variables are evaluated at load time are:</p>
10455 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
10456 <li class="listitem"><p>The right hand side of the <code class="literal">:=</code>
10457         and <code class="literal">!=</code> operators,</p></li>
10458 <li class="listitem"><p>Make directives like <code class="literal">.if</code> or
10459         <code class="literal">.for</code>,</p></li>
10460 <li class="listitem"><p>Dependency lines.</p></li>
10461 </ul></div>
10462 <p>A special exception are references to the iteration
10463         variables of <code class="literal">.for</code> loops, which are expanded
10464         inline, no matter in which context they appear.</p>
10465 <p>As the values of variables may change during load time,
10466         care must be taken not to evaluate them by accident. Typical
10467         examples for variables that should not be evaluated at load time
10468         are <code class="varname">DEPENDS</code> and
10469         <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
10470         clear, here is an example:</p>
10471 <pre class="programlisting">
10472 CONFIGURE_ARGS=         # none
10473 CFLAGS=                 -O
10474 CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
10475
10476 CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
10477
10478 CFLAGS+=                -Wall
10479         </pre>
10480 <p>This code shows how the use of the <code class="literal">:=</code>
10481         operator can quickly lead to unexpected results. The first
10482         paragraph is fairly common code. The second paragraph evaluates
10483         the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
10484         <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
10485         <code class="literal">-Wall</code> is appended to the
10486         <code class="varname">CFLAGS</code>, but this addition will not appear in
10487         <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
10488         paragraphs from above typically occur in completely unrelated
10489         files.</p>
10490 </div>
10491 <div class="sect2">
10492 <div class="titlepage"><div><div><h3 class="title">
10493 <a name="infr.var.run"></a>24.3.2. At runtime</h3></div></div></div>
10494 <p>After all the files have been loaded, the values of the
10495         variables cannot be changed anymore. Variables that are used in
10496         the shell commands are expanded at this point.</p>
10497 </div>
10498 </div>
10499 <div class="sect1">
10500 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10501 <a name="infr.varspec"></a>24.4. How can variables be specified?</h2></div></div></div>
10502 <p>There are many ways in which the definition and use of a
10503         variable can be restricted in order to detect bugs and
10504         violations of the (mostly unwritten) policies. See the
10505         <code class="literal">pkglint</code> developer's documentation for further
10506         details.</p>
10507 </div>
10508 <div class="sect1">
10509 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10510 <a name="infr.design.intf"></a>24.5. Designing interfaces for Makefile fragments</h2></div></div></div>
10511 <p>Most of the <code class="filename">.mk</code> files fall into one
10512         of the following classes. Cases where a file falls into more
10513         than one class should be avoided as it often leads to subtle
10514         bugs.</p>
10515 <div class="sect2">
10516 <div class="titlepage"><div><div><h3 class="title">
10517 <a name="infr.design.intf.proc"></a>24.5.1. Procedures with parameters</h3></div></div></div>
10518 <p>In a traditional imperative programming language some of
10519         the <code class="filename">.mk</code> files could be described as
10520         procedures. They take some input parameters and&mdash;after
10521         inclusion&mdash;provide a result in output parameters. Since all
10522         variables in <code class="filename">Makefile</code>s have global scope
10523         care must be taken not to use parameter names that have already
10524         another meaning. For example, <code class="varname">PKGNAME</code> is a
10525         bad choice for a parameter name.</p>
10526 <p>Procedures are completely evaluated at preprocessing time.
10527         That is, when calling a procedure all input parameters must be
10528         completely resolvable. For example,
10529         <code class="varname">CONFIGURE_ARGS</code> should never be an input
10530         parameter since it is very likely that further text will be
10531         added after calling the procedure, which would effectively apply
10532         the procedure to only a part of the variable. Also, references
10533         to other variables wit will be modified after calling the
10534         procedure.</p>
10535 <p>A procedure can declare its output parameters either as
10536         suitable for use in preprocessing directives or as only
10537         available at runtime. The latter alternative is for variables
10538         that contain references to other runtime variables.</p>
10539 <p>Procedures shall be written such that it is possible to
10540         call the procedure more than once. That is, the file must not
10541         contain multiple-inclusion guards.</p>
10542 <p>Examples for procedures are
10543         <code class="filename">mk/bsd.options.mk</code> and
10544         <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
10545         that the parameters are evaluated at load time, they should be
10546         assigned using the <code class="literal">:=</code> operator, which should
10547         be used only for this purpose.</p>
10548 </div>
10549 <div class="sect2">
10550 <div class="titlepage"><div><div><h3 class="title">
10551 <a name="infr.design.intf.action"></a>24.5.2. Actions taken on behalf of parameters</h3></div></div></div>
10552 <p>Action files take some input parameters and may define
10553         runtime variables. They shall not define loadtime variables.
10554         There are action files that are included implicitly by the
10555         pkgsrc infrastructure, while other must be included
10556         explicitly.</p>
10557 <p>An example for action files is
10558         <code class="filename">mk/subst.mk</code>.</p>
10559 </div>
10560 </div>
10561 <div class="sect1">
10562 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10563 <a name="infr.order"></a>24.6. The order in which files are loaded</h2></div></div></div>
10564 <p>Package <code class="filename">Makefile</code>s usually consist of
10565         a set of variable definitions, and include the file
10566         <code class="filename">../../mk/bsd.pkg.mk</code> in the very last line.
10567         Before that, they may also include various other
10568         <code class="filename">*.mk</code> files if they need to query the
10569         availability of certain features like the type of compiler or
10570         the X11 implementation. Due to the heavy use of preprocessor
10571         directives like <code class="literal">.if</code> and
10572         <code class="literal">.for</code>, the order in which the files are loaded
10573         matters.</p>
10574 <p>This section describes at which point the various files
10575         are loaded and gives reasons for that order.</p>
10576 <div class="sect2">
10577 <div class="titlepage"><div><div><h3 class="title">
10578 <a name="infr.order.prefs"></a>24.6.1. The order in <code class="filename">bsd.prefs.mk</code>
10579 </h3></div></div></div>
10580 <p>The very first action in <code class="filename">bsd.prefs.mk</code>
10581         is to define some essential variables like
10582         <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code> and
10583         <code class="varname">MACHINE_ARCH</code>.</p>
10584 <p>Then, the user settings are loaded from the file specified
10585         in <code class="varname">MAKECONF</code>, which is usually <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.
10586         After that, those variables
10587         that have not been overridden by the user are loaded from
10588         <code class="filename">mk/defaults/mk.conf</code>.</p>
10589 <p>After the user settings, the system settings and platform
10590         settings are loaded, which may override the user
10591         settings.</p>
10592 <p>Then, the tool definitions are loaded. The tool wrappers
10593         are not yet in effect. This only happens when building a
10594         package, so the proper variables must be used instead of the
10595         direct tool names.</p>
10596 <p>As the last steps, some essential variables from the
10597         wrapper and the package system flavor are loaded, as well as the
10598         variables that have been cached in earlier phases of a package
10599         build.</p>
10600 </div>
10601 <div class="sect2">
10602 <div class="titlepage"><div><div><h3 class="title">
10603 <a name="infr.order.pkg"></a>24.6.2. The order in <code class="filename">bsd.pkg.mk</code>
10604 </h3></div></div></div>
10605 <p>First, <code class="filename">bsd.prefs.mk</code> is loaded.</p>
10606 <p>Then, the various <code class="filename">*-vars.mk</code> files are
10607         loaded, which fill default values for those variables that have
10608         not been defined by the package. These variables may later
10609         be used even in unrelated files.</p>
10610 <p>Then, the file <code class="filename">bsd.pkg.error.mk</code>
10611         provides the target <code class="literal">error-check</code> that is added
10612         as a special dependency to all other targets that use
10613         <code class="varname">DELAYED_ERROR_MSG</code> or
10614         <code class="varname">DELAYED_WARNING_MSG</code>.</p>
10615 <p>Then, the package-specific hacks from
10616         <code class="filename">hacks.mk</code> are included.</p>
10617 <p>Then, various other files follow. Most of them don't have
10618         any dependencies on what they need to have included before or
10619         after them, though some do.</p>
10620 <p>The code to check <code class="varname">PKG_FAIL_REASON</code> and
10621         <code class="varname">PKG_SKIP_REASON</code> is then executed, which
10622         restricts the use of these variables to all the files that have
10623         been included before. Appearances in later files will be
10624         silently ignored.</p>
10625 <p>Then, the files for the main targets are included, in the
10626         order of later execution, though the actual order should not
10627         matter.</p>
10628 <p>At last, some more files are included that don't set any
10629         interesting variables but rather just define make targets to be
10630         executed.</p>
10631 </div>
10632 </div>
10633 </div>
10634 <div class="chapter">
10635 <div class="titlepage"><div><div><h2 class="title">
10636 <a name="regression"></a>Chapter 25. Regression tests</h2></div></div></div>
10637 <div class="toc">
10638 <p><b>Table of Contents</b></p>
10639 <dl>
10640 <dt><span class="sect1"><a href="#regression.descr">25.1. The regression tests framework</a></span></dt>
10641 <dt><span class="sect1"><a href="#regression.run">25.2. Running the regression tests</a></span></dt>
10642 <dt><span class="sect1"><a href="#regression.new">25.3. Adding a new regression test</a></span></dt>
10643 <dd><dl>
10644 <dt><span class="sect2"><a href="#regression.fun.override">25.3.1. Overridable functions</a></span></dt>
10645 <dt><span class="sect2"><a href="#regression.fun.helper">25.3.2. Helper functions</a></span></dt>
10646 </dl></dd>
10647 </dl>
10648 </div>
10649 <p>The pkgsrc infrastructure consists of a large codebase,
10650         and there are many corners where every little bit of a file is
10651         well thought out, making pkgsrc likely to fail as soon as
10652         anything is changed near those parts. To prevent most changes
10653         from breaking anything, a suite of regression tests should go
10654         along with every important part of the pkgsrc infrastructure.
10655         This chapter describes how regression tests work in pkgsrc and
10656         how you can add new tests.</p>
10657 <div class="sect1">
10658 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10659 <a name="regression.descr"></a>25.1. The regression tests framework</h2></div></div></div>
10660 <p></p>
10661 </div>
10662 <div class="sect1">
10663 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10664 <a name="regression.run"></a>25.2. Running the regression tests</h2></div></div></div>
10665 <p>You first need to install the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_regress/README.html" target="_top"><code class="filename">pkgtools/pkg_regress</code></a> package, which
10666         provides the <span class="command"><strong>pkg_regress</strong></span> command. Then you
10667         can simply run that command, which will run all tests in the
10668         <code class="filename">regress</code> category.</p>
10669 </div>
10670 <div class="sect1">
10671 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10672 <a name="regression.new"></a>25.3. Adding a new regression test</h2></div></div></div>
10673 <p>Every directory in the <code class="filename">regress</code>
10674         category that contains a file called <code class="filename">spec</code>
10675         is considered a regression test. This file is a shell program
10676         that is included by the <span class="command"><strong>pkg_regress</strong></span> command.
10677         The following functions can be overridden to suit your
10678         needs.</p>
10679 <div class="sect2">
10680 <div class="titlepage"><div><div><h3 class="title">
10681 <a name="regression.fun.override"></a>25.3.1. Overridable functions</h3></div></div></div>
10682 <p>These functions do not take any parameters. They are all
10683         called in <span class="quote">&#8220;<span class="quote">set -e</span>&#8221;</span> mode, so you should be careful
10684         to check the exitcodes of any commands you run in the
10685         test.</p>
10686 <div class="variablelist"><dl class="variablelist">
10687 <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
10688 <dd><p>This function prepares the environment for the
10689         test. By default it does nothing.</p></dd>
10690 <dt><span class="term"><code class="varname">do_test()</code></span></dt>
10691 <dd><p>This function runs the actual test. By default,
10692         it calls <code class="varname">TEST_MAKE</code> with the arguments
10693         <code class="varname">MAKEARGS_TEST</code> and writes its output including
10694         error messages into the file
10695         <code class="varname">TEST_OUTFILE</code>.</p></dd>
10696 <dt><span class="term"><code class="varname">check_result()</code></span></dt>
10697 <dd><p>This function is run after the test and is
10698         typically used to compare the actual output from the one that is
10699         expected. It can make use of the various helper functions from
10700         the next section.</p></dd>
10701 <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
10702 <dd><p>This function cleans everything up after the
10703         test has been run. By default it does nothing.</p></dd>
10704 </dl></div>
10705 </div>
10706 <div class="sect2">
10707 <div class="titlepage"><div><div><h3 class="title">
10708 <a name="regression.fun.helper"></a>25.3.2. Helper functions</h3></div></div></div>
10709 <div class="variablelist"><dl class="variablelist">
10710 <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
10711 <dd><p>This function compares the exitcode of the
10712         <span class="command"><strong>do_test()</strong></span> function with its first parameter.
10713         If they differ, the test will fail.</p></dd>
10714 <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
10715 <dd><p>This function checks for each of its parameters
10716         if the output from <span class="command"><strong>do_test()</strong></span> matches the
10717         extended regular expression. If it does not, the test will
10718         fail.</p></dd>
10719 <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
10720 <dd><p>This function checks for each of its parameters
10721         if the output from <span class="command"><strong>do_test()</strong></span> does
10722         <span class="emphasis"><em>not</em></span> match the extended regular expression.
10723         If any of the regular expressions matches, the test will
10724         fail.</p></dd>
10725 </dl></div>
10726 </div>
10727 </div>
10728 </div>
10729 <div class="chapter">
10730 <div class="titlepage"><div><div><h2 class="title">
10731 <a name="porting"></a>Chapter 26. Porting pkgsrc</h2></div></div></div>
10732 <div class="toc">
10733 <p><b>Table of Contents</b></p>
10734 <dl>
10735 <dt><span class="sect1"><a href="#porting.opsys">26.1. Porting pkgsrc to a new operating system</a></span></dt>
10736 <dt><span class="sect1"><a href="#porting.compiler">26.2. Adding support for a new compiler</a></span></dt>
10737 </dl>
10738 </div>
10739 <p>The pkgsrc system has already been ported to many
10740         operating systems, hardware architectures and compilers. This
10741         chapter explains the necessary steps to make pkgsrc even more
10742         portable.</p>
10743 <div class="sect1">
10744 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10745 <a name="porting.opsys"></a>26.1. Porting pkgsrc to a new operating system</h2></div></div></div>
10746 <p>To port pkgsrc to a new operating system (called
10747         <code class="literal">MyOS</code> in this example), you need to touch the
10748         following files:</p>
10749 <div class="variablelist"><dl class="variablelist">
10750 <dt><span class="term"><code class="filename">pkgtools/bootstrap-mk-files/files/mods/<em class="replaceable"><code>MyOS</code></em>.sys.mk</code></span></dt>
10751 <dd><p>This file contains some basic definitions, for
10752         example the name of the C
10753         compiler.</p></dd>
10754 <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
10755 <dd><p>Insert code that defines the variables
10756         <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
10757         <code class="varname">LOWER_OS_VERSION</code>,
10758         <code class="varname">LOWER_VENDOR</code>,
10759         <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
10760         <code class="varname">APPEND_ELF</code>, and the other variables that
10761         appear in this file.</p></dd>
10762 <dt><span class="term"><code class="filename">mk/platform/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
10763 <dd><p>This file contains the platform-specific
10764         definitions that are used by pkgsrc. Start by copying one of the
10765         other files and edit it to your
10766         needs.</p></dd>
10767 <dt><span class="term"><code class="filename">mk/platform/<em class="replaceable"><code>MyOS</code></em>.pkg.dist</code></span></dt>
10768 <dd><p>This file contains a list of directories,
10769         together with their permission bits and ownership. These
10770         directories will be created automatically with every package
10771         that explicitly sets <code class="varname">USE_MTREE</code>. This feature will
10772         be removed.</p></dd>
10773 <dt><span class="term"><code class="filename">mk/platform/<em class="replaceable"><code>MyOS</code></em>.x11.dist</code></span></dt>
10774 <dd><p>Just copy one of the pre-existing x11.dist files
10775         to your
10776         <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
10777 <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
10778 <dd><p>On some operating systems, the tools that are
10779         provided with the base system are not good enough for pkgsrc.
10780         For example, there are many versions of <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?sed+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">sed</span>(1)</span></a> that have a
10781         narrow limit on the line length they can process. Therefore
10782         pkgsrc brings its own tools, which can be enabled
10783         here.</p></dd>
10784 <dt><span class="term"><code class="filename">mk/tools/tools.<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
10785 <dd><p>This file defines the paths to all the tools
10786         that are needed by one or the other package in pkgsrc, as well
10787         as by pkgsrc itself. Find out where these tools are on your
10788         platform and add them.</p></dd>
10789 </dl></div>
10790 <p>Now, you should be able to build some basic packages, like
10791         <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/lang/perl5/README.html" target="_top"><code class="filename">lang/perl5</code></a>, <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a>.</p>
10792 </div>
10793 <div class="sect1">
10794 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10795 <a name="porting.compiler"></a>26.2. Adding support for a new compiler</h2></div></div></div>
10796 <p>TODO</p>
10797 </div>
10798 </div>
10799 </div>
10800 <div class="appendix">
10801 <div class="titlepage"><div><div><h1 class="title">
10802 <a name="examples"></a>Appendix A. A simple example package: bison</h1></div></div></div>
10803 <div class="toc">
10804 <p><b>Table of Contents</b></p>
10805 <dl>
10806 <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
10807 <dd><dl>
10808 <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
10809 <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
10810 <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
10811 <dt><span class="sect2"><a href="#checking-package-with-pkglint">A.1.4. Checking a package with <span class="command"><strong>pkglint</strong></span></a></span></dt>
10812 </dl></dd>
10813 <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
10814 </dl>
10815 </div>
10816 <p>We checked to find a piece of software that wasn't in the packages
10817     collection, and picked GNU bison. Quite why someone would want to have
10818     <span class="command"><strong>bison</strong></span> when Berkeley <span class="command"><strong>yacc</strong></span> is already
10819     present in the tree is beyond us, but it's useful for the purposes of
10820     this exercise.</p>
10821 <div class="sect1">
10822 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10823 <a name="example-files"></a>A.1. files</h2></div></div></div>
10824 <div class="sect2">
10825 <div class="titlepage"><div><div><h3 class="title">
10826 <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
10827 <pre class="programlisting">
10828 # $NetBSD$
10829 #
10830
10831 DISTNAME=       bison-1.25
10832 CATEGORIES=     devel
10833 MASTER_SITES=   ${MASTER_SITE_GNU}
10834
10835 MAINTAINER=     pkgsrc-users@NetBSD.org
10836 HOMEPAGE=       http://www.gnu.org/software/bison/bison.html
10837 COMMENT=        GNU yacc clone
10838
10839 GNU_CONFIGURE=  yes
10840 INFO_FILES=     yes
10841
10842 .include "../../mk/bsd.pkg.mk"
10843 </pre>
10844 </div>
10845 <div class="sect2">
10846 <div class="titlepage"><div><div><h3 class="title">
10847 <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
10848 <pre class="programlisting">
10849 GNU version of yacc.  Can make re-entrant parsers, and numerous other
10850 improvements.  Why you would want this when Berkeley <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?yacc+1+NetBSD-5.0.1+i386"><span class="citerefentry"><span class="refentrytitle">yacc</span>(1)</span></a> is part
10851 of the NetBSD source tree is beyond me.
10852 </pre>
10853 </div>
10854 <div class="sect2">
10855 <div class="titlepage"><div><div><h3 class="title">
10856 <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
10857 <pre class="programlisting">
10858 @comment $NetBSD$
10859 bin/bison
10860 man/man1/bison.1.gz
10861 share/bison.simple
10862 share/bison.hairy
10863 </pre>
10864 </div>
10865 <div class="sect2">
10866 <div class="titlepage"><div><div><h3 class="title">
10867 <a name="checking-package-with-pkglint"></a>A.1.4. Checking a package with <span class="command"><strong>pkglint</strong></span>
10868 </h3></div></div></div>
10869 <p>The NetBSD package system comes with
10870         <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>
10871         which helps to check the contents of these
10872         files. After installation it is quite easy to use, just change to the
10873         directory of the package you wish to examine and execute
10874         <span class="command"><strong>pkglint</strong></span>:</p>
10875 <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
10876 looks fine.</pre>
10877 <p>Depending on the supplied command line arguments (see pkglint(1)),
10878         more checks will be performed. Use e.g. <span class="command"><strong>pkglint -Call
10879         -Wall</strong></span> for a very thorough check.</p>
10880 </div>
10881 </div>
10882 <div class="sect1">
10883 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10884 <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
10885 <p>Create the directory where the package lives,
10886       plus any auxiliary directories:</p>
10887 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
10888 <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
10889 <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
10890 <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
10891 <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
10892       <code class="filename">PLIST</code> (see <a class="xref" href="#components" title="Chapter 11. Package components - files, directories and contents">Chapter 11, <i>Package components - files, directories and contents</i></a>)
10893       then continue with fetching the distfile:</p>
10894 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
10895 &gt;&gt; bison-1.25.tar.gz doesn't seem to exist on this system.
10896 &gt;&gt; Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
10897 Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
10898 ftp: Error retrieving file: 500 Internal error
10899
10900 &gt;&gt; Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
10901 Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
10902 ftp: Error retrieving file: 500 Internal error
10903
10904 &gt;&gt; Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
10905 Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
10906 Successfully retrieved file.</pre>
10907 <p>Generate the checksum of the distfile into
10908       <code class="filename">distinfo</code>:</p>
10909 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makedistinfo</code></strong></pre>
10910 <p>Now compile:</p>
10911 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
10912 &gt;&gt; Checksum OK for bison-1.25.tar.gz.
10913 ===&gt;  Extracting for bison-1.25
10914 ===&gt;  Patching for bison-1.25
10915 ===&gt;   Ignoring empty patch directory
10916 ===&gt;  Configuring for bison-1.25
10917 creating cache ./config.cache
10918 checking for gcc... cc
10919 checking whether we are using GNU C... yes
10920 checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
10921 checking how to run the C preprocessor... cc -E
10922 checking for minix/config.h... no
10923 checking for POSIXized ISC... no
10924 checking whether cross-compiling... no
10925 checking for ANSI C header files... yes
10926 checking for string.h... yes
10927 checking for stdlib.h... yes
10928 checking for memory.h... yes
10929 checking for working const... yes
10930 checking for working alloca.h... no
10931 checking for alloca... yes
10932 checking for strerror... yes
10933 updating cache ./config.cache
10934 creating ./config.status
10935 creating Makefile
10936 ===&gt;  Building for bison-1.25
10937 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g LR0.c
10938 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g allocate.c
10939 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g closure.c
10940 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g conflicts.c
10941 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g derives.c
10942 cc -c -DXPFILE=\"/usr/pkg/share/bison.simple\"  -DXPFILE1=\"/usr/pkg/share/bison.hairy\" -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1  -g  ./files.c
10943 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g getargs.c
10944 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g gram.c
10945 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g lalr.c
10946 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g lex.c
10947 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g main.c
10948 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g nullable.c
10949 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g output.c
10950 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g print.c
10951 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g reader.c
10952 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g reduce.c
10953 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g symtab.c
10954 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g warshall.c
10955 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g version.c
10956 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g getopt.c
10957 cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g getopt1.c
10958 cc  -g -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o         getargs.o gram.o lalr.o lex.o                                   main.o nullable.o output.o print.o reader.o reduce.o symtab.o   warshall.o version.o getopt.o getopt1.o
10959 ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
10960 rm -f bison.s1
10961 sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" &lt; ./bison.simple &gt; bison.s1</pre>
10962 <p>Everything seems OK, so install the files:</p>
10963 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
10964 &gt;&gt; Checksum OK for bison-1.25.tar.gz.
10965 ===&gt;  Installing for bison-1.25
10966 sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
10967 rm -f /usr/pkg/bin/bison
10968 cd /usr/pkg/share; rm -f bison.simple bison.hairy
10969 rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
10970 install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
10971 /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
10972 /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
10973 cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
10974 /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
10975 ===&gt;  Registering installation for bison-1.25</pre>
10976 <p>You can now use bison, and also - if you decide so - remove it with
10977       <span class="command"><strong>pkg_delete bison</strong></span>. Should you decide that you want a
10978       binary package, do this now:</p>
10979 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
10980 &gt;&gt; Checksum OK for bison-1.25.tar.gz.
10981 ===&gt;  Building package for bison-1.25
10982 Creating package bison-1.25.tgz
10983 Registering depends:.
10984 Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
10985 <p>Now that you don't need the source and object files
10986       any more, clean up:</p>
10987 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
10988 ===&gt;  Cleaning for bison-1.25</pre>
10989 </div>
10990 </div>
10991 <div class="appendix">
10992 <div class="titlepage"><div><div><h1 class="title">
10993 <a name="logs"></a>Appendix B. Build logs</h1></div></div></div>
10994 <div class="toc">
10995 <p><b>Table of Contents</b></p>
10996 <dl>
10997 <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
10998 <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
10999 </dl>
11000 </div>
11001 <div class="sect1">
11002 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
11003 <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
11004 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
11005 ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
11006 =&gt; figlet221.tar.gz doesn't seem to exist on this system.
11007 =&gt; Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
11008 =&gt; [172219 bytes]
11009 Connected to ftp.plig.net.
11010 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
11011 331 Guest login ok, send your complete e-mail address as password.
11012 230-You are user #5 of 500 simultaneous users allowed.
11013 230-
11014 230-  ___ _             _ _
11015 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
11016 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
11017 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
11018 230-         |_|   |_|     |___|         |___|
11019 230-
11020 230-** Welcome to ftp.plig.org **
11021 230-
11022 230-Please note that all transfers from this FTP site are logged. If you
11023 230-do not like this, please disconnect now.
11024 230-
11025 230-This archive is available via
11026 230-
11027 230-HTTP:  http://ftp.plig.org/
11028 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
11029 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
11030 230-
11031 230-Please email comments, bug reports and requests for packages to be
11032 230-mirrored to ftp-admin@plig.org.
11033 230-
11034 230-
11035 230 Logged in anonymously.
11036 Remote system type is UNIX.
11037 Using binary mode to transfer files.
11038 200 Type okay.
11039 250 "/pub" is new cwd.
11040 250-"/pub/figlet" is new cwd.
11041 250-
11042 250-Welcome to the figlet archive at ftp.figlet.org
11043 250-
11044 250-    ftp://ftp.figlet.org/pub/figlet/
11045 250-
11046 250-The official FIGlet web page is:
11047 250-    http://www.figlet.org/
11048 250-
11049 250-If you have questions, please mailto:info@figlet.org. If you want to
11050 250-contribute a font or something else, you can email us.
11051 250
11052 250 "/pub/figlet/program" is new cwd.
11053 250 "/pub/figlet/program/unix" is new cwd.
11054 local: figlet221.tar.gz remote: figlet221.tar.gz
11055 502 Unimplemented command.
11056 227 Entering Passive Mode (195,40,6,41,246,104)
11057 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
11058 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
11059 226 Transfer completed.
11060 172219 bytes received in 00:02 (75.99 KB/s)
11061 221 Goodbye.
11062 =&gt; Checksum OK for figlet221.tar.gz.
11063 ===&gt; Extracting for figlet-2.2.1nb2
11064 ===&gt; Required installed package ccache-[0-9]*: ccache-2.3nb1 found
11065 ===&gt; Patching for figlet-2.2.1nb2
11066 ===&gt; Applying pkgsrc patches for figlet-2.2.1nb2
11067 ===&gt; Overriding tools for figlet-2.2.1nb2
11068 ===&gt; Creating toolchain wrappers for figlet-2.2.1nb2
11069 ===&gt; Configuring for figlet-2.2.1nb2
11070 ===&gt; Building for figlet-2.2.1nb2
11071 gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
11072 chmod a+x figlet
11073 gcc -O2 -o chkfont chkfont.c
11074 =&gt; Unwrapping files-to-be-installed.
11075 <code class="prompt">#</code>
11076 <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
11077 ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
11078 ===&gt; Installing for figlet-2.2.1nb2
11079 install -d -o root -g wheel -m 755 /usr/pkg/bin
11080 install -d -o root -g wheel -m 755 /usr/pkg/man/man6
11081 mkdir -p /usr/pkg/share/figlet
11082 cp figlet /usr/pkg/bin
11083 cp chkfont /usr/pkg/bin
11084 chmod 555 figlist showfigfonts
11085 cp figlist /usr/pkg/bin
11086 cp showfigfonts /usr/pkg/bin
11087 cp fonts/*.flf /usr/pkg/share/figlet
11088 cp fonts/*.flc /usr/pkg/share/figlet
11089 cp figlet.6 /usr/pkg/man/man6
11090 ===&gt; Registering installation for figlet-2.2.1nb2
11091 <code class="prompt">#</code></pre>
11092 </div>
11093 <div class="sect1">
11094 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
11095 <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
11096 <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
11097 ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
11098 ===&gt; Packaging figlet-2.2.1nb2
11099 ===&gt; Building binary package for figlet-2.2.1nb2
11100 Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
11101 Using SrcDir value of /usr/pkg
11102 Registering depends:.
11103 <code class="prompt">#</code></pre>
11104 </div>
11105 </div>
11106 <div class="appendix">
11107 <div class="titlepage"><div><div><h1 class="title">
11108 <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h1></div></div></div>
11109 <div class="toc">
11110 <p><b>Table of Contents</b></p>
11111 <dl>
11112 <dt><span class="sect1"><a href="#ftp-distfiles">C.1. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
11113 <dt><span class="sect1"><a href="#ftp-misc">C.2. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
11114 <dt><span class="sect1"><a href="#ftp-packages">C.3. <code class="filename">packages</code>: Binary packages</a></span></dt>
11115 <dt><span class="sect1"><a href="#ftp-reports">C.4. <code class="filename">reports</code>: Bulk build reports</a></span></dt>
11116 <dt><span class="sect1"><a href="#ftp-source">C.5. <code class="filename">current</code>,
11117 <code class="filename">pkgsrc-20<em class="replaceable"><code>xx</code></em>Q<em class="replaceable"><code>y</code></em></code>:
11118 source packages</a></span></dt>
11119 </dl>
11120 </div>
11121 <p>As in other big projects, the directory layout of pkgsrc
11122         is quite complex for newbies. This chapter explains where you
11123         find things on the FTP server. The base directory on
11124         <code class="filename">ftp.NetBSD.org</code> is <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top"><code class="filename">/pub/pkgsrc/</code></a>.
11125         On other servers it may be different, but inside this directory,
11126         everything should look the same, no matter on which server you
11127         are. This directory contains some subdirectories, which are
11128         explained below.</p>
11129 <div class="sect1">
11130 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
11131 <a name="ftp-distfiles"></a>C.1. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
11132 <p>The directory <code class="filename">distfiles</code> contains lots
11133         of archive files from all pkgsrc packages, which are mirrored
11134         here. The subdirectories are called after their package names
11135         and are used when the distributed files have names that don't
11136         explicitly contain a version number or are otherwise too generic
11137         (for example <code class="filename">release.tar.gz</code>).</p>
11138 </div>
11139 <div class="sect1">
11140 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
11141 <a name="ftp-misc"></a>C.2. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
11142 <p>This directory contains things that individual pkgsrc
11143         developers find worth publishing.</p>
11144 </div>
11145 <div class="sect1">
11146 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
11147 <a name="ftp-packages"></a>C.3. <code class="filename">packages</code>: Binary packages</h2></div></div></div>
11148 <p>This directory contains binary packages for the various
11149         platforms that are supported by pkgsrc.
11150         Each subdirectory is of the form <em class="replaceable"><code>OPSYS</code></em>/<em class="replaceable"><code>ARCH</code></em>/<em class="replaceable"><code>OSVERSION_TAG</code></em>. The meaning of these variables is:</p>
11151 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
11152 <li class="listitem"><p><code class="varname">OPSYS</code> is the name of the
11153         operating system for which the packages have been built. The
11154         name is taken from the output of the <span class="command"><strong>uname</strong></span>
11155         command, so it may differ from the one you are used to
11156         hear.</p></li>
11157 <li class="listitem"><p><code class="varname">ARCH</code> is the hardware
11158         architecture of the platform for which the packages have been
11159         built. It also includes the <code class="varname">ABI</code> (Application
11160         Binary Interface) for platforms that have several of
11161         them.</p></li>
11162 <li class="listitem"><p><code class="varname">OSVERSION</code> is the version of
11163         the operating system. For version numbers that change often (for
11164         example NetBSD-current), the often-changing part should be
11165         replaced with an <code class="literal">x</code>, for example
11166         <code class="literal">4.99.x</code>.</p></li>
11167 <li class="listitem"><p><code class="varname">TAG</code> is either
11168         <code class="literal">20<em class="replaceable"><code>xx</code></em>Q<em class="replaceable"><code>y</code></em></code>
11169         for a stable branch, or <code class="literal">head</code> for packages
11170         built from the HEAD branch. The latter should only be used when
11171         the packages are updated on a regular basis. Otherwise the date
11172         from checking out pkgsrc should be appended, for example
11173         <code class="literal">head_20071015</code>.</p></li>
11174 </ul></div>
11175 <p>The rationale for exactly this scheme is that the pkgsrc users looking for binary packages
11176         can quickly click through the directories on the
11177         server and find the best binary packages for their machines. Since they
11178         usually know the operating system and the hardware architecture, OPSYS
11179         and ARCH are placed first. After these choices, they can select the
11180         best combination of OSVERSION and TAG together, since it is usually the
11181         case that packages stay compatible between different version of the
11182         operating system.</p>
11183 <p>In each of these directories, there is a
11184         whole binary packages collection for a specific platform. It has a directory called
11185         <code class="filename">All</code> which contains all binary packages.
11186         Besides that, there are various category directories that
11187         contain symbolic links to the real binary packages.</p>
11188 </div>
11189 <div class="sect1">
11190 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
11191 <a name="ftp-reports"></a>C.4. <code class="filename">reports</code>: Bulk build reports</h2></div></div></div>
11192 <p>Here are the reports from bulk builds, for those who want
11193         to fix packages that didn't build on some of the platforms. The
11194         structure of subdirectories should look like the one in <a class="xref" href="#ftp-packages" title="C.3. packages: Binary packages">Section C.3, &#8220;<code class="filename">packages</code>: Binary packages&#8221;</a>.</p>
11195 </div>
11196 <div class="sect1">
11197 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
11198 <a name="ftp-source"></a>C.5. <code class="filename">current</code>,
11199 <code class="filename">pkgsrc-20<em class="replaceable"><code>xx</code></em>Q<em class="replaceable"><code>y</code></em></code>:
11200 source packages</h2></div></div></div>
11201 <p>These directories contain the <span class="quote">&#8220;<span class="quote">real</span>&#8221;</span> pkgsrc,
11202         that is the files that define how to create binary packages from
11203         source archives.</p>
11204 <p>The directory <code class="filename">pkgsrc</code> contains a
11205         snapshot of the CVS repository, which is updated regularly. The
11206         file <code class="filename">pkgsrc.tar.gz</code> contains the same as the
11207         directory, ready to be downloaded as a whole.</p>
11208 <p>In the directories for the quarterly branches, there is an
11209         additional file called
11210         <code class="filename">pkgsrc-20<em class="replaceable"><code>xx</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
11211         which contains the state of pkgsrc when it was branched.</p>
11212 </div>
11213 </div>
11214 <div class="appendix">
11215 <div class="titlepage"><div><div><h1 class="title">
11216 <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h1></div></div></div>
11217 <div class="toc">
11218 <p><b>Table of Contents</b></p>
11219 <dl>
11220 <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
11221 <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
11222 </dl>
11223 </div>
11224 <p>This section contains information on editing the pkgsrc
11225         guide itself.</p>
11226 <div class="sect1">
11227 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
11228 <a name="targets"></a>D.1. Make targets</h2></div></div></div>
11229 <p>The pkgsrc guide's source code is stored in
11230         <code class="filename">pkgsrc/doc/guide/files</code>, and several files
11231         are created from it:</p>
11232 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
11233 <li class="listitem"><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
11234 <li class="listitem"><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
11235 <li class="listitem"><p><a class="ulink" href="http://www.NetBSD.org/docs/pkgsrc/" target="_top">http://www.NetBSD.org/docs/pkgsrc/</a></p></li>
11236 <li class="listitem"><p><a class="ulink" href="http://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf</a>:
11237         The PDF version of the pkgsrc guide.</p></li>
11238 <li class="listitem"><p><a class="ulink" href="http://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps</a>:
11239         PostScript version of the pkgsrc guide.</p></li>
11240 </ul></div>
11241 </div>
11242 <div class="sect1">
11243 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
11244 <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
11245 <p>The procedure to edit the pkgsrc guide is:</p>
11246 <div class="procedure"><ol class="procedure" type="1">
11247 <li class="step"><p>Make sure you have the packages needed to
11248         regenerate the pkgsrc guide (and other XML-based NetBSD
11249         documentation) installed. These are automatically installed when
11250         you install the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/pkgsrc-guide-tools/README.html" target="_top"><code class="filename">meta-pkgs/pkgsrc-guide-tools</code></a> package.</p></li>
11251 <li class="step"><p>Run <span class="command"><strong>cd doc/guide</strong></span> to get to the
11252         right directory. All further steps will take place
11253         here.</p></li>
11254 <li class="step"><p>Edit the XML file(s) in
11255         <code class="filename">files/</code>.</p></li>
11256 <li class="step"><p>Run <span class="command"><strong>bmake</strong></span> to check the pkgsrc
11257         guide for valid XML and to build the final output files. If you
11258         get any errors at this stage, you can just edit the files, as
11259         there are only symbolic links in the working directory, pointing
11260         to the files in <code class="filename">files/</code>.</p></li>
11261 <li class="step"><p><span class="command"><strong>(cd files &amp;&amp; cvs
11262         commit)</strong></span></p></li>
11263 <li class="step"><p>Run <span class="command"><strong>bmake clean &amp;&amp; bmake</strong></span> to
11264         regenerate the output files with the proper RCS
11265         Ids.</p></li>
11266 <li class="step">
11267 <p>Run <span class="command"><strong>bmake regen</strong></span> to install and
11268         commit the files in both <code class="filename">pkgsrc/doc</code> and
11269         <code class="filename">htdocs</code>.</p>
11270 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
11271 <h3 class="title">Note</h3>
11272 <p>If you have added, removed or renamed some chapters,
11273         you need to synchronize them using <span class="command"><strong>cvs add</strong></span> or
11274         <span class="command"><strong>cvs delete</strong></span> in the htdocs
11275         directory.</p>
11276 </div>
11277 </li>
11278 </ol></div>
11279 </div>
11280 </div>
11281 </div></body>
11282 </html>