1 <html xmlns="http://www.w3.org/1999/xhtml">
3 <meta name="generator" content=
4 "HTML Tidy for NetBSD (vers 1st August 2004), see www.w3.org" />
5 <meta http-equiv="Content-Type" content=
6 "text/html; charset=us-ascii" />
8 <title>The pkgsrc guide</title>
9 <link rel="stylesheet" href="/NetBSD.css" type="text/css" />
10 <meta name="generator" content=
11 "DocBook XSL Stylesheets VX.X.X" />
12 <meta name="description" content=
13 "Information about using the NetBSD package system (pkgsrc) from both a user view for installing packages as well as from a pkgsrc developers' view for creating new packages." />
16 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084"
18 <div class="book" lang="en" xml:lang="en">
19 <div class="titlepage">
22 <h1 class="title"><a name="the-pkgsrc-guide" id=
23 "the-pkgsrc-guide"></a>The pkgsrc guide</h1>
27 <h2 class="subtitle">Documentation on the NetBSD packages
32 <div class="authorgroup">
34 <h3 class="author"><span class=
35 "firstname">Alistair</span> <span class=
36 "surname">Crooks</span></h3>
38 <div class="affiliation">
40 <p><code class="email"><<a href=
41 "mailto:agc@NetBSD.org">agc@NetBSD.org</a>></code></p>
47 <h3 class="author"><span class=
48 "firstname">Hubert</span> <span class=
49 "surname">Feyrer</span></h3>
51 <div class="affiliation">
53 <p><code class="email"><<a href=
54 "mailto:hubertf@NetBSD.org">hubertf@NetBSD.org</a>></code></p>
59 <h3 class="corpauthor">The pkgsrc Developers</h3>
64 <p class="copyright">Copyright © 1994-2005 The
65 NetBSD Foundation, Inc</p>
68 <div xmlns="http://www.w3.org/TR/xhtml1/transitional">
69 <p xmlns="" class="pubdate">$NetBSD: pkgsrc.xml,v 1.10
70 2005/10/05 13:59:56 dillo Exp $</p>
74 <div class="abstract">
75 <p class="title"><b>Abstract</b></p>
77 <p>Information about using the NetBSD package system
78 (pkgsrc) from both a user view for installing packages
79 as well as from a pkgsrc developers' view for creating
88 <p><b>Table of Contents</b></p>
91 <dt><span class="chapter"><a href="#introduction">1. What
92 is pkgsrc?</a></span></dt>
96 <dt><span class="sect1"><a href=
97 "#introduction-section">1.1.
98 Introduction</a></span></dt>
100 <dt><span class="sect1"><a href="#overview">1.2.
101 Overview</a></span></dt>
103 <dt><span class="sect1"><a href="#terminology">1.3.
104 Terminology</a></span></dt>
106 <dt><span class="sect1"><a href="#typography">1.4.
107 Typography</a></span></dt>
111 <dt><span class="part"><a href="#users-guide">I. The pkgsrc
112 user's guide</a></span></dt>
116 <dt><span class="chapter"><a href="#getting">2. Where
117 to get pkgsrc</a></span></dt>
121 <dt><span class="sect1"><a href="#as-tar-file">2.1.
122 As tar file</a></span></dt>
124 <dt><span class="sect1"><a href="#via-sup">2.2. Via
127 <dt><span class="sect1"><a href="#via-cvs">2.3. Via
132 <dt><span class="chapter"><a href="#platforms">3. Using
133 pkgsrc on systems other than NetBSD</a></span></dt>
137 <dt><span class="sect1"><a href=
138 "#bootstrapping-pkgsrc">3.1. Bootstrapping
139 pkgsrc</a></span></dt>
141 <dt><span class="sect1"><a href=
142 "#platform-specific-notes">3.2. Platform-specific
143 notes</a></span></dt>
147 <dt><span class="sect2"><a href=
148 "#darwin">3.2.1. Darwin (Mac OS
151 <dt><span class="sect2"><a href=
152 "#freebsd">3.2.2. FreeBSD</a></span></dt>
154 <dt><span class="sect2"><a href=
155 "#interix">3.2.3. Interix</a></span></dt>
157 <dt><span class="sect2"><a href="#irix">3.2.4.
160 <dt><span class="sect2"><a href="#linux">3.2.5.
161 Linux</a></span></dt>
163 <dt><span class="sect2"><a href=
164 "#openbsd">3.2.6. OpenBSD</a></span></dt>
166 <dt><span class="sect2"><a href=
167 "#solaris">3.2.7. Solaris</a></span></dt>
173 <dt><span class="chapter"><a href="#using">4. Using
174 pkgsrc</a></span></dt>
178 <dt><span class="sect1"><a href=
179 "#getting-started">4.1. Working with binary
180 packages</a></span></dt>
184 <dt><span class="sect2"><a href=
185 "#where-to-get-binary-packages">4.1.1. Where to
186 get binary packages</a></span></dt>
188 <dt><span class="sect2"><a href=
189 "#how-to-use-binary-packages">4.1.2. How to use
190 binary packages</a></span></dt>
192 <dt><span class="sect2"><a href=
193 "#a-word-of-warning">4.1.3. A word of
194 warning</a></span></dt>
198 <dt><span class="sect1"><a href=
199 "#building-packages-from-source">4.2. Building
200 packages from source</a></span></dt>
204 <dt><span class="sect2"><a href=
205 "#requirements">4.2.1.
206 Requirements</a></span></dt>
208 <dt><span class="sect2"><a href=
209 "#fetching-distfiles">4.2.2. Fetching
210 distfiles</a></span></dt>
212 <dt><span class="sect2"><a href=
213 "#how-to-build-and-install">4.2.3. How to build
214 and install</a></span></dt>
216 <dt><span class="sect2"><a href=
217 "#selecting-the-compiler">4.2.4. Selecting the
218 compiler</a></span></dt>
224 <dt><span class="chapter"><a href="#configuring">5.
225 Configuring pkgsrc</a></span></dt>
229 <dt><span class="sect1"><a href=
230 "#general-configuration">5.1. General
231 configuration</a></span></dt>
233 <dt><span class="sect1"><a href=
234 "#variables-affecting-build">5.2. Variables
235 affecting the build process</a></span></dt>
237 <dt><span class="sect1"><a href=
238 "#developer-advanced-settings">5.3.
239 Developer/advanced settings</a></span></dt>
241 <dt><span class="sect1"><a href=
242 "#selecting-build-options">5.4. Selecting Build
243 Options</a></span></dt>
247 <dt><span class="chapter"><a href="#binary">6. Creating
248 binary packages</a></span></dt>
252 <dt><span class="sect1"><a href=
253 "#building-a-single-binary-package">6.1. Building a
254 single binary package</a></span></dt>
256 <dt><span class="sect1"><a href=
257 "#settings-for-creationg-of-binary-packages">6.2.
258 Settings for creation of binary
259 packages</a></span></dt>
261 <dt><span class="sect1"><a href="#bulkbuild">6.3.
262 Doing a bulk build of all packages</a></span></dt>
266 <dt><span class="sect2"><a href=
267 "#binary.configuration">6.3.1.
268 Configuration</a></span></dt>
270 <dt><span class="sect2"><a href=
271 "#other-environmental-considerations">6.3.2.
273 considerations</a></span></dt>
275 <dt><span class="sect2"><a href=
276 "#operation">6.3.3. Operation</a></span></dt>
278 <dt><span class="sect2"><a href=
279 "#what-it-does">6.3.4. What it
282 <dt><span class="sect2"><a href=
283 "#disk-space-requirements">6.3.5. Disk space
284 requirements</a></span></dt>
286 <dt><span class="sect2"><a href=
287 "#setting-up-a-sandbox">6.3.6. Setting up a
288 sandbox for chrooted builds</a></span></dt>
290 <dt><span class="sect2"><a href=
291 "#building-a-partial-set">6.3.7. Building a
292 partial set of packages</a></span></dt>
294 <dt><span class="sect2"><a href=
295 "#bulk-upload">6.3.8. Uploading results of a
296 bulk build</a></span></dt>
300 <dt><span class="sect1"><a href=
301 "#creating-cdroms">6.4. Creating a multiple CD-ROM
302 packages collection</a></span></dt>
306 <dt><span class="sect2"><a href=
307 "#cdpack-example">6.4.1. Example of
308 cdpack</a></span></dt>
314 <dt><span class="chapter"><a href="#faq">7. Frequently
315 Asked Questions</a></span></dt>
319 <dt><span class="sect1"><a href=
320 "#mailing-list-pointers">7.1. Are there any mailing
321 lists for pkg-related discussion?</a></span></dt>
323 <dt><span class="sect1"><a href=
324 "#pkgviews-docs">7.2. Where's the pkgviews
325 documentation?</a></span></dt>
327 <dt><span class="sect1"><a href=
328 "#faq-pkgtools">7.3. Utilities for package
329 management (pkgtools)</a></span></dt>
331 <dt><span class="sect1"><a href=
332 "#non-root-pkgsrc">7.4. How to use pkgsrc as
333 non-root</a></span></dt>
335 <dt><span class="sect1"><a href=
336 "#resume-transfers">7.5. How to resume transfers
337 when fetching distfiles?</a></span></dt>
339 <dt><span class="sect1"><a href=
340 "#XFree86-from-pkgsrc">7.6. How can I install/use
341 XFree86 from pkgsrc?</a></span></dt>
343 <dt><span class="sect1"><a href=
344 "#x.org-from-pkgsrc">7.7. How can I install/use
345 X.org from pkgsrc?</a></span></dt>
347 <dt><span class="sect1"><a href=
348 "#fetch-behind-firewall">7.8. How to fetch files
349 from behind a firewall</a></span></dt>
351 <dt><span class="sect1"><a href="#passive-ftp">7.9.
352 How do I tell <span><strong class="command">make
353 fetch</strong></span> to do passive
356 <dt><span class="sect1"><a href=
357 "#fetching-all-distfiles">7.10. How to fetch all
358 distfiles at once</a></span></dt>
360 <dt><span class="sect1"><a href=
361 "#tmac.andoc-missing">7.11. What does
362 “<span class="quote">Don't know how to make
363 /usr/share/tmac/tmac.andoc</span>”
364 mean?</a></span></dt>
366 <dt><span class="sect1"><a href=
367 "#bsd.own.mk-missing">7.12. What does
368 “<span class="quote">Could not find
369 bsd.own.mk</span>” mean?</a></span></dt>
371 <dt><span class="sect1"><a href=
372 "#using-sudo-with-pkgsrc">7.13. Using 'sudo' with
373 pkgsrc</a></span></dt>
375 <dt><span class="sect1"><a href="#faq.conf">7.14.
376 How do I change the location of configuration
377 files?</a></span></dt>
379 <dt><span class="sect1"><a href=
380 "#audit-packages">7.15. Automated security
381 checks</a></span></dt>
387 <dt><span class="part"><a href="#developers-guide">II. The
388 pkgsrc developer's guide</a></span></dt>
392 <dt><span class="chapter"><a href="#components">8.
393 Package components - files, directories and
394 contents</a></span></dt>
398 <dt><span class="sect1"><a href=
399 "#components.Makefile">8.1. <code xmlns=
400 "http://www.w3.org/TR/xhtml1/transitional" class=
401 "filename">Makefile</code></a></span></dt>
403 <dt><span class="sect1"><a href=
404 "#components.distinfo">8.2. <code xmlns=
405 "http://www.w3.org/TR/xhtml1/transitional" class=
406 "filename">distinfo</code></a></span></dt>
408 <dt><span class="sect1"><a href=
409 "#components.patches">8.3.
410 patches/*</a></span></dt>
412 <dt><span class="sect1"><a href=
413 "#other-mandatory-files">8.4. Other mandatory
414 files</a></span></dt>
416 <dt><span class="sect1"><a href=
417 "#components.optional">8.5. Optional
418 files</a></span></dt>
420 <dt><span class="sect1"><a href="#work-dir">8.6.
422 "http://www.w3.org/TR/xhtml1/transitional" class=
423 "filename">work*</code></a></span></dt>
425 <dt><span class="sect1"><a href="#files-dir">8.7.
427 "http://www.w3.org/TR/xhtml1/transitional" class=
428 "filename">files/*</code></a></span></dt>
432 <dt><span class="chapter"><a href="#makefile">9.
433 Programming in <code xmlns=
434 "http://www.w3.org/TR/xhtml1/transitional" class=
435 "filename">Makefile</code>s</a></span></dt>
439 <dt><span class="sect1"><a href=
440 "#makefile.variables">9.1. <code xmlns=
441 "http://www.w3.org/TR/xhtml1/transitional" class=
442 "filename">Makefile</code>
443 variables</a></span></dt>
447 <dt><span class="sect2"><a href=
448 "#makefile.variables.names">9.1.1. Naming
449 conventions</a></span></dt>
453 <dt><span class="sect1"><a href=
454 "#makefile.code">9.2. Code snippets</a></span></dt>
458 <dt><span class="sect2"><a href=
459 "#adding-to-list">9.2.1. Adding things to a
462 <dt><span class="sect2"><a href=
463 "#converting-internal-to-external">9.2.2.
464 Converting an internal list into an external
467 <dt><span class="sect2"><a href=
468 "#passing-variable-to-shell">9.2.3. Passing
469 variables to a shell command</a></span></dt>
471 <dt><span class="sect2"><a href=
472 "#quoting-guideline">9.2.4. Quoting
473 guideline</a></span></dt>
475 <dt><span class="sect2"><a href=
476 "#bsd-make-bug-workaround">9.2.5. Workaround
477 for a bug in BSD Make</a></span></dt>
483 <dt><span class="chapter"><a href="#plist">10. PLIST
484 issues</a></span></dt>
488 <dt><span class="sect1"><a href="#rcs-id">10.1. RCS
491 <dt><span class="sect1"><a href=
492 "#automatic-plist-generation">10.2. Semi-automatic
494 "http://www.w3.org/TR/xhtml1/transitional" class=
495 "filename">PLIST</code> generation</a></span></dt>
497 <dt><span class="sect1"><a href=
498 "#print-PLIST">10.3. Tweaking output of
499 <span><strong class="command">make
500 print-PLIST</strong></span></a></span></dt>
502 <dt><span class="sect1"><a href="#plist.misc">10.4.
503 Variable substitution in PLIST</a></span></dt>
505 <dt><span class="sect1"><a href=
506 "#manpage-compression">10.5. Man page
507 compression</a></span></dt>
509 <dt><span class="sect1"><a href=
510 "#using-PLIST_SRC">10.6. Changing PLIST source with
512 "varname">PLIST_SRC</code></a></span></dt>
514 <dt><span class="sect1"><a href=
515 "#platform-specific-plist">10.7. Platform-specific
516 and differing PLISTs</a></span></dt>
518 <dt><span class="sect1"><a href=
519 "#faq.common-dirs">10.8. Sharing directories
520 between packages</a></span></dt>
524 <dt><span class="chapter"><a href="#buildlink">11.
525 Buildlink methodology</a></span></dt>
529 <dt><span class="sect1"><a href=
530 "#converting-to-buildlink3">11.1. Converting
531 packages to use buildlink3</a></span></dt>
533 <dt><span class="sect1"><a href=
534 "#creating-buildlink3.mk">11.2. Writing
535 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
536 class="filename">buildlink3.mk</code>
537 files</a></span></dt>
541 <dt><span class="sect2"><a href=
542 "#anatomy-of-bl3">11.2.1. Anatomy of a
543 buildlink3.mk file</a></span></dt>
545 <dt><span class="sect2"><a href=
546 "#updating-buildlink-depends">11.2.2. Updating
548 "varname">BUILDLINK_DEPENDS.<em class=
549 "replaceable"><code>pkg</code></em></code> in
551 "http://www.w3.org/TR/xhtml1/transitional"
552 class="filename">buildlink3.mk</code>
553 files</a></span></dt>
557 <dt><span class="sect1"><a href=
558 "#writing-builtin.mk">11.3. Writing <code xmlns=
559 "http://www.w3.org/TR/xhtml1/transitional" class=
560 "filename">builtin.mk</code> files</a></span></dt>
564 <dt><span class="sect2"><a href=
565 "#anatomy-of-builtin.mk">11.3.1. Anatomy of a
567 "http://www.w3.org/TR/xhtml1/transitional"
568 class="filename">builtin.mk</code>
571 <dt><span class="sect2"><a href=
572 "#native-or-pkgsrc-preference">11.3.2. Global
573 preferences for native or pkgsrc
574 software</a></span></dt>
580 <dt><span class="chapter"><a href="#pkginstall">12. The
581 pkginstall framework</a></span></dt>
585 <dt><span class="sect1"><a href=
586 "#files-and-dirs-outside-prefix">12.1. Files and
587 directories outside the installation
588 prefix</a></span></dt>
592 <dt><span class="sect2"><a href=
593 "#dirs-outside-prefix">12.1.1. Directory
594 manipulation</a></span></dt>
596 <dt><span class="sect2"><a href=
597 "#files-outside-prefix">12.1.2. File
598 manipulation</a></span></dt>
602 <dt><span class="sect1"><a href="#conf-files">12.2.
603 Configuration files</a></span></dt>
607 <dt><span class="sect2"><a href=
608 "#conf-files-sysconfdir">12.2.1. How
609 <code class="varname">PKG_SYSCONFDIR</code> is
612 <dt><span class="sect2"><a href=
613 "#conf-files-configure">12.2.2. Telling the
614 software where configuration files
617 <dt><span class="sect2"><a href=
618 "#conf-files-patching">12.2.3. Patching
619 installations</a></span></dt>
621 <dt><span class="sect2"><a href=
622 "#conf-files-disable">12.2.4. Disabling
623 handling of configuration files</a></span></dt>
627 <dt><span class="sect1"><a href=
628 "#rcd-scripts">12.3. System startup
629 scripts</a></span></dt>
633 <dt><span class="sect2"><a href=
634 "#rcd-scripts-disable">12.3.1. Disabling
635 handling of system startup
636 scripts</a></span></dt>
640 <dt><span class="sect1"><a href=
641 "#users-and-groups">12.4. System users and
642 groups</a></span></dt>
644 <dt><span class="sect1"><a href="#shells">12.5.
645 System shells</a></span></dt>
649 <dt><span class="sect2"><a href=
650 "#shells-disable">12.5.1. Disabling handling of
651 configuration files</a></span></dt>
657 <dt><span class="chapter"><a href="#options">13.
658 Options handling</a></span></dt>
662 <dt><span class="sect1"><a href=
663 "#global-default-options">13.1. Global default
664 options</a></span></dt>
666 <dt><span class="sect1"><a href=
667 "#converting-to-options">13.2. Converting packages
669 "http://www.w3.org/TR/xhtml1/transitional" class=
670 "filename">bsd.options.mk</code></a></span></dt>
672 <dt><span class="sect1"><a href=
673 "#option-names">13.3. Option Names</a></span></dt>
677 <dt><span class="chapter"><a href="#build">14. The
678 build process</a></span></dt>
682 <dt><span class="sect1"><a href=
683 "#build.prefix">14.1. Program
684 location</a></span></dt>
686 <dt><span class="sect1"><a href=
687 "#main-targets">14.2. Main targets</a></span></dt>
689 <dt><span class="sect1"><a href=
690 "#build.helpful-targets">14.3. Other helpful
691 targets</a></span></dt>
695 <dt><span class="chapter"><a href="#fixes">15. Notes on
696 fixes for packages</a></span></dt>
700 <dt><span class="sect1"><a href=
701 "#general-operation">15.1. General
702 operation</a></span></dt>
706 <dt><span class="sect2"><a href=
707 "#pulling-vars-from-etc-mk.conf">15.1.1. How to
708 pull in variables from
709 /etc/mk.conf</a></span></dt>
711 <dt><span class="sect2"><a href=
712 "#where-to-install-documentation">15.1.2. Where
713 to install documentation</a></span></dt>
715 <dt><span class="sect2"><a href=
716 "#restricted-packages">15.1.3. Restricted
717 packages</a></span></dt>
719 <dt><span class="sect2"><a href=
720 "#dependencies">15.1.4. Handling
721 dependencies</a></span></dt>
723 <dt><span class="sect2"><a href=
724 "#conflicts">15.1.5. Handling conflicts with
725 other packages</a></span></dt>
727 <dt><span class="sect2"><a href=
728 "#not-building-packages">15.1.6. Packages that
729 cannot or should not be built</a></span></dt>
731 <dt><span class="sect2"><a href=
732 "#undeletable-packages">15.1.7. Packages which
733 should not be deleted, once
734 installed</a></span></dt>
736 <dt><span class="sect2"><a href=
737 "#security-handling">15.1.8. Handling packages
738 with security problems</a></span></dt>
740 <dt><span class="sect2"><a href=
741 "#compiler-bugs">15.1.9. How to handle compiler
744 <dt><span class="sect2"><a href=
745 "#bumping-pkgrevision">15.1.10. How to handle
746 incrementing versions when fixing an existing
747 package</a></span></dt>
749 <dt><span class="sect2"><a href=
750 "#portability-of-packages">15.1.11. Portability
751 of packages</a></span></dt>
755 <dt><span class="sect1"><a href=
756 "#downloading-issues">15.2. Possible downloading
757 issues</a></span></dt>
761 <dt><span class="sect2"><a href=
762 "#no-plain-download">15.2.1. Packages whose
763 distfiles aren't available for plain
764 downloading</a></span></dt>
766 <dt><span class="sect2"><a href=
767 "#modified-distfiles-same-name">15.2.2. How to
768 handle modified distfiles with the 'old'
773 <dt><span class="sect1"><a href=
774 "#configuration-gotchas">15.3. Configuration
775 gotchas</a></span></dt>
779 <dt><span class="sect2"><a href=
780 "#fixes.libtool">15.3.1. Shared libraries -
781 libtool</a></span></dt>
783 <dt><span class="sect2"><a href=
784 "#using-libtool">15.3.2. Using libtool on GNU
785 packages that already support
786 libtool</a></span></dt>
788 <dt><span class="sect2"><a href=
789 "#autoconf-automake">15.3.3. GNU
790 Autoconf/Automake</a></span></dt>
794 <dt><span class="sect1"><a href=
795 "#building-considerations">15.4. Building
796 considerations</a></span></dt>
800 <dt><span class="sect2"><a href=
801 "#cpp-defines">15.4.1. CPP
802 defines</a></span></dt>
804 <dt><span class="sect2"><a href=
805 "#cpp-list">15.4.2. Getting a list of CPP
806 defines</a></span></dt>
810 <dt><span class="sect1"><a href=
811 "#package-specific-actions">15.5. Package specific
812 actions</a></span></dt>
816 <dt><span class="sect2"><a href=
817 "#user-interaction">15.5.1. User
818 interaction</a></span></dt>
820 <dt><span class="sect2"><a href=
821 "#handling-licenses">15.5.2. Handling
822 licenses</a></span></dt>
824 <dt><span class="sect2"><a href=
825 "#installing-score-files">15.5.3. Installing
826 score files</a></span></dt>
828 <dt><span class="sect2"><a href=
829 "#perl-scripts">15.5.4. Packages containing
830 perl scripts</a></span></dt>
832 <dt><span class="sect2"><a href=
833 "#hardcoded-paths">15.5.5. Packages with
834 hardcoded paths to other
835 interpreters</a></span></dt>
837 <dt><span class="sect2"><a href=
838 "#perl-modules">15.5.6. Packages installing
839 perl modules</a></span></dt>
841 <dt><span class="sect2"><a href=
842 "#faq.info-files">15.5.7. Packages installing
843 info files</a></span></dt>
845 <dt><span class="sect2"><a href=
846 "#gconf2-data-files">15.5.8. Packages
847 installing GConf2 data files</a></span></dt>
849 <dt><span class="sect2"><a href=
850 "#scrollkeeper-data-files">15.5.9. Packages
851 installing scrollkeeper data
852 files</a></span></dt>
854 <dt><span class="sect2"><a href=
855 "#x11-fonts">15.5.10. Packages installing X11
856 fonts</a></span></dt>
858 <dt><span class="sect2"><a href=
859 "#gtk2-modules">15.5.11. Packages installing
860 GTK2 modules</a></span></dt>
862 <dt><span class="sect2"><a href=
863 "#sgml-xml-data">15.5.12. Packages installing
864 SGML or XML data</a></span></dt>
866 <dt><span class="sect2"><a href=
867 "#mime-database">15.5.13. Packages installing
868 extensions to the MIME database</a></span></dt>
870 <dt><span class="sect2"><a href=
871 "#intltool">15.5.14. Packages using
872 intltool</a></span></dt>
874 <dt><span class="sect2"><a href=
875 "#startup-scripts">15.5.15. Packages installing
876 startup scripts</a></span></dt>
880 <dt><span class="sect1"><a href=
881 "#feedback-to-author">15.6. Feedback to the
882 author</a></span></dt>
886 <dt><span class="chapter"><a href="#debug">16.
887 Debugging</a></span></dt>
889 <dt><span class="chapter"><a href="#submit">17.
890 Submitting and Committing</a></span></dt>
894 <dt><span class="sect1"><a href=
895 "#submitting-your-package">17.1. Submitting your
896 packages</a></span></dt>
898 <dt><span class="sect1"><a href=
899 "#general-notes-for-changes">17.2. General notes
900 when adding, updating, or removing
901 packages</a></span></dt>
903 <dt><span class="sect1"><a href=
904 "#committing-importing">17.3. Committing: Importing
905 a package into CVS</a></span></dt>
907 <dt><span class="sect1"><a href=
908 "#updating-package">17.4. Updating a package to a
909 newer version</a></span></dt>
911 <dt><span class="sect1"><a href=
912 "#moving-package">17.5. Moving a package in
913 pkgsrc</a></span></dt>
919 <dt><span class="appendix"><a href="#examples">A. A simple
920 example package: bison</a></span></dt>
924 <dt><span class="sect1"><a href="#example-files">A.1.
925 files</a></span></dt>
929 <dt><span class="sect2"><a href=
930 "#example-Makefile">A.1.1. Makefile</a></span></dt>
932 <dt><span class="sect2"><a href=
933 "#example-descr">A.1.2. DESCR</a></span></dt>
935 <dt><span class="sect2"><a href=
936 "#example-plist">A.1.3. PLIST</a></span></dt>
938 <dt><span class="sect2"><a href=
939 "#checking-package-with-pkglint">A.1.4. Checking a
940 package with <span><strong class=
941 "command">pkglint</strong></span></a></span></dt>
945 <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2.
946 Steps for building, installing,
947 packaging</a></span></dt>
951 <dt><span class="appendix"><a href="#logs">B. Build
956 <dt><span class="sect1"><a href="#logs.building">B.1.
957 Building figlet</a></span></dt>
959 <dt><span class="sect1"><a href="#logs.package">B.2.
960 Packaging figlet</a></span></dt>
964 <dt><span class="appendix"><a href="#ftp-layout">C. Layout
965 of the FTP server's package archive</a></span></dt>
967 <dt><span class="appendix"><a href="#editing">D. Editing
968 guidelines for the pkgsrc guide</a></span></dt>
972 <dt><span class="sect1"><a href="#targets">D.1.
973 Targets</a></span></dt>
975 <dt><span class="sect1"><a href="#procedure">D.2.
976 Procedure</a></span></dt>
982 <div class="chapter" lang="en" xml:lang="en">
983 <div class="titlepage">
986 <h2 class="title"><a name="introduction" id=
987 "introduction"></a>Chapter 1. What is
994 <p><b>Table of Contents</b></p>
997 <dt><span class="sect1"><a href=
998 "#introduction-section">1.1. Introduction</a></span></dt>
1000 <dt><span class="sect1"><a href="#overview">1.2.
1001 Overview</a></span></dt>
1003 <dt><span class="sect1"><a href="#terminology">1.3.
1004 Terminology</a></span></dt>
1006 <dt><span class="sect1"><a href="#typography">1.4.
1007 Typography</a></span></dt>
1011 <div class="sect1" lang="en" xml:lang="en">
1012 <div class="titlepage">
1015 <h2 class="title" style="clear: both"><a name=
1016 "introduction-section" id=
1017 "introduction-section"></a>1.1. Introduction</h2>
1022 <p>There is a lot of software freely available for
1023 Unix-based systems, which usually runs on NetBSD and other
1024 Unix-flavoured systems, too, sometimes with some
1025 modifications. The NetBSD Packages Collection (pkgsrc)
1026 incorporates any such changes necessary to make that
1027 software run, and makes the installation (and
1028 de-installation) of the software package easy by means of a
1031 <p>Once the software has been built, it is manipulated with
1032 the <span><strong class="command">pkg_*</strong></span>
1033 tools so that installation and de-installation, printing of
1034 an inventory of all installed packages and retrieval of
1035 one-line comments or more verbose descriptions are all
1038 <p>pkgsrc currently contains several thousand packages,
1041 <div class="itemizedlist">
1045 "http://www.w3.org/TR/xhtml1/transitional" href=
1046 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/apache/README.html"
1047 target="_top"><code xmlns="" class=
1048 "filename">www/apache</code></a> - The Apache web
1054 "http://www.w3.org/TR/xhtml1/transitional" href=
1055 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html"
1056 target="_top"><code xmlns="" class=
1057 "filename">www/mozilla</code></a> - The Mozilla web
1063 "http://www.w3.org/TR/xhtml1/transitional" href=
1064 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome/README.html"
1065 target="_top"><code xmlns="" class=
1066 "filename">meta-pkgs/gnome</code></a> - The GNOME
1067 Desktop Environment</p>
1072 "http://www.w3.org/TR/xhtml1/transitional" href=
1073 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/kde3/README.html"
1074 target="_top"><code xmlns="" class=
1075 "filename">meta-pkgs/kde3</code></a> - The K Desktop
1081 <p>...just to name a few.</p>
1083 <p>pkgsrc has built-in support for handling varying
1084 dependencies, such as pthreads and X11, and extended
1085 features such as IPv6 support on a range of platforms.</p>
1087 <p>pkgsrc was derived from FreeBSD's ports system, and
1088 initially developed for NetBSD only. Since then, pkgsrc has
1089 grown a lot, and now supports the following platforms:</p>
1091 <div class="itemizedlist">
1094 <p><a href="http://developer.apple.com/darwin/"
1095 target="_top">Darwin</a> (<a href=
1096 "http://www.apple.com/macosx/" target="_top">Mac OS
1101 <p><a href="http://www.DragonFlyBSD.org/" target=
1102 "_top">DragonFlyBSD</a></p>
1106 <p><a href="http://www.FreeBSD.org/" target=
1107 "_top">FreeBSD</a></p>
1111 <p>Microsoft Windows, via <a href=
1112 "http://www.microsoft.com/windows/sfu/" target=
1113 "_top">Interix</a></p>
1117 <p><a href="http://www.sgi.com/software/irix6.5/"
1118 target="_top">IRIX</a></p>
1122 <p><a href="http://www.linux.org/" target=
1123 "_top">Linux</a></p>
1127 <p><a href="http://www.NetBSD.org/" target=
1128 "_top">NetBSD</a> (of course)</p>
1132 <p><a href="http://h30097.www3.hp.com/" target=
1133 "_top">Tru64</a> (Digital UNIX, OSF1)</p>
1137 <p><a href="http://www.openbsd.org/" target=
1138 "_top">OpenBSD</a></p>
1142 <p><a href="http://www.sun.com/solaris/" target=
1143 "_top">Solaris</a></p>
1149 <div class="sect1" lang="en" xml:lang="en">
1150 <div class="titlepage">
1153 <h2 class="title" style="clear: both"><a name=
1154 "overview" id="overview"></a>1.2. Overview</h2>
1159 <p>This document is divided into two parts. The first,
1160 <a href="#users-guide" title=
1161 "Part I. The pkgsrc user's guide">The pkgsrc
1162 user's guide</a>, describes how one can use one of the
1163 packages in the Package Collection, either by installing a
1164 precompiled binary package, or by building one's own copy
1165 using the NetBSD package system. The second part, <a href=
1166 "#developers-guide" title=
1167 "Part II. The pkgsrc developer's guide">The
1168 pkgsrc developer's guide</a>, explains how to prepare a
1169 package so it can be easily built by other NetBSD users
1170 without knowing about the package's building details.</p>
1172 <p>This document is available in various formats:</p>
1174 <div class="itemizedlist">
1177 <p><a href="index.html" target="_top">HTML</a></p>
1181 <p><a href="pkgsrc.pdf" target="_top">PDF</a></p>
1185 <p><a href="pkgsrc.ps" target="_top">PS</a></p>
1189 <p><a href="pkgsrc.txt" target="_top">TXT</a></p>
1195 <div class="sect1" lang="en" xml:lang="en">
1196 <div class="titlepage">
1199 <h2 class="title" style="clear: both"><a name=
1201 "terminology"></a>1.3. Terminology</h2>
1206 <p>There has been a lot of talk about “<span class=
1207 "quote">ports</span>”, “<span class=
1208 "quote">packages</span>”, etc. so far. Here is a
1209 description of all the terminology used within this
1212 <div class="variablelist">
1214 <dt><span class="term">Package</span></dt>
1217 <p>A set of files and building instructions that
1218 describe what's necessary to build a certain piece of
1219 software using pkgsrc. Packages are traditionally
1220 stored under <code xmlns=
1221 "http://www.w3.org/TR/xhtml1/transitional" class=
1222 "filename">/usr/pkgsrc</code>.</p>
1225 <dt><span class="term">The NetBSD package
1229 <p>This is the former name of “<span class=
1230 "quote">pkgsrc</span>”. It is part of the
1231 NetBSD operating system and can be bootstrapped to
1232 run on non-NetBSD operating systems as well. It
1233 handles building (compiling), installing, and
1234 removing of packages.</p>
1237 <dt><span class="term">Distfile</span></dt>
1240 <p>This term describes the file or files that are
1241 provided by the author of the piece of software to
1242 distribute his work. All the changes necessary to
1243 build on NetBSD are reflected in the corresponding
1244 package. Usually the distfile is in the form of a
1245 compressed tar-archive, but other types are possible,
1246 too. Distfiles are usually stored below <code xmlns=
1247 "http://www.w3.org/TR/xhtml1/transitional" class=
1248 "filename">/usr/pkgsrc/distfiles</code>.</p>
1251 <dt><span class="term">Port</span></dt>
1254 <p>This is the term used by FreeBSD and OpenBSD
1255 people for what we call a package. In NetBSD
1256 terminology, “<span class=
1257 "quote">port</span>” refers to a different
1261 <dt><span class="term">Precompiled/binary
1265 <p>A set of binaries built with pkgsrc from a
1266 distfile and stuffed together in a single
1267 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
1268 class="filename">.tgz</code> file so it can be
1269 installed on machines of the same machine
1270 architecture without the need to recompile. Packages
1271 are usually generated in <code xmlns=
1272 "http://www.w3.org/TR/xhtml1/transitional" class=
1273 "filename">/usr/pkgsrc/packages</code>; there is also
1274 an archive on <a href=
1275 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target=
1276 "_top">ftp.NetBSD.org</a>.</p>
1278 <p>Sometimes, this is referred to by the term
1279 “<span class="quote">package</span>” too,
1280 especially in the context of precompiled
1284 <dt><span class="term">Program</span></dt>
1287 <p>The piece of software to be installed which will
1288 be constructed from all the files in the distfile by
1289 the actions defined in the corresponding package.</p>
1295 <div class="sect1" lang="en" xml:lang="en">
1296 <div class="titlepage">
1299 <h2 class="title" style="clear: both"><a name=
1301 "typography"></a>1.4. Typography</h2>
1306 <p>When giving examples for commands, shell prompts are
1307 used to show if the command should/can be issued as root,
1308 or if “<span class="quote">normal</span>” user
1309 privileges are sufficient. We use a <code class=
1310 "prompt">#</code> for root's shell prompt, and a
1311 <code class="prompt">%</code> for users' shell prompt,
1312 assuming they use the C-shell or tcsh.</p>
1316 <div class="part" lang="en" xml:lang="en">
1317 <div class="titlepage">
1320 <h1 class="title"><a name="users-guide" id=
1321 "users-guide"></a>Part I. The pkgsrc user's
1328 <p><b>Table of Contents</b></p>
1331 <dt><span class="chapter"><a href="#getting">2. Where to
1332 get pkgsrc</a></span></dt>
1336 <dt><span class="sect1"><a href="#as-tar-file">2.1.
1337 As tar file</a></span></dt>
1339 <dt><span class="sect1"><a href="#via-sup">2.2. Via
1342 <dt><span class="sect1"><a href="#via-cvs">2.3. Via
1347 <dt><span class="chapter"><a href="#platforms">3. Using
1348 pkgsrc on systems other than NetBSD</a></span></dt>
1352 <dt><span class="sect1"><a href=
1353 "#bootstrapping-pkgsrc">3.1. Bootstrapping
1354 pkgsrc</a></span></dt>
1356 <dt><span class="sect1"><a href=
1357 "#platform-specific-notes">3.2. Platform-specific
1358 notes</a></span></dt>
1362 <dt><span class="sect2"><a href="#darwin">3.2.1.
1363 Darwin (Mac OS X)</a></span></dt>
1365 <dt><span class="sect2"><a href="#freebsd">3.2.2.
1366 FreeBSD</a></span></dt>
1368 <dt><span class="sect2"><a href="#interix">3.2.3.
1369 Interix</a></span></dt>
1371 <dt><span class="sect2"><a href="#irix">3.2.4.
1372 IRIX</a></span></dt>
1374 <dt><span class="sect2"><a href="#linux">3.2.5.
1375 Linux</a></span></dt>
1377 <dt><span class="sect2"><a href="#openbsd">3.2.6.
1378 OpenBSD</a></span></dt>
1380 <dt><span class="sect2"><a href="#solaris">3.2.7.
1381 Solaris</a></span></dt>
1387 <dt><span class="chapter"><a href="#using">4. Using
1388 pkgsrc</a></span></dt>
1392 <dt><span class="sect1"><a href=
1393 "#getting-started">4.1. Working with binary
1394 packages</a></span></dt>
1398 <dt><span class="sect2"><a href=
1399 "#where-to-get-binary-packages">4.1.1. Where to
1400 get binary packages</a></span></dt>
1402 <dt><span class="sect2"><a href=
1403 "#how-to-use-binary-packages">4.1.2. How to use
1404 binary packages</a></span></dt>
1406 <dt><span class="sect2"><a href=
1407 "#a-word-of-warning">4.1.3. A word of
1408 warning</a></span></dt>
1412 <dt><span class="sect1"><a href=
1413 "#building-packages-from-source">4.2. Building
1414 packages from source</a></span></dt>
1418 <dt><span class="sect2"><a href=
1419 "#requirements">4.2.1.
1420 Requirements</a></span></dt>
1422 <dt><span class="sect2"><a href=
1423 "#fetching-distfiles">4.2.2. Fetching
1424 distfiles</a></span></dt>
1426 <dt><span class="sect2"><a href=
1427 "#how-to-build-and-install">4.2.3. How to build
1428 and install</a></span></dt>
1430 <dt><span class="sect2"><a href=
1431 "#selecting-the-compiler">4.2.4. Selecting the
1432 compiler</a></span></dt>
1438 <dt><span class="chapter"><a href="#configuring">5.
1439 Configuring pkgsrc</a></span></dt>
1443 <dt><span class="sect1"><a href=
1444 "#general-configuration">5.1. General
1445 configuration</a></span></dt>
1447 <dt><span class="sect1"><a href=
1448 "#variables-affecting-build">5.2. Variables affecting
1449 the build process</a></span></dt>
1451 <dt><span class="sect1"><a href=
1452 "#developer-advanced-settings">5.3.
1453 Developer/advanced settings</a></span></dt>
1455 <dt><span class="sect1"><a href=
1456 "#selecting-build-options">5.4. Selecting Build
1457 Options</a></span></dt>
1461 <dt><span class="chapter"><a href="#binary">6. Creating
1462 binary packages</a></span></dt>
1466 <dt><span class="sect1"><a href=
1467 "#building-a-single-binary-package">6.1. Building a
1468 single binary package</a></span></dt>
1470 <dt><span class="sect1"><a href=
1471 "#settings-for-creationg-of-binary-packages">6.2.
1472 Settings for creation of binary
1473 packages</a></span></dt>
1475 <dt><span class="sect1"><a href="#bulkbuild">6.3.
1476 Doing a bulk build of all packages</a></span></dt>
1480 <dt><span class="sect2"><a href=
1481 "#binary.configuration">6.3.1.
1482 Configuration</a></span></dt>
1484 <dt><span class="sect2"><a href=
1485 "#other-environmental-considerations">6.3.2.
1487 considerations</a></span></dt>
1489 <dt><span class="sect2"><a href=
1490 "#operation">6.3.3. Operation</a></span></dt>
1492 <dt><span class="sect2"><a href=
1493 "#what-it-does">6.3.4. What it
1494 does</a></span></dt>
1496 <dt><span class="sect2"><a href=
1497 "#disk-space-requirements">6.3.5. Disk space
1498 requirements</a></span></dt>
1500 <dt><span class="sect2"><a href=
1501 "#setting-up-a-sandbox">6.3.6. Setting up a
1502 sandbox for chrooted builds</a></span></dt>
1504 <dt><span class="sect2"><a href=
1505 "#building-a-partial-set">6.3.7. Building a
1506 partial set of packages</a></span></dt>
1508 <dt><span class="sect2"><a href=
1509 "#bulk-upload">6.3.8. Uploading results of a bulk
1510 build</a></span></dt>
1514 <dt><span class="sect1"><a href=
1515 "#creating-cdroms">6.4. Creating a multiple CD-ROM
1516 packages collection</a></span></dt>
1520 <dt><span class="sect2"><a href=
1521 "#cdpack-example">6.4.1. Example of
1522 cdpack</a></span></dt>
1528 <dt><span class="chapter"><a href="#faq">7. Frequently
1529 Asked Questions</a></span></dt>
1533 <dt><span class="sect1"><a href=
1534 "#mailing-list-pointers">7.1. Are there any mailing
1535 lists for pkg-related discussion?</a></span></dt>
1537 <dt><span class="sect1"><a href="#pkgviews-docs">7.2.
1538 Where's the pkgviews documentation?</a></span></dt>
1540 <dt><span class="sect1"><a href="#faq-pkgtools">7.3.
1541 Utilities for package management
1542 (pkgtools)</a></span></dt>
1544 <dt><span class="sect1"><a href=
1545 "#non-root-pkgsrc">7.4. How to use pkgsrc as
1546 non-root</a></span></dt>
1548 <dt><span class="sect1"><a href=
1549 "#resume-transfers">7.5. How to resume transfers when
1550 fetching distfiles?</a></span></dt>
1552 <dt><span class="sect1"><a href=
1553 "#XFree86-from-pkgsrc">7.6. How can I install/use
1554 XFree86 from pkgsrc?</a></span></dt>
1556 <dt><span class="sect1"><a href=
1557 "#x.org-from-pkgsrc">7.7. How can I install/use X.org
1558 from pkgsrc?</a></span></dt>
1560 <dt><span class="sect1"><a href=
1561 "#fetch-behind-firewall">7.8. How to fetch files from
1562 behind a firewall</a></span></dt>
1564 <dt><span class="sect1"><a href="#passive-ftp">7.9.
1565 How do I tell <span><strong class="command">make
1566 fetch</strong></span> to do passive
1567 FTP?</a></span></dt>
1569 <dt><span class="sect1"><a href=
1570 "#fetching-all-distfiles">7.10. How to fetch all
1571 distfiles at once</a></span></dt>
1573 <dt><span class="sect1"><a href=
1574 "#tmac.andoc-missing">7.11. What does
1575 “<span class="quote">Don't know how to make
1576 /usr/share/tmac/tmac.andoc</span>”
1577 mean?</a></span></dt>
1579 <dt><span class="sect1"><a href=
1580 "#bsd.own.mk-missing">7.12. What does
1581 “<span class="quote">Could not find
1582 bsd.own.mk</span>” mean?</a></span></dt>
1584 <dt><span class="sect1"><a href=
1585 "#using-sudo-with-pkgsrc">7.13. Using 'sudo' with
1586 pkgsrc</a></span></dt>
1588 <dt><span class="sect1"><a href="#faq.conf">7.14. How
1589 do I change the location of configuration
1590 files?</a></span></dt>
1592 <dt><span class="sect1"><a href=
1593 "#audit-packages">7.15. Automated security
1594 checks</a></span></dt>
1600 <div class="chapter" lang="en" xml:lang="en">
1601 <div class="titlepage">
1604 <h2 class="title"><a name="getting" id=
1605 "getting"></a>Chapter 2. Where to get
1612 <p><b>Table of Contents</b></p>
1615 <dt><span class="sect1"><a href="#as-tar-file">2.1. As
1616 tar file</a></span></dt>
1618 <dt><span class="sect1"><a href="#via-sup">2.2. Via
1621 <dt><span class="sect1"><a href="#via-cvs">2.3. Via
1626 <p>There are three ways to get pkgsrc. Either as a tar
1627 file, via SUP, or via CVS. All three ways are described
1630 <div class="sect1" lang="en" xml:lang="en">
1631 <div class="titlepage">
1634 <h2 class="title" style="clear: both"><a name=
1635 "as-tar-file" id="as-tar-file"></a>2.1. As tar
1641 <p>To get pkgsrc going, you need to get the pkgsrc.tar.gz
1643 "ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-current/tar_files/pkgsrc.tar.gz"
1644 target="_top">ftp.NetBSD.org</a> and unpack it into
1645 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
1646 class="filename">/usr/pkgsrc</code>.</p>
1649 <div class="sect1" lang="en" xml:lang="en">
1650 <div class="titlepage">
1653 <h2 class="title" style="clear: both"><a name=
1654 "via-sup" id="via-sup"></a>2.2. Via SUP</h2>
1659 <p>As an alternative to the tar file, you can get pkgsrc
1660 via the Software Update Protocol, SUP. To do so, make
1661 sure your supfile has a line</p>
1662 <pre class="programlisting">
1666 <p>in it, see the examples in <code xmlns=
1667 "http://www.w3.org/TR/xhtml1/transitional" class=
1668 "filename">/usr/share/examples/supfiles</code>, and that
1670 "http://www.w3.org/TR/xhtml1/transitional" class=
1671 "filename">/usr/pkgsrc</code> directory exists. Then,
1672 simply run <span><strong class="command">sup -v
1673 <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
1676 <div class="sect1" lang="en" xml:lang="en">
1677 <div class="titlepage">
1680 <h2 class="title" style="clear: both"><a name=
1681 "via-cvs" id="via-cvs"></a>2.3. Via CVS</h2>
1686 <p>To get pkgsrc via CVS, make sure you have
1687 “<span class="quote">cvs</span>” installed.
1688 To do an initial (full) checkout of pkgsrc, do the
1689 following steps:</p>
1690 <pre class="screen">
1691 <code class="prompt">%</code> <strong class=
1692 "userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
1693 <code class="prompt">%</code> <strong class=
1694 "userinput"><code>setenv CVS_RSH ssh</code></strong>
1695 <code class="prompt">%</code> <strong class=
1696 "userinput"><code>cd /usr</code></strong>
1697 <code class="prompt">%</code> <strong class=
1698 "userinput"><code>cvs checkout -P pkgsrc</code></strong>
1701 <p>This will create the <code xmlns=
1702 "http://www.w3.org/TR/xhtml1/transitional" class=
1703 "filename">pkgsrc</code> directory in your <code xmlns=
1704 "http://www.w3.org/TR/xhtml1/transitional" class=
1705 "filename">/usr</code>, and all the package source will
1706 be stored under <code xmlns=
1707 "http://www.w3.org/TR/xhtml1/transitional" class=
1708 "filename">/usr/pkgsrc</code>. To update pkgsrc after the
1709 initial checkout, make sure you have <code class=
1710 "varname">CVS_RSH</code> set as above, then do:</p>
1711 <pre class="screen">
1712 <code class="prompt">%</code> <strong class=
1713 "userinput"><code>cd /usr/pkgsrc</code></strong>
1714 <code class="prompt">%</code> <strong class=
1715 "userinput"><code>cvs -q update -dP</code></strong>
1718 <p>Please also note that it is possible to have multiple
1719 copies of the pkgsrc hierarchy in use at any one time -
1720 all work is done relatively within the pkgsrc tree.</p>
1724 <div class="chapter" lang="en" xml:lang="en">
1725 <div class="titlepage">
1728 <h2 class="title"><a name="platforms" id=
1729 "platforms"></a>Chapter 3. Using pkgsrc on
1730 systems other than NetBSD</h2>
1736 <p><b>Table of Contents</b></p>
1739 <dt><span class="sect1"><a href=
1740 "#bootstrapping-pkgsrc">3.1. Bootstrapping
1741 pkgsrc</a></span></dt>
1743 <dt><span class="sect1"><a href=
1744 "#platform-specific-notes">3.2. Platform-specific
1745 notes</a></span></dt>
1749 <dt><span class="sect2"><a href="#darwin">3.2.1.
1750 Darwin (Mac OS X)</a></span></dt>
1752 <dt><span class="sect2"><a href="#freebsd">3.2.2.
1753 FreeBSD</a></span></dt>
1755 <dt><span class="sect2"><a href="#interix">3.2.3.
1756 Interix</a></span></dt>
1758 <dt><span class="sect2"><a href="#irix">3.2.4.
1759 IRIX</a></span></dt>
1761 <dt><span class="sect2"><a href="#linux">3.2.5.
1762 Linux</a></span></dt>
1764 <dt><span class="sect2"><a href="#openbsd">3.2.6.
1765 OpenBSD</a></span></dt>
1767 <dt><span class="sect2"><a href="#solaris">3.2.7.
1768 Solaris</a></span></dt>
1774 <div class="sect1" lang="en" xml:lang="en">
1775 <div class="titlepage">
1778 <h2 class="title" style="clear: both"><a name=
1779 "bootstrapping-pkgsrc" id=
1780 "bootstrapping-pkgsrc"></a>3.1. Bootstrapping
1786 <p>For operating systems other than NetBSD, we provide a
1787 bootstrap kit to build the required tools to use pkgsrc
1788 on your platform. Besides support for native NetBSD,
1789 pkgsrc and the bootstrap kit have support for the
1790 following operating systems:</p>
1792 <div class="itemizedlist">
1795 <p>Darwin (Mac OS X)</p>
1807 <p>Interix (Windows 2000, XP, 2003)</p>
1827 <p>Tru64 (Digital UNIX/OSF1)</p>
1832 <p>Support for other platforms is under development.</p>
1834 <p>Installing the bootstrap kit should be as simple
1836 <pre class="screen">
1837 <code class="prompt">#</code> <strong class=
1838 "userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
1839 <code class="prompt">#</code> <strong class=
1840 "userinput"><code>cd pkgsrc/bootstrap</code></strong>
1841 <code class="prompt">#</code> <strong class=
1842 "userinput"><code>./bootstrap</code></strong>
1845 <p>See <a href="#getting" title=
1846 "Chapter 2. Where to get pkgsrc">Chapter 2,
1847 <i>Where to get pkgsrc</i></a> for other ways to get
1848 pkgsrc before bootstrapping. The given
1849 <span><strong class="command">bootstrap</strong></span>
1850 command will use the defaults of <code xmlns=
1851 "http://www.w3.org/TR/xhtml1/transitional" class=
1852 "filename">/usr/pkg</code> for the <span class=
1853 "emphasis"><em>prefix</em></span> where programs will be
1854 installed in, and <code xmlns=
1855 "http://www.w3.org/TR/xhtml1/transitional" class=
1856 "filename">/var/db/pkg</code> for the package database
1857 directory where pkgsrc will do its internal bookkeeping.
1858 However, these can also be set using command-line
1861 <p>Binary packages for the pkgsrc tools and an initial
1862 set of packages is available for supported platforms. An
1863 up-to-date list of these can be found on <a href=
1864 "http://www.pkgsrc.org/" target=
1865 "_top">www.pkgsrc.org</a>.</p>
1867 <div class="note" style=
1868 "margin-left: 0.5in; margin-right: 0.5in;">
1869 <h3 class="title">Note</h3>
1871 <p>The bootstrap installs a <span><strong class=
1872 "command">bmake</strong></span> tool. Use this
1873 <span><strong class="command">bmake</strong></span>
1874 when building via pkgsrc. For examples in this guide,
1875 use <span><strong class="command">bmake</strong></span>
1876 instead of “<span class=
1877 "quote">make</span>”.</p>
1881 <div class="sect1" lang="en" xml:lang="en">
1882 <div class="titlepage">
1885 <h2 class="title" style="clear: both"><a name=
1886 "platform-specific-notes" id=
1887 "platform-specific-notes"></a>3.2. Platform-specific
1893 <p>Here are some platform-specific notes you should be
1896 <div class="sect2" lang="en" xml:lang="en">
1897 <div class="titlepage">
1900 <h3 class="title"><a name="darwin" id=
1901 "darwin"></a>3.2.1. Darwin (Mac OS X)</h3>
1906 <p>Darwin 5.x and 6.x are supported. There are two
1907 methods of using pkgsrc on Mac OS X, by using a
1908 <a href="#platform.osx-image" title=
1909 "3.2.1.1. Using a disk image">disk image</a>, or a
1910 <a href="#platform.osx-ufs" title=
1911 "3.2.1.2. Using a UFS partition">UFS
1914 <p>Before you start, you will need to download and
1915 install the Mac OS X Developer Tools from Apple's
1916 Developer Connection. See <a href=
1917 "http://developer.apple.com/macosx/" target=
1918 "_top">http://developer.apple.com/macosx/</a> for
1919 details. Also, make sure you install X11 for Mac OS X
1920 and the X11 SDK from <a href=
1921 "http://www.apple.com/macosx/x11/download/" target=
1922 "_top">http://www.apple.com/macosx/x11/download/</a> if
1923 you intend to build packages that use the X11 Window
1926 <p>If you already have a UFS partition, or have a spare
1927 partition that you can format as UFS, it is recommended
1928 to use that instead of the disk image. It'll be
1929 somewhat faster and will mount automatically at boot
1930 time, where you must manually mount a disk image.</p>
1932 <div class="note" style=
1933 "margin-left: 0.5in; margin-right: 0.5in;">
1934 <h3 class="title">Note</h3>
1936 <p>You cannot use a HFS+ file system for pkgsrc,
1937 because pkgsrc currently requires the file system to
1938 be case-sensitive, and HFS+ is not.</p>
1941 <div class="sect3" lang="en" xml:lang="en">
1942 <div class="titlepage">
1945 <h4 class="title"><a name="platform.osx-image"
1946 id="platform.osx-image"></a>3.2.1.1. Using
1952 <p>Create the disk image:</p>
1953 <pre class="screen">
1954 <code class="prompt">#</code> <strong class=
1955 "userinput"><code>cd pkgsrc/bootstrap</code></strong>
1956 <code class="prompt">#</code> <strong class=
1957 "userinput"><code>./ufsdiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
1958 <code class="prompt">#</code> <strong class=
1959 "userinput"><code>./ufsdiskimage mount ~/Documents/NetBSD</code></strong>
1960 <code class="prompt">#</code> <strong class=
1961 "userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong>
1967 <div class="sect3" lang="en" xml:lang="en">
1968 <div class="titlepage">
1971 <h4 class="title"><a name="platform.osx-ufs"
1972 id="platform.osx-ufs"></a>3.2.1.2. Using a
1978 <p>By default, <code xmlns=
1979 "http://www.w3.org/TR/xhtml1/transitional" class=
1980 "filename">/usr</code> will be on your root file
1981 system, normally HFS+. It is possible to use the
1982 default <span class="emphasis"><em>prefix</em></span>
1984 "http://www.w3.org/TR/xhtml1/transitional" class=
1985 "filename">/usr/pkg</code> by symlinking <code xmlns=
1986 "http://www.w3.org/TR/xhtml1/transitional" class=
1987 "filename">/usr/pkg</code> to a directory on a UFS
1988 file system. Obviously, another symlink is required
1989 if you want to place the package database directory
1990 outside the <span class=
1991 "emphasis"><em>prefix</em></span>. e.g.</p>
1992 <pre class="screen">
1993 <code class="prompt">#</code> <strong class=
1994 "userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb --pkgsrcdir /Volumes/ufs/pkgsrc</code></strong>
1997 <p>If you created your partitions at the time of
1998 installing Mac OS X and formatted the target
1999 partition as UFS, it should automatically mount on
2001 "http://www.w3.org/TR/xhtml1/transitional" class=
2002 "filename">/Volumes/<volume name></code> when
2003 the machine boots. If you are (re)formatting a
2004 partition as UFS, you need to ensure that the
2005 partition map correctly reflects “<span class=
2006 "quote">Apple_UFS</span>” and not
2008 "quote">Apple_HFS</span>”.</p>
2010 <p>The problem is that none of the disk tools will
2011 let you touch a disk that is booted from. You can
2012 unmount the partition, but even if you newfs it, the
2013 partition type will be incorrect and the automounter
2014 won't mount it. It can be mounted manually, but it
2015 won't appear in Finder.</p>
2017 <p>You'll need to boot off of the OS X Installation
2018 (User) CD. When the Installation program starts, go
2019 up to the menu and select Disk Utility. Now, you will
2020 be able to select the partition you want to be UFS,
2021 and Format it Apple UFS. Quit the Disk Utility, quit
2022 the installer which will reboot your machine. The new
2023 UFS file system will appear in Finder.</p>
2025 <p>Be aware that the permissions on the new file
2026 system will be writable by root only.</p>
2028 <p>This note is as of 10.2 (Jaguar) and applies to
2029 earlier versions. Hopefully Apple will fix Disk
2030 Utility in 10.3 (Panther).</p>
2034 <div class="sect2" lang="en" xml:lang="en">
2035 <div class="titlepage">
2038 <h3 class="title"><a name="freebsd" id=
2039 "freebsd"></a>3.2.2. FreeBSD</h3>
2044 <p>FreeBSD 4.7 and 5.0 have been tested and are
2045 supported, other versions may work.</p>
2047 <p>Care should be taken so that the tools that this kit
2048 installs do not conflict with the FreeBSD userland
2049 tools. There are several steps:</p>
2051 <div class="orderedlist">
2054 <p>FreeBSD stores its ports pkg database in
2056 "http://www.w3.org/TR/xhtml1/transitional" class=
2057 "filename">/var/db/pkg</code>. It is therefore
2058 recommended that you choose a different location
2060 "http://www.w3.org/TR/xhtml1/transitional" class=
2061 "filename">/usr/pkgdb</code>) by using the
2062 --pkgdbdir option to the bootstrap script.</p>
2066 <p>If you do not intend to use the FreeBSD ports
2067 tools, it's probably a good idea to move them out
2068 of the way to avoid confusion, e.g.</p>
2069 <pre class="screen">
2070 <code class="prompt">#</code> <strong class=
2071 "userinput"><code>cd /usr/sbin</code></strong>
2072 <code class="prompt">#</code> <strong class=
2073 "userinput"><code>mv pkg_add pkg_add.orig</code></strong>
2074 <code class="prompt">#</code> <strong class=
2075 "userinput"><code>mv pkg_create pkg_create.orig</code></strong>
2076 <code class="prompt">#</code> <strong class=
2077 "userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
2078 <code class="prompt">#</code> <strong class=
2079 "userinput"><code>mv pkg_info pkg_info.orig</code></strong>
2084 <p>An example <code xmlns=
2085 "http://www.w3.org/TR/xhtml1/transitional" class=
2086 "filename">/etc/mk.conf</code> file will be
2087 placed in <code xmlns=
2088 "http://www.w3.org/TR/xhtml1/transitional" class=
2089 "filename">/etc/mk.conf.example</code> file when
2090 you use the bootstrap script.</p>
2096 <div class="sect2" lang="en" xml:lang="en">
2097 <div class="titlepage">
2100 <h3 class="title"><a name="interix" id=
2101 "interix"></a>3.2.3. Interix</h3>
2106 <p>Interix is a POSIX-compatible subsystem for the
2107 Windows NT kernel, providing a Unix-like environment
2108 with a tighter kernel integration than available with
2109 Cygwin. It is part of the Windows Services for Unix
2110 package, available for free for any licensed copy of
2111 Windows 2000, XP (not including XP Home), or 2003. SFU
2112 can be downloaded from <a href=
2113 "http://www.microsoft.com/windows/sfu/" target=
2114 "_top">http://www.microsoft.com/windows/sfu/</a>.</p>
2116 <p>Services for Unix 3.5, current as of this writing,
2117 has been tested. 3.0 or 3.1 may work, but are not
2118 officially supported. (The main difference in 3.0/3.1
2119 is lack of pthreads.)</p>
2121 <div class="sect3" lang="en" xml:lang="en">
2122 <div class="titlepage">
2125 <h4 class="title"><a name=
2126 "platform.interix-sfu-install" id=
2127 "platform.interix-sfu-install"></a>3.2.3.1. When
2128 installing Interix/SFU</h4>
2133 <p>At an absolute minimum, the following packages
2134 must be installed from the Windows Services for Unix
2135 3.5 distribution in order to use pkgsrc:</p>
2137 <div class="itemizedlist">
2140 <p>Utilities -> Base Utilities</p>
2144 <p>Interix GNU Components -> (all)</p>
2148 <p>Remote Connectivity</p>
2157 <p>When using pkgsrc on Interix, DO NOT install the
2158 Utilities subcomponent "UNIX Perl". That is Perl 5.6
2159 without shared module support, installed to
2160 /usr/local, and will only cause confusion. Instead,
2161 install Perl 5.8 from pkgsrc (or from a binary
2164 <p>The Remote Connectivity subcomponent "Windows
2165 Remote Shell Service" does not need to be installed,
2166 but Remote Connectivity itself should be installed in
2167 order to have a working inetd.</p>
2169 <p>Finally, during installation you may be asked
2170 whether to enable setuid behavior for Interix
2171 programs, and whether to make pathnames default to
2172 case-sensitive. Setuid should be enabled, and
2173 case-sensitivity MUST be enabled. (Without
2174 case-sensitivity, a large number of packages
2175 including perl will not build.)</p>
2178 <div class="sect3" lang="en" xml:lang="en">
2179 <div class="titlepage">
2182 <h4 class="title"><a name=
2183 "platform.interix-sfu-postinstall" id=
2184 "platform.interix-sfu-postinstall"></a>3.2.3.2. What
2185 to do if Interix/SFU is already installed</h4>
2190 <p>If SFU is already installed and you wish to alter
2191 these settings to work with pkgsrc, note the
2192 following things.</p>
2194 <div class="itemizedlist">
2197 <p>To uninstall UNIX Perl, use Add/Remove
2198 Programs, select Microsoft Windows Services for
2199 UNIX, then click Change. In the installer,
2200 choose Add or Remove, then uncheck
2201 Utilities->UNIX Perl.</p>
2205 <p>To enable case-sensitivity for the file
2206 system, run REGEDIT.EXE, and change the
2207 following registry key:</p>
2210 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
2213 <p>Set the DWORD value "obcaseinsensitive" to
2218 <p>To enable setuid binaries (optional), run
2219 REGEDIT.EXE, and change the following registry
2223 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services
2226 <p>Set the DWORD value "EnableSetuidBinaries"
2227 to 1; then reboot.</p>
2233 <div class="sect3" lang="en" xml:lang="en">
2234 <div class="titlepage">
2237 <h4 class="title"><a name=
2238 "platform.interix-notes" id=
2239 "platform.interix-notes"></a>3.2.3.3. Important
2240 notes for using pkgsrc</h4>
2245 <p>The package imanager (either the pkgsrc "su" user,
2246 or the user running "pkg_add") must be a member of
2247 the local Administrators group. Such a user must also
2248 be used to run the bootstrap. This is slightly
2249 relaxed from the normal pkgsrc requirement of
2252 <p>The package manager should use a umask of 002.
2253 "make install" will automatically complain if this is
2254 not the case. This ensures that directories written
2255 in /var/db/pkg are Administrators-group
2258 <p>The popular Interix binary packages from
2259 http://www.interopsystems.com/ use an older version
2260 of pkgsrc's pkg_* tools. Ideally, these should NOT be
2261 used in conjunction with pkgsrc. If you choose to use
2262 them at the same time as the pkgsrc packages, ensure
2263 that you use the proper pkg_* tools for each type of
2266 <p>The TERM setting used for DOS-type console windows
2267 (including those invoked by the csh and ksh startup
2268 shortcuts) is "interix". Most systems don't have a
2269 termcap/terminfo entry for it, but the following
2270 .termcap entry provides adequate emulation in most
2272 <pre class="programlisting">
2273 interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
2278 <div class="sect2" lang="en" xml:lang="en">
2279 <div class="titlepage">
2282 <h3 class="title"><a name="irix" id=
2283 "irix"></a>3.2.4. IRIX</h3>
2288 <p>You will need a working C compiler, either gcc or
2289 SGI's MIPS and MIPSpro compiler (cc/c89). Please set
2290 the <code class="varname">CC</code> environment
2291 variable according to your preference. If you do not
2292 have a license for the MIPSpro compiler suite, you can
2293 download a gcc tardist file from <a href=
2294 "http://freeware.sgi.com/" target=
2295 "_top">http://freeware.sgi.com/</a>.</p>
2297 <p>Please note that you will need IRIX 6.5.17 or
2298 higher, as this is the earliest version of IRIX
2299 providing support for <a href=
2300 "http://netbsd.gw.com/cgi-bin/man-cgi?if_indextoname+3+NetBSD-current">
2301 <span class="citerefentry"><span class=
2302 "refentrytitle">if_indextoname</span>(3)</span></a>,
2304 "http://netbsd.gw.com/cgi-bin/man-cgi?if_nametoindex+3+NetBSD-current">
2305 <span class="citerefentry"><span class=
2306 "refentrytitle">if_nametoindex</span>(3)</span></a>,
2309 <p>At this point in time, pkgsrc only supports one ABI
2310 at a time. That is, you can not switch between the old
2311 32-bit ABI, the new 32-bit ABI and the 64-bit ABI. If
2312 you start out using "abi=n32", that's what all your
2313 packages will be built with.</p>
2315 <p>Therefore, please make sure that you have no
2316 conflicting <code class="varname">CFLAGS</code> in your
2317 environment or the <code xmlns=
2318 "http://www.w3.org/TR/xhtml1/transitional" class=
2319 "filename">/etc/mk.conf</code>. Particularly, make sure
2320 that you do not try to link n32 object files with lib64
2321 or vice versa. Check your <code xmlns=
2322 "http://www.w3.org/TR/xhtml1/transitional" class=
2323 "filename">/etc/compiler.defaults</code>!</p>
2325 <p>If you have the actual pkgsrc tree mounted via NFS
2326 from a different host, please make sure to set
2327 <code class="varname">WRKOBJDIR</code> to a local
2328 directory, as it appears that IRIX linker occasionally
2329 runs into issues when trying to link over a
2330 network-mounted file system.</p>
2332 <p>The bootstrapping process should set all the right
2333 options for programs such as imake(1), but you may want
2334 to set some options depending on your local setup.
2335 Please see <code xmlns=
2336 "http://www.w3.org/TR/xhtml1/transitional" class=
2337 "filename">pkgsrc/mk/defaults/mk.conf</code> and, of
2338 course, your compiler's man pages for details.</p>
2340 <p>If you are using SGI's MIPSPro compiler, please
2342 <pre class="programlisting">
2343 PKGSRC_COMPILER= mipspro
2347 "http://www.w3.org/TR/xhtml1/transitional" class=
2348 "filename">/etc/mk.conf</code>. Otherwise, pkgsrc will
2349 assume you are using gcc and may end up passing invalid
2350 flags to the compiler. Note that bootstrap should
2351 create an appropriate <code xmlns=
2352 "http://www.w3.org/TR/xhtml1/transitional" class=
2353 "filename">mk.conf.example</code> by default.</p>
2355 <p>If you have both the MIPSPro compiler chain
2356 installed as well as gcc, but want to make sure that
2357 MIPRPro is used, please set your <code class=
2358 "varname">PATH</code> to <span class=
2359 "emphasis"><em>not</em></span> include the location of
2360 gcc (often <code xmlns=
2361 "http://www.w3.org/TR/xhtml1/transitional" class=
2362 "filename">/usr/freeware/bin</code>), and (important)
2363 pass the '--preserve-path' flag.</p>
2366 <div class="sect2" lang="en" xml:lang="en">
2367 <div class="titlepage">
2370 <h3 class="title"><a name="linux" id=
2371 "linux"></a>3.2.5. Linux</h3>
2376 <p>Some versions of Linux (for example Debian
2377 GNU/Linux) need either libtermcap or libcurses
2378 (libncurses). Installing the distributions
2379 libncurses-dev package (or equivalent) should fix the
2382 <p>pkgsrc supports both gcc (GNU Compiler Collection)
2383 and icc (Intel C++ Compiler). gcc is the default. icc
2384 8.0 and 8.1 on i386 have been tested.</p>
2386 <p>To bootstrap using icc, assuming the default icc
2387 installation directory:</p>
2388 <pre class="programlisting">
2389 env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
2390 ac_cv___attribute__=yes ./bootstrap
2393 <div class="note" style=
2394 "margin-left: 0.5in; margin-right: 0.5in;">
2395 <h3 class="title">Note</h3>
2397 <p>icc 8.1 needs the `-i-static' argument instead of
2401 <p>icc supports __attribute__, but the GNU configure
2402 test uses a nested function, which icc does not
2403 support. #undef'ing __attribute__ has the unfortunate
2404 side-effect of breaking many of the Linux header files,
2405 which cannot be compiled properly without
2406 __attribute__. The test must be overridden so that
2407 __attribute__ is assumed supported by the compiler.</p>
2409 <p>After bootstrapping, you should set <code class=
2410 "varname">PKGSRC_COMPILER</code> in <code xmlns=
2411 "http://www.w3.org/TR/xhtml1/transitional" class=
2412 "filename">/etc/mk.conf</code>:</p>
2413 <pre class="programlisting">
2414 PKGSRC_COMPILER= icc
2417 <p>The default installation directory for icc is
2418 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
2419 class="filename">/opt/intel_cc_80</code>, which is also
2420 the pkgsrc default. If you have installed it into a
2421 different directory, set <code class=
2422 "varname">ICCBASE</code> in <code xmlns=
2423 "http://www.w3.org/TR/xhtml1/transitional" class=
2424 "filename">/etc/mk.conf</code>:</p>
2425 <pre class="programlisting">
2429 <p>pkgsrc uses the static linking method of the runtime
2430 libraries provided by icc, so binaries can be run on
2431 other systems which do not have the shared libraries
2434 <p>Libtool, however, extracts a list of libraries from
2436 "http://netbsd.gw.com/cgi-bin/man-cgi?ld+1+NetBSD-current">
2437 <span class="citerefentry"><span class=
2438 "refentrytitle">ld</span>(1)</span></a> command run
2439 when linking a C++ shared library and records it,
2440 throwing away the -Bstatic and -Bdynamic options
2441 interspersed between the libraries. This means that
2442 libtool-linked C++ shared libraries will have a runtime
2443 dependency on the icc libraries until this is fixed in
2447 <div class="sect2" lang="en" xml:lang="en">
2448 <div class="titlepage">
2451 <h3 class="title"><a name="openbsd" id=
2452 "openbsd"></a>3.2.6. OpenBSD</h3>
2457 <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
2459 <p>Care should be taken so that the tools that this kit
2460 installs do not conflict with the OpenBSD userland
2461 tools. There are several steps:</p>
2463 <div class="orderedlist">
2466 <p>OpenBSD stores its ports pkg database in
2468 "http://www.w3.org/TR/xhtml1/transitional" class=
2469 "filename">/var/db/pkg</code>. It is therefore
2470 recommended that you choose a different location
2472 "http://www.w3.org/TR/xhtml1/transitional" class=
2473 "filename">/usr/pkgdb</code>) by using the
2474 --pkgdbdir option to the bootstrap script.</p>
2478 <p>If you do not intend to use the OpenBSD ports
2479 tools, it's probably a good idea to move them out
2480 of the way to avoid confusion, e.g.</p>
2481 <pre class="screen">
2482 <code class="prompt">#</code> <strong class=
2483 "userinput"><code>cd /usr/sbin</code></strong>
2484 <code class="prompt">#</code> <strong class=
2485 "userinput"><code>mv pkg_add pkg_add.orig</code></strong>
2486 <code class="prompt">#</code> <strong class=
2487 "userinput"><code>mv pkg_create pkg_create.orig</code></strong>
2488 <code class="prompt">#</code> <strong class=
2489 "userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
2490 <code class="prompt">#</code> <strong class=
2491 "userinput"><code>mv pkg_info pkg_info.orig</code></strong>
2496 <p>An example <code xmlns=
2497 "http://www.w3.org/TR/xhtml1/transitional" class=
2498 "filename">/etc/mk.conf</code> file will be
2499 placed in <code xmlns=
2500 "http://www.w3.org/TR/xhtml1/transitional" class=
2501 "filename">/etc/mk.conf.example</code> file when
2502 you use the bootstrap script. OpenBSD's make
2503 program uses <code xmlns=
2504 "http://www.w3.org/TR/xhtml1/transitional" class=
2505 "filename">/etc/mk.conf</code> as well. You can
2506 work around this by enclosing all the
2507 pkgsrc-specific parts of the file with:</p>
2508 <pre class="programlisting">
2510 # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
2520 <div class="sect2" lang="en" xml:lang="en">
2521 <div class="titlepage">
2524 <h3 class="title"><a name="solaris" id=
2525 "solaris"></a>3.2.7. Solaris</h3>
2530 <p>Solaris 2.6 through 9 are supported on both x86 and
2531 sparc. You will need a working C compiler. Both gcc
2532 2.95.3 and Sun WorkShop 5 have been tested.</p>
2534 <p>The following packages are required on Solaris 8 for
2535 the bootstrap process and to build packages.</p>
2537 <div class="itemizedlist">
2561 <p>Please note the use of GNU binutils on Solaris is
2562 <span class="emphasis"><em>not</em></span>
2565 <div class="sect3" lang="en" xml:lang="en">
2566 <div class="titlepage">
2569 <h4 class="title"><a name="solaris-gcc-note"
2570 id="solaris-gcc-note"></a>3.2.7.1. If you
2576 <p>It makes life much simpler if you only use the
2577 same gcc consistently for building all packages.</p>
2579 <p>It is recommended that an external gcc be used
2580 only for bootstrapping, then either build gcc from
2581 <a xmlns="http://www.w3.org/TR/xhtml1/transitional"
2583 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/lang/gcc/README.html"
2584 target="_top"><code xmlns="" class=
2585 "filename">lang/gcc</code></a> or install a binary
2586 gcc package, then remove gcc used during
2589 <p>Binary packages of gcc can be found through
2591 "http://www.sun.com/bigadmin/common/freewareSearch.html"
2593 "_top">http://www.sun.com/bigadmin/common/freewareSearch.html</a>.</p>
2596 <div class="sect3" lang="en" xml:lang="en">
2597 <div class="titlepage">
2600 <h4 class="title"><a name=
2601 "solaris-sun-workshop-note" id=
2602 "solaris-sun-workshop-note"></a>3.2.7.2. If
2603 you are using Sun WorkShop</h4>
2608 <p>You will need at least the following packages
2609 installed (from WorkShop 5.0)</p>
2611 <div class="itemizedlist">
2614 <p>SPROcc - Sun WorkShop Compiler C 5.0</p>
2618 <p>SPROcpl - Sun WorkShop Compiler C++ 5.0</p>
2622 <p>SPROild - Sun WorkShop Incremental
2627 <p>SPROlang - Sun WorkShop Compilers common
2633 <p>You should set <code class="varname">CC</code>,
2634 <code class="varname">CXX</code> and optionally,
2635 <code class="varname">CPP</code> in <code xmlns=
2636 "http://www.w3.org/TR/xhtml1/transitional" class=
2637 "filename">/etc/mk.conf</code>, e.g.:</p>
2638 <pre class="programlisting">
2641 CPP= /usr/ccs/lib/cpp
2644 <p>You may also want to build 64-bit binaries,
2646 <pre class="programlisting">
2647 CFLAGS= -xtarget=ultra -xarch=v9
2650 <p>Whichever compiler you use, please ensure the
2651 compiler tools and your $prefix are in your
2652 <code class="varname">PATH</code>. This includes
2654 "http://www.w3.org/TR/xhtml1/transitional" class=
2655 "filename">/usr/ccs/{bin,lib}</code> and e.g.
2657 "http://www.w3.org/TR/xhtml1/transitional" class=
2658 "filename">/usr/pkg/{bin,sbin}</code>.</p>
2664 <div class="chapter" lang="en" xml:lang="en">
2665 <div class="titlepage">
2668 <h2 class="title"><a name="using" id=
2669 "using"></a>Chapter 4. Using pkgsrc</h2>
2675 <p><b>Table of Contents</b></p>
2678 <dt><span class="sect1"><a href="#getting-started">4.1.
2679 Working with binary packages</a></span></dt>
2683 <dt><span class="sect2"><a href=
2684 "#where-to-get-binary-packages">4.1.1. Where to get
2685 binary packages</a></span></dt>
2687 <dt><span class="sect2"><a href=
2688 "#how-to-use-binary-packages">4.1.2. How to use
2689 binary packages</a></span></dt>
2691 <dt><span class="sect2"><a href=
2692 "#a-word-of-warning">4.1.3. A word of
2693 warning</a></span></dt>
2697 <dt><span class="sect1"><a href=
2698 "#building-packages-from-source">4.2. Building packages
2699 from source</a></span></dt>
2703 <dt><span class="sect2"><a href=
2704 "#requirements">4.2.1. Requirements</a></span></dt>
2706 <dt><span class="sect2"><a href=
2707 "#fetching-distfiles">4.2.2. Fetching
2708 distfiles</a></span></dt>
2710 <dt><span class="sect2"><a href=
2711 "#how-to-build-and-install">4.2.3. How to build and
2712 install</a></span></dt>
2714 <dt><span class="sect2"><a href=
2715 "#selecting-the-compiler">4.2.4. Selecting the
2716 compiler</a></span></dt>
2722 <div class="sect1" lang="en" xml:lang="en">
2723 <div class="titlepage">
2726 <h2 class="title" style="clear: both"><a name=
2727 "getting-started" id=
2728 "getting-started"></a>4.1. Working with binary
2734 <p>This section describes how to find, retrieve and
2735 install a precompiled binary package that someone else
2736 already prepared for your type of machine.</p>
2738 <div class="sect2" lang="en" xml:lang="en">
2739 <div class="titlepage">
2742 <h3 class="title"><a name=
2743 "where-to-get-binary-packages" id=
2744 "where-to-get-binary-packages"></a>4.1.1. Where
2745 to get binary packages</h3>
2750 <p>Precompiled packages are stored on ftp.NetBSD.org
2751 and its mirrors in the directory <code xmlns=
2752 "http://www.w3.org/TR/xhtml1/transitional" class=
2753 "filename">/pub/NetBSD/packages/<OSVERSION>/<ARCH>/</code>
2754 for anonymous FTP access. <code class=
2755 "varname">OSVERSION</code> is the NetBSD version
2756 (<span><strong class="command">uname
2757 -r</strong></span>), <code class="varname">ARCH</code>
2758 is the architecture (<span><strong class=
2759 "command">uname -p</strong></span>). In that directory,
2760 there is a subdirectory for each category plus a
2761 subdirectory <code xmlns=
2762 "http://www.w3.org/TR/xhtml1/transitional" class=
2763 "filename">All</code> which includes the actual
2764 binaries in <code xmlns=
2765 "http://www.w3.org/TR/xhtml1/transitional" class=
2766 "filename">.tgz</code> files. The category
2767 subdirectories use symbolic links to those files (this
2768 is the same directory layout as in <code xmlns=
2769 "http://www.w3.org/TR/xhtml1/transitional" class=
2770 "filename">/usr/pkgsrc/packages</code>).</p>
2772 <p>This same directory layout applies for CD-ROM
2773 distributions, only that the directory may be rooted
2774 somewhere else, probably somewhere below <code xmlns=
2775 "http://www.w3.org/TR/xhtml1/transitional" class=
2776 "filename">/cdrom</code>. Please consult your CD-ROMs
2777 documentation for the exact location.</p>
2780 <div class="sect2" lang="en" xml:lang="en">
2781 <div class="titlepage">
2784 <h3 class="title"><a name=
2785 "how-to-use-binary-packages" id=
2786 "how-to-use-binary-packages"></a>4.1.2. How
2787 to use binary packages</h3>
2792 <p>If you have the files on a CD-ROM or downloaded them
2793 to your hard disk, you can install them with the
2794 following command (be sure to <span><strong class=
2795 "command">su</strong></span> to root first):</p>
2796 <pre class="screen">
2797 <code class="prompt">#</code> <strong class=
2798 "userinput"><code>pkg_add /path/to/package.tgz</code></strong>
2801 <p>If you have FTP access and you don't want to
2802 download the packages via FTP prior to installation,
2803 you can do this automatically by giving
2804 <span><strong class="command">pkg_add</strong></span>
2806 <pre class="screen">
2807 <code class="prompt">#</code> <strong class=
2808 "userinput"><code>pkg_add ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/All/package.tgz</code></strong>
2811 <p>Note that any prerequisite packages needed to run
2812 the package in question will be installed, too,
2813 assuming they are present where you install from.</p>
2815 <p>To save some typing, you can set the <code class=
2816 "varname">PKG_PATH</code> environment variable to a
2817 semicolon-separated list of paths (including remote
2818 URLs); trailing slashes are not allowed.</p>
2820 <p>Additionally to the <code xmlns=
2821 "http://www.w3.org/TR/xhtml1/transitional" class=
2822 "filename">All</code> directory there exists a
2823 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
2824 class="filename">vulnerable</code> directory to which
2825 binary packages with known vulnerabilities are moved,
2826 since removing them could cause missing dependencies.
2827 To use these packages, add the <code xmlns=
2828 "http://www.w3.org/TR/xhtml1/transitional" class=
2829 "filename">vulnerable</code> directory to your
2830 <code class="varname">PKG_PATH</code>. However, you
2831 should run <a xmlns=
2832 "http://www.w3.org/TR/xhtml1/transitional" href=
2833 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html"
2834 target="_top"><code xmlns="" class=
2835 "filename">security/audit-packages</code></a>
2836 regularly, especially after installing new packages,
2837 and verify that the vulnerabilities are acceptable for
2838 your configuration. An example <code class=
2839 "varname">PKG_PATH</code> would be: <code xmlns=
2840 "http://www.w3.org/TR/xhtml1/transitional" class=
2841 "filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/All;ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/vulnerable</code>
2842 Please note that semicolon (';') is a shell
2843 meta-character, so you'll probably have to quote
2846 <p>After you've installed packages, be sure to have
2847 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
2848 class="filename">/usr/pkg/bin</code> and <code xmlns=
2849 "http://www.w3.org/TR/xhtml1/transitional" class=
2850 "filename">/usr/pkg/sbin</code> in your <code class=
2851 "varname">PATH</code> so you can actually start the
2852 just installed program.</p>
2855 <div class="sect2" lang="en" xml:lang="en">
2856 <div class="titlepage">
2859 <h3 class="title"><a name="a-word-of-warning" id=
2860 "a-word-of-warning"></a>4.1.3. A word of
2866 <p>Please pay very careful attention to the warnings
2867 expressed in the <a href=
2868 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current">
2869 <span class="citerefentry"><span class=
2870 "refentrytitle">pkg_add</span>(1)</span></a> manual
2871 page about the inherent dangers of installing binary
2872 packages which you did not create yourself, and the
2873 security holes that can be introduced onto your system
2874 by indiscriminate adding of such files.</p>
2878 <div class="sect1" lang="en" xml:lang="en">
2879 <div class="titlepage">
2882 <h2 class="title" style="clear: both"><a name=
2883 "building-packages-from-source" id=
2884 "building-packages-from-source"></a>4.2. Building
2885 packages from source</h2>
2890 <p>This assumes that the package is already in pkgsrc. If
2891 it is not, see <a href="#developers-guide" title=
2892 "Part II. The pkgsrc developer's guide">Part II,
2893 “The pkgsrc developer's guide”</a> for
2894 instructions how to create your own packages.</p>
2896 <div class="sect2" lang="en" xml:lang="en">
2897 <div class="titlepage">
2900 <h3 class="title"><a name="requirements" id=
2901 "requirements"></a>4.2.1. Requirements</h3>
2906 <p>To build packages from source on a NetBSD system the
2907 “<span class="quote">comp</span>” and the
2908 “<span class="quote">text</span>”
2909 distribution sets must be installed. If you want to
2910 build X11-related packages the “<span class=
2911 "quote">xbase</span>” and “<span class=
2912 "quote">xcomp</span>” distribution sets are
2916 <div class="sect2" lang="en" xml:lang="en">
2917 <div class="titlepage">
2920 <h3 class="title"><a name="fetching-distfiles"
2921 id="fetching-distfiles"></a>4.2.2. Fetching
2927 <p>The first step for building a package is downloading
2928 the distfiles (i.e. the unmodified source). If they
2929 have not yet been downloaded, pkgsrc will fetch them
2932 <p>You can overwrite some of the major distribution
2933 sites to fit to sites that are close to your own. Have
2934 a look at <code xmlns=
2935 "http://www.w3.org/TR/xhtml1/transitional" class=
2936 "filename">pkgsrc/mk/defaults/mk.conf</code> to find
2937 some examples — in particular, look for the
2938 <code class="varname">MASTER_SORT</code>, <code class=
2939 "varname">MASTER_SORT_REGEX</code> and <code class=
2940 "varname">INET_COUNTRY</code> definitions. This may
2941 save some of your bandwidth and time.</p>
2943 <p>You can change these settings either in your shell's
2944 environment, or, if you want to keep the settings, by
2945 editing the <code xmlns=
2946 "http://www.w3.org/TR/xhtml1/transitional" class=
2947 "filename">/etc/mk.conf</code> file, and adding the
2948 definitions there.</p>
2950 <p>If you don't have a permanent Internet connection
2951 and you want to know which files to download,
2952 <span><strong class="command">make
2953 fetch-list</strong></span> will tell you what you'll
2954 need. Put these distfiles into <code xmlns=
2955 "http://www.w3.org/TR/xhtml1/transitional" class=
2956 "filename">/usr/pkgsrc/distfiles</code>.</p>
2959 <div class="sect2" lang="en" xml:lang="en">
2960 <div class="titlepage">
2963 <h3 class="title"><a name=
2964 "how-to-build-and-install" id=
2965 "how-to-build-and-install"></a>4.2.3. How to
2966 build and install</h3>
2971 <p>Assuming that the distfile has been fetched (see
2972 previous section), become root and change into the
2973 relevant directory and run <span><strong class=
2974 "command">make</strong></span>.</p>
2976 <div class="note" style=
2977 "margin-left: 0.5in; margin-right: 0.5in;">
2978 <h3 class="title">Note</h3>
2980 <p>If using bootstrap or pkgsrc on a non-NetBSD
2981 system, use the pkgsrc <span><strong class=
2982 "command">bmake</strong></span> command instead of
2983 “<span class="quote">make</span>” in the
2984 examples in this guide.</p>
2987 <p>For example, type</p>
2988 <pre class="screen">
2989 <code class="prompt">%</code> <strong class=
2990 "userinput"><code>cd misc/figlet</code></strong>
2991 <code class="prompt">%</code> <strong class=
2992 "userinput"><code>make</code></strong>
2995 <p>at the shell prompt to build the various components
2996 of the package, and</p>
2997 <pre class="screen">
2998 <code class="prompt">#</code> <strong class=
2999 "userinput"><code>make install</code></strong>
3002 <p>to install the various components into the correct
3003 places on your system. Installing the package on your
3004 system requires you to be root. However, pkgsrc has a
3005 <span class="emphasis"><em>just-in-time-su</em></span>
3006 feature, which allows you to only become root for the
3007 actual installation step</p>
3009 <p>Taking the figlet utility as an example, we can
3010 install it on our system by building as shown in
3011 <a href="#logs" title=
3012 "Appendix B. Build logs">Appendix B, <i>Build
3015 <p>The program is installed under the default root of
3016 the packages tree - <code xmlns=
3017 "http://www.w3.org/TR/xhtml1/transitional" class=
3018 "filename">/usr/pkg</code>. Should this not conform to
3019 your tastes, set the <code class=
3020 "varname">LOCALBASE</code> variable in your
3021 environment, and it will use that value as the root of
3022 your packages tree. So, to use <code xmlns=
3023 "http://www.w3.org/TR/xhtml1/transitional" class=
3024 "filename">/usr/local</code>, set <code class=
3025 "varname">LOCALBASE=/usr/local</code> in your
3026 environment. Please note that you should use a
3027 directory which is dedicated to packages and not shared
3028 with other programs (i.e., do not try and use
3029 <code class="varname">LOCALBASE=/usr</code>). Also, you
3030 should not try to add any of your own files or
3031 directories (such as <code xmlns=
3032 "http://www.w3.org/TR/xhtml1/transitional" class=
3033 "filename">src/</code>, <code xmlns=
3034 "http://www.w3.org/TR/xhtml1/transitional" class=
3035 "filename">obj/</code>, or <code xmlns=
3036 "http://www.w3.org/TR/xhtml1/transitional" class=
3037 "filename">pkgsrc/</code>) below the <code class=
3038 "varname">LOCALBASE</code> tree. This is to prevent
3039 possible conflicts between programs and other files
3040 installed by the package system and whatever else may
3041 have been installed there.</p>
3043 <p>Some packages look in <code xmlns=
3044 "http://www.w3.org/TR/xhtml1/transitional" class=
3045 "filename">/etc/mk.conf</code> to alter some
3046 configuration options at build time. Have a look at
3047 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
3048 class="filename">pkgsrc/mk/defaults/mk.conf</code> to
3049 get an overview of what will be set there by default.
3050 Environment variables such as <code class=
3051 "varname">LOCALBASE</code> can be set in <code xmlns=
3052 "http://www.w3.org/TR/xhtml1/transitional" class=
3053 "filename">/etc/mk.conf</code> to save having to
3054 remember to set them each time you want to use
3057 <p>Occasionally, people want to “<span class=
3058 "quote">look under the covers</span>” to see what
3059 is going on when a package is building or being
3060 installed. This may be for debugging purposes, or out
3061 of simple curiosity. A number of utility values have
3062 been added to help with this.</p>
3064 <div class="orderedlist">
3067 <p>If you invoke the <a href=
3068 "http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current">
3069 <span class="citerefentry"><span class=
3070 "refentrytitle">make</span>(1)</span></a> command
3072 "varname">PKG_DEBUG_LEVEL=2</code>, then a huge
3073 amount of information will be displayed. For
3075 <pre class="screen">
3077 "userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong>
3080 <p>will show all the commands that are invoked,
3081 up to and including the “<span class=
3082 "quote">patch</span>” stage.</p>
3086 <p>If you want to know the value of a certain
3088 "http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current">
3089 <span class="citerefentry"><span class=
3090 "refentrytitle">make</span>(1)</span></a>
3091 definition, then the <code class=
3092 "varname">VARNAME</code> definition should be
3093 used, in conjunction with the show-var target.
3094 e.g. to show the expansion of the <a href=
3095 "http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current">
3096 <span class="citerefentry"><span class=
3097 "refentrytitle">make</span>(1)</span></a>
3098 variable <code class=
3099 "varname">LOCALBASE</code>:</p>
3100 <pre class="screen">
3101 <code class="prompt">%</code> <strong class=
3102 "userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
3104 <code class="prompt">%</code>
3111 <p>If you want to install a binary package that you've
3112 either created yourself (see next section), that you
3113 put into pkgsrc/packages manually or that is located on
3114 a remote FTP server, you can use the "bin-install"
3115 target. This target will install a binary package - if
3116 available - via <a href=
3117 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current">
3118 <span class="citerefentry"><span class=
3119 "refentrytitle">pkg_add</span>(1)</span></a>, else do a
3120 <span><strong class="command">make
3121 package</strong></span>. The list of remote FTP sites
3122 searched is kept in the variable <code class=
3123 "varname">BINPKG_SITES</code>, which defaults to
3124 ftp.NetBSD.org. Any flags that should be added to
3126 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current">
3127 <span class="citerefentry"><span class=
3128 "refentrytitle">pkg_add</span>(1)</span></a> can be put
3129 into <code class="varname">BIN_INSTALL_FLAGS</code>.
3131 "http://www.w3.org/TR/xhtml1/transitional" class=
3132 "filename">pkgsrc/mk/defaults/mk.conf</code> for more
3135 <p>A final word of warning: If you set up a system that
3136 has a non-standard setting for <code class=
3137 "varname">LOCALBASE</code>, be sure to set that before
3138 any packages are installed, as you can not use several
3139 directories for the same purpose. Doing so will result
3140 in pkgsrc not being able to properly detect your
3141 installed packages, and fail miserably. Note also that
3142 precompiled binary packages are usually built with the
3143 default <code class="varname">LOCALBASE</code> of
3144 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
3145 class="filename">/usr/pkg</code>, and that you should
3146 <span class="emphasis"><em>not</em></span> install any
3147 if you use a non-standard <code class=
3148 "varname">LOCALBASE</code>.</p>
3151 <div class="sect2" lang="en" xml:lang="en">
3152 <div class="titlepage">
3155 <h3 class="title"><a name=
3156 "selecting-the-compiler" id=
3157 "selecting-the-compiler"></a>4.2.4. Selecting
3163 <p>By default, pkgsrc will use GCC to build packages.
3164 This may be overridden by setting the following
3165 variables in /etc/mk.conf:</p>
3167 <div class="variablelist">
3169 <dt><span class="term"><code class=
3170 "varname">PKGSRC_COMPILER</code>:</span></dt>
3173 <p>This is a list of values specifying the chain
3174 of compilers to invoke when building packages.
3175 Valid values are:</p>
3177 <div class="itemizedlist">
3180 <p><code class="varname">distcc</code>:
3181 distributed C/C++ (chainable)</p>
3185 <p><code class="varname">ccache</code>:
3186 compiler cache (chainable)</p>
3190 <p><code class="varname">gcc</code>: GNU
3195 <p><code class="varname">mipspro</code>:
3196 Silicon Graphics, Inc. MIPSpro
3201 <p><code class="varname">mipspro</code>:
3202 Silicon Graphics, Inc. MIPSpro (o32)</p>
3206 <p><code class="varname">sunpro</code>:
3207 Microsystems, Inc. WorkShip/Forte/Sun ONE
3213 <p>The default is “<span class=
3214 "quote"><code class=
3215 "varname">gcc</code></span>”. You can use
3216 <code class="varname">ccache</code> and/or
3217 <code class="varname">distcc</code> with an
3218 appropriate <code class=
3219 "varname">PKGSRC_COMPILER</code> setting, e.g.
3220 “<span class="quote"><code class=
3221 "varname">ccache gcc</code></span>”. This
3222 variable should always be terminated with a value
3223 for a real compiler.</p>
3226 <dt><span class="term"><code class=
3227 "varname">GCC_REQD</code>:</span></dt>
3230 <p>This specifies the minimum version of GCC to
3231 use when building packages. If the system GCC
3232 doesn't satisfy this requirement, then pkgsrc
3233 will build and install one of the GCC packages to
3242 <div class="chapter" lang="en" xml:lang="en">
3243 <div class="titlepage">
3246 <h2 class="title"><a name="configuring" id=
3247 "configuring"></a>Chapter 5. Configuring
3254 <p><b>Table of Contents</b></p>
3257 <dt><span class="sect1"><a href=
3258 "#general-configuration">5.1. General
3259 configuration</a></span></dt>
3261 <dt><span class="sect1"><a href=
3262 "#variables-affecting-build">5.2. Variables affecting
3263 the build process</a></span></dt>
3265 <dt><span class="sect1"><a href=
3266 "#developer-advanced-settings">5.3. Developer/advanced
3267 settings</a></span></dt>
3269 <dt><span class="sect1"><a href=
3270 "#selecting-build-options">5.4. Selecting Build
3271 Options</a></span></dt>
3275 <div class="sect1" lang="en" xml:lang="en">
3276 <div class="titlepage">
3279 <h2 class="title" style="clear: both"><a name=
3280 "general-configuration" id=
3281 "general-configuration"></a>5.1. General
3287 <p>In this section, you can find some variables that
3288 apply to all pkgsrc packages. The preferred method of
3289 setting these variables is by setting them in
3290 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
3291 class="filename">/etc/mk.conf</code>.</p>
3293 <div class="itemizedlist">
3296 <p><code class="varname">LOCALBASE</code>: Where
3297 packages will be installed. The default is
3299 "http://www.w3.org/TR/xhtml1/transitional" class=
3300 "filename">/usr/pkg</code>. Do not mix binary
3301 packages with different <code class=
3302 "varname">LOCALBASE</code>s!</p>
3306 <p><code class="varname">CROSSBASE</code>: Where
3307 “<span class="quote">cross</span>”
3308 category packages will be installed. The default is
3310 "http://www.w3.org/TR/xhtml1/transitional" class=
3311 "filename">${LOCALBASE}/cross</code>.</p>
3315 <p><code class="varname">X11BASE</code>: Where X11
3316 is installed on the system. The default is
3318 "http://www.w3.org/TR/xhtml1/transitional" class=
3319 "filename">/usr/X11R6</code>.</p>
3323 <p><code class="varname">DISTDIR</code>: Where to
3324 store the downloaded copies of the original source
3325 distributions used for building pkgsrc packages.
3326 The default is <code xmlns=
3327 "http://www.w3.org/TR/xhtml1/transitional" class=
3328 "filename">${PKGSRCDIR}/distfiles</code>.</p>
3333 "varname">MASTER_SITE_OVERRIDE</code>: If set,
3334 override the packages' <code class=
3335 "varname">MASTER_SITES</code> with this value.</p>
3339 <p><code class="varname">MASTER_SITE_BACKUP</code>:
3340 Backup location(s) for distribution files and patch
3341 files if not found locally or in <code xmlns=
3342 "http://www.w3.org/TR/xhtml1/transitional" class=
3343 "filename">${MASTER_SITES}</code> or <code xmlns=
3344 "http://www.w3.org/TR/xhtml1/transitional" class=
3345 "filename">${PATCH_SITES}</code> respectively. The
3346 defaults are <code xmlns=
3347 "http://www.w3.org/TR/xhtml1/transitional" class=
3348 "filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
3350 "http://www.w3.org/TR/xhtml1/transitional" class=
3351 "filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p>
3355 <p><code class="varname">BINPKG_SITES</code>: List
3356 of sites carrying binary pkgs.</p>
3362 <div class="sect1" lang="en" xml:lang="en">
3363 <div class="titlepage">
3366 <h2 class="title" style="clear: both"><a name=
3367 "variables-affecting-build" id=
3368 "variables-affecting-build"></a>5.2. Variables
3369 affecting the build process</h2>
3376 <div class="itemizedlist">
3379 <p><code class="varname">PACKAGES</code>: The top
3380 level directory for the binary packages. The
3381 default is <code xmlns=
3382 "http://www.w3.org/TR/xhtml1/transitional" class=
3383 "filename">${PKGSRCDIR}/packages</code>.</p>
3387 <p><code class="varname">WRKOBJDIR</code>: The top
3388 level directory where, if defined, the separate
3389 working directories will get created, and
3390 symbolically linked to from <code xmlns=
3391 "http://www.w3.org/TR/xhtml1/transitional" class=
3392 "filename">${WRKDIR}</code> (see below). This is
3393 useful for building packages on several
3394 architectures, then <code xmlns=
3395 "http://www.w3.org/TR/xhtml1/transitional" class=
3396 "filename">${PKGSRCDIR}</code> can be NFS-mounted
3398 "http://www.w3.org/TR/xhtml1/transitional" class=
3399 "filename">${WRKOBJDIR}</code> is local to every
3400 architecture. (It should be noted that <code class=
3401 "varname">PKGSRCDIR</code> should not be set by the
3402 user — it is an internal definition which
3403 refers to the root of the pkgsrc tree. It is
3404 possible to have many pkgsrc tree instances.)</p>
3408 <p><code class="varname">LOCALPATCHES</code>:
3409 Directory for local patches that aren't part of
3410 pkgsrc. See <a href="#components.patches" title=
3411 "8.3. patches/*">Section 8.3,
3412 “patches/*”</a> for more information.
3413 <em class="replaceable"><code>rel</code></em> and
3414 <em class="replaceable"><code>arch</code></em> are
3415 replaced with OS release (“<span class=
3416 "quote">2.0</span>”, etc.) and architecture
3417 (“<span class="quote">mipsel</span>”,
3422 <p><code class="varname">PKGMAKECONF</code>:
3423 Location of the <code xmlns=
3424 "http://www.w3.org/TR/xhtml1/transitional" class=
3425 "filename">mk.conf</code> file used by a package's
3426 BSD-style Makefile. If this is not set,
3427 <code class="varname">MAKECONF</code> is set to
3429 "http://www.w3.org/TR/xhtml1/transitional" class=
3430 "filename">/dev/null</code> to avoid picking up
3431 settings used by builds in <code xmlns=
3432 "http://www.w3.org/TR/xhtml1/transitional" class=
3433 "filename">/usr/src</code>.</p>
3439 <div class="sect1" lang="en" xml:lang="en">
3440 <div class="titlepage">
3443 <h2 class="title" style="clear: both"><a name=
3444 "developer-advanced-settings" id=
3445 "developer-advanced-settings"></a>5.3. Developer/advanced
3453 <div class="itemizedlist">
3456 <p><code class="varname">PKG_DEVELOPER</code>: Run
3457 some sanity checks that package developers
3460 <div class="itemizedlist">
3463 <p>make sure patches apply with zero fuzz</p>
3467 <p>run check-shlibs to see that all binaries
3468 will find their shared libs.</p>
3475 <p><code class="varname">PKG_DEBUG_LEVEL</code>:
3476 The level of debugging output which is displayed
3477 whilst making and installing the package. The
3478 default value for this is 0, which will not display
3479 the commands as they are executed (normal, default,
3480 quiet operation); the value 1 will display all
3481 shell commands before their invocation, and the
3482 value 2 will display both the shell commands before
3483 their invocation, and their actual execution
3484 progress with <span><strong class="command">set
3485 -x</strong></span> will be displayed.</p>
3491 <div class="sect1" lang="en" xml:lang="en">
3492 <div class="titlepage">
3495 <h2 class="title" style="clear: both"><a name=
3496 "selecting-build-options" id=
3497 "selecting-build-options"></a>5.4. Selecting
3503 <p>Some packages have build time options, usually to
3504 select between different dependencies, enable optional
3505 support for big dependencies or enable experimental
3508 <p>To see which options, if any, a package supports, and
3509 which options are mutually exclusive, run
3510 <span><strong class="command">make
3511 show-options</strong></span>, for example:</p>
3512 <pre class="programlisting">
3513 The following options are supported by this package:
3514 ssl Enable SSL support.
3515 Exactly one of the following gecko options is required:
3516 firefox Use firefox as gecko rendering engine.
3517 mozilla Use mozilla as gecko rendering engine.
3518 At most one of the following database options may be selected:
3519 mysql Enable support for MySQL database.
3520 pgsql Enable support for PostgreSQL database.
3522 These options are enabled by default: firefox
3523 These options are currently enabled: mozilla ssl
3526 <p>The following variables can be defined in <code xmlns=
3527 "http://www.w3.org/TR/xhtml1/transitional" class=
3528 "filename">/etc/mk.conf</code> to select which options to
3529 enable for a package: <code class=
3530 "varname">PKG_DEFAULT_OPTIONS</code>, which can be used
3531 to select or disable options for all packages that
3532 support them, and <code class=
3533 "varname">PKG_OPTIONS.<em class=
3534 "replaceable"><code>pkgbase</code></em></code>, which can
3535 be used to select or disable options specifically for
3537 "replaceable"><code>pkgbase</code></em>. Options listed
3538 in these variables are selected, options preceded by
3539 “<span class="quote">-</span>” are
3542 <p>The following settings are consulted in the order
3543 given, and the last setting that selects or disables an
3546 <div class="orderedlist">
3549 <p>the default options as suggested by the package
3554 <p>the options implied by the settings of legacy
3555 variables (see below)</p>
3560 "varname">PKG_DEFAULT_OPTIONS</code></p>
3564 <p><code class="varname">PKG_OPTIONS.<em class=
3565 "replaceable"><code>pkgbase</code></em></code></p>
3570 <p>For groups of mutually exclusive options, the last
3571 option selected is used, all others are automatically
3572 disabled. If an option of the group is explicitly
3573 disabled, the previously selected option, if any, is
3574 used. It is an error if no option from a required group
3575 of options is selected, and building the package will
3578 <p>Before the options framework was introduced, build
3579 options were selected by setting a variable in
3580 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
3581 class="filename">/etc/mk.conf</code> for each option. To
3582 ease transition to the options framework for the user,
3583 these legacy variables are converted to the appropriate
3584 options setting automatically. A warning is issued to
3585 prompt the user to update <code xmlns=
3586 "http://www.w3.org/TR/xhtml1/transitional" class=
3587 "filename">/etc/mk.conf</code> to use the options
3588 framework directly. Support for these legacy variables
3589 will be removed eventually.</p>
3593 <div class="chapter" lang="en" xml:lang="en">
3594 <div class="titlepage">
3597 <h2 class="title"><a name="binary" id=
3598 "binary"></a>Chapter 6. Creating binary
3605 <p><b>Table of Contents</b></p>
3608 <dt><span class="sect1"><a href=
3609 "#building-a-single-binary-package">6.1. Building a
3610 single binary package</a></span></dt>
3612 <dt><span class="sect1"><a href=
3613 "#settings-for-creationg-of-binary-packages">6.2.
3614 Settings for creation of binary
3615 packages</a></span></dt>
3617 <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing
3618 a bulk build of all packages</a></span></dt>
3622 <dt><span class="sect2"><a href=
3623 "#binary.configuration">6.3.1.
3624 Configuration</a></span></dt>
3626 <dt><span class="sect2"><a href=
3627 "#other-environmental-considerations">6.3.2. Other
3628 environmental considerations</a></span></dt>
3630 <dt><span class="sect2"><a href="#operation">6.3.3.
3631 Operation</a></span></dt>
3633 <dt><span class="sect2"><a href=
3634 "#what-it-does">6.3.4. What it does</a></span></dt>
3636 <dt><span class="sect2"><a href=
3637 "#disk-space-requirements">6.3.5. Disk space
3638 requirements</a></span></dt>
3640 <dt><span class="sect2"><a href=
3641 "#setting-up-a-sandbox">6.3.6. Setting up a sandbox
3642 for chrooted builds</a></span></dt>
3644 <dt><span class="sect2"><a href=
3645 "#building-a-partial-set">6.3.7. Building a partial
3646 set of packages</a></span></dt>
3648 <dt><span class="sect2"><a href=
3649 "#bulk-upload">6.3.8. Uploading results of a bulk
3650 build</a></span></dt>
3654 <dt><span class="sect1"><a href="#creating-cdroms">6.4.
3655 Creating a multiple CD-ROM packages
3656 collection</a></span></dt>
3660 <dt><span class="sect2"><a href=
3661 "#cdpack-example">6.4.1. Example of
3662 cdpack</a></span></dt>
3668 <div class="sect1" lang="en" xml:lang="en">
3669 <div class="titlepage">
3672 <h2 class="title" style="clear: both"><a name=
3673 "building-a-single-binary-package" id=
3674 "building-a-single-binary-package"></a>6.1. Building
3675 a single binary package</h2>
3680 <p>Once you have built and installed a package, you can
3681 create a <span class="emphasis"><em>binary
3682 package</em></span> which can be installed on another
3683 system with <a href=
3684 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current">
3685 <span class="citerefentry"><span class=
3686 "refentrytitle">pkg_add</span>(1)</span></a>. This saves
3687 having to build the same package on a group of hosts and
3688 wasting CPU time. It also provides a simple means for
3689 others to install your package, should you distribute
3692 <p>To create a binary package, change into the
3693 appropriate directory in pkgsrc, and run
3694 <span><strong class="command">make
3695 package</strong></span>:</p>
3696 <pre class="screen">
3697 <code class="prompt">#</code> <strong class=
3698 "userinput"><code>cd misc/figlet</code></strong>
3699 <code class="prompt">#</code> <strong class=
3700 "userinput"><code>make package</code></strong>
3703 <p>This will build and install your package (if not
3704 already done), and then build a binary package from what
3705 was installed. You can then use the <span><strong class=
3706 "command">pkg_*</strong></span> tools to manipulate it.
3707 Binary packages are created by default in <code xmlns=
3708 "http://www.w3.org/TR/xhtml1/transitional" class=
3709 "filename">/usr/pkgsrc/packages</code>, in the form of a
3710 gzipped tar file. See <a href="#logs.package" title=
3711 "B.2. Packaging figlet">Section B.2,
3712 “Packaging figlet”</a> for a continuation of
3714 "http://www.w3.org/TR/xhtml1/transitional" href=
3715 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/misc/figlet/README.html"
3716 target="_top"><code xmlns="" class=
3717 "filename">misc/figlet</code></a> example.</p>
3719 <p>See <a href="#submit" title=
3720 "Chapter 17. Submitting and Committing">Chapter
3721 17, <i>Submitting and Committing</i></a> for information
3722 on how to submit such a binary package.</p>
3725 <div class="sect1" lang="en" xml:lang="en">
3726 <div class="titlepage">
3729 <h2 class="title" style="clear: both"><a name=
3730 "settings-for-creationg-of-binary-packages" id=
3731 "settings-for-creationg-of-binary-packages"></a>6.2. Settings
3732 for creation of binary packages</h2>
3737 <p>See <a href="#build.helpful-targets" title=
3738 "14.3. Other helpful targets">Section 14.3,
3739 “Other helpful targets”</a>.</p>
3742 <div class="sect1" lang="en" xml:lang="en">
3743 <div class="titlepage">
3746 <h2 class="title" style="clear: both"><a name=
3747 "bulkbuild" id="bulkbuild"></a>6.3. Doing a
3748 bulk build of all packages</h2>
3753 <p>If you want to get a full set of precompiled binary
3754 packages, this section describes how to get them. Beware
3755 that the bulk build will remove all currently installed
3756 packages from your system! Having an FTP server
3757 configured either on the machine doing the bulk builds or
3758 on a nearby NFS server can help to make the packages
3759 available to everyone. See <a href=
3760 "http://netbsd.gw.com/cgi-bin/man-cgi?ftpd+8+NetBSD-current">
3761 <span class="citerefentry"><span class=
3762 "refentrytitle">ftpd</span>(8)</span></a> for more
3763 information. If you use a remote NFS server's storage, be
3764 sure to not actually compile on NFS storage, as this
3765 slows things down a lot.</p>
3767 <div class="sect2" lang="en" xml:lang="en">
3768 <div class="titlepage">
3771 <h3 class="title"><a name="binary.configuration"
3773 "binary.configuration"></a>6.3.1. Configuration</h3>
3778 <div class="sect3" lang="en" xml:lang="en">
3779 <div class="titlepage">
3782 <h4 class="title"><a name="binary.mk.conf" id=
3783 "binary.mk.conf"></a>6.3.1.1. /etc/mk.conf</h4>
3788 <p>You may want to set variables in <code xmlns=
3789 "http://www.w3.org/TR/xhtml1/transitional" class=
3790 "filename">/etc/mk.conf</code>. Look at <code xmlns=
3791 "http://www.w3.org/TR/xhtml1/transitional" class=
3792 "filename">pkgsrc/mk/defaults/mk.conf</code> for
3793 details of the default settings. You will want to
3794 ensure that <code class=
3795 "varname">ACCEPTABLE_LICENSES</code> meet your local
3796 policy. As used in this example, <code class=
3797 "varname">_ACCEPTABLE=yes</code> accepts <span class=
3798 "emphasis"><em>all</em></span> licenses.</p>
3799 <pre class="programlisting">
3800 PACKAGES?= ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
3801 WRKOBJDIR?= /usr/tmp/pkgsrc # build here instead of in pkgsrc
3803 BSDXSRCDIR= /usr/xsrc # for x11/xservers
3804 OBJHOSTNAME?= yes # use work.`hostname`
3805 FAILOVER_FETCH= yes # insist on the correct checksum
3811 <div class="sect3" lang="en" xml:lang="en">
3812 <div class="titlepage">
3815 <h4 class="title"><a name="build.conf" id=
3816 "build.conf"></a>6.3.1.2. <code xmlns=
3817 "http://www.w3.org/TR/xhtml1/transitional"
3818 class="filename">build.conf</code></h4>
3824 "http://www.w3.org/TR/xhtml1/transitional" class=
3825 "filename">pkgsrc/mk/bulk</code>, copy <code xmlns=
3826 "http://www.w3.org/TR/xhtml1/transitional" class=
3827 "filename">build.conf-example</code> to <code xmlns=
3828 "http://www.w3.org/TR/xhtml1/transitional" class=
3829 "filename">build.conf</code> and edit it, following
3830 the comments in that file. This is the config file
3831 that determines where log files are generated after
3832 the build, where to mail the build report to, where
3833 your pkgsrc tree is located and the user to which
3835 "http://netbsd.gw.com/cgi-bin/man-cgi?su+8+NetBSD-current">
3836 <span class="citerefentry"><span class=
3837 "refentrytitle">su</span>(8)</span></a> to do a
3838 <span><strong class="command">cvs
3839 update</strong></span>.</p>
3842 <div class="sect3" lang="en" xml:lang="en">
3843 <div class="titlepage">
3846 <h4 class="title"><a name="pre-build.local" id=
3847 "pre-build.local"></a>6.3.1.3. <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
3848 class="filename">pre-build.local</code></h4>
3853 <p>It is possible to configure the bulk build to
3854 perform certain site-specific tasks at the end of the
3855 pre-build stage. If the file <code xmlns=
3856 "http://www.w3.org/TR/xhtml1/transitional" class=
3857 "filename">pre-build.local</code> exists in
3859 "http://www.w3.org/TR/xhtml1/transitional" class=
3860 "filename">/usr/pkgsrc/mk/bulk</code>, it will be
3861 executed (as a <a href=
3862 "http://netbsd.gw.com/cgi-bin/man-cgi?sh+1+NetBSD-current">
3863 <span class="citerefentry"><span class=
3864 "refentrytitle">sh</span>(1)</span></a> script) at
3865 the end of the usual pre-build stage. An example use
3867 "http://www.w3.org/TR/xhtml1/transitional" class=
3868 "filename">pre-build.local</code> is to have the
3870 <pre class="screen">
3871 <code class="prompt">#</code> <strong class=
3872 "userinput"><code>echo "I do not have enough disk space to build this pig." \
3873 > pkgsrc/misc/openoffice/$BROKENF</code></strong>
3876 <p>to prevent the system from trying to build a
3877 particular package which requires nearly 3 GB of disk
3882 <div class="sect2" lang="en" xml:lang="en">
3883 <div class="titlepage">
3886 <h3 class="title"><a name=
3887 "other-environmental-considerations" id=
3888 "other-environmental-considerations"></a>6.3.2. Other
3889 environmental considerations</h3>
3895 "http://www.w3.org/TR/xhtml1/transitional" class=
3896 "filename">/usr/pkg</code> will be completely deleted
3897 at the start of bulk builds, make sure your login shell
3898 is placed somewhere else. Either drop it into
3899 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
3900 class="filename">/usr/local/bin</code> (and adjust your
3901 login shell in the passwd file), or (re-)install it via
3903 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current">
3904 <span class="citerefentry"><span class=
3905 "refentrytitle">pkg_add</span>(1)</span></a> from
3906 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
3907 class="filename">/etc/rc.local</code>, so you can login
3908 after a reboot (remember that your current process
3909 won't die if the package is removed, you just can't
3910 start any new instances of the shell any more). Also,
3911 if you use NetBSD earlier than 1.5, or you still want
3912 to use the pkgsrc version of ssh for some reason, be
3913 sure to install ssh before starting it from
3914 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
3915 class="filename">rc.local</code>:</p>
3916 <pre class="programlisting">
3917 ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
3918 if [ -f /usr/pkg/etc/rc.d/sshd ]; then
3919 /usr/pkg/etc/rc.d/sshd
3923 <p>Not doing so will result in you being not able to
3924 log in via ssh after the bulk build is finished or if
3925 the machine gets rebooted or crashes. You have been
3929 <div class="sect2" lang="en" xml:lang="en">
3930 <div class="titlepage">
3933 <h3 class="title"><a name="operation" id=
3934 "operation"></a>6.3.3. Operation</h3>
3939 <p>Make sure you don't need any of the packages still
3942 <div class="warning" style=
3943 "margin-left: 0.5in; margin-right: 0.5in;">
3944 <h3 class="title">Warning</h3>
3946 <p>During the bulk build, <span class=
3947 "emphasis"><em>all packages will be
3948 removed!</em></span></p>
3951 <p>Be sure to remove all other things that might
3952 interfere with builds, like some libs installed in
3953 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
3954 class="filename">/usr/local</code>, etc. then become
3956 <pre class="screen">
3957 <code class="prompt">#</code> <strong class=
3958 "userinput"><code>cd /usr/pkgsrc</code></strong>
3959 <code class="prompt">#</code> <strong class=
3960 "userinput"><code>sh mk/bulk/build</code></strong>
3963 <p>If for some reason your last build didn't complete
3964 (power failure, system panic, ...), you can continue it
3966 <pre class="screen">
3967 <code class="prompt">#</code> <strong class=
3968 "userinput"><code>sh mk/bulk/build restart</code></strong>
3971 <p>At the end of the bulk build, you will get a summary
3972 via mail, and find build logs in the directory
3973 specified by <code class="varname">FTP</code> in the
3974 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
3975 class="filename">build.conf</code> file.</p>
3978 <div class="sect2" lang="en" xml:lang="en">
3979 <div class="titlepage">
3982 <h3 class="title"><a name="what-it-does" id=
3983 "what-it-does"></a>6.3.4. What it does</h3>
3988 <p>The bulk builds consist of three steps:</p>
3990 <div class="variablelist">
3992 <dt><span class="term">1. pre-build</span></dt>
3995 <p>The script updates your pkgsrc tree via
3996 (anon)cvs, then cleans out any broken distfiles,
3997 and removes all packages installed.</p>
4000 <dt><span class="term">2. the bulk
4004 <p>This is basically “<span class=
4005 "quote">make bulk-package</span>” with an
4006 optimised order in which packages will be built.
4007 Packages that don't require other packages will
4008 be built first, and packages with many
4009 dependencies will be built later.</p>
4012 <dt><span class="term">3. post-build</span></dt>
4015 <p>Generates a report that's placed in the
4016 directory specified in the <code xmlns=
4017 "http://www.w3.org/TR/xhtml1/transitional" class=
4018 "filename">build.conf</code> file named
4020 "http://www.w3.org/TR/xhtml1/transitional" class=
4021 "filename">broken.html</code>, a short version of
4022 that report will also be mailed to the build's
4028 <p>During the build, a list of broken packages will be
4029 compiled in <code xmlns=
4030 "http://www.w3.org/TR/xhtml1/transitional" class=
4031 "filename">/usr/pkgsrc/.broken</code> (or <code xmlns=
4032 "http://www.w3.org/TR/xhtml1/transitional" class=
4033 "filename">.../.broken.${MACHINE}</code> if
4034 <code class="varname">OBJMACHINE</code> is set),
4035 individual build logs of broken builds can be found in
4036 the package's directory. These files are used by the
4037 bulk-targets to mark broken builds to not waste time
4038 trying to rebuild them, and they can be used to debug
4039 these broken package builds later.</p>
4042 <div class="sect2" lang="en" xml:lang="en">
4043 <div class="titlepage">
4046 <h3 class="title"><a name=
4047 "disk-space-requirements" id=
4048 "disk-space-requirements"></a>6.3.5. Disk
4049 space requirements</h3>
4054 <p>Currently, roughly the following requirements are
4055 valid for NetBSD 2.0/i386:</p>
4057 <div class="itemizedlist">
4060 <p>10 GB - distfiles (NFS ok)</p>
4064 <p>8 GB - full set of all binaries (NFS ok)</p>
4068 <p>5 GB - temp space for compiling (local disk
4074 <p>Note that all pkgs will be de-installed as soon as
4075 they are turned into a binary package, and that sources
4076 are removed, so there is no excessively huge demand to
4077 disk space. Afterwards, if the package is needed again,
4078 it will be installed via <a href=
4079 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current">
4080 <span class="citerefentry"><span class=
4081 "refentrytitle">pkg_add</span>(1)</span></a> instead of
4082 building again, so there are no cycles wasted by
4086 <div class="sect2" lang="en" xml:lang="en">
4087 <div class="titlepage">
4090 <h3 class="title"><a name="setting-up-a-sandbox"
4091 id="setting-up-a-sandbox"></a>6.3.6. Setting
4092 up a sandbox for chrooted builds</h3>
4097 <p>If you don't want all the packages nuked from a
4098 machine (rendering it useless for anything but pkg
4099 compiling), there is the possibility of doing the
4100 package bulk build inside a chroot environment.</p>
4102 <p>The first step is to set up a chroot sandbox, e.g.
4103 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
4104 class="filename">/usr/sandbox</code>. This can be done
4105 by using null mounts, or manually.</p>
4107 <p>There is a shell script called <code xmlns=
4108 "http://www.w3.org/TR/xhtml1/transitional" class=
4109 "filename">pkgsrc/mk/bulk/mksandbox</code> which will
4110 set up the sandbox environment using null mounts. It
4111 will also create a script called <code xmlns=
4112 "http://www.w3.org/TR/xhtml1/transitional" class=
4113 "filename">sandbox</code> in the root of the sandbox
4114 environment, which will allow the null mounts to be
4115 activated using the <span><strong class=
4116 "command">sandbox mount</strong></span> command and
4117 deactivated using the <span><strong class=
4118 "command">sandbox umount</strong></span> command.</p>
4120 <p>To set up a sandbox environment by hand, after
4121 extracting all the sets from a NetBSD installation or
4122 doing a <span><strong class="command">make distribution
4123 DESTDIR=/usr/sandbox</strong></span> in <code xmlns=
4124 "http://www.w3.org/TR/xhtml1/transitional" class=
4125 "filename">/usr/src/etc</code>, be sure the following
4126 items are present and properly configured:</p>
4128 <div class="procedure">
4132 <pre class="screen">
4133 <code class="prompt">#</code> <strong class=
4134 "userinput"><code>cp /netbsd /usr/sandbox</code></strong>
4140 "http://www.w3.org/TR/xhtml1/transitional" class=
4141 "filename">/dev/*</code></p>
4142 <pre class="screen">
4143 <code class="prompt">#</code> <strong class=
4144 "userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong>
4150 "http://www.w3.org/TR/xhtml1/transitional" class=
4151 "filename">/etc/resolv.conf</code> (for <a xmlns=
4152 "http://www.w3.org/TR/xhtml1/transitional" href=
4153 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/smtpd/README.html"
4154 target="_top"><code xmlns="" class=
4155 "filename">security/smtpd</code></a> and
4157 <pre class="screen">
4158 <code class="prompt">#</code> <strong class=
4159 "userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong>
4164 <p>Working(!) mail config (hostname,
4166 <pre class="screen">
4167 <code class="prompt">#</code> <strong class=
4168 "userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong>
4174 "http://www.w3.org/TR/xhtml1/transitional" class=
4175 "filename">/etc/localtime</code> (for <a xmlns=
4176 "http://www.w3.org/TR/xhtml1/transitional" href=
4177 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/smtpd/README.html"
4178 target="_top"><code xmlns="" class=
4179 "filename">security/smtpd</code></a>):</p>
4180 <pre class="screen">
4181 <code class="prompt">#</code> <strong class=
4182 "userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong>
4188 "http://www.w3.org/TR/xhtml1/transitional" class=
4189 "filename">/usr/src</code> (system sources, for
4191 "http://www.w3.org/TR/xhtml1/transitional" href=
4192 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/sysutils/aperture/README.html"
4193 target="_top"><code xmlns="" class=
4194 "filename">sysutils/aperture</code></a>,
4195 <a xmlns="http://www.w3.org/TR/xhtml1/transitional"
4197 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/net/ppp-mppe/README.html"
4198 target="_top"><code xmlns="" class=
4199 "filename">net/ppp-mppe</code></a>):</p>
4200 <pre class="screen">
4201 <code class="prompt">#</code> <strong class=
4202 "userinput"><code>ln -s ../disk1/cvs .</code></strong>
4203 <code class="prompt">#</code> <strong class=
4204 "userinput"><code>ln -s cvs/src-2.0 src</code></strong>
4209 <p>Create <code xmlns=
4210 "http://www.w3.org/TR/xhtml1/transitional" class=
4211 "filename">/var/db/pkg</code> (not part of
4212 default install):</p>
4213 <pre class="screen">
4214 <code class="prompt">#</code> <strong class=
4215 "userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong>
4220 <p>Create <code xmlns=
4221 "http://www.w3.org/TR/xhtml1/transitional" class=
4222 "filename">/usr/pkg</code> (not part of default
4224 <pre class="screen">
4225 <code class="prompt">#</code> <strong class=
4226 "userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong>
4231 <p>Checkout pkgsrc via cvs into <code xmlns=
4232 "http://www.w3.org/TR/xhtml1/transitional" class=
4233 "filename">/usr/sandbox/usr/pkgsrc</code>:</p>
4234 <pre class="screen">
4235 <code class="prompt">#</code> <strong class=
4236 "userinput"><code>cd /usr/sandbox/usr</code></strong>
4237 <code class="prompt">#</code> <strong class=
4238 "userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong>
4241 <p>Do not mount/link this to the copy of your
4242 pkgsrc tree you do development in, as this will
4243 likely cause problems!</p>
4247 <p>Make <code xmlns=
4248 "http://www.w3.org/TR/xhtml1/transitional" class=
4249 "filename">/usr/sandbox/usr/pkgsrc/packages</code>
4251 "http://www.w3.org/TR/xhtml1/transitional" class=
4252 "filename">.../distfiles</code> point somewhere
4253 appropriate. NFS- and/or nullfs-mounts may come
4258 <p>Edit <code xmlns=
4259 "http://www.w3.org/TR/xhtml1/transitional" class=
4260 "filename">/etc/mk.conf</code>, see <a href=
4261 "#binary.mk.conf" title=
4262 "6.3.1.1. /etc/mk.conf">Section 6.3.1.1,
4263 “/etc/mk.conf”</a>.</p>
4267 <p>Adjust <code xmlns=
4268 "http://www.w3.org/TR/xhtml1/transitional" class=
4269 "filename">mk/bulk/build.conf</code> to suit your
4274 <p>If you have set <code class=
4275 "varname">CVS_USER</code> in <code xmlns=
4276 "http://www.w3.org/TR/xhtml1/transitional" class=
4277 "filename">build.conf</code>, make sure that
4278 account exists and can do a <span><strong class=
4279 "command">cvs ${CVS_FLAGS} update</strong></span>
4285 <p>When the chroot sandbox is set up, you can start the
4286 build with the following steps:</p>
4287 <pre class="screen">
4288 <code class="prompt">#</code> <strong class=
4289 "userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
4290 <code class="prompt">#</code> <strong class=
4291 "userinput"><code>sh mk/bulk/do-sandbox-build</code></strong>
4294 <p>This will just jump inside the sandbox and start
4295 building. At the end of the build, mail will be sent
4296 with the results of the build. Created binary pkgs will
4298 "http://www.w3.org/TR/xhtml1/transitional" class=
4299 "filename">/usr/sandbox/usr/pkgsrc/packages</code>
4300 (wherever that points/mounts to/from).</p>
4303 <div class="sect2" lang="en" xml:lang="en">
4304 <div class="titlepage">
4307 <h3 class="title"><a name=
4308 "building-a-partial-set" id=
4309 "building-a-partial-set"></a>6.3.7. Building
4310 a partial set of packages</h3>
4315 <p>In addition to building a complete set of all
4316 packages in pkgsrc, the <code xmlns=
4317 "http://www.w3.org/TR/xhtml1/transitional" class=
4318 "filename">pkgsrc/mk/bulk/build</code> script may be
4319 used to build a subset of the packages contained in
4320 pkgsrc. By setting <code class=
4321 "varname">SPECIFIC_PKGS</code> in <code xmlns=
4322 "http://www.w3.org/TR/xhtml1/transitional" class=
4323 "filename">/etc/mk.conf</code>, the variables</p>
4325 <div class="itemizedlist">
4328 <p>SITE_SPECIFIC_PKGS</p>
4332 <p>HOST_SPECIFIC_PKGS</p>
4336 <p>GROUP_SPECIFIC_PKGS</p>
4340 <p>USER_SPECIFIC_PKGS</p>
4345 <p>will define the set of packages which should be
4346 built. The bulk build code will also include any
4347 packages which are needed as dependencies for the
4348 explicitly listed packages.</p>
4350 <p>One use of this is to do a bulk build with
4351 <code class="varname">SPECIFIC_PKGS</code> in a chroot
4352 sandbox periodically to have a complete set of the
4353 binary packages needed for your site available without
4354 the overhead of building extra packages that are not
4358 <div class="sect2" lang="en" xml:lang="en">
4359 <div class="titlepage">
4362 <h3 class="title"><a name="bulk-upload" id=
4363 "bulk-upload"></a>6.3.8. Uploading results
4364 of a bulk build</h3>
4369 <p>This section describes how pkgsrc developers can
4370 upload binary pkgs built by bulk builds to
4373 <p>If you would like to automatically create checksum
4374 files for the binary packages you intend to upload,
4375 remember to set <code class="varname">MKSUMS=yes</code>
4376 in your <code xmlns=
4377 "http://www.w3.org/TR/xhtml1/transitional" class=
4378 "filename">mk/bulk/build.conf</code>.</p>
4380 <p>If you would like to PGP sign the checksum files
4381 (highly recommended!), remember to set <code class=
4382 "varname">SIGN_AS=username@NetBSD.org</code> in your
4383 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
4384 class="filename">mk/bulk/build.conf</code>. This will
4385 prompt you for your GPG password to sign the files
4386 before uploading everything.</p>
4388 <p>Then, make sure that you have <code class=
4389 "varname">RSYNC_DST</code> set properly in your
4390 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
4391 class="filename">mk/bulk/build.conf</code> file, i.e.
4392 adjust it to something like one of the following:</p>
4393 <pre class="screen">
4394 RSYNC_DST=$CVS_USER@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload
4397 <p>Please use appropriate values for "pkgsrc-200xQy",
4398 "NetBSD-a.b.c" and "arch" here. If your login on
4399 ftp.NetBSD.org is different from <code class=
4400 "varname">CVS_USER</code>, write your login directly
4401 into the variable, e.g. my local account is "feyrer",
4402 but for my login "hubertf", I use:</p>
4403 <pre class="screen">
4404 RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload
4407 <p>A separate <code xmlns=
4408 "http://www.w3.org/TR/xhtml1/transitional" class=
4409 "filename">upload</code> directory is used here to
4410 allow "closing" the directory during upload. To do so,
4411 run the following command on ftp.NetBSD.org next:</p>
4412 <pre class="screen">
4413 nbftp% <strong class=
4414 "userinput"><code>mkdir -p -m 750 /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload</code></strong>
4417 <p>Please note that <code xmlns=
4418 "http://www.w3.org/TR/xhtml1/transitional" class=
4419 "filename">/pub/NetBSD/packages</code> is only
4420 appropriate for packages for the NetBSD operating
4421 system. Binary packages for other operating systems
4422 should go into <code xmlns=
4423 "http://www.w3.org/TR/xhtml1/transitional" class=
4424 "filename">/pub/pkgsrc</code>.</p>
4426 <p>Before uploading the binary pkgs, ssh authentication
4427 needs to be set up. This example shows how to set up
4428 temporary keys for the root account <span class=
4429 "emphasis"><em>inside the sandbox</em></span> (assuming
4430 that no keys should be present there usually):</p>
4431 <pre class="screen">
4432 <code class="prompt">#</code> <strong class=
4433 "userinput"><code>chroot /usr/sandbox</code></strong>
4434 chroot-<code class="prompt">#</code> <strong class=
4435 "userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
4436 chroot-<code class="prompt">#</code> <strong class=
4437 "userinput"><code>ssh-keygen -t dsa</code></strong>
4438 chroot-<code class="prompt">#</code> <strong class=
4439 "userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong>
4442 <p>Now take the output of <code xmlns=
4443 "http://www.w3.org/TR/xhtml1/transitional" class=
4444 "filename">id-dsa.pub</code> and append it to your
4445 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
4446 class="filename">~/.ssh/authorized_keys</code> file on
4447 ftp.NetBSD.org. You can remove the key after the upload
4450 <p>Next, test if your ssh connection really works:</p>
4451 <pre class="screen">
4452 chroot-<code class="prompt">#</code> <strong class=
4453 "userinput"><code>ssh ftp.NetBSD.org date</code></strong>
4456 <p>Use "-l yourNetBSDlogin" here as appropriate!</p>
4458 <p>Now after all this works, you can exit the sandbox
4459 and start the upload:</p>
4460 <pre class="screen">
4461 chroot-<code class="prompt">#</code> <strong class=
4462 "userinput"><code>exit</code></strong>
4463 <code class="prompt">#</code> <strong class=
4464 "userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
4465 <code class="prompt">#</code> <strong class=
4466 "userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong>
4469 <p>The upload process may take quite some time. Use
4471 "http://netbsd.gw.com/cgi-bin/man-cgi?ls+1+NetBSD-current">
4472 <span class="citerefentry"><span class=
4473 "refentrytitle">ls</span>(1)</span></a> or <a href=
4474 "http://netbsd.gw.com/cgi-bin/man-cgi?du+1+NetBSD-current">
4475 <span class="citerefentry"><span class=
4476 "refentrytitle">du</span>(1)</span></a> on the FTP
4477 server to monitor progress of the upload. The upload
4478 script will take care of not uploading restricted
4479 packages and putting vulnerable packages into the
4480 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
4481 class="filename">vulnerable</code> subdirectory.</p>
4483 <p>After the upload has ended, first thing is to revoke
4485 <pre class="screen">
4486 nbftp% <strong class=
4487 "userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
4491 <p>Use whatever is needed to remove the key you've
4492 entered before! Last, move the uploaded packages out of
4494 "http://www.w3.org/TR/xhtml1/transitional" class=
4495 "filename">upload</code> directory to have them
4496 accessible to everyone:</p>
4497 <pre class="screen">
4498 nbftp% <strong class=
4499 "userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
4500 nbftp% <strong class=
4501 "userinput"><code>mv upload/* .</code></strong>
4502 nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
4503 nbftp% <strong class="userinput"><code>chmod 755 .</code></strong>
4508 <div class="sect1" lang="en" xml:lang="en">
4509 <div class="titlepage">
4512 <h2 class="title" style="clear: both"><a name=
4513 "creating-cdroms" id=
4514 "creating-cdroms"></a>6.4. Creating a multiple
4515 CD-ROM packages collection</h2>
4520 <p>After your pkgsrc bulk-build has completed, you may
4521 wish to create a CD-ROM set of the resulting binary
4522 packages to assist in installing packages on other
4523 machines. The <a xmlns=
4524 "http://www.w3.org/TR/xhtml1/transitional" href=
4525 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/cdpack/README.html"
4526 target="_top"><code xmlns="" class=
4527 "filename">pkgtools/cdpack</code></a> package provides a
4528 simple tool for creating the ISO 9660 images.
4529 <span><strong class="command">cdpack</strong></span>
4530 arranges the packages on the CD-ROMs in a way that keeps
4531 all the dependencies for a given package on the same CD
4532 as that package.</p>
4534 <div class="sect2" lang="en" xml:lang="en">
4535 <div class="titlepage">
4538 <h3 class="title"><a name="cdpack-example" id=
4539 "cdpack-example"></a>6.4.1. Example of
4545 <p>Complete documentation for cdpack is found in the
4546 cdpack(1) man page. The following short example assumes
4547 that the binary packages are left in <code xmlns=
4548 "http://www.w3.org/TR/xhtml1/transitional" class=
4549 "filename">/usr/pkgsrc/packages/All</code> and that
4550 sufficient disk space exists in <code xmlns=
4551 "http://www.w3.org/TR/xhtml1/transitional" class=
4552 "filename">/u2</code> to hold the ISO 9660 images.</p>
4553 <pre class="screen">
4554 <code class="prompt">#</code> <strong class=
4555 "userinput"><code>mkdir /u2/images</code></strong>
4556 <code class="prompt">#</code> <strong class=
4557 "userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
4558 <code class="prompt">#</code> <strong class=
4559 "userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong>
4562 <p>If you wish to include a common set of files
4563 (<code xmlns="http://www.w3.org/TR/xhtml1/transitional"
4564 class="filename">COPYRIGHT</code>, <code xmlns=
4565 "http://www.w3.org/TR/xhtml1/transitional" class=
4566 "filename">README</code>, etc.) on each CD in the
4567 collection, then you need to create a directory which
4568 contains these files. e.g.</p>
4569 <pre class="screen">
4570 <code class="prompt">#</code> <strong class=
4571 "userinput"><code>mkdir /tmp/common</code></strong>
4572 <code class="prompt">#</code> <strong class=
4573 "userinput"><code>echo "This is a README" > /tmp/common/README</code></strong>
4574 <code class="prompt">#</code> <strong class=
4575 "userinput"><code>echo "Another file" > /tmp/common/COPYING</code></strong>
4576 <code class="prompt">#</code> <strong class=
4577 "userinput"><code>mkdir /tmp/common/bin</code></strong>
4578 <code class="prompt">#</code> <strong class=
4579 "userinput"><code>echo "#!/bin/sh" > /tmp/common/bin/myscript</code></strong>
4580 <code class="prompt">#</code> <strong class=
4581 "userinput"><code>echo "echo Hello world" >> /tmp/common/bin/myscript</code></strong>
4582 <code class="prompt">#</code> <strong class=
4583 "userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong>
4586 <p>Now create the images:</p>
4587 <pre class="screen">
4588 <code class="prompt">#</code> <strong class=
4589 "userinput"><code>cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images</code></strong>
4592 <p>Each image will contain <code xmlns=
4593 "http://www.w3.org/TR/xhtml1/transitional" class=
4594 "filename">README</code>, <code xmlns=
4595 "http://www.w3.org/TR/xhtml1/transitional" class=
4596 "filename">COPYING</code>, and <code xmlns=
4597 "http://www.w3.org/TR/xhtml1/transitional" class=
4598 "filename">bin/myscript</code> in their root
4604 <div class="chapter" lang="en" xml:lang="en">
4605 <div class="titlepage">
4608 <h2 class="title"><a name="faq" id=
4609 "faq"></a>Chapter 7. Frequently Asked
4616 <p><b>Table of Contents</b></p>
4619 <dt><span class="sect1"><a href=
4620 "#mailing-list-pointers">7.1. Are there any mailing
4621 lists for pkg-related discussion?</a></span></dt>
4623 <dt><span class="sect1"><a href="#pkgviews-docs">7.2.
4624 Where's the pkgviews documentation?</a></span></dt>
4626 <dt><span class="sect1"><a href="#faq-pkgtools">7.3.
4627 Utilities for package management
4628 (pkgtools)</a></span></dt>
4630 <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4.
4631 How to use pkgsrc as non-root</a></span></dt>
4633 <dt><span class="sect1"><a href=
4634 "#resume-transfers">7.5. How to resume transfers when
4635 fetching distfiles?</a></span></dt>
4637 <dt><span class="sect1"><a href=
4638 "#XFree86-from-pkgsrc">7.6. How can I install/use
4639 XFree86 from pkgsrc?</a></span></dt>
4641 <dt><span class="sect1"><a href=
4642 "#x.org-from-pkgsrc">7.7. How can I install/use X.org
4643 from pkgsrc?</a></span></dt>
4645 <dt><span class="sect1"><a href=
4646 "#fetch-behind-firewall">7.8. How to fetch files from
4647 behind a firewall</a></span></dt>
4649 <dt><span class="sect1"><a href="#passive-ftp">7.9. How
4650 do I tell <span><strong class="command">make
4651 fetch</strong></span> to do passive
4652 FTP?</a></span></dt>
4654 <dt><span class="sect1"><a href=
4655 "#fetching-all-distfiles">7.10. How to fetch all
4656 distfiles at once</a></span></dt>
4658 <dt><span class="sect1"><a href=
4659 "#tmac.andoc-missing">7.11. What does
4660 “<span class="quote">Don't know how to make
4661 /usr/share/tmac/tmac.andoc</span>”
4662 mean?</a></span></dt>
4664 <dt><span class="sect1"><a href=
4665 "#bsd.own.mk-missing">7.12. What does
4666 “<span class="quote">Could not find
4667 bsd.own.mk</span>” mean?</a></span></dt>
4669 <dt><span class="sect1"><a href=
4670 "#using-sudo-with-pkgsrc">7.13. Using 'sudo' with
4671 pkgsrc</a></span></dt>
4673 <dt><span class="sect1"><a href="#faq.conf">7.14. How
4674 do I change the location of configuration
4675 files?</a></span></dt>
4677 <dt><span class="sect1"><a href="#audit-packages">7.15.
4678 Automated security checks</a></span></dt>
4682 <p>This section contains hints, tips & tricks on
4683 special things in pkgsrc that we didn't find a better place
4684 for in the previous chapters, and it contains items for
4685 both pkgsrc users and developers.</p>
4687 <div class="sect1" lang="en" xml:lang="en">
4688 <div class="titlepage">
4691 <h2 class="title" style="clear: both"><a name=
4692 "mailing-list-pointers" id=
4693 "mailing-list-pointers"></a>7.1. Are there any
4694 mailing lists for pkg-related discussion?</h2>
4699 <p>The following mailing lists may be of interest to
4702 <div class="itemizedlist">
4706 "http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs"
4707 target="_top">pkgsrc-bugs</a>: A list where problem
4708 reports related to pkgsrc are sent and
4714 "http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk"
4715 target="_top">pkgsrc-bulk</a>: A list where the
4716 results of pkgsrc bulk builds are sent and
4722 "http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes"
4723 target="_top">pkgsrc-changes</a>: A list where all
4724 commit messages to pkgsrc are sent.</p>
4729 "http://www.NetBSD.org/MailingLists/index.html#tech-pkg"
4730 target="_top">tech-pkg</a>: A general discussion
4731 list for all things related to pkgsrc.</p>
4736 <p>To subscribe, do:</p>
4737 <pre class="programlisting">
4738 <code class="prompt">%</code> echo subscribe <em class=
4739 "replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
4742 <p>Archives for all these mailing lists are available
4743 from <a href="http://mail-index.NetBSD.org/" target=
4744 "_top">http://mail-index.NetBSD.org/</a>.</p>
4747 <div class="sect1" lang="en" xml:lang="en">
4748 <div class="titlepage">
4751 <h2 class="title" style="clear: both"><a name=
4753 "pkgviews-docs"></a>7.2. Where's the pkgviews
4759 <p>Pkgviews is tightly integrated with buildlink. You can
4760 find a pkgviews User's guide in <code xmlns=
4761 "http://www.w3.org/TR/xhtml1/transitional" class=
4762 "filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
4765 <div class="sect1" lang="en" xml:lang="en">
4766 <div class="titlepage">
4769 <h2 class="title" style="clear: both"><a name=
4771 "faq-pkgtools"></a>7.3. Utilities for package
4772 management (pkgtools)</h2>
4778 "http://www.w3.org/TR/xhtml1/transitional" class=
4779 "filename">pkgsrc/pkgtools</code> directory pkgtools
4780 contains a number of useful utilities for both users and
4781 developers of pkgsrc. This section attempts only to make
4782 the reader aware of the utilities and when they might be
4783 useful, and not to duplicate the documentation that comes
4784 with each package.</p>
4786 <p>Utilities used by pkgsrc (automatically installed when
4789 <div class="itemizedlist">
4793 "http://www.w3.org/TR/xhtml1/transitional" href=
4794 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/x11-links/README.html"
4795 target="_top"><code xmlns="" class=
4796 "filename">pkgtools/x11-links</code></a>: Symlinks
4797 for use by buildlink.</p>
4802 <p>OS tool augmentation (automatically installed when
4805 <div class="itemizedlist">
4809 "http://www.w3.org/TR/xhtml1/transitional" href=
4810 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/digest/README.html"
4811 target="_top"><code xmlns="" class=
4812 "filename">pkgtools/digest</code></a>: Calculates
4813 various kinds of checksums (including SHA1).</p>
4818 "http://www.w3.org/TR/xhtml1/transitional" href=
4819 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/libnbcompat/README.html"
4820 target="_top"><code xmlns="" class=
4821 "filename">pkgtools/libnbcompat</code></a>:
4822 Compatibility library for pkgsrc tools.</p>
4827 "http://www.w3.org/TR/xhtml1/transitional" href=
4828 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/mtree/README.html"
4829 target="_top"><code xmlns="" class=
4830 "filename">pkgtools/mtree</code></a>: Installed on
4831 non-BSD systems due to lack of native mtree.</p>
4836 "http://www.w3.org/TR/xhtml1/transitional" href=
4837 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html"
4838 target="_top"><code xmlns="" class=
4839 "filename">pkgtools/pkg_install</code></a>:
4840 Up-to-date replacement for <code xmlns=
4841 "http://www.w3.org/TR/xhtml1/transitional" class=
4842 "filename">/usr/sbin/pkg_install</code>, or for use
4843 on operating systems where pkg_install is not
4849 <p>Utilities used by pkgsrc (not automatically
4852 <div class="itemizedlist">
4856 "http://www.w3.org/TR/xhtml1/transitional" href=
4857 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_tarup/README.html"
4858 target="_top"><code xmlns="" class=
4859 "filename">pkgtools/pkg_tarup</code></a>: Create a
4860 binary package from an already-installed package.
4861 Used by <span><strong class="command">make
4862 replace</strong></span> to save the old
4868 "http://www.w3.org/TR/xhtml1/transitional" href=
4869 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/dfdisk/README.html"
4870 target="_top"><code xmlns="" class=
4871 "filename">pkgtools/dfdisk</code></a>: Adds extra
4872 functionality to pkgsrc, allowing it to fetch
4873 distfiles from multiple locations. It currently
4874 supports the following methods: multiple CD-ROMs
4875 and network FTP/HTTP connections.</p>
4880 "http://www.w3.org/TR/xhtml1/transitional" href=
4881 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/xpkgwedge/README.html"
4882 target="_top"><code xmlns="" class=
4883 "filename">pkgtools/xpkgwedge</code></a>: Put X11
4884 packages someplace else (enabled by default).</p>
4889 "http://www.w3.org/TR/xhtml1/transitional" href=
4890 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/cpuflags/README.html"
4891 target="_top"><code xmlns="" class=
4892 "filename">devel/cpuflags</code></a>: Determine the
4893 best compiler flags to optimise code for your
4894 current CPU and compiler.</p>
4899 <p>Utilities for keeping track of installed packages,
4900 being up to date, etc:</p>
4902 <div class="itemizedlist">
4906 "http://www.w3.org/TR/xhtml1/transitional" href=
4907 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_chk/README.html"
4908 target="_top"><code xmlns="" class=
4909 "filename">pkgtools/pkg_chk</code></a>: Reports on
4910 packages whose installed versions do not match the
4911 latest pkgsrc entries.</p>
4916 "http://www.w3.org/TR/xhtml1/transitional" href=
4917 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdep/README.html"
4918 target="_top"><code xmlns="" class=
4919 "filename">pkgtools/pkgdep</code></a>: Makes
4920 dependency graphs of packages, to aid in choosing a
4921 strategy for updating.</p>
4926 "http://www.w3.org/TR/xhtml1/transitional" href=
4927 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdepgraph/README.html"
4928 target="_top"><code xmlns="" class=
4929 "filename">pkgtools/pkgdepgraph</code></a>: Makes
4930 graphs from the output of <a xmlns=
4931 "http://www.w3.org/TR/xhtml1/transitional" href=
4932 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdep/README.html"
4933 target="_top"><code xmlns="" class=
4934 "filename">pkgtools/pkgdep</code></a> (uses
4940 "http://www.w3.org/TR/xhtml1/transitional" href=
4941 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html"
4942 target="_top"><code xmlns="" class=
4943 "filename">pkgtools/pkglint</code></a>: The
4944 pkglint(1) program checks a pkgsrc entry for
4945 errors, lintpkgsrc(1) does various checks on the
4946 complete pkgsrc system.</p>
4951 "http://www.w3.org/TR/xhtml1/transitional" href=
4952 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgsurvey/README.html"
4953 target="_top"><code xmlns="" class=
4954 "filename">pkgtools/pkgsurvey</code></a>: Report
4955 what packages you have installed.</p>
4960 <p>Utilities for people maintaining or creating
4961 individual packages:</p>
4963 <div class="itemizedlist">
4967 "http://www.w3.org/TR/xhtml1/transitional" href=
4968 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html"
4969 target="_top"><code xmlns="" class=
4970 "filename">pkgtools/pkgdiff</code></a>: Automate
4971 making and maintaining patches for a package
4972 (includes pkgdiff, pkgvi, mkpatches, etc.).</p>
4977 "http://www.w3.org/TR/xhtml1/transitional" href=
4978 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/rpm2pkg/README.html"
4979 target="_top"><code xmlns="" class=
4980 "filename">pkgtools/rpm2pkg</code></a>, <a xmlns=
4981 "http://www.w3.org/TR/xhtml1/transitional" href=
4982 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/url2pkg/README.html"
4983 target="_top"><code xmlns="" class=
4984 "filename">pkgtools/url2pkg</code></a>: Aids in
4985 converting to pkgsrc.</p>
4990 "http://www.w3.org/TR/xhtml1/transitional" href=
4991 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/gensolpkg/README.html"
4992 target="_top"><code xmlns="" class=
4993 "filename">pkgtools/gensolpkg</code></a>: Convert
4994 pkgsrc to a Solaris package.</p>
4999 <p>Utilities for people maintaining pkgsrc (or: more
5000 obscure pkg utilities)</p>
5002 <div class="itemizedlist">
5006 "http://www.w3.org/TR/xhtml1/transitional" href=
5007 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_comp/README.html"
5008 target="_top"><code xmlns="" class=
5009 "filename">pkgtools/pkg_comp</code></a>: Build
5010 packages in a chrooted area.</p>
5015 "http://www.w3.org/TR/xhtml1/transitional" href=
5016 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/libkver/README.html"
5017 target="_top"><code xmlns="" class=
5018 "filename">pkgtools/libkver</code></a>: Spoof
5019 kernel version for chrooted cross builds.</p>
5025 <div class="sect1" lang="en" xml:lang="en">
5026 <div class="titlepage">
5029 <h2 class="title" style="clear: both"><a name=
5030 "non-root-pkgsrc" id=
5031 "non-root-pkgsrc"></a>7.4. How to use pkgsrc
5037 <p>If you want to use pkgsrc as non-root user, you can
5038 set some variables to make pkgsrc work under these
5039 conditions. At the very least, you need to set
5040 <code class="varname">UNPRIVILEGED</code> to
5041 “<span class="quote">yes</span>”; this will
5042 turn on unprivileged mode and set multiple related
5043 variables to allow installation of packages as
5046 <p>In case the defaults are not enough, you may want to
5047 tune some other variables used. For example, if the
5048 automatic user/group detection leads to incorrect values
5049 (or not the ones you would like to use), you can change
5050 them by setting <code class=
5051 "varname">UNPRIVILEGED_USER</code> and <code class=
5052 "varname">UNPRIVILEGED_GROUP</code> respectively.</p>
5054 <p>As regards bootstrapping, please note that the
5055 <span><strong class="command">bootstrap</strong></span>
5056 script will ease non-root configuration when given the
5058 "quote">--ignore-user-check</span>” flag, as it
5059 will choose and use multiple default directories under
5060 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
5061 class="filename">~/pkg</code> as the installation
5062 targets. These directories can be overriden by the
5063 “<span class="quote">--prefix</span>” flag
5064 provided by the script, as well as some others that allow
5065 finer tuning of the tree layout.</p>
5068 <div class="sect1" lang="en" xml:lang="en">
5069 <div class="titlepage">
5072 <h2 class="title" style="clear: both"><a name=
5073 "resume-transfers" id=
5074 "resume-transfers"></a>7.5. How to resume
5075 transfers when fetching distfiles?</h2>
5080 <p>By default, resuming transfers in pkgsrc is disabled,
5081 but you can enable this feature by adding the option
5082 <code class="varname">PKG_RESUME_TRANSFERS=YES</code>
5084 "http://www.w3.org/TR/xhtml1/transitional" class=
5085 "filename">/etc/mk.conf</code>. If, during a fetch step,
5086 an incomplete distfile is found, pkgsrc will try to
5089 <p>You can also use a different program than the default
5091 "http://netbsd.gw.com/cgi-bin/man-cgi?ftp+1+NetBSD-current">
5092 <span class="citerefentry"><span class=
5093 "refentrytitle">ftp</span>(1)</span></a> by changing the
5094 <code class="varname">FETCH_CMD</code> variable. Don't
5095 forget to set <code class=
5096 "varname">FETCH_RESUME_ARGS</code> and <code class=
5097 "varname">FETCH_OUTPUT_ARGS</code> if you are not using
5100 <p>For example, if you want to use <code xmlns=
5101 "http://www.w3.org/TR/xhtml1/transitional" class=
5102 "filename">wget</code> to resume downloads, you'll have
5103 to use something like:</p>
5104 <pre class="programlisting">
5106 FETCH_BEFORE_ARGS= --passive-ftp
5107 FETCH_RESUME_ARGS= -c
5108 FETCH_OUTPUT_ARGS= -O
5112 <div class="sect1" lang="en" xml:lang="en">
5113 <div class="titlepage">
5116 <h2 class="title" style="clear: both"><a name=
5117 "XFree86-from-pkgsrc" id=
5118 "XFree86-from-pkgsrc"></a>7.6. How can I
5119 install/use XFree86 from pkgsrc?</h2>
5124 <p>If you want to use XFree86 from pkgsrc instead of your
5125 system's own X11 (<code xmlns=
5126 "http://www.w3.org/TR/xhtml1/transitional" class=
5127 "filename">/usr/X11R6</code>, <code xmlns=
5128 "http://www.w3.org/TR/xhtml1/transitional" class=
5129 "filename">/usr/openwin</code>, ...), you will have to
5130 add the following line into <code xmlns=
5131 "http://www.w3.org/TR/xhtml1/transitional" class=
5132 "filename">/etc/mk.conf</code>:</p>
5133 <pre class="programlisting">
5138 <div class="sect1" lang="en" xml:lang="en">
5139 <div class="titlepage">
5142 <h2 class="title" style="clear: both"><a name=
5143 "x.org-from-pkgsrc" id=
5144 "x.org-from-pkgsrc"></a>7.7. How can I
5145 install/use X.org from pkgsrc?</h2>
5150 <p>If you want to use X.org from pkgsrc instead of your
5151 system's own X11 (<code xmlns=
5152 "http://www.w3.org/TR/xhtml1/transitional" class=
5153 "filename">/usr/X11R6</code>, <code xmlns=
5154 "http://www.w3.org/TR/xhtml1/transitional" class=
5155 "filename">/usr/openwin</code>, ...) you will have to add
5156 the following line into <code xmlns=
5157 "http://www.w3.org/TR/xhtml1/transitional" class=
5158 "filename">/etc/mk.conf</code>:</p>
5159 <pre class="programlisting">
5164 <div class="sect1" lang="en" xml:lang="en">
5165 <div class="titlepage">
5168 <h2 class="title" style="clear: both"><a name=
5169 "fetch-behind-firewall" id=
5170 "fetch-behind-firewall"></a>7.8. How to fetch
5171 files from behind a firewall</h2>
5176 <p>If you are sitting behind a firewall which does not
5177 allow direct connections to Internet hosts (i.e.
5178 non-NAT), you may specify the relevant proxy hosts. This
5179 is done using an environment variable in the form of a
5180 URL, e.g. in Amdahl, the machine “<span class=
5181 "quote">orpheus.amdahl.com</span>” is one of the
5182 firewalls, and it uses port 80 as the proxy port number.
5183 So the proxy environment variables are:</p>
5184 <pre class="programlisting">
5185 ftp_proxy=ftp://orpheus.amdahl.com:80/
5186 http_proxy=http://orpheus.amdahl.com:80/
5190 <div class="sect1" lang="en" xml:lang="en">
5191 <div class="titlepage">
5194 <h2 class="title" style="clear: both"><a name=
5195 "passive-ftp" id="passive-ftp"></a>7.9. How do
5196 I tell <span><strong class="command">make
5197 fetch</strong></span> to do passive FTP?</h2>
5202 <p>This depends on which utility is used to retrieve
5203 distfiles. From <code xmlns=
5204 "http://www.w3.org/TR/xhtml1/transitional" class=
5205 "filename">bsd.pkg.mk</code>, <code class=
5206 "varname">FETCH_CMD</code> is assigned the first
5207 available command from the following list:</p>
5209 <div class="itemizedlist">
5213 "http://www.w3.org/TR/xhtml1/transitional" class=
5214 "filename">${LOCALBASE}/bin/ftp</code></p>
5219 "http://www.w3.org/TR/xhtml1/transitional" class=
5220 "filename">/usr/bin/ftp</code></p>
5225 <p>On a default NetBSD installation, this will be
5226 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
5227 class="filename">/usr/bin/ftp</code>, which automatically
5228 tries passive connections first, and falls back to active
5229 connections if the server refuses to do passive. For the
5230 other tools, add the following to your <code xmlns=
5231 "http://www.w3.org/TR/xhtml1/transitional" class=
5232 "filename">/etc/mk.conf</code> file: <code class=
5233 "varname">PASSIVE_FETCH=1</code>.</p>
5235 <p>Having that option present will prevent <code xmlns=
5236 "http://www.w3.org/TR/xhtml1/transitional" class=
5237 "filename">/usr/bin/ftp</code> from falling back to
5238 active transfers.</p>
5241 <div class="sect1" lang="en" xml:lang="en">
5242 <div class="titlepage">
5245 <h2 class="title" style="clear: both"><a name=
5246 "fetching-all-distfiles" id=
5247 "fetching-all-distfiles"></a>7.10. How to
5248 fetch all distfiles at once</h2>
5253 <p>You would like to download all the distfiles in a
5254 single batch from work or university, where you can't run
5255 a <span><strong class="command">make
5256 fetch</strong></span>. There is an archive of distfiles
5258 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/"
5259 target="_top">ftp.NetBSD.org</a>, but downloading the
5260 entire directory may not be appropriate.</p>
5262 <p>The answer here is to do a <span><strong class=
5263 "command">make fetch-list</strong></span> in <code xmlns=
5264 "http://www.w3.org/TR/xhtml1/transitional" class=
5265 "filename">/usr/pkgsrc</code> or one of its
5266 subdirectories, carry the resulting list to your machine
5267 at work/school and use it there. If you don't have a
5268 NetBSD-compatible <a href=
5269 "http://netbsd.gw.com/cgi-bin/man-cgi?ftp+1+NetBSD-current">
5270 <span class="citerefentry"><span class=
5271 "refentrytitle">ftp</span>(1)</span></a> (like lukemftp)
5272 at work, don't forget to set <code class=
5273 "varname">FETCH_CMD</code> to something that fetches a
5277 <pre class="screen">
5278 <code class="prompt">%</code> <strong class=
5279 "userinput"><code>cd /usr/pkgsrc</code></strong>
5280 <code class="prompt">%</code> <strong class=
5281 "userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh</code></strong>
5282 <code class="prompt">%</code> <strong class=
5283 "userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong>
5287 <pre class="screen">
5288 <code class="prompt">%</code> <strong class=
5289 "userinput"><code>sh /tmp/fetch.sh</code></strong>
5292 <p>then tar up <code xmlns=
5293 "http://www.w3.org/TR/xhtml1/transitional" class=
5294 "filename">/tmp/distfiles</code> and take it home.</p>
5296 <p>If you have a machine running NetBSD, and you want to
5297 get <span class="emphasis"><em>all</em></span> distfiles
5298 (even ones that aren't for your machine architecture),
5299 you can do so by using the above-mentioned
5300 <span><strong class="command">make
5301 fetch-list</strong></span> approach, or fetch the
5302 distfiles directly by running:</p>
5303 <pre class="screen">
5304 <code class="prompt">%</code> <strong class=
5305 "userinput"><code>make mirror-distfiles</code></strong>
5308 <p>If you even decide to ignore <code class=
5309 "varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you
5310 can get everything by running:</p>
5311 <pre class="screen">
5312 <code class="prompt">%</code> <strong class=
5313 "userinput"><code>make fetch NO_SKIP=yes</code></strong>
5317 <div class="sect1" lang="en" xml:lang="en">
5318 <div class="titlepage">
5321 <h2 class="title" style="clear: both"><a name=
5322 "tmac.andoc-missing" id=
5323 "tmac.andoc-missing"></a>7.11. What does
5324 “<span class="quote">Don't know how to make
5325 /usr/share/tmac/tmac.andoc</span>” mean?</h2>
5330 <p>When compiling the <a xmlns=
5331 "http://www.w3.org/TR/xhtml1/transitional" href=
5332 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html"
5333 target="_top"><code xmlns="" class=
5334 "filename">pkgtools/pkg_install</code></a> package, you
5335 get the error from make that it doesn't know how to make
5336 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
5337 class="filename">/usr/share/tmac/tmac.andoc</code>? This
5338 indicates that you don't have installed the
5339 “<span class="quote">text</span>” set (nroff,
5340 ...) from the NetBSD base distribution on your machine.
5341 It is recommended to do that to format man pages.</p>
5343 <p>In the case of the <a xmlns=
5344 "http://www.w3.org/TR/xhtml1/transitional" href=
5345 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html"
5346 target="_top"><code xmlns="" class=
5347 "filename">pkgtools/pkg_install</code></a> package, you
5348 can get away with setting <code class=
5349 "varname">NOMAN=YES</code> either in the environment or
5350 in <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
5351 class="filename">/etc/mk.conf</code>.</p>
5354 <div class="sect1" lang="en" xml:lang="en">
5355 <div class="titlepage">
5358 <h2 class="title" style="clear: both"><a name=
5359 "bsd.own.mk-missing" id=
5360 "bsd.own.mk-missing"></a>7.12. What does
5361 “<span class="quote">Could not find
5362 bsd.own.mk</span>” mean?</h2>
5367 <p>You didn't install the compiler set, <code xmlns=
5368 "http://www.w3.org/TR/xhtml1/transitional" class=
5369 "filename">comp.tgz</code>, when you installed your
5370 NetBSD machine. Please get and install it, by extracting
5372 "http://www.w3.org/TR/xhtml1/transitional" class=
5373 "filename">/</code>:</p>
5374 <pre class="screen">
5375 <code class="prompt">#</code> <strong class=
5376 "userinput"><code>cd /</code></strong>
5377 <code class="prompt">#</code> <strong class=
5378 "userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong>
5381 <p><code xmlns="http://www.w3.org/TR/xhtml1/transitional"
5382 class="filename">comp.tgz</code> is part of every NetBSD
5383 release. Get the one that corresponds to your release
5384 (determine via <span><strong class="command">uname
5385 -r</strong></span>).</p>
5388 <div class="sect1" lang="en" xml:lang="en">
5389 <div class="titlepage">
5392 <h2 class="title" style="clear: both"><a name=
5393 "using-sudo-with-pkgsrc" id=
5394 "using-sudo-with-pkgsrc"></a>7.13. Using
5395 'sudo' with pkgsrc</h2>
5400 <p>When installing packages as non-root user and using
5401 the just-in-time <a href=
5402 "http://netbsd.gw.com/cgi-bin/man-cgi?su+1+NetBSD-current">
5403 <span class="citerefentry"><span class=
5404 "refentrytitle">su</span>(1)</span></a> feature of
5405 pkgsrc, it can become annoying to type in the root
5406 password for each required package installed. To avoid
5407 this, the sudo package can be used, which does password
5408 caching over a limited time. To use it, install sudo
5409 (either as binary package or from <a xmlns=
5410 "http://www.w3.org/TR/xhtml1/transitional" href=
5411 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/sudo/README.html"
5412 target="_top"><code xmlns="" class=
5413 "filename">security/sudo</code></a>) and then put the
5414 following into your <code xmlns=
5415 "http://www.w3.org/TR/xhtml1/transitional" class=
5416 "filename">/etc/mk.conf</code>:</p>
5417 <pre class="programlisting">
5418 .if exists(${LOCALBASE}/bin/sudo)
5419 SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
5424 <div class="sect1" lang="en" xml:lang="en">
5425 <div class="titlepage">
5428 <h2 class="title" style="clear: both"><a name=
5429 "faq.conf" id="faq.conf"></a>7.14. How do I
5430 change the location of configuration files?</h2>
5435 <p>As the system administrator, you can choose where
5436 configuration files are installed. The default settings
5437 make all these files go into <code xmlns=
5438 "http://www.w3.org/TR/xhtml1/transitional" class=
5439 "filename">${PREFIX}/etc</code> or some of its
5440 subdirectories; this may be suboptimal depending on your
5441 expectations (e.g., a read-only, NFS-exported
5442 <code class="varname">PREFIX</code> with a need of
5443 per-machine configuration of the provided packages).</p>
5445 <p>In order to change the defaults, you can modify the
5446 <code class="varname">PKG_SYSCONFBASE</code> variable (in
5447 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
5448 class="filename">/etc/mk.conf</code>) to point to your
5449 preferred configuration directory; some common examples
5450 include <code xmlns=
5451 "http://www.w3.org/TR/xhtml1/transitional" class=
5452 "filename">/etc</code> or <code xmlns=
5453 "http://www.w3.org/TR/xhtml1/transitional" class=
5454 "filename">/etc/pkg</code>.</p>
5456 <p>Furthermore, you can change this value on a
5457 per-package basis by setting the <code class=
5458 "varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>
5459 variable. <code class="varname">PKG_SYSCONFVAR</code>'s
5460 value usually matches the name of the package you would
5461 like to modify, that is, the contents of <code class=
5462 "varname">PKGBASE</code>.</p>
5464 <p>Note that after changing these settings, you must
5465 rebuild and reinstall any affected packages.</p>
5468 <div class="sect1" lang="en" xml:lang="en">
5469 <div class="titlepage">
5472 <h2 class="title" style="clear: both"><a name=
5473 "audit-packages" id=
5474 "audit-packages"></a>7.15. Automated security
5480 <p>Please be aware that there can often be bugs in
5481 third-party software, and some of these bugs can leave a
5482 machine vulnerable to exploitation by attackers. In an
5483 effort to lessen the exposure, the NetBSD packages team
5484 maintains a database of known-exploits to packages which
5485 have at one time been included in pkgsrc. The database
5486 can be downloaded automatically, and a security audit of
5487 all packages installed on a system can take place. To do
5488 this, install the <a xmlns=
5489 "http://www.w3.org/TR/xhtml1/transitional" href=
5490 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html"
5491 target="_top"><code xmlns="" class=
5492 "filename">security/audit-packages</code></a> package. It
5493 has two components:</p>
5495 <div class="orderedlist">
5498 <p><span><strong class=
5499 "command">download-vulnerability-list</strong></span>,
5500 an easy way to download a list of the security
5501 vulnerabilities information. This list is kept up
5502 to date by the NetBSD security officer and the
5503 NetBSD packages team, and is distributed from the
5504 NetBSD ftp server:</p>
5507 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/pkg-vulnerabilities"
5509 "_top">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/pkg-vulnerabilities</a></p>
5513 <p><span><strong class=
5514 "command">audit-packages</strong></span>, an easy
5515 way to audit the current machine, checking each
5516 vulnerability which is known. If a vulnerable
5517 package is installed, it will be shown by output to
5518 stdout, including a description of the type of
5519 vulnerability, and a URL containing more
5525 <p>Use of the <a xmlns=
5526 "http://www.w3.org/TR/xhtml1/transitional" href=
5527 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html"
5528 target="_top"><code xmlns="" class=
5529 "filename">security/audit-packages</code></a> package is
5530 strongly recommended! After “<span class=
5531 "quote">audit-packages</span>” is installed, please
5532 read the package's message, which you can get by running
5533 <strong class="userinput"><code>pkg_info -D
5534 audit-package</code></strong>.</p>
5539 <div class="part" lang="en" xml:lang="en">
5540 <div class="titlepage">
5543 <h1 class="title"><a name="developers-guide" id=
5544 "developers-guide"></a>Part II. The pkgsrc
5545 developer's guide</h1>
5551 <p><b>Table of Contents</b></p>
5554 <dt><span class="chapter"><a href="#components">8.
5555 Package components - files, directories and
5556 contents</a></span></dt>
5560 <dt><span class="sect1"><a href=
5561 "#components.Makefile">8.1. <code xmlns=
5562 "http://www.w3.org/TR/xhtml1/transitional" class=
5563 "filename">Makefile</code></a></span></dt>
5565 <dt><span class="sect1"><a href=
5566 "#components.distinfo">8.2. <code xmlns=
5567 "http://www.w3.org/TR/xhtml1/transitional" class=
5568 "filename">distinfo</code></a></span></dt>
5570 <dt><span class="sect1"><a href=
5571 "#components.patches">8.3. patches/*</a></span></dt>
5573 <dt><span class="sect1"><a href=
5574 "#other-mandatory-files">8.4. Other mandatory
5575 files</a></span></dt>
5577 <dt><span class="sect1"><a href=
5578 "#components.optional">8.5. Optional
5579 files</a></span></dt>
5581 <dt><span class="sect1"><a href="#work-dir">8.6.
5583 "http://www.w3.org/TR/xhtml1/transitional" class=
5584 "filename">work*</code></a></span></dt>
5586 <dt><span class="sect1"><a href="#files-dir">8.7.
5588 "http://www.w3.org/TR/xhtml1/transitional" class=
5589 "filename">files/*</code></a></span></dt>
5593 <dt><span class="chapter"><a href="#makefile">9.
5594 Programming in <code xmlns=
5595 "http://www.w3.org/TR/xhtml1/transitional" class=
5596 "filename">Makefile</code>s</a></span></dt>
5600 <dt><span class="sect1"><a href=
5601 "#makefile.variables">9.1. <code xmlns=
5602 "http://www.w3.org/TR/xhtml1/transitional" class=
5603 "filename">Makefile</code> variables</a></span></dt>
5607 <dt><span class="sect2"><a href=
5608 "#makefile.variables.names">9.1.1. Naming
5609 conventions</a></span></dt>
5613 <dt><span class="sect1"><a href="#makefile.code">9.2.
5614 Code snippets</a></span></dt>
5618 <dt><span class="sect2"><a href=
5619 "#adding-to-list">9.2.1. Adding things to a
5620 list</a></span></dt>
5622 <dt><span class="sect2"><a href=
5623 "#converting-internal-to-external">9.2.2.
5624 Converting an internal list into an external
5625 list</a></span></dt>
5627 <dt><span class="sect2"><a href=
5628 "#passing-variable-to-shell">9.2.3. Passing
5629 variables to a shell command</a></span></dt>
5631 <dt><span class="sect2"><a href=
5632 "#quoting-guideline">9.2.4. Quoting
5633 guideline</a></span></dt>
5635 <dt><span class="sect2"><a href=
5636 "#bsd-make-bug-workaround">9.2.5. Workaround for
5637 a bug in BSD Make</a></span></dt>
5643 <dt><span class="chapter"><a href="#plist">10. PLIST
5644 issues</a></span></dt>
5648 <dt><span class="sect1"><a href="#rcs-id">10.1. RCS
5651 <dt><span class="sect1"><a href=
5652 "#automatic-plist-generation">10.2. Semi-automatic
5654 "http://www.w3.org/TR/xhtml1/transitional" class=
5655 "filename">PLIST</code> generation</a></span></dt>
5657 <dt><span class="sect1"><a href="#print-PLIST">10.3.
5658 Tweaking output of <span><strong class="command">make
5659 print-PLIST</strong></span></a></span></dt>
5661 <dt><span class="sect1"><a href="#plist.misc">10.4.
5662 Variable substitution in PLIST</a></span></dt>
5664 <dt><span class="sect1"><a href=
5665 "#manpage-compression">10.5. Man page
5666 compression</a></span></dt>
5668 <dt><span class="sect1"><a href=
5669 "#using-PLIST_SRC">10.6. Changing PLIST source with
5671 "varname">PLIST_SRC</code></a></span></dt>
5673 <dt><span class="sect1"><a href=
5674 "#platform-specific-plist">10.7. Platform-specific
5675 and differing PLISTs</a></span></dt>
5677 <dt><span class="sect1"><a href=
5678 "#faq.common-dirs">10.8. Sharing directories between
5679 packages</a></span></dt>
5683 <dt><span class="chapter"><a href="#buildlink">11.
5684 Buildlink methodology</a></span></dt>
5688 <dt><span class="sect1"><a href=
5689 "#converting-to-buildlink3">11.1. Converting packages
5690 to use buildlink3</a></span></dt>
5692 <dt><span class="sect1"><a href=
5693 "#creating-buildlink3.mk">11.2. Writing <code xmlns=
5694 "http://www.w3.org/TR/xhtml1/transitional" class=
5695 "filename">buildlink3.mk</code> files</a></span></dt>
5699 <dt><span class="sect2"><a href=
5700 "#anatomy-of-bl3">11.2.1. Anatomy of a
5701 buildlink3.mk file</a></span></dt>
5703 <dt><span class="sect2"><a href=
5704 "#updating-buildlink-depends">11.2.2. Updating
5706 "varname">BUILDLINK_DEPENDS.<em class="replaceable">
5707 <code>pkg</code></em></code> in <code xmlns=
5708 "http://www.w3.org/TR/xhtml1/transitional" class=
5709 "filename">buildlink3.mk</code>
5710 files</a></span></dt>
5714 <dt><span class="sect1"><a href=
5715 "#writing-builtin.mk">11.3. Writing <code xmlns=
5716 "http://www.w3.org/TR/xhtml1/transitional" class=
5717 "filename">builtin.mk</code> files</a></span></dt>
5721 <dt><span class="sect2"><a href=
5722 "#anatomy-of-builtin.mk">11.3.1. Anatomy of a
5724 "http://www.w3.org/TR/xhtml1/transitional" class=
5725 "filename">builtin.mk</code> file</a></span></dt>
5727 <dt><span class="sect2"><a href=
5728 "#native-or-pkgsrc-preference">11.3.2. Global
5729 preferences for native or pkgsrc
5730 software</a></span></dt>
5736 <dt><span class="chapter"><a href="#pkginstall">12. The
5737 pkginstall framework</a></span></dt>
5741 <dt><span class="sect1"><a href=
5742 "#files-and-dirs-outside-prefix">12.1. Files and
5743 directories outside the installation
5744 prefix</a></span></dt>
5748 <dt><span class="sect2"><a href=
5749 "#dirs-outside-prefix">12.1.1. Directory
5750 manipulation</a></span></dt>
5752 <dt><span class="sect2"><a href=
5753 "#files-outside-prefix">12.1.2. File
5754 manipulation</a></span></dt>
5758 <dt><span class="sect1"><a href="#conf-files">12.2.
5759 Configuration files</a></span></dt>
5763 <dt><span class="sect2"><a href=
5764 "#conf-files-sysconfdir">12.2.1. How <code class=
5765 "varname">PKG_SYSCONFDIR</code> is
5768 <dt><span class="sect2"><a href=
5769 "#conf-files-configure">12.2.2. Telling the
5770 software where configuration files
5773 <dt><span class="sect2"><a href=
5774 "#conf-files-patching">12.2.3. Patching
5775 installations</a></span></dt>
5777 <dt><span class="sect2"><a href=
5778 "#conf-files-disable">12.2.4. Disabling handling
5779 of configuration files</a></span></dt>
5783 <dt><span class="sect1"><a href="#rcd-scripts">12.3.
5784 System startup scripts</a></span></dt>
5788 <dt><span class="sect2"><a href=
5789 "#rcd-scripts-disable">12.3.1. Disabling handling
5790 of system startup scripts</a></span></dt>
5794 <dt><span class="sect1"><a href=
5795 "#users-and-groups">12.4. System users and
5796 groups</a></span></dt>
5798 <dt><span class="sect1"><a href="#shells">12.5.
5799 System shells</a></span></dt>
5803 <dt><span class="sect2"><a href=
5804 "#shells-disable">12.5.1. Disabling handling of
5805 configuration files</a></span></dt>
5811 <dt><span class="chapter"><a href="#options">13. Options
5812 handling</a></span></dt>
5816 <dt><span class="sect1"><a href=
5817 "#global-default-options">13.1. Global default
5818 options</a></span></dt>
5820 <dt><span class="sect1"><a href=
5821 "#converting-to-options">13.2. Converting packages to
5823 "http://www.w3.org/TR/xhtml1/transitional" class=
5824 "filename">bsd.options.mk</code></a></span></dt>
5826 <dt><span class="sect1"><a href="#option-names">13.3.
5827 Option Names</a></span></dt>
5831 <dt><span class="chapter"><a href="#build">14. The build
5832 process</a></span></dt>
5836 <dt><span class="sect1"><a href="#build.prefix">14.1.
5837 Program location</a></span></dt>
5839 <dt><span class="sect1"><a href="#main-targets">14.2.
5840 Main targets</a></span></dt>
5842 <dt><span class="sect1"><a href=
5843 "#build.helpful-targets">14.3. Other helpful
5844 targets</a></span></dt>
5848 <dt><span class="chapter"><a href="#fixes">15. Notes on
5849 fixes for packages</a></span></dt>
5853 <dt><span class="sect1"><a href=
5854 "#general-operation">15.1. General
5855 operation</a></span></dt>
5859 <dt><span class="sect2"><a href=
5860 "#pulling-vars-from-etc-mk.conf">15.1.1. How to
5861 pull in variables from
5862 /etc/mk.conf</a></span></dt>
5864 <dt><span class="sect2"><a href=
5865 "#where-to-install-documentation">15.1.2. Where
5866 to install documentation</a></span></dt>
5868 <dt><span class="sect2"><a href=
5869 "#restricted-packages">15.1.3. Restricted
5870 packages</a></span></dt>
5872 <dt><span class="sect2"><a href=
5873 "#dependencies">15.1.4. Handling
5874 dependencies</a></span></dt>
5876 <dt><span class="sect2"><a href=
5877 "#conflicts">15.1.5. Handling conflicts with
5878 other packages</a></span></dt>
5880 <dt><span class="sect2"><a href=
5881 "#not-building-packages">15.1.6. Packages that
5882 cannot or should not be built</a></span></dt>
5884 <dt><span class="sect2"><a href=
5885 "#undeletable-packages">15.1.7. Packages which
5886 should not be deleted, once
5887 installed</a></span></dt>
5889 <dt><span class="sect2"><a href=
5890 "#security-handling">15.1.8. Handling packages
5891 with security problems</a></span></dt>
5893 <dt><span class="sect2"><a href=
5894 "#compiler-bugs">15.1.9. How to handle compiler
5895 bugs</a></span></dt>
5897 <dt><span class="sect2"><a href=
5898 "#bumping-pkgrevision">15.1.10. How to handle
5899 incrementing versions when fixing an existing
5900 package</a></span></dt>
5902 <dt><span class="sect2"><a href=
5903 "#portability-of-packages">15.1.11. Portability
5904 of packages</a></span></dt>
5908 <dt><span class="sect1"><a href=
5909 "#downloading-issues">15.2. Possible downloading
5910 issues</a></span></dt>
5914 <dt><span class="sect2"><a href=
5915 "#no-plain-download">15.2.1. Packages whose
5916 distfiles aren't available for plain
5917 downloading</a></span></dt>
5919 <dt><span class="sect2"><a href=
5920 "#modified-distfiles-same-name">15.2.2. How to
5921 handle modified distfiles with the 'old'
5922 name</a></span></dt>
5926 <dt><span class="sect1"><a href=
5927 "#configuration-gotchas">15.3. Configuration
5928 gotchas</a></span></dt>
5932 <dt><span class="sect2"><a href=
5933 "#fixes.libtool">15.3.1. Shared libraries -
5934 libtool</a></span></dt>
5936 <dt><span class="sect2"><a href=
5937 "#using-libtool">15.3.2. Using libtool on GNU
5938 packages that already support
5939 libtool</a></span></dt>
5941 <dt><span class="sect2"><a href=
5942 "#autoconf-automake">15.3.3. GNU
5943 Autoconf/Automake</a></span></dt>
5947 <dt><span class="sect1"><a href=
5948 "#building-considerations">15.4. Building
5949 considerations</a></span></dt>
5953 <dt><span class="sect2"><a href=
5954 "#cpp-defines">15.4.1. CPP
5955 defines</a></span></dt>
5957 <dt><span class="sect2"><a href=
5958 "#cpp-list">15.4.2. Getting a list of CPP
5959 defines</a></span></dt>
5963 <dt><span class="sect1"><a href=
5964 "#package-specific-actions">15.5. Package specific
5965 actions</a></span></dt>
5969 <dt><span class="sect2"><a href=
5970 "#user-interaction">15.5.1. User
5971 interaction</a></span></dt>
5973 <dt><span class="sect2"><a href=
5974 "#handling-licenses">15.5.2. Handling
5975 licenses</a></span></dt>
5977 <dt><span class="sect2"><a href=
5978 "#installing-score-files">15.5.3. Installing
5979 score files</a></span></dt>
5981 <dt><span class="sect2"><a href=
5982 "#perl-scripts">15.5.4. Packages containing perl
5983 scripts</a></span></dt>
5985 <dt><span class="sect2"><a href=
5986 "#hardcoded-paths">15.5.5. Packages with
5987 hardcoded paths to other
5988 interpreters</a></span></dt>
5990 <dt><span class="sect2"><a href=
5991 "#perl-modules">15.5.6. Packages installing perl
5992 modules</a></span></dt>
5994 <dt><span class="sect2"><a href=
5995 "#faq.info-files">15.5.7. Packages installing
5996 info files</a></span></dt>
5998 <dt><span class="sect2"><a href=
5999 "#gconf2-data-files">15.5.8. Packages installing
6000 GConf2 data files</a></span></dt>
6002 <dt><span class="sect2"><a href=
6003 "#scrollkeeper-data-files">15.5.9. Packages
6004 installing scrollkeeper data
6005 files</a></span></dt>
6007 <dt><span class="sect2"><a href=
6008 "#x11-fonts">15.5.10. Packages installing X11
6009 fonts</a></span></dt>
6011 <dt><span class="sect2"><a href=
6012 "#gtk2-modules">15.5.11. Packages installing GTK2
6013 modules</a></span></dt>
6015 <dt><span class="sect2"><a href=
6016 "#sgml-xml-data">15.5.12. Packages installing
6017 SGML or XML data</a></span></dt>
6019 <dt><span class="sect2"><a href=
6020 "#mime-database">15.5.13. Packages installing
6021 extensions to the MIME database</a></span></dt>
6023 <dt><span class="sect2"><a href=
6024 "#intltool">15.5.14. Packages using
6025 intltool</a></span></dt>
6027 <dt><span class="sect2"><a href=
6028 "#startup-scripts">15.5.15. Packages installing
6029 startup scripts</a></span></dt>
6033 <dt><span class="sect1"><a href=
6034 "#feedback-to-author">15.6. Feedback to the
6035 author</a></span></dt>
6039 <dt><span class="chapter"><a href="#debug">16.
6040 Debugging</a></span></dt>
6042 <dt><span class="chapter"><a href="#submit">17.
6043 Submitting and Committing</a></span></dt>
6047 <dt><span class="sect1"><a href=
6048 "#submitting-your-package">17.1. Submitting your
6049 packages</a></span></dt>
6051 <dt><span class="sect1"><a href=
6052 "#general-notes-for-changes">17.2. General notes when
6053 adding, updating, or removing
6054 packages</a></span></dt>
6056 <dt><span class="sect1"><a href=
6057 "#committing-importing">17.3. Committing: Importing a
6058 package into CVS</a></span></dt>
6060 <dt><span class="sect1"><a href=
6061 "#updating-package">17.4. Updating a package to a
6062 newer version</a></span></dt>
6064 <dt><span class="sect1"><a href=
6065 "#moving-package">17.5. Moving a package in
6066 pkgsrc</a></span></dt>
6072 <div class="chapter" lang="en" xml:lang="en">
6073 <div class="titlepage">
6076 <h2 class="title"><a name="components" id=
6077 "components"></a>Chapter 8. Package
6078 components - files, directories and contents</h2>
6084 <p><b>Table of Contents</b></p>
6087 <dt><span class="sect1"><a href=
6088 "#components.Makefile">8.1. <code xmlns=
6089 "http://www.w3.org/TR/xhtml1/transitional" class=
6090 "filename">Makefile</code></a></span></dt>
6092 <dt><span class="sect1"><a href=
6093 "#components.distinfo">8.2. <code xmlns=
6094 "http://www.w3.org/TR/xhtml1/transitional" class=
6095 "filename">distinfo</code></a></span></dt>
6097 <dt><span class="sect1"><a href=
6098 "#components.patches">8.3. patches/*</a></span></dt>
6100 <dt><span class="sect1"><a href=
6101 "#other-mandatory-files">8.4. Other mandatory
6102 files</a></span></dt>
6104 <dt><span class="sect1"><a href=
6105 "#components.optional">8.5. Optional
6106 files</a></span></dt>
6108 <dt><span class="sect1"><a href="#work-dir">8.6.
6109 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
6110 class="filename">work*</code></a></span></dt>
6112 <dt><span class="sect1"><a href="#files-dir">8.7.
6113 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
6114 class="filename">files/*</code></a></span></dt>
6118 <p>Whenever you're preparing a package, there are a number
6119 of files involved which are described in the following
6122 <div class="sect1" lang="en" xml:lang="en">
6123 <div class="titlepage">
6126 <h2 class="title" style="clear: both"><a name=
6127 "components.Makefile" id=
6128 "components.Makefile"></a>8.1. <code xmlns=
6129 "http://www.w3.org/TR/xhtml1/transitional" class=
6130 "filename">Makefile</code></h2>
6135 <p>Building, installation and creation of a binary
6136 package are all controlled by the package's <code xmlns=
6137 "http://www.w3.org/TR/xhtml1/transitional" class=
6138 "filename">Makefile</code>. The <code xmlns=
6139 "http://www.w3.org/TR/xhtml1/transitional" class=
6140 "filename">Makefile</code> describes various things about
6141 a package, for example from where to get it, how to
6142 configure, build, and install it.</p>
6144 <p>A package <code xmlns=
6145 "http://www.w3.org/TR/xhtml1/transitional" class=
6146 "filename">Makefile</code> contains several sections that
6147 describe the package.</p>
6149 <p>In the first section there are the following
6150 variables, which should appear exactly in the order given
6153 <div class="itemizedlist">
6156 <p><code class="varname">DISTNAME</code> is the
6157 basename of the distribution file to be downloaded
6158 from the package's website.</p>
6162 <p><code class="varname">PKGNAME</code> is the name
6163 of the package, as used by pkgsrc. You only need to
6164 provide it if it differs from <code class=
6165 "varname">DISTNAME</code>. Usually it is the
6166 directory name together with the version number. It
6167 must match the regular expression <code class=
6168 "varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>,
6169 that is, it starts with a letter or digit, and
6170 contains only letters, digits, dashes, underscores,
6171 dots and plus signs.</p>
6175 <p><code class="varname">CATEGORIES</code> is a
6176 list of categories which the package fits in. You
6177 can choose any of the top-level directories of
6180 <p>Currently the following values are available for
6181 <code class="varname">CATEGORIES</code>. If more
6182 than one is used, they need to be separated by
6184 <pre class="programlisting">
6185 archivers cross geography meta-pkgs security
6186 audio databases graphics misc shells
6187 benchmarks devel ham multimedia sysutils
6188 biology editors inputmethod net textproc
6189 cad emulators lang news time
6190 chat finance mail parallel wm
6191 comms fonts math pkgtools www
6192 converters games mbone print x11
6197 <p><code class="varname">MASTER_SITES</code> is a
6198 list of URLs where the distribution files can be
6199 downloaded. Each URL must end with a slash.</p>
6201 <p>The <code class="varname">MASTER_SITES</code>
6202 may make use of the following predefined sites:</p>
6203 <pre class="programlisting">
6204 ${MASTER_SITE_APACHE}
6205 ${MASTER_SITE_BACKUP}
6206 ${MASTER_SITE_CYGWIN}
6207 ${MASTER_SITE_DEBIAN}
6208 ${MASTER_SITE_FREEBSD}
6209 ${MASTER_SITE_FREEBSD_LOCAL}
6210 ${MASTER_SITE_GNOME}
6212 ${MASTER_SITE_GNUSTEP}
6213 ${MASTER_SITE_IFARCHIVE}
6214 ${MASTER_SITE_MOZILLA}
6215 ${MASTER_SITE_OPENOFFICE}
6216 ${MASTER_SITE_PERL_CPAN}
6217 ${MASTER_SITE_R_CRAN}
6218 ${MASTER_SITE_SOURCEFORGE}
6219 ${MASTER_SITE_SUNSITE}
6221 ${MASTER_SITE_TEX_CTAN}
6222 ${MASTER_SITE_XCONTRIB}
6223 ${MASTER_SITE_XEMACS}
6226 <p>If one of these predefined sites is chosen, you
6227 may want to specify a subdirectory of that site.
6228 Since these macros may expand to more than one
6229 actual site, you <span class=
6230 "emphasis"><em>must</em></span> use the following
6231 construct to specify a subdirectory:</p>
6232 <pre class="programlisting">
6233 ${MASTER_SITE_GNU:=subdirectory/name/}
6234 ${MASTER_SITE_SOURCEFORGE:=project_name/}
6237 <p>Note the trailing slash after the subdirectory
6240 <p>If the package has multiple <code class=
6241 "varname">DISTFILES</code> or multiple <code class=
6242 "varname">PATCHFILES</code> from different sites,
6243 set <code class="varname">SITES_foo</code> to a
6244 list of URIs where file “<span class=
6245 "quote">foo</span>” may be found.
6246 “<span class="quote">foo</span>”
6247 includes the suffix, e.g.:</p>
6248 <pre class="programlisting">
6249 DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
6250 DISTFILES+= foo-file.tar.gz
6251 SITES_foo-file.tar.gz=http://www.somewhere.com/somehow/ \
6252 http://www.somewhereelse.com/mirror/somehow/
6257 <p><code class="varname">DISTFILES</code>: Name(s)
6258 of archive file(s) containing distribution. The
6259 default is <code xmlns=
6260 "http://www.w3.org/TR/xhtml1/transitional" class=
6261 "filename">${DISTNAME}${EXTRACT_SUFX}</code>.
6262 Should only be set if you have more than one
6265 <p>Note that the normal default setting of
6266 <code class="varname">DISTFILES</code> must be made
6267 explicit if you want to add to it (rather than
6268 replace it), as you usually would.</p>
6272 <p><code class="varname">EXTRACT_SUFX</code>:
6273 Suffix of the distribution file, will be appended
6274 to <code class="varname">DISTNAME</code>. Defaults
6276 "http://www.w3.org/TR/xhtml1/transitional" class=
6277 "filename">.tar.gz</code>.</p>
6282 <p>The second section contains information about
6283 separately downloaded patches, if any.</p>
6285 <div class="itemizedlist">
6288 <p><code class="varname">PATCHFILES:</code> Name(s)
6289 of additional files that contain distribution
6290 patches. There is no default. pkgsrc will look for
6291 them at <code class="varname">PATCH_SITES</code>.
6292 They will automatically be uncompressed before
6293 patching if the names end with <code xmlns=
6294 "http://www.w3.org/TR/xhtml1/transitional" class=
6295 "filename">.gz</code> or <code xmlns=
6296 "http://www.w3.org/TR/xhtml1/transitional" class=
6297 "filename">.Z</code>.</p>
6301 <p><code class="varname">PATCH_SITES</code>:
6302 Primary location(s) for distribution patch files
6303 (see <code class="varname">PATCHFILES</code> below)
6304 if not found locally.</p>
6309 <p>The third section contains the following
6312 <div class="itemizedlist">
6315 <p><code class="varname">MAINTAINER</code> is the
6316 email address of the person who feels responsible
6317 for this package, and who is most likely to look at
6318 problems or questions regarding this package which
6319 have been reported with <a href=
6320 "http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-current">
6321 <span class="citerefentry"><span class=
6322 "refentrytitle">send-pr</span>(1)</span></a>. Other
6323 developers should contact the <code class=
6324 "varname">MAINTAINER</code> before making major
6325 changes to the package. When packaging a new
6326 program, set <code class=
6327 "varname">MAINTAINER</code> to yourself. If you
6328 really can't maintain the package for future
6329 updates, set it to <code class="email"><<a href=
6330 "mailto:tech-pkg@NetBSD.org">tech-pkg@NetBSD.org</a>></code>.</p>
6334 <p><code class="varname">HOMEPAGE</code> is a URL
6335 where users can find more information about the
6340 <p><code class="varname">COMMENT</code> is a
6341 one-line description of the package (should not
6342 include the package name).</p>
6347 <p>Other variables that affect the build:</p>
6349 <div class="itemizedlist">
6352 <p><code class="varname">WRKSRC</code>: The
6353 directory where the interesting distribution files
6354 of the package are found. The default is
6356 "http://www.w3.org/TR/xhtml1/transitional" class=
6357 "filename">${WRKDIR}/${DISTNAME}</code>, which
6358 works for most packages.</p>
6360 <p>If a package doesn't create a subdirectory for
6361 itself (most GNU software does, for instance), but
6362 extracts itself in the current directory, you
6363 should set <code class="varname">WRKSRC=
6364 ${WRKDIR}</code>.</p>
6366 <p>If a package doesn't create a subdirectory with
6367 the name of <code class="varname">DISTNAME</code>
6368 but some different name, set <code class=
6369 "varname">WRKSRC</code> to point to the proper name
6371 "http://www.w3.org/TR/xhtml1/transitional" class=
6372 "filename">${WRKDIR}</code>, for example
6373 <code class="varname">WRKSRC=
6374 ${WRKDIR}/${DISTNAME}/unix</code>. See <a xmlns=
6375 "http://www.w3.org/TR/xhtml1/transitional" href=
6376 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/lang/tcl/README.html"
6377 target="_top"><code xmlns="" class=
6378 "filename">lang/tcl</code></a> and <a xmlns=
6379 "http://www.w3.org/TR/xhtml1/transitional" href=
6380 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/tk/README.html"
6381 target="_top"><code xmlns="" class=
6382 "filename">x11/tk</code></a> for other
6385 <p>The name of the working directory created by
6386 pkgsrc is taken from the <code class=
6387 "varname">WRKDIR_BASENAME</code> variable. By
6388 default, its value is <code xmlns=
6389 "http://www.w3.org/TR/xhtml1/transitional" class=
6390 "filename">work</code>. If you want to use the same
6391 pkgsrc tree for building different kinds of binary
6392 packages, you can change the variable according to
6393 your needs. Two other variables handle common cases
6394 of setting <code class=
6395 "varname">WRKDIR_BASENAME</code> individually. If
6396 <code class="varname">OBJHOSTNAME</code> is defined
6398 "http://www.w3.org/TR/xhtml1/transitional" class=
6399 "filename">/etc/mk.conf</code>, the first component
6400 of the host's name is attached to the directory
6401 name. If <code class="varname">OBJMACHINE</code> is
6402 defined, the platform name is attached, which might
6403 look like <code xmlns=
6404 "http://www.w3.org/TR/xhtml1/transitional" class=
6405 "filename">work.i386</code> or <code xmlns=
6406 "http://www.w3.org/TR/xhtml1/transitional" class=
6407 "filename">work.sparc</code>.</p>
6412 <p>Please pay attention to the following gotchas:</p>
6414 <div class="itemizedlist">
6417 <p>Add <code class="varname">MANCOMPRESSED</code>
6418 if man pages are installed in compressed form by
6419 the package; see comment in <code xmlns=
6420 "http://www.w3.org/TR/xhtml1/transitional" class=
6421 "filename">bsd.pkg.mk</code>.</p>
6425 <p>Replace <code xmlns=
6426 "http://www.w3.org/TR/xhtml1/transitional" class=
6427 "filename">/usr/local</code> with
6428 “<span class="quote">${PREFIX}</span>”
6429 in all files (see patches, below).</p>
6433 <p>If the package installs any info files, see
6434 <a href="#faq.info-files" title=
6435 "15.5.7. Packages installing info files">Section 15.5.7,
6436 “Packages installing info
6437 files”</a>.</p>
6443 <div class="sect1" lang="en" xml:lang="en">
6444 <div class="titlepage">
6447 <h2 class="title" style="clear: both"><a name=
6448 "components.distinfo" id=
6449 "components.distinfo"></a>8.2. <code xmlns=
6450 "http://www.w3.org/TR/xhtml1/transitional" class=
6451 "filename">distinfo</code></h2>
6457 "http://www.w3.org/TR/xhtml1/transitional" class=
6458 "filename">distinfo</code> file contains the message
6459 digest, or checksum, of each distfile needed for the
6460 package. This ensures that the distfiles retrieved from
6461 the Internet have not been corrupted during transfer or
6462 altered by a malign force to introduce a security hole.
6463 Due to recent rumor about weaknesses of digest
6464 algorithms, all distfiles are protected using both SHA1
6465 and RMD160 message digests, as well as the file size.</p>
6468 "http://www.w3.org/TR/xhtml1/transitional" class=
6469 "filename">distinfo</code> file also contains the
6470 checksums for all the patches found in the <code xmlns=
6471 "http://www.w3.org/TR/xhtml1/transitional" class=
6472 "filename">patches</code> directory (see <a href=
6473 "#components.patches" title=
6474 "8.3. patches/*">Section 8.3,
6475 “patches/*”</a>).</p>
6477 <p>To regenerate the <code xmlns=
6478 "http://www.w3.org/TR/xhtml1/transitional" class=
6479 "filename">distinfo</code> file, use the
6480 <span><strong class="command">make
6481 makedistinfo</strong></span> or <span><strong class=
6482 "command">make mdi</strong></span> command.</p>
6484 <p>Some packages have different sets of distfiles
6485 depending on the platform, for example <a xmlns=
6486 "http://www.w3.org/TR/xhtml1/transitional" href=
6487 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/navigator/README.html"
6488 target="_top"><code xmlns="" class=
6489 "filename">www/navigator</code></a>). These are kept in
6490 the same <code xmlns=
6491 "http://www.w3.org/TR/xhtml1/transitional" class=
6492 "filename">distinfo</code> file and care should be taken
6493 when upgrading such a package to ensure distfile
6494 information is not lost.</p>
6497 <div class="sect1" lang="en" xml:lang="en">
6498 <div class="titlepage">
6501 <h2 class="title" style="clear: both"><a name=
6502 "components.patches" id=
6503 "components.patches"></a>8.3. patches/*</h2>
6508 <p>This directory contains files that are used by the
6510 "http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current">
6511 <span class="citerefentry"><span class=
6512 "refentrytitle">patch</span>(1)</span></a> command to
6513 modify the sources as distributed in the distribution
6514 file into a form that will compile and run perfectly on
6515 NetBSD. The files are applied successively in alphabetic
6516 order (as returned by a shell “<span class=
6517 "quote">patches/patch-*</span>” glob expansion), so
6518 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
6519 class="filename">patch-aa</code> is applied before
6520 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
6521 class="filename">patch-ab</code>, etc.</p>
6524 "http://www.w3.org/TR/xhtml1/transitional" class=
6525 "filename">patch-*</code> files should be in
6526 <span><strong class="command">diff -bu</strong></span>
6527 format, and apply without a fuzz to avoid problems. (To
6528 force patches to apply with fuzz you can set <code class=
6529 "varname">PATCH_FUZZ_FACTOR=-F2</code>). Furthermore, do
6530 not put changes for more than one file into a single
6531 patch file, as this will make future modifications more
6534 <p>Similar, a file should be patched at most once, not
6535 several times by several different patches. If a file
6536 needs several patches, they should be combined into one
6539 <p>One important thing to mention is to pay attention
6540 that no RCS IDs get stored in the patch files, as these
6541 will cause problems when later checked into the NetBSD
6542 CVS tree. Use the <span><strong class=
6543 "command">pkgdiff</strong></span> from the <a xmlns=
6544 "http://www.w3.org/TR/xhtml1/transitional" href=
6545 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html"
6546 target="_top"><code xmlns="" class=
6547 "filename">pkgtools/pkgdiff</code></a> package to avoid
6550 <p>For even more automation, we recommend using
6551 <span><strong class="command">mkpatches</strong></span>
6552 from the same package to make a whole set of patches. You
6553 just have to backup files before you edit them to
6554 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
6555 class="filename">filename.orig</code>, e.g. with
6556 <span><strong class="command">cp -p filename
6557 filename.orig</strong></span> or, easier, by using
6558 <span><strong class="command">pkgvi</strong></span> again
6559 from the same package. If you upgrade a package this way,
6560 you can easily compare the new set of patches with the
6561 previously existing one with <span><strong class=
6562 "command">patchdiff</strong></span>.</p>
6564 <p>When you have finished a package, remember to generate
6565 the checksums for the patch files by using the
6566 <span><strong class="command">make
6567 makepatchsum</strong></span> command, see <a href=
6568 "#components.distinfo" title=
6569 "8.2. distinfo">Section 8.2,
6570 “<code xmlns="http://www.w3.org/TR/xhtml1/transitional"
6571 class="filename">distinfo</code>”</a>.</p>
6573 <p>When adding a patch that corrects a problem in the
6574 distfile (rather than e.g. enforcing pkgsrc's view of
6575 where man pages should go), send the patch as a bug
6576 report to the maintainer. This benefits non-pkgsrc users
6577 of the package, and usually enables removing the patch in
6580 <p>Patch files that are distributed by the author or
6581 other maintainers can be listed in <code class=
6582 "varname">$PATCHFILES</code>.</p>
6584 <p>If it is desired to store any patches that should not
6585 be committed into pkgsrc, they can be kept outside the
6586 pkgsrc tree in the <code xmlns=
6587 "http://www.w3.org/TR/xhtml1/transitional" class=
6588 "filename">$LOCALPATCHES</code> directory. The directory
6589 tree there is expected to have the same
6590 “<span class="quote">category/package</span>”
6591 structure as pkgsrc, and patches are expected to be
6592 stored inside these dirs (also known as <code xmlns=
6593 "http://www.w3.org/TR/xhtml1/transitional" class=
6594 "filename">$LOCALPATCHES/$PKGPATH</code>). For example,
6595 if you want to keep a private patch for <code xmlns=
6596 "http://www.w3.org/TR/xhtml1/transitional" class=
6597 "filename">pkgsrc/graphics/png</code>, keep it in
6598 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
6600 "filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
6601 files in the named directory are expected to be patch
6602 files, and <span class="emphasis"><em>they are applied
6603 after pkgsrc patches are applied</em></span>.</p>
6606 <div class="sect1" lang="en" xml:lang="en">
6607 <div class="titlepage">
6610 <h2 class="title" style="clear: both"><a name=
6611 "other-mandatory-files" id=
6612 "other-mandatory-files"></a>8.4. Other
6613 mandatory files</h2>
6618 <div class="variablelist">
6620 <dt><span class="term"><code xmlns=
6621 "http://www.w3.org/TR/xhtml1/transitional" class=
6622 "filename">DESCR</code></span></dt>
6625 <p>A multi-line description of the piece of
6626 software. This should include any credits where
6627 they are due. Please bear in mind that others do
6628 not share your sense of humour (or spelling
6629 idiosyncrasies), and that others will read
6630 everything that you write here.</p>
6633 <dt><span class="term"><code xmlns=
6634 "http://www.w3.org/TR/xhtml1/transitional" class=
6635 "filename">PLIST</code></span></dt>
6638 <p>This file governs the files that are installed
6639 on your system: all the binaries, manual pages,
6640 etc. There are other directives which may be
6641 entered in this file, to control the creation and
6642 deletion of directories, and the location of
6643 inserted files. See <a href="#plist" title=
6644 "Chapter 10. PLIST issues">Chapter 10,
6645 <i>PLIST issues</i></a> for more information.</p>
6651 <div class="sect1" lang="en" xml:lang="en">
6652 <div class="titlepage">
6655 <h2 class="title" style="clear: both"><a name=
6656 "components.optional" id=
6657 "components.optional"></a>8.5. Optional
6663 <div class="variablelist">
6665 <dt><span class="term"><code xmlns=
6666 "http://www.w3.org/TR/xhtml1/transitional" class=
6667 "filename">INSTALL</code></span></dt>
6670 <p>This shell script is invoked twice by <a href=
6671 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current">
6672 <span class="citerefentry"><span class=
6673 "refentrytitle">pkg_add</span>(1)</span></a>. First
6674 time after package extraction and before files are
6675 moved in place, the second time after the files to
6676 install are moved in place. This can be used to do
6677 any custom procedures not possible with @exec
6678 commands in <code xmlns=
6679 "http://www.w3.org/TR/xhtml1/transitional" class=
6680 "filename">PLIST</code>. See <a href=
6681 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current">
6682 <span class="citerefentry"><span class=
6683 "refentrytitle">pkg_add</span>(1)</span></a> and
6685 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current">
6686 <span class="citerefentry"><span class=
6687 "refentrytitle">pkg_create</span>(1)</span></a> for
6688 more information.</p>
6691 <dt><span class="term"><code xmlns=
6692 "http://www.w3.org/TR/xhtml1/transitional" class=
6693 "filename">DEINSTALL</code></span></dt>
6696 <p>This script is executed before and after any
6697 files are removed. It is this script's
6698 responsibility to clean up any additional messy
6699 details around the package's installation, since
6700 all pkg_delete knows is how to delete the files
6701 created in the original distribution. See <a href=
6702 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current">
6703 <span class="citerefentry"><span class=
6704 "refentrytitle">pkg_delete</span>(1)</span></a> and
6706 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current">
6707 <span class="citerefentry"><span class=
6708 "refentrytitle">pkg_create</span>(1)</span></a> for
6709 more information.</p>
6712 <dt><span class="term"><code xmlns=
6713 "http://www.w3.org/TR/xhtml1/transitional" class=
6714 "filename">MESSAGE</code></span></dt>
6717 <p>This file is displayed after installation of the
6718 package. Useful for things like legal notices on
6719 almost-free software and hints for updating config
6720 files after installing modules for apache, PHP etc.
6721 Please note that you can modify variables in it
6722 easily by using <code class=
6723 "varname">MESSAGE_SUBST</code> in the package's
6725 "http://www.w3.org/TR/xhtml1/transitional" class=
6726 "filename">Makefile</code>:</p>
6727 <pre class="programlisting">
6728 MESSAGE_SUBST+= SOMEVAR="somevalue"
6731 <p>replaces "${SOMEVAR}" with “<span class=
6732 "quote">somevalue</span>” in <code xmlns=
6733 "http://www.w3.org/TR/xhtml1/transitional" class=
6734 "filename">MESSAGE</code>.</p>
6740 <div class="sect1" lang="en" xml:lang="en">
6741 <div class="titlepage">
6744 <h2 class="title" style="clear: both"><a name=
6745 "work-dir" id="work-dir"></a>8.6. <code xmlns=
6746 "http://www.w3.org/TR/xhtml1/transitional" class=
6747 "filename">work*</code></h2>
6752 <p>When you type <span><strong class=
6753 "command">make</strong></span>, the distribution files
6754 are unpacked into the directory denoted by <code class=
6755 "varname">WRKDIR</code>. It can be removed by running
6756 <span><strong class="command">make clean</strong></span>.
6757 Besides the sources, this directory is also used to keep
6758 various timestamp files. The directory gets <span class=
6759 "emphasis"><em>removed completely</em></span> on clean.
6760 The default is <code xmlns=
6761 "http://www.w3.org/TR/xhtml1/transitional" class=
6762 "filename">${.CURDIR}/work</code> or <code xmlns=
6763 "http://www.w3.org/TR/xhtml1/transitional" class=
6764 "filename">${.CURDIR}/work.${MACHINE_ARCH}</code> if
6765 <code class="varname">OBJMACHINE</code> is set.</p>
6768 <div class="sect1" lang="en" xml:lang="en">
6769 <div class="titlepage">
6772 <h2 class="title" style="clear: both"><a name=
6774 "files-dir"></a>8.7. <code xmlns=
6775 "http://www.w3.org/TR/xhtml1/transitional" class=
6776 "filename">files/*</code></h2>
6781 <p>If you have any files that you wish to be placed in
6782 the package prior to configuration or building, you could
6783 place these files here and use a “<span class=
6784 "quote">${CP}</span>” command in the
6785 “<span class="quote">pre-configure</span>”
6786 target to achieve this. Alternatively, you could simply
6787 diff the file against <code xmlns=
6788 "http://www.w3.org/TR/xhtml1/transitional" class=
6789 "filename">/dev/null</code> and use the patch mechanism
6790 to manage the creation of this file.</p>
6794 <div class="chapter" lang="en" xml:lang="en">
6795 <div class="titlepage">
6798 <h2 class="title"><a name="makefile" id=
6799 "makefile"></a>Chapter 9. Programming in
6801 "http://www.w3.org/TR/xhtml1/transitional" class=
6802 "filename">Makefile</code>s</h2>
6808 <p><b>Table of Contents</b></p>
6811 <dt><span class="sect1"><a href=
6812 "#makefile.variables">9.1. <code xmlns=
6813 "http://www.w3.org/TR/xhtml1/transitional" class=
6814 "filename">Makefile</code> variables</a></span></dt>
6818 <dt><span class="sect2"><a href=
6819 "#makefile.variables.names">9.1.1. Naming
6820 conventions</a></span></dt>
6824 <dt><span class="sect1"><a href="#makefile.code">9.2.
6825 Code snippets</a></span></dt>
6829 <dt><span class="sect2"><a href=
6830 "#adding-to-list">9.2.1. Adding things to a
6831 list</a></span></dt>
6833 <dt><span class="sect2"><a href=
6834 "#converting-internal-to-external">9.2.2.
6835 Converting an internal list into an external
6836 list</a></span></dt>
6838 <dt><span class="sect2"><a href=
6839 "#passing-variable-to-shell">9.2.3. Passing
6840 variables to a shell command</a></span></dt>
6842 <dt><span class="sect2"><a href=
6843 "#quoting-guideline">9.2.4. Quoting
6844 guideline</a></span></dt>
6846 <dt><span class="sect2"><a href=
6847 "#bsd-make-bug-workaround">9.2.5. Workaround for a
6848 bug in BSD Make</a></span></dt>
6854 <p>Pkgsrc consists of many <code xmlns=
6855 "http://www.w3.org/TR/xhtml1/transitional" class=
6856 "filename">Makefile</code> fragments, each of which forms a
6857 well-defined part of the pkgsrc system. Using the <a href=
6858 "http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current">
6859 <span class="citerefentry"><span class=
6860 "refentrytitle">make</span>(1)</span></a> system as a
6861 programming language for a big system like pkgsrc requires
6862 some discipline to keep the code correct and
6865 <p>The basic ingredients for <code xmlns=
6866 "http://www.w3.org/TR/xhtml1/transitional" class=
6867 "filename">Makefile</code> programming are variables (which
6868 are actually macros) and shell commands. Among these shell
6869 commands may even be more complex ones like <a href=
6870 "http://netbsd.gw.com/cgi-bin/man-cgi?awk+1+NetBSD-current">
6871 <span class="citerefentry"><span class=
6872 "refentrytitle">awk</span>(1)</span></a> programs. To make
6873 sure that every shell command runs as intended it is
6874 necessary to quote all variables correctly when they are
6877 <p>This chapter describes some patterns, that appear quite
6878 often in <code xmlns=
6879 "http://www.w3.org/TR/xhtml1/transitional" class=
6880 "filename">Makefile</code>s, including the pitfalls that
6881 come along with them.</p>
6883 <div class="sect1" lang="en" xml:lang="en">
6884 <div class="titlepage">
6887 <h2 class="title" style="clear: both"><a name=
6888 "makefile.variables" id=
6889 "makefile.variables"></a>9.1. <code xmlns=
6890 "http://www.w3.org/TR/xhtml1/transitional" class=
6891 "filename">Makefile</code> variables</h2>
6896 <p><code xmlns="http://www.w3.org/TR/xhtml1/transitional"
6897 class="filename">Makefile</code> variables contain
6898 strings that can be processed using the five operators
6899 ``='', ``+='', ``?='', ``:='', and ``!='', which are
6900 described in the <a href=
6901 "http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current">
6902 <span class="citerefentry"><span class=
6903 "refentrytitle">make</span>(1)</span></a> man page.</p>
6905 <p>When a variable's value is parsed from a <code xmlns=
6906 "http://www.w3.org/TR/xhtml1/transitional" class=
6907 "filename">Makefile</code>, the hash character ``#'' and
6908 the backslash character ``\'' are handled specially. If a
6909 backslash is followed by a newline, any whitespace
6910 immediately in front of the backslash, the backslash, the
6911 newline, and any whitespace immediately behind the
6912 newline are replaced with a single space. A backspace
6913 character and an immediately following hash character are
6914 replaced with a single hash character. Otherwise, the
6915 backslash is passed as is. In a variable assignment, any
6916 hash character that is not preceded by a backslash starts
6917 a comment that continues upto the end of the logical
6920 <p><span class="emphasis"><em>Note:</em></span> Because
6921 of this parsing algorithm the only way to create a
6922 variable consisting of a single backslash is using the
6923 ``!='' operator, for example: <code class=
6924 "varname">BACKSLASH!=echo "\\"</code>.</p>
6926 <p>So far for defining variables. The other thing you can
6927 do with variables is evaluating them. A variable is
6928 evaluated when it is part of the right side of the ``:=''
6929 or the ``!='' operator, or directly before executing a
6930 shell command which the variable is part of. In all other
6932 "http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current">
6933 <span class="citerefentry"><span class=
6934 "refentrytitle">make</span>(1)</span></a> performs lazy
6935 evaluation, that is, variables are not evaluated until
6936 there's no other way. The ``modifiers'' mentioned in the
6937 man page also evaluate the variable.</p>
6939 <p>Some of the modifiers split the string into words and
6940 then operate on the words, others operate on the string
6941 as a whole. When a string is split into words, it is
6942 split as you would expect it from <a href=
6943 "http://netbsd.gw.com/cgi-bin/man-cgi?sh+1+NetBSD-current">
6944 <span class="citerefentry"><span class=
6945 "refentrytitle">sh</span>(1)</span></a>.</p>
6947 <p>No rule without exception—the
6948 <span><strong class="command">.for</strong></span> loop
6949 does not follow the shell quoting rules but splits at
6950 sequences of whitespace.</p>
6952 <p>There are several types of variables that should be
6953 handled differently. Strings and two types of lists.</p>
6955 <div class="itemizedlist">
6958 <p><span class="emphasis"><em>Strings</em></span>
6959 can contain arbitrary characters. Nevertheless, you
6960 should restrict yourself to only using printable
6961 characters. Examples are <code class=
6962 "varname">PREFIX</code> and <code class=
6963 "varname">COMMENT</code>.</p>
6967 <p><span class="emphasis"><em>Internal
6968 lists</em></span> are lists that are never exported
6969 to any shell command. Their elements are separated
6970 by whitespace. Therefore, the elements themselves
6971 cannot have embedded whitespace. Any other
6972 characters are allowed. Internal lists can be used
6973 in <span><strong class=
6974 "command">.for</strong></span> loops. Examples are
6975 <code class="varname">DEPENDS</code> and
6976 <code class="varname">BUILD_DEPENDS</code>.</p>
6980 <p><span class="emphasis"><em>External
6981 lists</em></span> are lists that may be exported to
6982 a shell command. Their elements can contain any
6983 characters, including whitespace. That's why they
6984 cannot be used in <span><strong class=
6985 "command">.for</strong></span> loops. Examples are
6986 <code class="varname">DISTFILES</code> and
6987 <code class="varname">MASTER_SITES</code>.</p>
6992 <div class="sect2" lang="en" xml:lang="en">
6993 <div class="titlepage">
6996 <h3 class="title"><a name=
6997 "makefile.variables.names" id=
6998 "makefile.variables.names"></a>9.1.1. Naming
7004 <div class="itemizedlist">
7007 <p>All variable names starting with an underscore
7008 are reserved for use by the pkgsrc
7009 infrastructure. They shall not be used by package
7011 "http://www.w3.org/TR/xhtml1/transitional" class=
7012 "filename">Makefile</code>s.</p>
7016 <p>In <span><strong class=
7017 "command">.for</strong></span> loops you should
7018 use lowercase variable names for the iteration
7023 <p>All list variables should have a ``plural''
7024 name, e.g. <code class=
7025 "varname">PKG_OPTIONS</code> or <code class=
7026 "varname">DISTFILES</code>.</p>
7033 <div class="sect1" lang="en" xml:lang="en">
7034 <div class="titlepage">
7037 <h2 class="title" style="clear: both"><a name=
7039 "makefile.code"></a>9.2. Code snippets</h2>
7044 <p>This section presents you with some code snippets you
7045 should use in your own code. If you don't find anything
7046 appropriate here, you should test your code and add it
7049 <div class="sect2" lang="en" xml:lang="en">
7050 <div class="titlepage">
7053 <h3 class="title"><a name="adding-to-list" id=
7054 "adding-to-list"></a>9.2.1. Adding things to
7059 <pre class="programlisting">
7060 STRING= foo * bar `date`
7062 ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
7064 ANOTHER_EXT_LIST= a=b c=d
7066 INT_LIST+= ${STRING} # 1
7067 INT_LIST+= ${ANOTHER_INT_LIST} # 2
7068 EXT_LIST+= ${STRING:Q} # 3
7069 EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
7072 <p>When you add a string to an external list (example
7073 3), it must be quoted. In all other cases, you must not
7074 add a quoting level. You must not merge internal and
7075 external lists, unless you are sure that all entries
7076 are correctly interpreted in both lists.</p>
7079 <div class="sect2" lang="en" xml:lang="en">
7080 <div class="titlepage">
7083 <h3 class="title"><a name=
7084 "converting-internal-to-external" id=
7085 "converting-internal-to-external"></a>9.2.2. Converting
7086 an internal list into an external list</h3>
7090 <pre class="programlisting">
7092 .for i in ${INT_LIST}
7097 <p>This code converts the internal list <code class=
7098 "varname">INT_LIST</code> into the external list
7099 <code class="varname">EXT_LIST</code>. As the elements
7100 of an internal list are unquoted they must be quoted
7101 here. The reason for appending <code class=
7102 "varname">""</code> is explained below.</p>
7105 <div class="sect2" lang="en" xml:lang="en">
7106 <div class="titlepage">
7109 <h3 class="title"><a name=
7110 "passing-variable-to-shell" id=
7111 "passing-variable-to-shell"></a>9.2.3. Passing
7112 variables to a shell command</h3>
7116 <pre class="programlisting">
7117 STRING= foo bar < > * `date` $$HOME ' "
7118 EXT_LIST= string=${STRING:Q} x=second\ item
7122 echo "${STRING}" # 2
7123 echo "${STRING:Q}" # 3
7124 echo ${STRING:Q} # 4
7125 echo x${STRING:Q} | sed 1s,.,, # 5
7126 env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
7129 <p>Example 1 leads to a syntax error in the shell, as
7130 the characters are just copied.</p>
7132 <p>Example 2 leads to a syntax error too, and if you
7133 leave out the last " character from <code class=
7134 "varname">${STRING}</code>, <a href=
7135 "http://netbsd.gw.com/cgi-bin/man-cgi?date+1+NetBSD-current">
7136 <span class="citerefentry"><span class=
7137 "refentrytitle">date</span>(1)</span></a> will be
7138 executed. The <code class="varname">$HOME</code> shell
7139 variable would be evaluated, too.</p>
7141 <p>Example 3 outputs each space character preceded by a
7142 backslash (or not), depending on the implementation of
7144 "http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current">
7145 <span class="citerefentry"><span class=
7146 "refentrytitle">echo</span>(1)</span></a> command.</p>
7148 <p>Example 4 handles correctly every string that does
7149 not start with a dash. In that case, the result depends
7150 on the implementation of the <a href=
7151 "http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current">
7152 <span class="citerefentry"><span class=
7153 "refentrytitle">echo</span>(1)</span></a> command. As
7154 long as you can guarantee that your input does not
7155 start with a dash, this form is appropriate.</p>
7157 <p>Example 5 handles even the case of a leading dash
7160 <p>The <code class="varname">EXT_LIST</code> does not
7161 need to be quoted because the quoting has already been
7162 done when adding elements to the list.</p>
7164 <p>As internal lists shall not be passed to the shell,
7165 there is no example for it.</p>
7168 <div class="sect2" lang="en" xml:lang="en">
7169 <div class="titlepage">
7172 <h3 class="title"><a name="quoting-guideline" id=
7173 "quoting-guideline"></a>9.2.4. Quoting
7179 <p>There are many possible sources of wrongly quoted
7180 variables. This section lists some of the commonly
7183 <div class="itemizedlist">
7186 <p>Whenever you use the value of a list, think
7187 about what happens to leading or trailing
7188 whitespace. If the list is a well-formed shell
7189 expression, you can apply the <code class=
7190 "varname">:M*</code> modifier to strip leading
7191 and trailing whitespace from each word. The
7192 <code class="varname">:M</code> operator first
7193 splits its argument according to the rules of the
7194 shell, and then creates a new list consisting of
7195 all words that match the shell glob expression
7196 <code class="varname">*</code>, that is: all. One
7197 class of situations where this is needed is when
7198 adding a variable like <code class=
7199 "varname">CPPFLAGS</code> to <code class=
7200 "varname">CONFIGURE_ARGS</code>. If the configure
7201 script invokes other configure scripts, it strips
7202 the leading and trailing whitespace from the
7203 variable and then passes it to the other
7204 configure scripts. But these configure scripts
7205 expect the (child) <code class=
7206 "varname">CPPFLAGS</code> variable to be the same
7207 as the parent <code class=
7208 "varname">CPPFLAGS</code>. That's why we better
7209 pass the <code class="varname">CPPFLAGS</code>
7210 value properly trimmed. And here is how we do
7212 <pre class="programlisting">
7214 CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
7215 CPPFLAGS+= ${MY_CPPFLAGS}
7217 CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
7220 echo x${CPPFLAGS:Q}x # leading and trailing whitespace
7221 echo x${CONFIGURE_ARGS}x # properly trimmed
7226 <p>The example above contains one bug: The
7227 <code class="varname">${PREFIX}</code> is a
7228 properly quoted shell expression, but there is
7229 the C compiler after it, which also expects a
7230 properly quoted string (this time in C syntax).
7231 The version above is therefore only correct if
7232 <code class="varname">${PREFIX}</code> does not
7233 have embedded backslashes or double quotes. If
7234 you want to allow these, you have to add another
7235 layer of quoting to each variable that is used as
7236 a C string literal. You cannot use the
7237 <code class="varname">:Q</code> operator for it,
7238 as this operator only works for the shell.</p>
7242 <p>Whenever a variable can be empty, the
7243 <code class="varname">:Q</code> operator can have
7244 surprising results. Here are two completely
7245 different cases which can be solved with the same
7247 <pre class="programlisting">
7250 for i in a ${EMPTY:Q} c; do \
7255 .for i in a:\ a:\test.txt
7261 <p>The first example will only print two of the
7262 three lines we might have expected. This is
7263 because <code class="varname">${EMPTY:Q}</code>
7264 expands to the empty string, which the shell
7265 cannot see. The workaround is to write
7266 <code class="varname">${EMPTY:Q}""</code>. This
7267 pattern can be often found as <code class=
7268 "varname">${TEST} -z ${VAR:Q}</code> or as
7269 <code class="varname">${TEST} -f
7270 ${FNAME:Q}</code> (both of these are wrong).</p>
7272 <p>The second example will only print three lines
7273 instead of four. The first line looks like
7274 <code class="varname">a:\ echo foo</code>. This
7275 is because the backslash of the value
7276 <code class="varname">a:\</code> is interpreted
7277 as a line-continuation by <a href=
7278 "http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current">
7279 <span class="citerefentry"><span class=
7280 "refentrytitle">make</span>(1)</span></a>, which
7281 makes the second line the arguments of the
7283 "http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current">
7284 <span class="citerefentry"><span class=
7285 "refentrytitle">echo</span>(1)</span></a> command
7286 from the first line. To avoid this, write
7287 <code class="varname">${i:Q}""</code>.</p>
7293 <div class="sect2" lang="en" xml:lang="en">
7294 <div class="titlepage">
7297 <h3 class="title"><a name=
7298 "bsd-make-bug-workaround" id=
7299 "bsd-make-bug-workaround"></a>9.2.5. Workaround
7300 for a bug in BSD Make</h3>
7305 <p>The pkgsrc bmake program does not handle the
7306 following assignment correctly. In case <code class=
7307 "varname">_othervar_</code> contains a ``-'' character,
7308 one of the closing braces is included in <code class=
7309 "varname">${VAR}</code> after this code executes.</p>
7310 <pre class="programlisting">
7311 VAR:= ${VAR:N${_othervar_:C/-//}}
7314 <p>For a more complex code snippet and a workaround,
7315 see the package <a xmlns=
7316 "http://www.w3.org/TR/xhtml1/transitional" href=
7317 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/regress/make-quoting/README.html"
7318 target="_top"><code xmlns="" class=
7319 "filename">regress/make-quoting</code></a>, testcase
7320 <code class="varname">bug1</code>.</p>
7325 <div class="chapter" lang="en" xml:lang="en">
7326 <div class="titlepage">
7329 <h2 class="title"><a name="plist" id=
7330 "plist"></a>Chapter 10. PLIST issues</h2>
7336 <p><b>Table of Contents</b></p>
7339 <dt><span class="sect1"><a href="#rcs-id">10.1. RCS
7342 <dt><span class="sect1"><a href=
7343 "#automatic-plist-generation">10.2. Semi-automatic
7344 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
7345 class="filename">PLIST</code>
7346 generation</a></span></dt>
7348 <dt><span class="sect1"><a href="#print-PLIST">10.3.
7349 Tweaking output of <span><strong class="command">make
7350 print-PLIST</strong></span></a></span></dt>
7352 <dt><span class="sect1"><a href="#plist.misc">10.4.
7353 Variable substitution in PLIST</a></span></dt>
7355 <dt><span class="sect1"><a href=
7356 "#manpage-compression">10.5. Man page
7357 compression</a></span></dt>
7359 <dt><span class="sect1"><a href=
7360 "#using-PLIST_SRC">10.6. Changing PLIST source with
7361 <code class="varname">PLIST_SRC</code></a></span></dt>
7363 <dt><span class="sect1"><a href=
7364 "#platform-specific-plist">10.7. Platform-specific and
7365 differing PLISTs</a></span></dt>
7367 <dt><span class="sect1"><a href=
7368 "#faq.common-dirs">10.8. Sharing directories between
7369 packages</a></span></dt>
7374 "http://www.w3.org/TR/xhtml1/transitional" class=
7375 "filename">PLIST</code> file contains a package's
7376 “<span class="quote">packing list</span>”, i.e.
7377 a list of files that belong to the package (relative to the
7378 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
7379 class="filename">${PREFIX}</code> directory it's been
7380 installed in) plus some additional statements - see the
7382 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current">
7383 <span class="citerefentry"><span class=
7384 "refentrytitle">pkg_create</span>(1)</span></a> man page
7385 for a full list. This chapter addresses some issues that
7386 need attention when dealing with the <code xmlns=
7387 "http://www.w3.org/TR/xhtml1/transitional" class=
7388 "filename">PLIST</code> file (or files, see below!).</p>
7390 <div class="sect1" lang="en" xml:lang="en">
7391 <div class="titlepage">
7394 <h2 class="title" style="clear: both"><a name=
7395 "rcs-id" id="rcs-id"></a>10.1. RCS ID</h2>
7400 <p>Be sure to add a RCS ID line as the first thing in any
7401 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
7402 class="filename">PLIST</code> file you write:</p>
7403 <pre class="programlisting">
7408 <div class="sect1" lang="en" xml:lang="en">
7409 <div class="titlepage">
7412 <h2 class="title" style="clear: both"><a name=
7413 "automatic-plist-generation" id=
7414 "automatic-plist-generation"></a>10.2. Semi-automatic
7416 "http://www.w3.org/TR/xhtml1/transitional" class=
7417 "filename">PLIST</code> generation</h2>
7422 <p>You can use the <span><strong class="command">make
7423 print-PLIST</strong></span> command to output a PLIST
7424 that matches any new files since the package was
7425 extracted. See <a href="#build.helpful-targets" title=
7426 "14.3. Other helpful targets">Section 14.3,
7427 “Other helpful targets”</a> for more
7428 information on this target.</p>
7431 <div class="sect1" lang="en" xml:lang="en">
7432 <div class="titlepage">
7435 <h2 class="title" style="clear: both"><a name=
7437 "print-PLIST"></a>10.3. Tweaking output of
7438 <span><strong class="command">make
7439 print-PLIST</strong></span></h2>
7444 <p>If you have used any of the *-dirs packages, as
7445 explained in <a href="#faq.common-dirs" title=
7446 "10.8. Sharing directories between packages">Section 10.8,
7447 “Sharing directories between packages”</a>,
7448 you may have noticed that <span><strong class=
7449 "command">make print-PLIST</strong></span> outputs a set
7450 of <code class="varname">@comment</code>s instead of real
7451 <code class="varname">@dirrm</code> lines. You can also
7452 do this for specific directories and files, so that the
7453 results of that command are very close to reality. This
7454 helps <span class="emphasis"><em>a lot</em></span> during
7455 the update of packages.</p>
7457 <p>The <code class="varname">PRINT_PLIST_AWK</code>
7458 variable takes a set of AWK patterns and actions that are
7459 used to filter the output of print-PLIST. You can
7460 <span class="emphasis"><em>append</em></span> any chunk
7461 of AWK scripting you like to it, but be careful with
7464 <p>For example, to get all files inside the <code xmlns=
7465 "http://www.w3.org/TR/xhtml1/transitional" class=
7466 "filename">libdata/foo</code> directory removed from the
7467 resulting PLIST:</p>
7468 <pre class="programlisting">
7469 PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
7472 <p>And to get all the <code class="varname">@dirrm</code>
7473 lines referring to a specific (shared) directory
7474 converted to <code class="varname">@comment</code>s:</p>
7475 <pre class="programlisting">
7476 PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
7480 <div class="sect1" lang="en" xml:lang="en">
7481 <div class="titlepage">
7484 <h2 class="title" style="clear: both"><a name=
7486 "plist.misc"></a>10.4. Variable substitution
7492 <p>A number of variables are substituted automatically in
7493 PLISTs when a package is installed on a system. This
7494 includes the following variables:</p>
7496 <div class="variablelist">
7498 <dt><span class="term"><code class=
7499 "varname">${MACHINE_ARCH}</code>, <code class=
7500 "varname">${MACHINE_GNU_ARCH}</code></span></dt>
7503 <p>Some packages like emacs and perl embed
7504 information about which architecture they were
7505 built on into the pathnames where they install
7506 their files. To handle this case, PLIST will be
7507 preprocessed before actually used, and the symbol
7508 “<span class="quote"><code class=
7509 "varname">${MACHINE_ARCH}</code></span>” will
7510 be replaced by what <span><strong class=
7511 "command">uname -p</strong></span> gives. The same
7512 is done if the string <code class=
7513 "varname">${MACHINE_GNU_ARCH}</code> is embedded in
7514 PLIST somewhere - use this on packages that have
7515 GNU autoconf-created configure scripts.</p>
7517 <div class="note" style=
7518 "margin-left: 0.5in; margin-right: 0.5in;">
7519 <h3 class="title">Legacy note</h3>
7521 <p>There used to be a symbol “<span class=
7522 "quote"><code class=
7523 "varname">$ARCH</code></span>” that was
7524 replaced by the output of <span><strong class=
7525 "command">uname -m</strong></span>, but that's no
7526 longer supported and has been removed.</p>
7530 <dt><span class="term"><code class=
7531 "varname">${OPSYS}</code>, <code class=
7532 "varname">${LOWER_OPSYS}</code>, <code class=
7533 "varname">${OS_VERSION}</code></span></dt>
7536 <p>Some packages want to embed the OS name and
7537 version into some paths. To do this, use these
7538 variables in the <code xmlns=
7539 "http://www.w3.org/TR/xhtml1/transitional" class=
7540 "filename">PLIST</code>:</p>
7542 <div class="itemizedlist">
7545 <p><code class="varname">${OPSYS}</code> -
7546 output of “<span class=
7547 "quote"><span><strong class="command">uname
7548 -s</strong></span></span>”</p>
7553 "varname">${LOWER_OPSYS}</code> - lowercase
7554 common name (eg. “<span class=
7555 "quote">solaris</span>”)</p>
7559 <p><code class="varname">${OS_VERSION}</code>
7560 - “<span class=
7561 "quote"><span><strong class="command">uname
7562 -r</strong></span></span>”</p>
7568 <dt><span class="term"><code class=
7569 "varname">${PKGLOCALEDIR}</code></span></dt>
7572 <p>Packages that install locale files should list
7573 them in the PLIST as “<span class=
7574 "quote">${PKGLOCALEDIR}/locale/de/LC_MESSAGES/...</span>”
7575 instead of “<span class=
7576 "quote">share/locale/de/LC_MESSAGES/...</span>”.
7577 This properly handles the fact that different
7578 operating systems expect locale files to be either
7580 "http://www.w3.org/TR/xhtml1/transitional" class=
7581 "filename">share</code> or <code xmlns=
7582 "http://www.w3.org/TR/xhtml1/transitional" class=
7583 "filename">lib</code> by default.</p>
7588 <p>For a complete list of values which are replaced by
7589 default, please look in <code xmlns=
7590 "http://www.w3.org/TR/xhtml1/transitional" class=
7591 "filename">bsd.pkg.mk</code> (and search for <span class=
7592 "emphasis"><em>PLIST_SUBST</em></span>).</p>
7594 <p>If you want to change other variables not listed
7595 above, you can add variables and their expansions to this
7596 variable in the following way, similar to <code class=
7597 "varname">MESSAGE_SUBST</code> (see <a href=
7598 "#components.optional" title=
7599 "8.5. Optional files">Section 8.5,
7600 “Optional files”</a>):</p>
7601 <pre class="programlisting">
7602 PLIST_SUBST+= SOMEVAR="somevalue"
7605 <p>This replaces all occurrences of “<span class=
7606 "quote">${SOMEVAR}</span>” in the PLIST with
7607 “<span class="quote">somevalue</span>”.</p>
7610 <div class="sect1" lang="en" xml:lang="en">
7611 <div class="titlepage">
7614 <h2 class="title" style="clear: both"><a name=
7615 "manpage-compression" id=
7616 "manpage-compression"></a>10.5. Man page
7622 <p>Man pages should be installed in compressed form if
7623 <code class="varname">MANZ</code> is set (in <code xmlns=
7624 "http://www.w3.org/TR/xhtml1/transitional" class=
7625 "filename">bsd.own.mk</code>), and uncompressed
7626 otherwise. To handle this in the <code xmlns=
7627 "http://www.w3.org/TR/xhtml1/transitional" class=
7628 "filename">PLIST</code> file, the suffix
7629 “<span class="quote">.gz</span>” is
7630 appended/removed automatically for man pages according to
7631 <code class="varname">MANZ</code> and <code class=
7632 "varname">MANCOMPRESSED</code> being set or not, see
7633 above for details. This modification of the <code xmlns=
7634 "http://www.w3.org/TR/xhtml1/transitional" class=
7635 "filename">PLIST</code> file is done on a copy of it, not
7636 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
7637 class="filename">PLIST</code> itself.</p>
7640 <div class="sect1" lang="en" xml:lang="en">
7641 <div class="titlepage">
7644 <h2 class="title" style="clear: both"><a name=
7645 "using-PLIST_SRC" id=
7646 "using-PLIST_SRC"></a>10.6. Changing PLIST
7647 source with <code class=
7648 "varname">PLIST_SRC</code></h2>
7653 <p>To use one or more files as source for the
7654 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
7655 class="filename">PLIST</code> used in generating the
7656 binary package, set the variable <code class=
7657 "varname">PLIST_SRC</code> to the names of that file(s).
7658 The files are later concatenated using <a href=
7659 "http://netbsd.gw.com/cgi-bin/man-cgi?cat+1+NetBSD-current">
7660 <span class="citerefentry"><span class=
7661 "refentrytitle">cat</span>(1)</span></a>, and order of
7662 things is important.</p>
7665 <div class="sect1" lang="en" xml:lang="en">
7666 <div class="titlepage">
7669 <h2 class="title" style="clear: both"><a name=
7670 "platform-specific-plist" id=
7671 "platform-specific-plist"></a>10.7. Platform-specific
7672 and differing PLISTs</h2>
7677 <p>Some packages decide to install a different set of
7678 files based on the operating system being used. These
7679 differences can be automatically handled by using the
7680 following files:</p>
7682 <div class="itemizedlist">
7686 "http://www.w3.org/TR/xhtml1/transitional" class=
7687 "filename">PLIST.common</code></p>
7692 "http://www.w3.org/TR/xhtml1/transitional" class=
7693 "filename">PLIST.${OPSYS}</code></p>
7698 "http://www.w3.org/TR/xhtml1/transitional" class=
7699 "filename">PLIST.${MACHINE_ARCH}</code></p>
7704 "http://www.w3.org/TR/xhtml1/transitional" class=
7705 "filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p>
7710 "http://www.w3.org/TR/xhtml1/transitional" class=
7711 "filename">PLIST.common_end</code></p>
7717 <div class="sect1" lang="en" xml:lang="en">
7718 <div class="titlepage">
7721 <h2 class="title" style="clear: both"><a name=
7722 "faq.common-dirs" id=
7723 "faq.common-dirs"></a>10.8. Sharing
7724 directories between packages</h2>
7729 <p>A “<span class="quote">shared
7730 directory</span>” is a directory where multiple
7731 (and unrelated) packages install files. These directories
7732 are problematic because you have to add special tricks in
7733 the PLIST to conditionally remove them, or have some
7734 centralized package handle them.</p>
7736 <p>Within pkgsrc, you'll find both approaches. If a
7737 directory is shared by a few unrelated packages, it's
7738 often not worth to add an extra package to remove it.
7739 Therefore, one simply does:</p>
7740 <pre class="programlisting">
7741 @unexec ${RMDIR} %D/path/to/shared/directory 2>/dev/null || ${TRUE}
7744 <p>in the PLISTs of all affected packages, instead of the
7745 regular "@dirrm" line.</p>
7747 <p>However, if the directory is shared across many
7748 packages, two different solutions are available:</p>
7750 <div class="orderedlist">
7753 <p>If the packages have a common dependency, the
7754 directory can be removed in that. For example, see
7755 <a xmlns="http://www.w3.org/TR/xhtml1/transitional"
7757 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/textproc/scrollkeeper/README.html"
7758 target="_top"><code xmlns="" class=
7759 "filename">textproc/scrollkeeper</code></a>, which
7760 removes the shared directory <code xmlns=
7761 "http://www.w3.org/TR/xhtml1/transitional" class=
7762 "filename">share/omf</code>.</p>
7766 <p>If the packages using the directory are not
7767 related at all (they have no common dependencies),
7768 a *-dirs package is used.</p>
7773 <p>From now on, we'll discuss the second solution. To get
7774 an idea of the *-dirs packages available, issue:</p>
7775 <pre class="programlisting">
7776 <code class="prompt">%</code> cd .../pkgsrc
7777 <code class="prompt">%</code> ls -d */*-dirs
7780 <p>Their use from other packages is very simple. The
7781 <code class="varname">USE_DIRS</code> variable takes a
7782 list of package names (without the “<span class=
7783 "quote">-dirs</span>” part) together with the
7784 required version number (always pick the latest one when
7785 writing new packages).</p>
7787 <p>For example, if a package installs files under
7788 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
7789 class="filename">share/applications</code>, it should
7790 have the following line in it:</p>
7791 <pre class="programlisting">
7795 <p>After regenerating the PLIST using
7796 <span><strong class="command">make
7797 print-PLIST</strong></span>, you should get the right
7798 (commented out) lines.</p>
7800 <p>Note that even if your package is using <code xmlns=
7801 "http://www.w3.org/TR/xhtml1/transitional" class=
7802 "filename">$X11BASE</code>, it must not depend on the
7803 *-x11-dirs packages. Just specify the name without that
7804 part and pkgsrc (in particular, <code xmlns=
7805 "http://www.w3.org/TR/xhtml1/transitional" class=
7806 "filename">mk/dirs.mk</code>) will take care of it.</p>
7810 <div class="chapter" lang="en" xml:lang="en">
7811 <div class="titlepage">
7814 <h2 class="title"><a name="buildlink" id=
7815 "buildlink"></a>Chapter 11. Buildlink
7822 <p><b>Table of Contents</b></p>
7825 <dt><span class="sect1"><a href=
7826 "#converting-to-buildlink3">11.1. Converting packages
7827 to use buildlink3</a></span></dt>
7829 <dt><span class="sect1"><a href=
7830 "#creating-buildlink3.mk">11.2. Writing <code xmlns=
7831 "http://www.w3.org/TR/xhtml1/transitional" class=
7832 "filename">buildlink3.mk</code> files</a></span></dt>
7836 <dt><span class="sect2"><a href=
7837 "#anatomy-of-bl3">11.2.1. Anatomy of a
7838 buildlink3.mk file</a></span></dt>
7840 <dt><span class="sect2"><a href=
7841 "#updating-buildlink-depends">11.2.2. Updating
7842 <code class="varname">BUILDLINK_DEPENDS.<em class=
7843 "replaceable"><code>pkg</code></em></code> in
7845 "http://www.w3.org/TR/xhtml1/transitional" class=
7846 "filename">buildlink3.mk</code>
7847 files</a></span></dt>
7851 <dt><span class="sect1"><a href=
7852 "#writing-builtin.mk">11.3. Writing <code xmlns=
7853 "http://www.w3.org/TR/xhtml1/transitional" class=
7854 "filename">builtin.mk</code> files</a></span></dt>
7858 <dt><span class="sect2"><a href=
7859 "#anatomy-of-builtin.mk">11.3.1. Anatomy of a
7861 "http://www.w3.org/TR/xhtml1/transitional" class=
7862 "filename">builtin.mk</code> file</a></span></dt>
7864 <dt><span class="sect2"><a href=
7865 "#native-or-pkgsrc-preference">11.3.2. Global
7866 preferences for native or pkgsrc
7867 software</a></span></dt>
7873 <p>Buildlink is a framework in pkgsrc that controls what
7874 headers and libraries are seen by a package's configure and
7875 build processes. This is implemented in a two step
7878 <div class="orderedlist">
7881 <p>Symlink headers and libraries for dependencies
7882 into <code class="varname">BUILDLINK_DIR</code>,
7883 which by default is a subdirectory of <code class=
7884 "varname">WRKDIR</code>.</p>
7888 <p>Create wrapper scripts that are used in place of
7889 the normal compiler tools that translate <code class=
7890 "option">-I${LOCALBASE}/include</code> and
7891 <code class="option">-L${LOCALBASE}/lib</code> into
7892 references to <code class=
7893 "varname">BUILDLINK_DIR</code>. The wrapper scripts
7894 also make native compiler on some operating systems
7895 look like GCC, so that packages that expect GCC won't
7896 require modifications to build with those native
7902 <p>This normalizes the environment in which a package is
7903 built so that the package may be built consistently despite
7904 what other software may be installed. Please note that the
7905 normal system header and library paths, e.g. <code xmlns=
7906 "http://www.w3.org/TR/xhtml1/transitional" class=
7907 "filename">/usr/include</code>, <code xmlns=
7908 "http://www.w3.org/TR/xhtml1/transitional" class=
7909 "filename">/usr/lib</code>, etc., are always searched --
7910 buildlink3 is designed to insulate the package build from
7911 non-system-supplied software.</p>
7913 <div class="sect1" lang="en" xml:lang="en">
7914 <div class="titlepage">
7917 <h2 class="title" style="clear: both"><a name=
7918 "converting-to-buildlink3" id=
7919 "converting-to-buildlink3"></a>11.1. Converting
7920 packages to use buildlink3</h2>
7925 <p>The process of converting packages to use the
7926 buildlink3 framework (“<span class=
7927 "quote">bl3ifying</span>”) is fairly
7928 straightforward. The things to keep in mind are:</p>
7930 <div class="orderedlist">
7933 <p>Ensure that the build always calls the wrapper
7934 scripts instead of the actual toolchain. Some
7935 packages are tricky, and the only way to know for
7936 sure is the check <code xmlns=
7937 "http://www.w3.org/TR/xhtml1/transitional" class=
7938 "filename">${WRKDIR}/.work.log</code> to see if the
7939 wrappers are being invoked.</p>
7943 <p>Don't override <code class=
7944 "varname">PREFIX</code> from within the package
7945 Makefile, e.g. Java VMs, standalone shells, etc.,
7946 because the code to symlink files into <code xmlns=
7947 "http://www.w3.org/TR/xhtml1/transitional" class=
7948 "filename">${BUILDLINK_DIR}</code> looks for files
7949 relative to “<span class="quote">pkg_info -qp
7951 "replaceable"><code>pkgname</code></em></span>”.</p>
7955 <p>Remember that <span class=
7956 "emphasis"><em>only</em></span> the <code xmlns=
7957 "http://www.w3.org/TR/xhtml1/transitional" class=
7958 "filename">buildlink3.mk</code> files that you list
7959 in a package's Makefile are added as dependencies
7960 for that package.</p>
7965 <p>If a dependency on a particular package is required
7966 for its libraries and headers, then we replace:</p>
7967 <pre class="programlisting">
7968 DEPENDS+= foo>=1.1.0:../../category/foo
7972 <pre class="programlisting">
7973 .include "../../category/foo/buildlink3.mk"
7976 <p>The buildlink3.mk files usually define the required
7977 dependencies. If you need a newer version of the
7978 dependency when using buildlink3.mk files, then you can
7979 define it in your Makefile; for example:</p>
7980 <pre class="programlisting">
7981 BUILDLINK_DEPENDS.foo+= foo>=1.1.0
7982 .include "../../category/foo/buildlink3.mk"
7985 <p>There are several <code xmlns=
7986 "http://www.w3.org/TR/xhtml1/transitional" class=
7987 "filename">buildlink3.mk</code> files in <code xmlns=
7988 "http://www.w3.org/TR/xhtml1/transitional" class=
7989 "filename">pkgsrc/mk</code> that handle special package
7992 <div class="itemizedlist">
7996 "http://www.w3.org/TR/xhtml1/transitional" class=
7997 "filename">bdb.buildlink3.mk</code> chooses either
7998 the native or a pkgsrc Berkeley DB implementation
7999 based on the values of <code class=
8000 "varname">BDB_ACCEPTED</code> and <code class=
8001 "varname">BDB_DEFAULT</code>.</p>
8006 "http://www.w3.org/TR/xhtml1/transitional" class=
8007 "filename">curses.buildlink3.mk</code>: If the
8008 system comes with neither Curses nor NCurses, this
8009 will take care to install the <a xmlns=
8010 "http://www.w3.org/TR/xhtml1/transitional" href=
8011 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/ncurses/README.html"
8012 target="_top"><code xmlns="" class=
8013 "filename">devel/ncurses</code></a> package.</p>
8018 "http://www.w3.org/TR/xhtml1/transitional" class=
8019 "filename">krb5.buildlink3.mk</code> uses the value
8020 of <code class="varname">KRB5_ACCEPTED</code> to
8021 choose between adding a dependency on Heimdal or
8022 MIT-krb5 for packages that require a Kerberos 5
8028 "http://www.w3.org/TR/xhtml1/transitional" class=
8029 "filename">motif.buildlink3.mk</code> checks for a
8030 system-provided Motif installation or adds a
8031 dependency on <a xmlns=
8032 "http://www.w3.org/TR/xhtml1/transitional" href=
8033 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/lesstif/README.html"
8034 target="_top"><code xmlns="" class=
8035 "filename">x11/lesstif</code></a> or <a xmlns=
8036 "http://www.w3.org/TR/xhtml1/transitional" href=
8037 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/openmotif/README.html"
8038 target="_top"><code xmlns="" class=
8039 "filename">x11/openmotif</code></a>.</p>
8044 "http://www.w3.org/TR/xhtml1/transitional" class=
8045 "filename">ossaudio.buildlink3.mk</code> defines
8046 several variables that may be used by packages that
8047 use the Open Sound System (OSS) API.</p>
8052 "http://www.w3.org/TR/xhtml1/transitional" class=
8053 "filename">pgsql.buildlink3.mk</code> will accept
8054 either Postgres 7.3 or 7.4, whichever is found
8055 installed. See the file for more information.</p>
8060 "http://www.w3.org/TR/xhtml1/transitional" class=
8061 "filename">pthread.buildlink3.mk</code> uses the
8062 value of <code class="varname">PTHREAD_OPTS</code>
8063 and checks for native pthreads or adds a dependency
8065 "http://www.w3.org/TR/xhtml1/transitional" href=
8066 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/pth/README.html"
8067 target="_top"><code xmlns="" class=
8068 "filename">devel/pth</code></a> as needed.</p>
8073 "http://www.w3.org/TR/xhtml1/transitional" class=
8074 "filename">xaw.buildlink3.mk</code> uses the value
8075 of <code class="varname">XAW_TYPE</code> to choose
8076 a particular Athena widgets library.</p>
8081 <p>The comments in those <code xmlns=
8082 "http://www.w3.org/TR/xhtml1/transitional" class=
8083 "filename">buildlink3.mk</code> files provide a more
8084 complete description of how to use them properly.</p>
8087 <div class="sect1" lang="en" xml:lang="en">
8088 <div class="titlepage">
8091 <h2 class="title" style="clear: both"><a name=
8092 "creating-buildlink3.mk" id=
8093 "creating-buildlink3.mk"></a>11.2. Writing
8095 "http://www.w3.org/TR/xhtml1/transitional" class=
8096 "filename">buildlink3.mk</code> files</h2>
8101 <p>A package's <code xmlns=
8102 "http://www.w3.org/TR/xhtml1/transitional" class=
8103 "filename">buildlink3.mk</code> file is included by
8104 Makefiles to indicate the need to compile and link
8105 against header files and libraries provided by the
8106 package. A <code xmlns=
8107 "http://www.w3.org/TR/xhtml1/transitional" class=
8108 "filename">buildlink3.mk</code> file should always
8109 provide enough information to add the correct type of
8110 dependency relationship and include any other
8111 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
8112 class="filename">buildlink3.mk</code> files that it needs
8113 to find headers and libraries that it needs in turn.</p>
8115 <p>To generate an initial <code xmlns=
8116 "http://www.w3.org/TR/xhtml1/transitional" class=
8117 "filename">buildlink3.mk</code> file for further editing,
8118 Rene Hexel's <a xmlns=
8119 "http://www.w3.org/TR/xhtml1/transitional" href=
8120 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/createbuildlink/README.html"
8121 target="_top"><code xmlns="" class=
8122 "filename">pkgtools/createbuildlink</code></a> package is
8123 highly recommended. For most packages, the following
8124 command will generate a good starting point for
8125 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
8126 class="filename">buildlink3.mk</code> files:</p>
8127 <pre class="screen">
8128 <code class="prompt">%</code> <strong class=
8129 "userinput"><code>cd pkgsrc/<em class=
8130 "replaceable"><code>category</code></em>/<em class=
8131 "replaceable"><code>pkgdir</code></em>
8133 "prompt">%</code> createbuildlink >buildlink3.mk</code></strong>
8136 <div class="sect2" lang="en" xml:lang="en">
8137 <div class="titlepage">
8140 <h3 class="title"><a name="anatomy-of-bl3" id=
8141 "anatomy-of-bl3"></a>11.2.1. Anatomy of a
8142 buildlink3.mk file</h3>
8147 <p>The following real-life example <code xmlns=
8148 "http://www.w3.org/TR/xhtml1/transitional" class=
8149 "filename">buildlink3.mk</code> is taken from
8150 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
8151 class="filename">pkgsrc/graphics/tiff</code>:</p>
8152 <pre class="programlisting">
8153 # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
8155 BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
8156 TIFF_BUILDLINK3_MK:= ${TIFF_BUILDLINK3_MK}+
8158 .if !empty(BUILDLINK_DEPTH:M+)
8159 BUILDLINK_DEPENDS+= tiff
8162 BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ntiff}
8163 BUILDLINK_PACKAGES+= tiff
8165 .if !empty(TIFF_BUILDLINK3_MK:M+)
8166 BUILDLINK_DEPENDS.tiff+= tiff>=3.6.1
8167 BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
8168 .endif # TIFF_BUILDLINK3_MK
8170 .include "../../devel/zlib/buildlink3.mk"
8171 .include "../../graphics/jpeg/buildlink3.mk"
8173 BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
8176 <p>The header and footer manipulate <code class=
8177 "varname">BUILDLINK_DEPTH</code>, which is common
8178 across all <code xmlns=
8179 "http://www.w3.org/TR/xhtml1/transitional" class=
8180 "filename">buildlink3.mk</code> files and is used to
8181 track at what depth we are including <code xmlns=
8182 "http://www.w3.org/TR/xhtml1/transitional" class=
8183 "filename">buildlink3.mk</code> files.</p>
8185 <p>The first section controls if the dependency on
8186 <em class="replaceable"><code>pkg</code></em> is added.
8187 <code class="varname">BUILDLINK_DEPENDS</code> is the
8188 global list of packages for which dependencies are
8189 added by buildlink3.</p>
8191 <p>The second section advises pkgsrc that the
8192 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
8193 class="filename">buildlink3.mk</code> file for
8194 <em class="replaceable"><code>pkg</code></em> has been
8195 included at some point. <code class=
8196 "varname">BUILDLINK_PACKAGES</code> is the global list
8197 of packages for which <code xmlns=
8198 "http://www.w3.org/TR/xhtml1/transitional" class=
8199 "filename">buildlink3.mk</code> files have been
8200 included. It must <span class=
8201 "emphasis"><em>always</em></span> be appended to within
8203 "http://www.w3.org/TR/xhtml1/transitional" class=
8204 "filename">buildlink3.mk</code> file.</p>
8206 <p>The third section is protected from multiple
8207 inclusion and controls how the dependency on <em class=
8208 "replaceable"><code>pkg</code></em> is added. Several
8209 important variables are set in the section:</p>
8211 <div class="itemizedlist">
8215 "varname">BUILDLINK_DEPENDS.<em class=
8216 "replaceable"><code>pkg</code></em></code> is the
8217 actual dependency recorded in the installed
8218 package; this should always be set using
8219 <span><strong class="command">+=</strong></span>
8220 to ensure that we're appending to any
8221 pre-existing list of values. This variable should
8222 be set to the first version of the package that
8223 had the last change in the major number of a
8224 shared library or that had a major API
8230 "varname">BUILDLINK_PKGSRCDIR.<em class=
8231 "replaceable"><code>pkg</code></em></code> is the
8232 location of the <em class=
8233 "replaceable"><code>pkg</code></em> pkgsrc
8239 "varname">BUILDLINK_DEPMETHOD.<em class=
8240 "replaceable"><code>pkg</code></em></code> (not
8241 shown above) controls whether we use <code class=
8242 "varname">BUILD_DEPENDS</code> or <code class=
8243 "varname">DEPENDS</code> to add the dependency on
8244 <em class="replaceable"><code>pkg</code></em>.
8245 The build dependency is selected by setting
8247 "varname">BUILDLINK_DEPMETHOD.<em class=
8248 "replaceable"><code>pkg</code></em></code> to
8249 “<span class="quote">build</span>”.
8250 By default, the full dependency is used.</p>
8255 "varname">BUILDLINK_INCDIRS.<em class=
8256 "replaceable"><code>pkg</code></em></code> and
8258 "varname">BUILDLINK_LIBDIRS.<em class="replaceable">
8259 <code>pkg</code></em></code> (not shown above)
8260 are lists of subdirectories of <code xmlns=
8261 "http://www.w3.org/TR/xhtml1/transitional" class=
8262 "filename">${BUILDLINK_PREFIX.<em class=
8263 "replaceable"><code>pkg</code></em>}</code> to
8264 add to the header and library search paths. These
8265 default to “<span class=
8266 "quote">include</span>” and
8267 “<span class="quote">lib</span>”
8273 "varname">BUILDLINK_CPPFLAGS.<em class=
8274 "replaceable"><code>pkg</code></em></code> (not
8275 shown above) is the list of preprocessor flags to
8276 add to <code class="varname">CPPFLAGS</code>,
8277 which are passed on to the configure and build
8278 phases. The “<span class=
8279 "quote">-I</span>” option should be avoided
8280 and instead be handled using <code class=
8281 "varname">BUILDLINK_INCDIRS.<em class=
8282 "replaceable"><code>pkg</code></em></code> as
8288 <p>The following variables are all optionally defined
8289 within this second section (protected against multiple
8290 inclusion) and control which package files are
8291 symlinked into <code xmlns=
8292 "http://www.w3.org/TR/xhtml1/transitional" class=
8293 "filename">${BUILDLINK_DIR}</code> and how their names
8294 are transformed during the symlinking:</p>
8296 <div class="itemizedlist">
8300 "varname">BUILDLINK_FILES.<em class=
8301 "replaceable"><code>pkg</code></em></code> (not
8302 shown above) is a shell glob pattern relative to
8304 "http://www.w3.org/TR/xhtml1/transitional" class=
8305 "filename">${BUILDLINK_PREFIX.<em class=
8306 "replaceable"><code>pkg</code></em>}</code> to be
8307 symlinked into <code xmlns=
8308 "http://www.w3.org/TR/xhtml1/transitional" class=
8309 "filename">${BUILDLINK_DIR}</code>, e.g.
8311 "http://www.w3.org/TR/xhtml1/transitional" class=
8312 "filename">include/*.h</code>.</p>
8317 "varname">BUILDLINK_FILES_CMD.<em class=
8318 "replaceable"><code>pkg</code></em></code> (not
8319 shown above) is a shell pipeline that outputs to
8320 stdout a list of files relative to <code xmlns=
8321 "http://www.w3.org/TR/xhtml1/transitional" class=
8322 "filename">${BUILDLINK_PREFIX.<em class=
8323 "replaceable"><code>pkg</code></em>}</code>. The
8324 resulting files are to be symlinked into
8326 "http://www.w3.org/TR/xhtml1/transitional" class=
8327 "filename">${BUILDLINK_DIR}</code>. By default,
8328 this takes the <code xmlns=
8329 "http://www.w3.org/TR/xhtml1/transitional" class=
8330 "filename">+CONTENTS</code> of a <em class=
8331 "replaceable"><code>pkg</code></em> and filters
8332 it through <code class=
8333 "varname">${BUILDLINK_CONTENTS_FILTER.<em class=
8334 "replaceable"><code>pkg</code></em>}</code>.</p>
8339 "varname">BUILDLINK_CONTENTS_FILTER.<em class=
8340 "replaceable"><code>pkg</code></em></code> (not
8341 shown above) is a filter command that filters
8343 "http://www.w3.org/TR/xhtml1/transitional" class=
8344 "filename">+CONTENTS</code> input into a list of
8345 files relative to <code xmlns=
8346 "http://www.w3.org/TR/xhtml1/transitional" class=
8347 "filename">${BUILDLINK_PREFIX.<em class=
8348 "replaceable"><code>pkg</code></em>}</code> on
8349 stdout. By default for overwrite packages,
8351 "varname">BUILDLINK_CONTENTS_FILTER.<em class=
8352 "replaceable"><code>pkg</code></em></code>
8353 outputs the contents of the <code xmlns=
8354 "http://www.w3.org/TR/xhtml1/transitional" class=
8355 "filename">include</code> and <code xmlns=
8356 "http://www.w3.org/TR/xhtml1/transitional" class=
8357 "filename">lib</code> directories in the package
8359 "http://www.w3.org/TR/xhtml1/transitional" class=
8360 "filename">+CONTENTS</code>, and for pkgviews
8361 packages, it outputs any libtool archives in
8363 "http://www.w3.org/TR/xhtml1/transitional" class=
8364 "filename">lib</code> directories.</p>
8369 "varname">BUILDLINK_TRANSFORM.<em class=
8370 "replaceable"><code>pkg</code></em></code> (not
8371 shown above) is a list of sed arguments used to
8372 transform the name of the source filename into a
8373 destination filename, e.g. <span><strong class=
8375 "s|/curses.h|/ncurses.h|g"</strong></span>.</p>
8380 <p>The last section includes any <code xmlns=
8381 "http://www.w3.org/TR/xhtml1/transitional" class=
8382 "filename">buildlink3.mk</code> needed for <em class=
8383 "replaceable"><code>pkg</code></em>'s library
8384 dependencies. Including these <code xmlns=
8385 "http://www.w3.org/TR/xhtml1/transitional" class=
8386 "filename">buildlink3.mk</code> files means that the
8387 headers and libraries for these dependencies are also
8388 symlinked into <code xmlns=
8389 "http://www.w3.org/TR/xhtml1/transitional" class=
8390 "filename">${BUILDLINK_DIR}</code> whenever the
8391 <em class="replaceable"><code>pkg</code></em>
8392 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
8393 class="filename">buildlink3.mk</code> file is
8397 <div class="sect2" lang="en" xml:lang="en">
8398 <div class="titlepage">
8401 <h3 class="title"><a name=
8402 "updating-buildlink-depends" id=
8403 "updating-buildlink-depends"></a>11.2.2. Updating
8405 "varname">BUILDLINK_DEPENDS.<em class="replaceable">
8406 <code>pkg</code></em></code> in <code xmlns=
8407 "http://www.w3.org/TR/xhtml1/transitional" class=
8408 "filename">buildlink3.mk</code> files</h3>
8413 <p>There are two situations that require increasing the
8414 dependency listed in <code class=
8415 "varname">BUILDLINK_DEPENDS.<em class=
8416 "replaceable"><code>pkg</code></em></code> after a
8419 <div class="orderedlist">
8422 <p>if the sonames (major number of the library
8423 version) of any installed shared libraries
8428 <p>if the API or interface to the header files
8434 <p>In these cases, <code class=
8435 "varname">BUILDLINK_DEPENDS.<em class=
8436 "replaceable"><code>pkg</code></em></code> should be
8437 adjusted to require at least the new package version.
8438 In some cases, the packages that depend on this new
8439 version may need their <code class=
8440 "varname">PKGREVISION</code>s increased and, if they
8442 "http://www.w3.org/TR/xhtml1/transitional" class=
8443 "filename">buildlink3.mk</code> files, their
8444 <code class="varname">BUILDLINK_DEPENDS.<em class=
8445 "replaceable"><code>pkg</code></em></code> adjusted,
8446 too. This is needed so that binary packages made using
8447 it will require the correct package dependency and not
8448 settle for an older one which will not contain the
8449 necessary shared libraries.</p>
8451 <p>Please take careful consideration before adjusting
8452 <code class="varname">BUILDLINK_DEPENDS.<em class=
8453 "replaceable"><code>pkg</code></em></code> as we don't
8454 want to cause unneeded package deletions and rebuilds.
8455 In many cases, new versions of packages work just fine
8456 with older dependencies. See <a href="#dependencies"
8457 title="15.1.4. Handling dependencies">Section
8458 15.1.4, “Handling dependencies”</a> for
8459 more information about dependencies on other packages,
8460 including the <code class=
8461 "varname">BUILDLINK_RECOMMENDED</code> and <code class=
8462 "varname">RECOMMENDED</code> definitions.</p>
8466 <div class="sect1" lang="en" xml:lang="en">
8467 <div class="titlepage">
8470 <h2 class="title" style="clear: both"><a name=
8471 "writing-builtin.mk" id=
8472 "writing-builtin.mk"></a>11.3. Writing
8474 "http://www.w3.org/TR/xhtml1/transitional" class=
8475 "filename">builtin.mk</code> files</h2>
8480 <p>Some packages in pkgsrc install headers and libraries
8481 that coincide with headers and libraries present in the
8482 base system. Aside from a <code xmlns=
8483 "http://www.w3.org/TR/xhtml1/transitional" class=
8484 "filename">buildlink3.mk</code> file, these packages
8485 should also include a <code xmlns=
8486 "http://www.w3.org/TR/xhtml1/transitional" class=
8487 "filename">builtin.mk</code> file that includes the
8488 necessary checks to decide whether using the built-in
8489 software or the pkgsrc software is appropriate.</p>
8491 <p>The only requirements of a builtin.mk file for
8492 <em class="replaceable"><code>pkg</code></em> are:</p>
8494 <div class="orderedlist">
8497 <p>It should set <code class=
8498 "varname">USE_BUILTIN.<em class=
8499 "replaceable"><code>pkg</code></em></code> to
8500 either “<span class="quote">yes</span>”
8501 or “<span class="quote">no</span>”
8502 after it is included.</p>
8506 <p>It should <span class=
8507 "emphasis"><em>not</em></span> override any
8508 <code class="varname">USE_BUILTIN.<em class=
8509 "replaceable"><code>pkg</code></em></code> which is
8510 already set before the <code xmlns=
8511 "http://www.w3.org/TR/xhtml1/transitional" class=
8512 "filename">builtin.mk</code> file is included.</p>
8516 <p>It should be written to allow multiple
8517 inclusion. This is <span class=
8518 "emphasis"><em>very</em></span> important and takes
8519 careful attention to <code xmlns=
8520 "http://www.w3.org/TR/xhtml1/transitional" class=
8521 "filename">Makefile</code> coding.</p>
8526 <div class="sect2" lang="en" xml:lang="en">
8527 <div class="titlepage">
8530 <h3 class="title"><a name="anatomy-of-builtin.mk"
8532 "anatomy-of-builtin.mk"></a>11.3.1. Anatomy
8534 "http://www.w3.org/TR/xhtml1/transitional" class=
8535 "filename">builtin.mk</code> file</h3>
8540 <p>The following is the recommended template for
8541 builtin.mk files:</p>
8542 <pre class="programlisting">
8543 .if !defined(IS_BUILTIN.foo)
8545 # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
8546 # genuinely exists in the system or not.
8550 # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
8551 # version can be determined.
8553 . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
8554 BUILTIN_PKG.foo?= foo-1.0
8556 .endif # IS_BUILTIN.foo
8558 .if !defined(USE_BUILTIN.foo)
8559 USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
8560 . if defined(BUILTIN_PKG.foo)
8561 . for _depend_ in ${BUILDLINK_DEPENDS.foo}
8562 . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
8564 if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then \
8572 .endif # USE_BUILTIN.foo
8574 CHECK_BUILTIN.foo?= no
8575 .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
8577 # Here we place code that depends on whether USE_BUILTIN.foo is set to
8580 .endif # CHECK_BUILTIN.foo
8583 <p>The first section sets <code class=
8584 "varname">IS_BUILTIN.<em class=
8585 "replaceable"><code>pkg</code></em></code> depending on
8586 if <em class="replaceable"><code>pkg</code></em> really
8587 exists in the base system. This should not be a base
8588 system software with similar functionality to
8589 <em class="replaceable"><code>pkg</code></em>; it
8590 should only be “<span class=
8591 "quote">yes</span>” if the actual package is
8592 included as part of the base system. This variable is
8593 only used internally within the <code xmlns=
8594 "http://www.w3.org/TR/xhtml1/transitional" class=
8595 "filename">builtin.mk</code> file.</p>
8597 <p>The second section sets <code class=
8598 "varname">BUILTIN_PKG.<em class=
8599 "replaceable"><code>pkg</code></em></code> to the
8600 version of <em class=
8601 "replaceable"><code>pkg</code></em> in the base system
8602 if it exists (if <code class=
8603 "varname">IS_BUILTIN.<em class=
8604 "replaceable"><code>pkg</code></em></code> is
8605 “<span class="quote">yes</span>”). This
8606 variable is only used internally within the
8607 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
8608 class="filename">builtin.mk</code> file.</p>
8610 <p>The third section sets <code class=
8611 "varname">USE_BUILTIN.<em class=
8612 "replaceable"><code>pkg</code></em></code> and is
8613 <span class="emphasis"><em>required</em></span> in all
8614 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
8615 class="filename">builtin.mk</code> files. The code in
8616 this section must make the determination whether the
8617 built-in software is adequate to satisfy the
8618 dependencies listed in <code class=
8619 "varname">BUILDLINK_DEPENDS.<em class=
8620 "replaceable"><code>pkg</code></em></code>. This is
8621 typically done by comparing <code class=
8622 "varname">BUILTIN_PKG.<em class=
8623 "replaceable"><code>pkg</code></em></code> against each
8624 of the dependencies in <code class=
8625 "varname">BUILDLINK_DEPENDS.<em class=
8626 "replaceable"><code>pkg</code></em></code>.
8627 <code class="varname">USE_BUILTIN.<em class=
8628 "replaceable"><code>pkg</code></em></code> <span class=
8629 "emphasis"><em>must</em></span> be set to the correct
8630 value by the end of the <code xmlns=
8631 "http://www.w3.org/TR/xhtml1/transitional" class=
8632 "filename">builtin.mk</code> file. Note that
8633 <code class="varname">USE_BUILTIN.<em class=
8634 "replaceable"><code>pkg</code></em></code> may be
8635 “<span class="quote">yes</span>” even if
8636 <code class="varname">IS_BUILTIN.<em class=
8637 "replaceable"><code>pkg</code></em></code> is
8638 “<span class="quote">no</span>” because we
8639 may make the determination that the built-in version of
8640 the software is similar enough to be used as a
8643 <p>The last section is guarded by <code class=
8644 "varname">CHECK_BUILTIN.<em class=
8645 "replaceable"><code>pkg</code></em></code>, and
8646 includes code that uses the value of <code class=
8647 "varname">USE_BUILTIN.<em class=
8648 "replaceable"><code>pkg</code></em></code> set in the
8649 previous section. This typically includes, e.g., adding
8650 additional dependency restrictions and listing
8651 additional files to symlink into <code xmlns=
8652 "http://www.w3.org/TR/xhtml1/transitional" class=
8653 "filename">${BUILDLINK_DIR}</code> (via <code class=
8654 "varname">BUILDLINK_FILES.<em class=
8655 "replaceable"><code>pkg</code></em></code>).</p>
8658 <div class="sect2" lang="en" xml:lang="en">
8659 <div class="titlepage">
8662 <h3 class="title"><a name=
8663 "native-or-pkgsrc-preference" id=
8664 "native-or-pkgsrc-preference"></a>11.3.2. Global
8665 preferences for native or pkgsrc software</h3>
8670 <p>When building packages, it's possible to choose
8671 whether to set a global preference for using either the
8672 built-in (native) version or the pkgsrc version of
8673 software to satisfy a dependency. This is controlled by
8674 setting <code class="varname">PREFER_PKGSRC</code> and
8675 <code class="varname">PREFER_NATIVE</code>. These
8676 variables take values of either “<span class=
8677 "quote">yes</span>”, “<span class=
8678 "quote">no</span>”, or a list of packages.
8679 <code class="varname">PREFER_PKGSRC</code> tells pkgsrc
8680 to use the pkgsrc versions of software, while
8681 <code class="varname">PREFER_NATIVE</code> tells pkgsrc
8682 to use the built-in versions. Preferences are
8683 determined by the most specific instance of the package
8684 in either <code class="varname">PREFER_PKGSRC</code> or
8685 <code class="varname">PREFER_NATIVE</code>. If a
8686 package is specified in neither or in both variables,
8687 then <code class="varname">PREFER_PKGSRC</code> has
8688 precedence over <code class=
8689 "varname">PREFER_NATIVE</code>. For example, to require
8690 using pkgsrc versions of software for all but the most
8691 basic bits on a NetBSD system, you can set:</p>
8692 <pre class="programlisting">
8694 PREFER_NATIVE= getopt skey tcp_wrappers
8697 <p>A package <span class=
8698 "emphasis"><em>must</em></span> have a <code xmlns=
8699 "http://www.w3.org/TR/xhtml1/transitional" class=
8700 "filename">builtin.mk</code> file to be listed in
8701 <code class="varname">PREFER_NATIVE</code>, otherwise
8702 it is simply ignored in that list.</p>
8707 <div class="chapter" lang="en" xml:lang="en">
8708 <div class="titlepage">
8711 <h2 class="title"><a name="pkginstall" id=
8712 "pkginstall"></a>Chapter 12. The pkginstall
8719 <p><b>Table of Contents</b></p>
8722 <dt><span class="sect1"><a href=
8723 "#files-and-dirs-outside-prefix">12.1. Files and
8724 directories outside the installation
8725 prefix</a></span></dt>
8729 <dt><span class="sect2"><a href=
8730 "#dirs-outside-prefix">12.1.1. Directory
8731 manipulation</a></span></dt>
8733 <dt><span class="sect2"><a href=
8734 "#files-outside-prefix">12.1.2. File
8735 manipulation</a></span></dt>
8739 <dt><span class="sect1"><a href="#conf-files">12.2.
8740 Configuration files</a></span></dt>
8744 <dt><span class="sect2"><a href=
8745 "#conf-files-sysconfdir">12.2.1. How <code class=
8746 "varname">PKG_SYSCONFDIR</code> is
8749 <dt><span class="sect2"><a href=
8750 "#conf-files-configure">12.2.2. Telling the
8751 software where configuration files
8754 <dt><span class="sect2"><a href=
8755 "#conf-files-patching">12.2.3. Patching
8756 installations</a></span></dt>
8758 <dt><span class="sect2"><a href=
8759 "#conf-files-disable">12.2.4. Disabling handling of
8760 configuration files</a></span></dt>
8764 <dt><span class="sect1"><a href="#rcd-scripts">12.3.
8765 System startup scripts</a></span></dt>
8769 <dt><span class="sect2"><a href=
8770 "#rcd-scripts-disable">12.3.1. Disabling handling
8771 of system startup scripts</a></span></dt>
8775 <dt><span class="sect1"><a href=
8776 "#users-and-groups">12.4. System users and
8777 groups</a></span></dt>
8779 <dt><span class="sect1"><a href="#shells">12.5. System
8780 shells</a></span></dt>
8784 <dt><span class="sect2"><a href=
8785 "#shells-disable">12.5.1. Disabling handling of
8786 configuration files</a></span></dt>
8792 <p>This chapter describes the framework known as
8793 <code class="literal">pkginstall</code>, whose key features
8796 <div class="itemizedlist">
8799 <p>Generic installation and manipulation of
8800 directories and files outside the pkgsrc-handled
8801 tree, <code class="varname">LOCALBASE</code>.</p>
8805 <p>Automatic handling of configuration files during
8806 installation, provided that packages are correctly
8811 <p>Generation and installation of system startup
8816 <p>Registration of system users and groups.</p>
8820 <p>Registration of system shells.</p>
8825 <p>The following sections inspect each of the above points
8826 in detail. Note that in order to use any of the described
8827 functionalities, you must add the following to your
8828 package's <code xmlns=
8829 "http://www.w3.org/TR/xhtml1/transitional" class=
8830 "filename">Makefile</code>:</p>
8831 <pre class="programlisting">
8835 <p>You may be thinking that many of the things described
8836 here could be easily done with simple code in the package's
8837 post-installation target (<code class=
8838 "literal">post-install</code>). <span class=
8839 "emphasis"><em>This is incorrect</em></span>, as the code
8840 in them is only executed when building from source.
8841 Machines using binary packages could not benefit from it at
8842 all (as the code itself could be unavailable). Therefore,
8843 the only way to achieve any of the items described above is
8844 by means of the installation scripts, which are
8845 automatically generated by pkginstall.</p>
8847 <div class="sect1" lang="en" xml:lang="en">
8848 <div class="titlepage">
8851 <h2 class="title" style="clear: both"><a name=
8852 "files-and-dirs-outside-prefix" id=
8853 "files-and-dirs-outside-prefix"></a>12.1. Files and
8854 directories outside the installation prefix</h2>
8859 <p>As you already know, the <code xmlns=
8860 "http://www.w3.org/TR/xhtml1/transitional" class=
8861 "filename">PLIST</code> file holds a list of files and
8862 directories that belong to a package. The names used in
8863 it are relative to the installation prefix (<code xmlns=
8864 "http://www.w3.org/TR/xhtml1/transitional" class=
8865 "filename">${PREFIX}</code>), which means that it cannot
8866 register files outside this directory (absolute path
8867 names are not allowed). Despite this restriction, some
8868 packages need to install files outside this location;
8869 e.g., under <code xmlns=
8870 "http://www.w3.org/TR/xhtml1/transitional" class=
8871 "filename">${VARBASE}</code> or <code xmlns=
8872 "http://www.w3.org/TR/xhtml1/transitional" class=
8873 "filename">${PKG_SYSCONFDIR}</code>.</p>
8875 <p>The only way to achieve this is to create such files
8876 during installation time by using the installation
8877 scripts. These scripts can run arbitrary commands, so
8878 they have the potential to create and manage files
8879 anywhere in the file system. Here is where pkginstall
8880 comes into play: it provides generic scripts to abstract
8881 the manipulation of such files and directories based on
8882 variables set in the package's <code xmlns=
8883 "http://www.w3.org/TR/xhtml1/transitional" class=
8884 "filename">Makefile</code>. The rest of this section
8885 describes these variables.</p>
8887 <div class="sect2" lang="en" xml:lang="en">
8888 <div class="titlepage">
8891 <h3 class="title"><a name="dirs-outside-prefix"
8892 id="dirs-outside-prefix"></a>12.1.1. Directory
8898 <p>The following variables can be set to request the
8899 creation of directories anywhere in the file
8902 <div class="itemizedlist">
8905 <p><code class="varname">MAKE_DIRS</code> and
8906 <code class="varname">OWN_DIRS</code> contain a
8907 list of directories that should be created and
8908 should attempt to be destroyed by the
8909 installation scripts. The difference between the
8910 two is that the latter prompts the administrator
8911 to remove any directories that may be left after
8912 deinstallation (because they were not empty),
8913 while the former does not.</p>
8917 <p><code class="varname">MAKE_DIRS_PERMS</code>
8918 and <code class="varname">OWN_DIRS_PERMS</code>
8919 contain a list of tuples describing which
8920 directories should be created and should attempt
8921 to be destroyed by the installation scripts. Each
8922 tuple holds the following values, separated by
8923 spaces: the directory name, its owner, its group
8924 and its numerical mode. For example:</p>
8925 <pre class="programlisting">
8926 MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
8929 <p>The difference between the two is exactly the
8930 same as their non-<code class=
8931 "varname">PERMS</code> counterparts.</p>
8937 <div class="sect2" lang="en" xml:lang="en">
8938 <div class="titlepage">
8941 <h3 class="title"><a name="files-outside-prefix"
8942 id="files-outside-prefix"></a>12.1.2. File
8948 <p>Creating non-empty files outside the installation
8949 prefix is tricky because the <code xmlns=
8950 "http://www.w3.org/TR/xhtml1/transitional" class=
8951 "filename">PLIST</code> forces all files to be inside
8952 it. To overcome this problem, the only solution is to
8953 extract the file in the known place (i.e., inside the
8954 installation prefix) and copy it to the appropriate
8955 location during installation (done by the installation
8956 scripts generated by pkginstall). We will call the
8957 former the <span class="emphasis"><em>master
8958 file</em></span> in the following paragraphs, which
8959 describe the variables that can be used to
8960 automatically and consistently handle files outside the
8961 installation prefix:</p>
8963 <div class="itemizedlist">
8966 <p><code class="varname">CONF_FILES</code> and
8967 <code class="varname">SUPPORT_FILES</code> are
8968 pairs of master and target files. During
8969 installation time, the master file is copied to
8970 the target one if and only if the latter does not
8971 exist. Upon deinstallation, the target file is
8972 removed provided that it was not modified by the
8975 <p>The difference between the two is that the
8976 latter prompts the administrator to remove any
8977 files that may be left after deinstallation
8978 (because they were not empty), while the former
8983 <p><code class="varname">CONF_FILES_PERMS</code>
8985 "varname">SUPPORT_FILES_PERMS</code> contain
8986 tuples describing master files as well as their
8987 target locations. For each of them, it also
8988 specifies their owner, their group and their
8989 numeric permissions, in this order. For
8991 <pre class="programlisting">
8992 SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
8995 <p>The difference between the two is exactly the
8996 same as their non-<code class=
8997 "varname">PERMS</code> counterparts.</p>
9004 <div class="sect1" lang="en" xml:lang="en">
9005 <div class="titlepage">
9008 <h2 class="title" style="clear: both"><a name=
9009 "conf-files" id="conf-files"></a>12.2.
9010 Configuration files</h2>
9015 <p>Configuration files are special in the sense that they
9016 are installed in their own specific directory,
9017 <code class="varname">PKG_SYSCONFDIR</code>, and need
9018 special treatment during installation (most of which is
9019 automated by pkginstall). The main concept you must bear
9020 in mind is that files marked as configuration files are
9021 automatically copied to the right place (somewhere inside
9022 <code class="varname">PKG_SYSCONFDIR</code>) during
9023 installation <span class="emphasis"><em>if and only
9024 if</em></span> they didn't exist before. Similarly, they
9025 will not be removed if they have local modifications.
9026 This ensures that administrators never lose any custom
9027 changes they may have made.</p>
9029 <div class="sect2" lang="en" xml:lang="en">
9030 <div class="titlepage">
9033 <h3 class="title"><a name="conf-files-sysconfdir"
9034 id="conf-files-sysconfdir"></a>12.2.1. How
9035 <code class="varname">PKG_SYSCONFDIR</code> is
9041 <p>As said before, the <code class=
9042 "varname">PKG_SYSCONFDIR</code> variable specifies
9043 where configuration files shall be installed. Its
9044 contents are set based upon the following
9047 <div class="itemizedlist">
9050 <p><code class="varname">PKG_SYSCONFBASE</code>:
9051 The configuration's root directory. Defaults to
9053 "http://www.w3.org/TR/xhtml1/transitional" class=
9054 "filename">${PREFIX}/etc</code> although it may
9055 be overridden by the user to point to his
9056 preferred location (e.g., <code xmlns=
9057 "http://www.w3.org/TR/xhtml1/transitional" class=
9058 "filename">/etc</code>, <code xmlns=
9059 "http://www.w3.org/TR/xhtml1/transitional" class=
9060 "filename">/etc/pkg</code>, etc.). Packages must
9061 not use it directly.</p>
9066 "varname">PKG_SYSCONFSUBDIR</code>: A
9067 subdirectory of <code class=
9068 "varname">PKG_SYSCONFBASE</code> under which the
9069 configuration files for the package being built
9070 shall be installed. The definition of this
9071 variable only makes sense in the package's
9073 "http://www.w3.org/TR/xhtml1/transitional" class=
9074 "filename">Makefile</code> (i.e., it is not
9075 user-customizable).</p>
9077 <p>As an example, consider the Apache package,
9079 "http://www.w3.org/TR/xhtml1/transitional" href=
9080 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/apache2/README.html"
9081 target="_top"><code xmlns="" class=
9082 "filename">www/apache2</code></a>, which places
9083 its configuration files under the <code xmlns=
9084 "http://www.w3.org/TR/xhtml1/transitional" class=
9085 "filename">httpd/</code> subdirectory of
9086 <code class="varname">PKG_SYSCONFBASE</code>.
9087 This should be set in the package Makefile.</p>
9091 <p><code class="varname">PKG_SYSCONFVAR</code>:
9092 Specifies the name of the variable that holds
9093 this package's configuration directory (if
9094 different from <code class=
9095 "varname">PKG_SYSCONFBASE</code>). It defaults to
9096 <code class="varname">PKGBASE</code>'s value, and
9097 is always prefixed with <code class=
9098 "literal">PKG_SYSCONFDIR</code>.</p>
9103 "varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>:
9104 Holds the directory where the configuration files
9105 for the package identified by <code class=
9106 "varname">PKG_SYSCONFVAR</code>'s shall be
9112 <p>Based on the above variables, pkginstall determines
9113 the value of <code class=
9114 "varname">PKG_SYSCONFDIR</code>, which is the
9115 <span class="emphasis"><em>only</em></span> variable
9116 that can be used within a package to refer to its
9117 configuration directory. The algorithm used to set its
9118 value is basically the following:</p>
9120 <div class="orderedlist">
9124 "varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>
9125 is set, its value is used.</p>
9129 <p>If the previous variable is not defined but
9130 <code class="varname">PKG_SYSCONFSUBDIR</code> is
9131 set in the package's <code xmlns=
9132 "http://www.w3.org/TR/xhtml1/transitional" class=
9133 "filename">Makefile</code>, the resulting value
9135 "http://www.w3.org/TR/xhtml1/transitional" class=
9136 "filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p>
9140 <p>Otherwise, it is set to <code xmlns=
9141 "http://www.w3.org/TR/xhtml1/transitional" class=
9142 "filename">${PKG_SYSCONFBASE}</code>.</p>
9147 <p>It is worth mentioning that <code xmlns=
9148 "http://www.w3.org/TR/xhtml1/transitional" class=
9149 "filename">${PKG_SYSCONFDIR}</code> is automatically
9150 added to <code xmlns=
9151 "http://www.w3.org/TR/xhtml1/transitional" class=
9152 "filename">OWN_DIRS</code>. See <a href=
9153 "#dirs-outside-prefix" title=
9154 "12.1.1. Directory manipulation">Section 12.1.1,
9155 “Directory manipulation”</a> what this
9159 <div class="sect2" lang="en" xml:lang="en">
9160 <div class="titlepage">
9163 <h3 class="title"><a name="conf-files-configure"
9164 id="conf-files-configure"></a>12.2.2. Telling the
9165 software where configuration files are</h3>
9170 <p>Given that pkgsrc (and users!) expect configuration
9171 files to be in a known place, you need to teach each
9172 package where it shall install its files. In some cases
9173 you will have to patch the package Makefiles to achieve
9174 it. If you are lucky, though, it may be as easy as
9175 passing an extra flag to the configuration script; this
9176 is the case of GNU Autoconf- generated files:</p>
9177 <pre class="programlisting">
9178 CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
9181 <p>Note that this specifies where the package has to
9182 <span class="emphasis"><em>look for</em></span> its
9183 configuration files, not where they will be originally
9184 installed (although the difference is never explicit,
9188 <div class="sect2" lang="en" xml:lang="en">
9189 <div class="titlepage">
9192 <h3 class="title"><a name="conf-files-patching"
9193 id="conf-files-patching"></a>12.2.3. Patching
9199 <p>As said before, pkginstall automatically handles
9200 configuration files. This means that <span class=
9201 "strong"><strong>the packages themselves must not touch
9202 the contents of <code xmlns=
9203 "http://www.w3.org/TR/xhtml1/transitional" class=
9204 "filename">${PKG_SYSCONFDIR}</code>
9205 directly</strong></span>. Bad news is that many
9206 software installation scripts will, out of the box,
9207 mess with the contents of that directory. So what is
9208 the correct procedure to fix this issue?</p>
9210 <p>You must teach the package (usually by manually
9211 patching it) to install any configuration files under
9212 the examples hierarchy, <code xmlns=
9213 "http://www.w3.org/TR/xhtml1/transitional" class=
9214 "filename">share/examples/${PKGBASE}/</code>. This way,
9216 "http://www.w3.org/TR/xhtml1/transitional" class=
9217 "filename">PLIST</code> registers them and the
9218 administrator always has the original copies
9221 <p>Once the required configuration files are in place
9222 (i.e., under the examples hierarchy), the pkginstall
9223 framework can use them as master copies during the
9224 package installation to update what is in <code xmlns=
9225 "http://www.w3.org/TR/xhtml1/transitional" class=
9226 "filename">${PKG_SYSCONFDIR}</code>. To achieve this,
9227 the variables <code class="varname">CONF_FILES</code>
9228 and <code class="varname">CONF_FILES_PERMS</code> are
9229 used. Check out <a href="#files-outside-prefix" title=
9230 "12.1.2. File manipulation">Section 12.1.2,
9231 “File manipulation”</a> for information
9232 about their syntax and their purpose. Here is an
9233 example, taken from the <a xmlns=
9234 "http://www.w3.org/TR/xhtml1/transitional" href=
9235 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/mail/mutt/README.html"
9236 target="_top"><code xmlns="" class=
9237 "filename">mail/mutt</code></a> package:</p>
9238 <pre class="programlisting">
9239 EGDIR= ${PREFIX}/share/doc/mutt/samples
9240 CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
9243 <p>Note that the <code class="varname">EGDIR</code>
9244 variable is specific to that package and has no meaning
9248 <div class="sect2" lang="en" xml:lang="en">
9249 <div class="titlepage">
9252 <h3 class="title"><a name="conf-files-disable"
9253 id="conf-files-disable"></a>12.2.4. Disabling
9254 handling of configuration files</h3>
9259 <p>The automatic copying of config files can be toggled
9260 by setting the environment variable <code class=
9261 "varname">PKG_CONFIG</code> prior to package
9266 <div class="sect1" lang="en" xml:lang="en">
9267 <div class="titlepage">
9270 <h2 class="title" style="clear: both"><a name=
9271 "rcd-scripts" id="rcd-scripts"></a>12.3. System
9272 startup scripts</h2>
9277 <p>System startup scripts are special files because they
9278 must be installed in a place known by the underlying OS,
9279 usually outside the installation prefix. Therefore, the
9280 same rules described in <a href=
9281 "#files-and-dirs-outside-prefix" title=
9282 "12.1. Files and directories outside the installation prefix">
9283 Section 12.1, “Files and directories outside the
9284 installation prefix”</a> apply, and the same
9285 solutions can be used. However, pkginstall provides a
9286 special mechanism to handle these files.</p>
9288 <p>In order to provide system startup scripts, the
9291 <div class="orderedlist">
9294 <p>Store the script inside <code xmlns=
9295 "http://www.w3.org/TR/xhtml1/transitional" class=
9296 "filename">${FILESDIR}</code>, with the
9297 <code class="literal">.sh</code> suffix appended.
9298 Considering the <a xmlns=
9299 "http://www.w3.org/TR/xhtml1/transitional" href=
9300 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/cups/README.html"
9301 target="_top"><code xmlns="" class=
9302 "filename">print/cups</code></a> package as an
9303 example, it has a <code xmlns=
9304 "http://www.w3.org/TR/xhtml1/transitional" class=
9305 "filename">cupsd.sh</code> in its files
9310 <p>Tell pkginstall to handle it, appending the name
9311 of the script, without its extension, to the
9312 <code class="varname">RCD_SCRIPTS</code> variable.
9313 Continuing the previous example:</p>
9314 <pre class="programlisting">
9321 <p>Once this is done, pkginstall will do the following
9322 steps for each script in an automated fashion:</p>
9324 <div class="orderedlist">
9327 <p>Process the file found in the files directory
9328 applying all the substitutions described in the
9330 "http://www.w3.org/TR/xhtml1/transitional" class=
9331 "filename">FILES_SUBST</code> variable.</p>
9335 <p>Copy the script from the files directory to the
9336 examples hierarchy, <code xmlns=
9337 "http://www.w3.org/TR/xhtml1/transitional" class=
9338 "filename">${PREFIX}/share/examples/rc.d/</code>.
9339 Note that this master file must be explicitly
9340 registered in the <code xmlns=
9341 "http://www.w3.org/TR/xhtml1/transitional" class=
9342 "filename">PLIST</code>.</p>
9346 <p>Add code to the installation scripts to copy the
9347 startup script from the examples hierarchy into the
9348 system-wide startup scripts directory.</p>
9353 <div class="sect2" lang="en" xml:lang="en">
9354 <div class="titlepage">
9357 <h3 class="title"><a name="rcd-scripts-disable"
9358 id="rcd-scripts-disable"></a>12.3.1. Disabling
9359 handling of system startup scripts</h3>
9364 <p>The automatic copying of config files can be toggled
9365 by setting the environment variable <code class=
9366 "varname">PKG_RCD_SCRIPTS</code> prior to package
9367 installation. Note that the scripts will be always
9368 copied inside the examples hierarchy, <code xmlns=
9369 "http://www.w3.org/TR/xhtml1/transitional" class=
9370 "filename">${PREFIX}/share/examples/rc.d/</code>, no
9371 matter what the value of this variable is.</p>
9375 <div class="sect1" lang="en" xml:lang="en">
9376 <div class="titlepage">
9379 <h2 class="title" style="clear: both"><a name=
9380 "users-and-groups" id="users-and-groups"></a>12.4.
9381 System users and groups</h2>
9386 <p>If a package needs to create special users and/or
9387 groups during installation, it can do so by using the
9388 pkginstall framework.</p>
9390 <p>Users can be created by adding entries to the
9391 <code class="varname">PKG_USERS</code> variable. Each
9392 entry has the following syntax, which mimics <code xmlns=
9393 "http://www.w3.org/TR/xhtml1/transitional" class=
9394 "filename">/etc/passwd</code>:</p>
9395 <pre class="programlisting">
9396 user:group[:[userid][:[descr][:[home][:shell]]]]
9399 <p>Only the user and group are required; everything else
9400 is optional, but the colons must be in the right places
9401 when specifying optional bits. By default, a new user
9402 will have home directory <code xmlns=
9403 "http://www.w3.org/TR/xhtml1/transitional" class=
9404 "filename">/nonexistent</code>, and login shell
9405 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
9406 class="filename">/sbin/nologin</code> unless they are
9407 specified as part of the user element. Note that if the
9408 description contains spaces, then spaces should be
9409 backslash-escaped, as in:</p>
9410 <pre class="programlisting">
9411 foo:foogrp::The\ Foomister
9414 <p>Similarly, groups can be created using the
9415 <code class="varname">PKG_GROUPS</code> variable, whose
9417 <pre class="programlisting">
9421 <p>As before, only the group name is required; the
9422 numeric identifier is optional.</p>
9425 <div class="sect1" lang="en" xml:lang="en">
9426 <div class="titlepage">
9429 <h2 class="title" style="clear: both"><a name=
9430 "shells" id="shells"></a>12.5. System shells</h2>
9435 <p>Packages that install system shells should register
9436 them in the shell database, <code xmlns=
9437 "http://www.w3.org/TR/xhtml1/transitional" class=
9438 "filename">/etc/shells</code>, to make things easier to
9439 the administrator. This must be done from the
9440 installation scripts to keep binary packages working on
9441 any system. pkginstall provides an easy way to accomplish
9444 <p>When a package provides a shell interpreter, it has to
9445 set the <code class="varname">PKG_SHELL</code> variable
9446 to its absolute file name. This will add some hooks to
9447 the installation scripts to handle it. Consider the
9448 following example, taken from <a xmlns=
9449 "http://www.w3.org/TR/xhtml1/transitional" href=
9450 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/shells/zsh/README.html"
9451 target="_top"><code xmlns="" class=
9452 "filename">shells/zsh</code></a>:</p>
9453 <pre class="programlisting">
9455 PKG_SHELL= ${PREFIX}/bin/zsh
9458 <div class="sect2" lang="en" xml:lang="en">
9459 <div class="titlepage">
9462 <h3 class="title"><a name="shells-disable" id=
9463 "shells-disable"></a>12.5.1. Disabling handling
9464 of configuration files</h3>
9469 <p>The automatic registration of shell interpreters can
9470 be disabled by the administrator by setting the
9471 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
9472 class="filename">PKG_REGISTER_SHELLS</code> environment
9473 variable to <code class="literal">NO</code>.</p>
9478 <div class="chapter" lang="en" xml:lang="en">
9479 <div class="titlepage">
9482 <h2 class="title"><a name="options" id=
9483 "options"></a>Chapter 13. Options
9490 <p><b>Table of Contents</b></p>
9493 <dt><span class="sect1"><a href=
9494 "#global-default-options">13.1. Global default
9495 options</a></span></dt>
9497 <dt><span class="sect1"><a href=
9498 "#converting-to-options">13.2. Converting packages to
9500 "http://www.w3.org/TR/xhtml1/transitional" class=
9501 "filename">bsd.options.mk</code></a></span></dt>
9503 <dt><span class="sect1"><a href="#option-names">13.3.
9504 Option Names</a></span></dt>
9508 <p>Many packages have the ability to be built to support
9509 different sets of features. <code xmlns=
9510 "http://www.w3.org/TR/xhtml1/transitional" class=
9511 "filename">bsd.options.mk</code> is a framework in pkgsrc
9512 that provides generic handling of those options that
9513 determine different ways in which the packages can be
9514 built. It's possible for the user to specify exactly which
9515 sets of options will be built into a package or to allow a
9516 set of global default options apply.</p>
9518 <div class="sect1" lang="en" xml:lang="en">
9519 <div class="titlepage">
9522 <h2 class="title" style="clear: both"><a name=
9523 "global-default-options" id=
9524 "global-default-options"></a>13.1. Global
9525 default options</h2>
9530 <p>Global default options are listed in <code class=
9531 "varname">PKG_DEFAULT_OPTIONS</code>, which is a list of
9532 the options that should be built into every package if
9533 that option is supported. This variable should be set in
9534 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
9535 class="filename">/etc/mk.conf</code>.</p>
9538 <div class="sect1" lang="en" xml:lang="en">
9539 <div class="titlepage">
9542 <h2 class="title" style="clear: both"><a name=
9543 "converting-to-options" id=
9544 "converting-to-options"></a>13.2. Converting
9545 packages to use <code xmlns=
9546 "http://www.w3.org/TR/xhtml1/transitional" class=
9547 "filename">bsd.options.mk</code></h2>
9552 <p>The following example shows how <code xmlns=
9553 "http://www.w3.org/TR/xhtml1/transitional" class=
9554 "filename">bsd.options.mk</code> should be used by the
9555 hypothetical ``wibble'' package, either in the package
9556 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
9557 class="filename">Makefile</code>, or in a file, e.g.
9558 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
9559 class="filename">options.mk</code>, that is included by
9560 the main package <code xmlns=
9561 "http://www.w3.org/TR/xhtml1/transitional" class=
9562 "filename">Makefile</code>.</p>
9563 <pre class="programlisting">
9564 PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
9565 PKG_SUPPORTED_OPTIONS= wibble-foo ldap
9566 PKG_OPTIONS_OPTIONAL_GROUPS= database
9567 PKG_OPTIONS_GROUP.database= mysql pgsql
9568 PKG_SUGGESTED_OPTIONS= wibble-foo
9569 PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
9570 PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
9572 .include "../../mk/bsd.prefs.mk"
9574 # this package was previously named wibble2
9575 .if defined(PKG_OPTIONS.wibble2)
9576 PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
9577 PKG_OPTIONS_DEPRECATED_WARNINGS+= \
9578 "Deprecated variable PKG_OPTIONS.wibble2 used, use "${PKG_OPTIONS_VAR:Q}" instead."
9581 .include "../../mk/bsd.options.mk"
9583 # Package-specific option-handling
9588 .if !empty(PKG_OPTIONS:Mwibble-foo)
9589 CONFIGURE_ARGS+= --enable-foo
9595 .if !empty(PKG_OPTIONS:Mldap)
9596 . include "../../databases/openldap/buildlink3.mk"
9597 CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap}
9601 ### database support
9603 .if !empty(PKG_OPTIONS:Mmysql)
9604 . include "../../mk/mysql.buildlink3.mk"
9606 .if !empty(PKG_OPTIONS:Mpgsql)
9607 . include "../../mk/pgsql.buildlink3.mk"
9611 <p>The first section contains the information about which
9612 build options are supported by the package, and any
9613 default options settings if needed.</p>
9615 <div class="orderedlist">
9618 <p><code class="varname">PKG_OPTIONS_VAR</code> is
9619 the name of the <a href=
9620 "http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current">
9621 <span class="citerefentry"><span class=
9622 "refentrytitle">make</span>(1)</span></a> variable
9623 that the user can set to override the default
9624 options. It should be set to “<span class=
9625 "quote">PKG_OPTIONS.<em class=
9626 "replaceable"><code>pkgbase</code></em></span>”.</p>
9631 "varname">PKG_SUPPORTED_OPTIONS</code> is a list of
9632 build options supported by the package.</p>
9637 "varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
9638 list of names of groups of mutually exclusive
9639 options. The options in each group are listed in
9640 <code class="varname">PKG_OPTIONS_GROUP.<em class=
9641 "replaceable"><code>groupname</code></em></code>.
9642 The most specific setting of any option from the
9643 group takes precedence over all other options in
9644 the group. Options from the groups will be
9645 automatically added to <code class=
9646 "varname">PKG_SUPPORTED_OPTIONS</code>.</p>
9651 "varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is
9653 "varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but
9654 building the packages will fail if no option from
9655 the group is selected.</p>
9660 "varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a
9661 list of names of sets of options. At least one
9662 option from each set must be selected. The options
9663 in each set are listed in <code class=
9664 "varname">PKG_OPTIONS_SET.<em class=
9665 "replaceable"><code>setname</code></em></code>.
9666 Options from the sets will be automatically added
9668 "varname">PKG_SUPPORTED_OPTIONS</code>. Building
9669 the package will fail if no option from the set is
9675 "varname">PKG_SUGGESTED_OPTIONS</code> is a list of
9676 build options which are enabled by default.</p>
9681 "varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
9682 of “<span class="quote"><em class=
9683 "replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable">
9684 <code>option</code></em></span>” pairs that
9685 map legacy <code xmlns=
9686 "http://www.w3.org/TR/xhtml1/transitional" class=
9687 "filename">/etc/mk.conf</code> variables to their
9688 option counterparts. Pairs should be added with
9689 “<span class="quote">+=</span>” to keep
9690 the listing of global legacy variables. A warning
9691 will be issued if the user uses a legacy
9697 "varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
9698 of “<span class="quote"><em class=
9699 "replaceable"><code>old-option</code></em>:<em class="replaceable">
9700 <code>new-option</code></em></span>” pairs
9701 that map options that have been renamed to their
9702 new counterparts. Pairs should be added with
9703 “<span class="quote">+=</span>” to keep
9704 the listing of global legacy options. A warning
9705 will be issued if the user uses a legacy
9710 <p><code class="varname">PKG_LEGACY_OPTIONS</code>
9711 is a list of options implied by deprecated
9712 variables used. This can be used for cases that
9713 neither <code class=
9714 "varname">PKG_OPTIONS_LEGACY_VARS</code> nor
9716 "varname">PKG_OPTIONS_LEGACY_OPTS</code> can
9717 handle, e. g. when <code class=
9718 "varname">PKG_OPTIONS_VAR</code> is renamed.</p>
9723 "varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
9724 a list of warnings about deprecated variables or
9725 options used, and what to use instead.</p>
9730 <p>A package should never modify <code class=
9731 "varname">PKG_DEFAULT_OPTIONS</code> or the variable
9732 named in <code class="varname">PKG_OPTIONS_VAR</code>.
9733 These are strictly user-settable. To suggest a default
9734 set of options, use <code class=
9735 "varname">PKG_SUGGESTED_OPTIONS</code>.</p>
9737 <p><code class="varname">PKG_OPTIONS_VAR</code> must be
9738 defined before including <code xmlns=
9739 "http://www.w3.org/TR/xhtml1/transitional" class=
9740 "filename">bsd.options.mk</code>. If none of <code class=
9741 "varname">PKG_SUPPORTED_OPTIONS</code>, <code class=
9742 "varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
9743 <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code>
9744 are defined (as can happen with platform-specific options
9745 if none of them is supported on the current platform),
9746 <code class="varname">PKG_OPTIONS</code> is set to the
9747 empty list and the package is otherwise treated as not
9748 using the options framework.</p>
9750 <p>After the inclusion of <code xmlns=
9751 "http://www.w3.org/TR/xhtml1/transitional" class=
9752 "filename">bsd.options.mk</code>, the variable
9753 <code class="varname">PKG_OPTIONS</code> contains the
9754 list of selected build options, properly filtered to
9755 remove unsupported and duplicate options.</p>
9757 <p>The remaining sections contain the logic that is
9758 specific to each option. The correct way to check for an
9759 option is to check whether it is listed in <code class=
9760 "varname">PKG_OPTIONS</code>:</p>
9761 <pre class="programlisting">
9762 .if !empty(PKG_OPTIONS:M<em class=
9763 "replaceable"><code>option</code></em>)
9767 <div class="sect1" lang="en" xml:lang="en">
9768 <div class="titlepage">
9771 <h2 class="title" style="clear: both"><a name=
9773 "option-names"></a>13.3. Option Names</h2>
9778 <p>Options that enable similar features in different
9779 packages (like optional support for a library) should use
9780 a common name in all packages that support it (like the
9781 name of the library). If another package already has an
9782 option with the same meaning, use the same name.</p>
9784 <p>Options that enable features specific to one package,
9785 where it's unlikely that another (unrelated) package has
9786 the same (or a similar) optional feature, should use a
9787 name prefixed with <code class="varname"><em class=
9788 "replaceable"><code>pkgname</code></em>-</code>.</p>
9790 <p>If a group of related packages share an optional
9791 feature specific to that group, prefix it with the name
9792 of the “<span class="quote">main</span>”
9793 package (e. g. <code class=
9794 "varname">djbware-errno-hack</code>).</p>
9796 <p>For new options, add a line to <code xmlns=
9797 "http://www.w3.org/TR/xhtml1/transitional" class=
9798 "filename">mk/defaults/options.description</code>. Lines
9799 have two fields, separated by tab. The first field is the
9800 option name, the second its description. The description
9801 should be a whole sentence (starting with an uppercase
9802 letter and ending with a period) that describes what
9803 enabling the option does. E. g. “<span class=
9804 "quote">Enable ispell support.</span>” The file is
9805 sorted by option names.</p>
9809 <div class="chapter" lang="en" xml:lang="en">
9810 <div class="titlepage">
9813 <h2 class="title"><a name="build" id=
9814 "build"></a>Chapter 14. The build
9821 <p><b>Table of Contents</b></p>
9824 <dt><span class="sect1"><a href="#build.prefix">14.1.
9825 Program location</a></span></dt>
9827 <dt><span class="sect1"><a href="#main-targets">14.2.
9828 Main targets</a></span></dt>
9830 <dt><span class="sect1"><a href=
9831 "#build.helpful-targets">14.3. Other helpful
9832 targets</a></span></dt>
9836 <p>The basic steps for building a program are always the
9837 same. First the program's source (<span class=
9838 "emphasis"><em>distfile</em></span>) must be brought to the
9839 local system and then extracted. After any patches to
9840 compile properly on NetBSD are applied, the software can be
9841 configured, then built (usually by compiling), and finally
9842 the generated binaries, etc. can be put into place on the
9843 system. These are exactly the steps performed by the NetBSD
9844 package system, which is implemented as a series of targets
9845 in a central Makefile, <code xmlns=
9846 "http://www.w3.org/TR/xhtml1/transitional" class=
9847 "filename">pkgsrc/mk/bsd.pkg.mk</code>.</p>
9849 <div class="sect1" lang="en" xml:lang="en">
9850 <div class="titlepage">
9853 <h2 class="title" style="clear: both"><a name=
9855 "build.prefix"></a>14.1. Program location</h2>
9860 <p>Before outlining the process performed by the NetBSD
9861 package system in the next section, here's a brief
9862 discussion on where programs are installed, and which
9863 variables influence this.</p>
9865 <p>The automatic variable <code class=
9866 "varname">PREFIX</code> indicates where all files of the
9867 final program shall be installed. It is usually set to
9868 <code class="varname">LOCALBASE</code> (<code xmlns=
9869 "http://www.w3.org/TR/xhtml1/transitional" class=
9870 "filename">/usr/pkg</code>), or <code class=
9871 "varname">CROSSBASE</code> for pkgs in the
9872 “<span class="quote">cross</span>” category.
9873 The value of <code class="varname">PREFIX</code> needs to
9874 be put into the various places in the program's source
9875 where paths to these files are encoded. See <a href=
9876 "#components.patches" title=
9877 "8.3. patches/*">Section 8.3,
9878 “patches/*”</a> and <a href="#fixes.libtool"
9880 "15.3.1. Shared libraries - libtool">Section 15.3.1,
9881 “Shared libraries - libtool”</a> for more
9884 <p>When choosing which of these variables to use, follow
9885 the following rules:</p>
9887 <div class="itemizedlist">
9890 <p><code class="varname">PREFIX</code> always
9891 points to the location where the current pkg will
9892 be installed. When referring to a pkg's own
9893 installation path, use “<span class=
9894 "quote">${PREFIX}</span>”.</p>
9898 <p><code class="varname">LOCALBASE</code> is where
9899 all non-X11 pkgs are installed. If you need to
9900 construct a -I or -L argument to the compiler to
9901 find includes and libraries installed by another
9902 non-X11 pkg, use “<span class=
9903 "quote">${LOCALBASE}</span>”.</p>
9907 <p><code class="varname">X11BASE</code> is where
9908 the actual X11 distribution (from xsrc, etc.) is
9909 installed. When looking for <span class=
9910 "emphasis"><em>standard</em></span> X11 includes
9911 (not those installed by a pkg), use
9913 "quote">${X11BASE}</span>”.</p>
9917 <p>X11-based packages are special in that they may
9918 be installed in either <code class=
9919 "varname">X11BASE</code> or <code class=
9920 "varname">LOCALBASE</code>.</p>
9922 <p>Usually, X11 packages should be installed under
9923 <code class="varname">LOCALBASE</code> whenever
9924 possible. Note that you will need to include
9926 "http://www.w3.org/TR/xhtml1/transitional" class=
9927 "filename">../../mk/x11.buildlink3.mk</code> in
9928 them to request the presence of X11 and to get the
9929 right compilation flags.</p>
9931 <p>Even though, there are some packages that cannot
9932 be installed under <code class=
9933 "varname">LOCALBASE</code>: those that come with
9934 app-defaults files. These packages are special and
9935 they must be placed under <code class=
9936 "varname">X11BASE</code>. To accomplish this, set
9937 either <code class="varname">USE_X11BASE</code> or
9938 <code class="varname">USE_IMAKE</code> in your
9941 <p>Some notes: If you need to find includes or
9942 libraries installed by a pkg that has <code class=
9943 "varname">USE_IMAKE</code> or <code class=
9944 "varname">USE_X11BASE</code> in its pkg
9945 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
9946 class="filename">Makefile</code>, you need to look
9947 in <span class="emphasis"><em>both</em></span>
9949 "http://www.w3.org/TR/xhtml1/transitional" class=
9950 "filename">${X11BASE}</code> and <code xmlns=
9951 "http://www.w3.org/TR/xhtml1/transitional" class=
9952 "filename">${LOCALBASE}</code>. To force
9953 installation of all X11 packages in <code class=
9954 "varname">LOCALBASE</code>, the <a xmlns=
9955 "http://www.w3.org/TR/xhtml1/transitional" href=
9956 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/xpkgwedge/README.html"
9957 target="_top"><code xmlns="" class=
9958 "filename">pkgtools/xpkgwedge</code></a> package is
9959 enabled by default.</p>
9963 <p><code class="varname">X11PREFIX</code> should be
9964 used to refer to the installed location of an X11
9965 package. <code class="varname">X11PREFIX</code>
9966 will be set to <code class="varname">X11BASE</code>
9967 if xpkgwedge is not installed, and to <code class=
9968 "varname">LOCALBASE</code> if xpkgwedge is
9973 <p>If xpkgwedge is installed, it is possible to
9974 have some packages installed in <code class=
9975 "varname">X11BASE</code> and some in <code class=
9976 "varname">LOCALBASE</code>. To determine the prefix
9977 of an installed package, the <code class=
9978 "varname">EVAL_PREFIX</code> definition can be
9979 used. It takes pairs in the format
9981 "quote">DIRNAME=<package></span>”, and
9983 "http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current">
9984 <span class="citerefentry"><span class=
9985 "refentrytitle">make</span>(1)</span></a> variable
9986 <code class="varname">DIRNAME</code> will be set to
9987 the prefix of the installed package
9988 <package>, or “<span class=
9989 "quote">${X11PREFIX}</span>” if the package
9990 is not installed.</p>
9992 <p>This is best illustrated by example.</p>
9994 <p>The following lines are taken from <code xmlns=
9995 "http://www.w3.org/TR/xhtml1/transitional" class=
9996 "filename">pkgsrc/wm/scwm/Makefile</code>:</p>
9997 <pre class="programlisting">
9998 EVAL_PREFIX+= GTKDIR=gtk+
9999 CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE} \
10000 --with-gtk-prefix="${GTKDIR}" \
10004 <p>Specific defaults can be defined for the
10005 packages evaluated using <code class=
10006 "varname">EVAL_PREFIX</code>, by using a definition
10008 <pre class="programlisting">
10009 GTKDIR_DEFAULT= ${LOCALBASE}
10012 <p>where <code class="varname">GTKDIR</code>
10013 corresponds to the first definition in the
10014 <code class="varname">EVAL_PREFIX</code> pair.</p>
10018 <p>Within <code xmlns=
10019 "http://www.w3.org/TR/xhtml1/transitional" class=
10020 "filename">${PREFIX}</code>, packages should
10021 install files according to <a href=
10022 "http://netbsd.gw.com/cgi-bin/man-cgi?hier+7+NetBSD-current">
10023 <span class="citerefentry"><span class=
10024 "refentrytitle">hier</span>(7)</span></a>, with the
10025 exception that manual pages go into <code xmlns=
10026 "http://www.w3.org/TR/xhtml1/transitional" class=
10027 "filename">${PREFIX}/man</code>, not <code xmlns=
10028 "http://www.w3.org/TR/xhtml1/transitional" class=
10029 "filename">${PREFIX}/share/man</code>.</p>
10035 <div class="sect1" lang="en" xml:lang="en">
10036 <div class="titlepage">
10039 <h2 class="title" style="clear: both"><a name=
10041 "main-targets"></a>14.2. Main targets</h2>
10046 <p>The main targets used during the build process defined
10047 in <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
10048 class="filename">bsd.pkg.mk</code> are:</p>
10050 <div class="variablelist">
10052 <dt><span class="term">fetch</span></dt>
10055 <p>This will check if the file(s) given in the
10056 variables <code class="varname">DISTFILES</code>
10057 and <code class="varname">PATCHFILES</code> (as
10058 defined in the package's Makefile) are present on
10059 the local system in <code xmlns=
10060 "http://www.w3.org/TR/xhtml1/transitional" class=
10061 "filename">/usr/pkgsrc/distfiles</code>. If they
10062 are not present, an attempt will be made to fetch
10063 them using commands of the form:</p>
10064 <pre class="programlisting">
10065 ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
10068 <p>where ${site} varies through several
10069 possibilities in turn: first, <code class=
10070 "varname">MASTER_SITE_OVERRIDE</code> is tried,
10071 then the sites specified in either <code class=
10072 "varname">SITES_file</code> if defined, else
10073 <code class="varname">MASTER_SITES</code> or
10074 <code class="varname">PATCH_SITES</code>, as
10075 applies, then finally the value of <code class=
10076 "varname">MASTER_SITE_BACKUP</code>. The order of
10077 all except the first can be optionally sorted by
10078 the user, via setting either <code class=
10079 "varname">MASTER_SORT_AWK</code> or <code class=
10080 "varname">MASTER_SORT_REGEX</code>.</p>
10083 <dt><span class="term">checksum</span></dt>
10086 <p>After the distfile(s) are fetched, their
10087 checksum is generated and compared with the
10088 checksums stored in the distinfo file. If the
10089 checksums don't match, the build is aborted. This
10090 is to ensure the same distfile is used for
10091 building, and that the distfile wasn't changed,
10092 e.g. by some malign force, deliberately changed
10093 distfiles on the master distribution site or
10094 network lossage.</p>
10097 <dt><span class="term">extract</span></dt>
10100 <p>When the distfiles are present on the local
10101 system, they need to be extracted, as they are
10102 usually in the form of some compressed archive
10103 format, most commonly <code xmlns=
10104 "http://www.w3.org/TR/xhtml1/transitional" class=
10105 "filename">.tar.gz</code>.</p>
10107 <p>If only some of the distfiles need to be
10108 uncompressed, the files to be uncompressed should
10109 be put into <code class=
10110 "varname">EXTRACT_ONLY</code>.</p>
10112 <p>If the distfiles are not in <code xmlns=
10113 "http://www.w3.org/TR/xhtml1/transitional" class=
10114 "filename">.tar.gz</code> format, they can be
10115 extracted by setting either <code class=
10116 "varname">EXTRACT_SUFX</code>, or <code class=
10117 "varname">EXTRACT_CMD</code>, <code class=
10118 "varname">EXTRACT_BEFORE_ARGS</code> and
10119 <code class="varname">EXTRACT_AFTER_ARGS</code>. In
10120 the former case, pkgsrc knows how to extract a
10121 number of suffixes (<code xmlns=
10122 "http://www.w3.org/TR/xhtml1/transitional" class=
10123 "filename">.tar.gz</code>, <code xmlns=
10124 "http://www.w3.org/TR/xhtml1/transitional" class=
10125 "filename">.tgz</code>, <code xmlns=
10126 "http://www.w3.org/TR/xhtml1/transitional" class=
10127 "filename">.tar.gz2</code>, <code xmlns=
10128 "http://www.w3.org/TR/xhtml1/transitional" class=
10129 "filename">.tbz</code>, <code xmlns=
10130 "http://www.w3.org/TR/xhtml1/transitional" class=
10131 "filename">.tar.Z</code>, <code xmlns=
10132 "http://www.w3.org/TR/xhtml1/transitional" class=
10133 "filename">.tar</code>, <code xmlns=
10134 "http://www.w3.org/TR/xhtml1/transitional" class=
10135 "filename">.shar.gz</code>, <code xmlns=
10136 "http://www.w3.org/TR/xhtml1/transitional" class=
10137 "filename">.shar.bz2</code>, <code xmlns=
10138 "http://www.w3.org/TR/xhtml1/transitional" class=
10139 "filename">.shar.Z</code>, <code xmlns=
10140 "http://www.w3.org/TR/xhtml1/transitional" class=
10141 "filename">.shar</code>, <code xmlns=
10142 "http://www.w3.org/TR/xhtml1/transitional" class=
10143 "filename">.Z</code>, <code xmlns=
10144 "http://www.w3.org/TR/xhtml1/transitional" class=
10145 "filename">.bz2</code> and <code xmlns=
10146 "http://www.w3.org/TR/xhtml1/transitional" class=
10147 "filename">.gz</code>; see the definition of the
10148 various <code class="varname">DECOMPRESS_CMD</code>
10149 variables in <code xmlns=
10150 "http://www.w3.org/TR/xhtml1/transitional" class=
10151 "filename">bsd.pkg.extract.mk</code> for a complete
10152 list). Here's an example on how to use the other
10153 variables for a program that comes with a
10154 compressed shell archive whose name ends in
10156 "http://www.w3.org/TR/xhtml1/transitional" class=
10157 "filename">.msg.gz</code>:</p>
10158 <pre class="programlisting">
10159 EXTRACT_SUFX= .msg.gz
10161 EXTRACT_BEFORE_ARGS=
10162 EXTRACT_AFTER_ARGS= |sh
10166 <dt><span class="term">patch</span></dt>
10169 <p>After extraction, all the patches named by the
10170 <code class="varname">PATCHFILES</code>, those
10171 present in the patches subdirectory of the package
10172 as well as in $LOCALPATCHES/$PKGPATH (e.g.
10174 "http://www.w3.org/TR/xhtml1/transitional" class=
10175 "filename">/usr/local/patches/graphics/png</code>)
10176 are applied. Patchfiles ending in <code xmlns=
10177 "http://www.w3.org/TR/xhtml1/transitional" class=
10178 "filename">.Z</code> or <code xmlns=
10179 "http://www.w3.org/TR/xhtml1/transitional" class=
10180 "filename">.gz</code> are uncompressed before they
10181 are applied, files ending in <code xmlns=
10182 "http://www.w3.org/TR/xhtml1/transitional" class=
10183 "filename">.orig</code> or <code xmlns=
10184 "http://www.w3.org/TR/xhtml1/transitional" class=
10185 "filename">.rej</code> are ignored. Any special
10186 options to <a href=
10187 "http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current">
10188 <span class="citerefentry"><span class=
10189 "refentrytitle">patch</span>(1)</span></a> can be
10190 handed in <code class=
10191 "varname">PATCH_DIST_ARGS</code>. See <a href=
10192 "#components.patches" title=
10193 "8.3. patches/*">Section 8.3,
10194 “patches/*”</a> for more details.</p>
10196 <p>By default <a href=
10197 "http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current">
10198 <span class="citerefentry"><span class=
10199 "refentrytitle">patch</span>(1)</span></a> is given
10200 special args to make it fail if the patches apply
10201 with some lines of fuzz. Please fix (regen) the
10202 patches so that they apply cleanly. The rationale
10203 behind this is that patches that don't apply
10204 cleanly may end up being applied in the wrong
10205 place, and cause severe harm there.</p>
10208 <dt><span class="term">configure</span></dt>
10211 <p>Most pieces of software need information on the
10212 header files, system calls, and library routines
10213 which are available in NetBSD. This is the process
10214 known as configuration, and is usually automated.
10215 In most cases, a script is supplied with the
10216 source, and its invocation results in generation of
10217 header files, Makefiles, etc.</p>
10219 <p>If the program's distfile contains its own
10220 configure script, this can be invoked by setting
10221 <code class="varname">HAS_CONFIGURE</code>. If the
10222 configure script is a GNU autoconf script,
10223 <code class="varname">GNU_CONFIGURE</code> should
10224 be specified instead. In either case, any arguments
10225 to the configure script can be specified in the
10226 <code class="varname">CONFIGURE_ARGS</code>
10227 variable, and the configure script's name can be
10228 set in <code class=
10229 "varname">CONFIGURE_SCRIPT</code> if it differs
10230 from the default “<span class=
10231 "quote">configure</span>”. Here's an example
10233 "http://www.w3.org/TR/xhtml1/transitional" href=
10234 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/sysutils/top/README.html"
10235 target="_top"><code xmlns="" class=
10236 "filename">sysutils/top</code></a> package:</p>
10237 <pre class="programlisting">
10239 CONFIGURE_SCRIPT= Configure
10240 CONFIGURE_ARGS+= netbsd13
10243 <p>If the program uses an Imakefile for
10244 configuration, the appropriate steps can be invoked
10245 by setting <code class="varname">USE_IMAKE</code>
10246 to “<span class="quote">YES</span>”.
10247 (If you only want the package installed in
10248 <code class="varname">$X11PREFIX</code> but xmkmf
10249 not being run, set <code class=
10250 "varname">USE_X11BASE</code> instead!)</p>
10253 <dt><span class="term">build</span></dt>
10256 <p>Once configuration has taken place, the software
10257 will be built by invoking <code class=
10258 "varname">$MAKE_PROGRAM</code> on <code class=
10259 "varname">$MAKEFILE</code> with <code class=
10260 "varname">$BUILD_TARGET</code> as the target to
10261 build. The default <code class=
10262 "varname">MAKE_PROGRAM</code> is
10263 “<span class="quote">gmake</span>” if
10264 <code class="varname">USE_TOOLS</code> contains
10265 “<span class="quote">gmake</span>”,
10266 “<span class="quote">make</span>”
10267 otherwise. <code class="varname">MAKEFILE</code> is
10268 set to “<span class=
10269 "quote">Makefile</span>” by default, and
10270 <code class="varname">BUILD_TARGET</code> defaults
10271 to “<span class="quote">all</span>”.
10272 Any of these variables can be set in the package's
10273 Makefile to change the default build process.</p>
10276 <dt><span class="term">install</span></dt>
10279 <p>Once the build stage has completed, the final
10280 step is to install the software in public
10281 directories, so users can access the programs and
10282 files. As in the build-target, <code class=
10283 "varname">$MAKE_PROGRAM</code> is invoked on
10284 <code class="varname">$MAKEFILE</code> here, but
10285 with the <code class=
10286 "varname">$INSTALL_TARGET</code> instead, the
10287 latter defaulting to “<span class=
10288 "quote">install</span>” (plus
10289 “<span class=
10290 "quote">install.man</span>”, if <code class=
10291 "varname">USE_IMAKE</code> is set).</p>
10296 <p>If no target is specified, the default is
10297 “<span class="quote">build</span>”. If a
10298 subsequent stage is requested, all prior stages are made:
10299 e.g. <span><strong class="command">make
10300 build</strong></span> will also perform the equivalent
10302 <pre class="programlisting">
10312 <div class="sect1" lang="en" xml:lang="en">
10313 <div class="titlepage">
10316 <h2 class="title" style="clear: both"><a name=
10317 "build.helpful-targets" id=
10318 "build.helpful-targets"></a>14.3. Other
10319 helpful targets</h2>
10324 <div class="variablelist">
10326 <dt><span class="term">pre/post-*</span></dt>
10329 <p>For any of the main targets described in the
10330 previous section, two auxiliary targets exist with
10331 “<span class="quote">pre-</span>” and
10332 “<span class="quote">post-</span>” used
10333 as a prefix for the main target's name. These
10334 targets are invoked before and after the main
10335 target is called, allowing extra configuration or
10336 installation steps be performed from a package's
10337 Makefile, for example, which a program's configure
10338 script or install target omitted.</p>
10341 <dt><span class="term">do-*</span></dt>
10344 <p>Should one of the main targets do the wrong
10345 thing, and should there be no variable to fix this,
10346 you can redefine it with the do-* target. (Note
10347 that redefining the target itself instead of the
10348 do-* target is a bad idea, as the pre-* and post-*
10349 targets won't be called anymore, etc.) You will not
10350 usually need to do this.</p>
10353 <dt><span class="term">reinstall</span></dt>
10356 <p>If you did a <span><strong class="command">make
10357 install</strong></span> and you noticed some file
10358 was not installed properly, you can repeat the
10359 installation with this target, which will ignore
10360 the “<span class="quote">already
10361 installed</span>” flag.</p>
10364 <dt><span class="term">deinstall</span></dt>
10367 <p>This target does a <a href=
10368 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current">
10369 <span class="citerefentry"><span class=
10370 "refentrytitle">pkg_delete</span>(1)</span></a> in
10371 the current directory, effectively de-installing
10372 the package. The following variables can be used to
10373 tune the behaviour:</p>
10375 <div class="variablelist">
10377 <dt><span class="term"><code class=
10378 "varname">PKG_VERBOSE</code></span></dt>
10381 <p>Add a "-v" to the <a href=
10382 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current">
10383 <span class="citerefentry"><span class=
10384 "refentrytitle">pkg_delete</span>(1)</span></a>
10388 <dt><span class="term"><code class=
10389 "varname">DEINSTALLDEPENDS</code></span></dt>
10392 <p>Remove all packages that require (depend
10393 on) the given package. This can be used to
10394 remove any packages that may have been pulled
10395 in by a given package, e.g. if
10396 <span><strong class="command">make deinstall
10397 DEINSTALLDEPENDS=1</strong></span> is done in
10399 "http://www.w3.org/TR/xhtml1/transitional"
10400 class="filename">pkgsrc/x11/kde</code>, this
10401 is likely to remove whole KDE. Works by
10402 adding “<span class=
10403 "quote">-R</span>” to the <a href=
10404 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current">
10405 <span class="citerefentry"><span class=
10406 "refentrytitle">pkg_delete</span>(1)</span></a>
10413 <dt><span class="term">update</span></dt>
10416 <p>This target causes the current package to be
10417 updated to the latest version. The package and all
10418 depending packages first get de-installed, then
10419 current versions of the corresponding packages get
10420 compiled and installed. This is similar to manually
10421 noting which packages are currently installed, then
10422 performing a series of <span><strong class=
10423 "command">make deinstall</strong></span> and
10424 <span><strong class="command">make
10425 install</strong></span> (or whatever <code class=
10426 "varname">UPDATE_TARGET</code> is set to) for these
10429 <p>You can use the “<span class=
10430 "quote">update</span>” target to resume
10431 package updating in case a previous
10432 <span><strong class="command">make
10433 update</strong></span> was interrupted for some
10434 reason. However, in this case, make sure you don't
10435 call <span><strong class="command">make
10436 clean</strong></span> or otherwise remove the list
10437 of dependent packages in <code class=
10438 "varname">WRKDIR</code>. Otherwise, you lose the
10439 ability to automatically update the current package
10440 along with the dependent packages you have
10443 <p>Resuming an interrupted <span><strong class=
10444 "command">make update</strong></span> will only
10445 work as long as the package tree remains unchanged.
10446 If the source code for one of the packages to be
10447 updated has been changed, resuming
10448 <span><strong class="command">make
10449 update</strong></span> will most certainly
10452 <p>The following variables can be used either on
10453 the command line or in <code xmlns=
10454 "http://www.w3.org/TR/xhtml1/transitional" class=
10455 "filename">/etc/mk.conf</code> to alter the
10456 behaviour of <span><strong class="command">make
10457 update</strong></span>:</p>
10459 <div class="variablelist">
10461 <dt><span class="term"><code class=
10462 "varname">UPDATE_TARGET</code></span></dt>
10465 <p>Install target to recursively use for the
10466 updated package and the dependent packages.
10467 Defaults to <code class=
10468 "varname">DEPENDS_TARGET</code> if set,
10469 “<span class=
10470 "quote">install</span>” otherwise for
10471 <span><strong class="command">make
10472 update</strong></span>. e.g.
10473 <span><strong class="command">make update
10474 UPDATE_TARGET=package</strong></span></p>
10477 <dt><span class="term"><code class=
10478 "varname">NOCLEAN</code></span></dt>
10481 <p>Don't clean up after updating. Useful if
10482 you want to leave the work sources of the
10483 updated packages around for inspection or
10484 other purposes. Be sure you eventually clean
10485 up the source tree (see the
10486 “<span class=
10487 "quote">clean-update</span>” target
10488 below) or you may run into troubles with old
10489 source code still lying around on your next
10490 <span><strong class=
10491 "command">make</strong></span> or
10492 <span><strong class="command">make
10493 update</strong></span>.</p>
10496 <dt><span class="term"><code class=
10497 "varname">REINSTALL</code></span></dt>
10500 <p>Deinstall each package before installing
10501 (making <code class=
10502 "varname">DEPENDS_TARGET</code>). This may be
10503 necessary if the “<span class=
10504 "quote">clean-update</span>” target
10505 (see below) was called after interrupting a
10506 running <span><strong class="command">make
10507 update</strong></span>.</p>
10510 <dt><span class="term"><code class=
10511 "varname">DEPENDS_TARGET</code></span></dt>
10514 <p>Allows you to disable recursion and
10515 hardcode the target for packages. The default
10516 is “<span class=
10517 "quote">update</span>” for the update
10518 target, facilitating a recursive update of
10519 prerequisite packages. Only set <code class=
10520 "varname">DEPENDS_TARGET</code> if you want
10521 to disable recursive updates. Use
10522 <code class="varname">UPDATE_TARGET</code>
10523 instead to just set a specific target for
10524 each package to be installed during
10525 <span><strong class="command">make
10526 update</strong></span> (see above).</p>
10532 <dt><span class="term">clean-update</span></dt>
10535 <p>Clean the source tree for all packages that
10536 would get updated if <span><strong class=
10537 "command">make update</strong></span> was called
10538 from the current directory. This target should not
10539 be used if the current package (or any of its
10540 depending packages) have already been de-installed
10541 (e.g., after calling <span><strong class=
10542 "command">make update</strong></span>) or you may
10543 lose some packages you intended to update. As a
10544 rule of thumb: only use this target <span class=
10545 "emphasis"><em>before</em></span> the first time
10546 you run <span><strong class="command">make
10547 update</strong></span> and only if you have a dirty
10548 package tree (e.g., if you used <code class=
10549 "varname">NOCLEAN</code>).</p>
10551 <p>If you are unsure about whether your tree is
10552 clean, you can either perform a
10553 <span><strong class="command">make
10554 clean</strong></span> at the top of the tree, or
10555 use the following sequence of commands from the
10556 directory of the package you want to update
10557 (<span class="emphasis"><em>before</em></span>
10558 running <span><strong class="command">make
10559 update</strong></span> for the first time,
10560 otherwise you lose all the packages you wanted to
10562 <pre class="screen">
10563 <code class="prompt">#</code> <strong class=
10564 "userinput"><code>make clean-update</code></strong>
10565 <code class="prompt">#</code> <strong class=
10566 "userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
10567 <code class="prompt">#</code> <strong class=
10568 "userinput"><code>make update</code></strong>
10571 <p>The following variables can be used either on
10572 the command line or in <code xmlns=
10573 "http://www.w3.org/TR/xhtml1/transitional" class=
10574 "filename">/etc/mk.conf</code> to alter the
10575 behaviour of <span><strong class="command">make
10576 clean-update</strong></span>:</p>
10578 <div class="variablelist">
10580 <dt><span class="term"><code class=
10581 "varname">CLEAR_DIRLIST</code></span></dt>
10584 <p>After <span><strong class="command">make
10585 clean</strong></span>, do not reconstruct the
10586 list of directories to update for this
10587 package. Only use this if
10588 <span><strong class="command">make
10589 update</strong></span> successfully installed
10590 all packages you wanted to update. Normally,
10591 this is done automatically on
10592 <span><strong class="command">make
10593 update</strong></span>, but may have been
10594 suppressed by the <code class=
10595 "varname">NOCLEAN</code> variable (see
10602 <dt><span class="term">info</span></dt>
10605 <p>This target invokes <a href=
10606 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_info+1+NetBSD-current">
10607 <span class="citerefentry"><span class=
10608 "refentrytitle">pkg_info</span>(1)</span></a> for
10609 the current package. You can use this to check
10610 which version of a package is installed.</p>
10613 <dt><span class="term">readme</span></dt>
10616 <p>This target generates a <code xmlns=
10617 "http://www.w3.org/TR/xhtml1/transitional" class=
10618 "filename">README.html</code> file, which can be
10619 viewed using a browser such as <a xmlns=
10620 "http://www.w3.org/TR/xhtml1/transitional" href=
10621 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html"
10622 target="_top"><code xmlns="" class=
10623 "filename">www/mozilla</code></a> or <a xmlns=
10624 "http://www.w3.org/TR/xhtml1/transitional" href=
10625 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/links/README.html"
10626 target="_top"><code xmlns="" class=
10627 "filename">www/links</code></a>. The generated
10628 files contain references to any packages which are
10629 in the <code class="varname">PACKAGES</code>
10630 directory on the local host. The generated files
10631 can be made to refer to URLs based on <code class=
10632 "varname">FTP_PKG_URL_HOST</code> and <code class=
10633 "varname">FTP_PKG_URL_DIR</code>. For example, if I
10634 wanted to generate <code xmlns=
10635 "http://www.w3.org/TR/xhtml1/transitional" class=
10636 "filename">README.html</code> files which pointed
10637 to binary packages on the local machine, in the
10638 directory <code xmlns=
10639 "http://www.w3.org/TR/xhtml1/transitional" class=
10640 "filename">/usr/packages</code>, set <code class=
10641 "varname">FTP_PKG_URL_HOST=file://localhost</code>
10643 "varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
10644 <code class="varname">${PACKAGES}</code> directory
10645 and its subdirectories will be searched for all the
10646 binary packages.</p>
10649 <dt><span class="term">readme-all</span></dt>
10652 <p>Use this target to create a file <code xmlns=
10653 "http://www.w3.org/TR/xhtml1/transitional" class=
10654 "filename">README-all.html</code> which contains a
10655 list of all packages currently available in the
10656 NetBSD Packages Collection, together with the
10657 category they belong to and a short description.
10658 This file is compiled from the <code xmlns=
10659 "http://www.w3.org/TR/xhtml1/transitional" class=
10660 "filename">pkgsrc/*/README.html</code> files, so be
10661 sure to run this <span class=
10662 "emphasis"><em>after</em></span> a
10663 <span><strong class="command">make
10664 readme</strong></span>.</p>
10667 <dt><span class="term">cdrom-readme</span></dt>
10670 <p>This is very much the same as the
10671 “<span class="quote">readme</span>”
10672 target (see above), but is to be used when
10673 generating a pkgsrc tree to be written to a CD-ROM.
10674 This target also produces <code xmlns=
10675 "http://www.w3.org/TR/xhtml1/transitional" class=
10676 "filename">README.html</code> files, and can be
10677 made to refer to URLs based on <code class=
10678 "varname">CDROM_PKG_URL_HOST</code> and
10679 <code class="varname">CDROM_PKG_URL_DIR</code>.</p>
10682 <dt><span class="term">show-distfiles</span></dt>
10685 <p>This target shows which distfiles and patchfiles
10686 are needed to build the package. (<code class=
10687 "varname">DISTFILES</code> and <code class=
10688 "varname">PATCHFILES</code>, but not <code xmlns=
10689 "http://www.w3.org/TR/xhtml1/transitional" class=
10690 "filename">patches/*</code>)</p>
10693 <dt><span class="term">show-downlevel</span></dt>
10696 <p>This target shows nothing if the package is not
10697 installed. If a version of this package is
10698 installed, but is not the version provided in this
10699 version of pkgsrc, then a warning message is
10700 displayed. This target can be used to show which of
10701 your installed packages are downlevel, and so the
10702 old versions can be deleted, and the current ones
10706 <dt><span class="term">show-pkgsrc-dir</span></dt>
10709 <p>This target shows the directory in the pkgsrc
10710 hierarchy from which the package can be built and
10711 installed. This may not be the same directory as
10712 the one from which the package was installed. This
10713 target is intended to be used by people who may
10714 wish to upgrade many packages on a single host, and
10715 can be invoked from the top-level pkgsrc Makefile
10716 by using the “<span class=
10717 "quote">show-host-specific-pkgs</span>”
10722 "term">show-installed-depends</span></dt>
10725 <p>This target shows which installed packages match
10726 the current package's <code class=
10727 "varname">DEPENDS</code>. Useful if out of date
10728 dependencies are causing build problems.</p>
10731 <dt><span class="term">check-shlibs</span></dt>
10734 <p>After a package is installed, check all its
10735 binaries and (on ELF platforms) shared libraries to
10736 see if they find the shared libs they need. Run by
10737 default if <code class=
10738 "varname">PKG_DEVELOPER</code> is set in
10740 "http://www.w3.org/TR/xhtml1/transitional" class=
10741 "filename">/etc/mk.conf</code>.</p>
10744 <dt><span class="term">print-PLIST</span></dt>
10747 <p>After a “<span class="quote">make
10748 install</span>” from a new or upgraded pkg,
10749 this prints out an attempt to generate a new
10751 "http://www.w3.org/TR/xhtml1/transitional" class=
10752 "filename">PLIST</code> from a <span><strong class=
10753 "command">find -newer
10754 work/.extract_done</strong></span>. An attempt is
10755 made to care for shared libs etc., but it is
10756 <span class="emphasis"><em>strongly</em></span>
10757 recommended to review the result before putting it
10759 "http://www.w3.org/TR/xhtml1/transitional" class=
10760 "filename">PLIST</code>. On upgrades, it's useful
10761 to diff the output of this command against an
10762 already existing <code xmlns=
10763 "http://www.w3.org/TR/xhtml1/transitional" class=
10764 "filename">PLIST</code> file.</p>
10766 <p>If the package installs files via <a href=
10767 "http://netbsd.gw.com/cgi-bin/man-cgi?tar+1+NetBSD-current">
10768 <span class="citerefentry"><span class=
10769 "refentrytitle">tar</span>(1)</span></a> or other
10770 methods that don't update file access times, be
10771 sure to add these files manually to your
10773 "http://www.w3.org/TR/xhtml1/transitional" class=
10774 "filename">PLIST</code>, as the “<span class=
10775 "quote">find -newer</span>” command used by
10776 this target won't catch them!</p>
10778 <p>See <a href="#print-PLIST" title=
10779 "10.3. Tweaking output of make print-PLIST">Section 10.3,
10780 “Tweaking output of <span><strong class=
10782 print-PLIST</strong></span>”</a> for more
10783 information on this target.</p>
10786 <dt><span class="term">bulk-package</span></dt>
10789 <p>Used to do bulk builds. If an appropriate binary
10790 package already exists, no action is taken. If not,
10791 this target will compile, install and package it
10792 (and its depends, if <code class=
10793 "varname">PKG_DEPENDS</code> is set properly. See
10794 <a href="#binary.configuration" title=
10795 "6.3.1. Configuration">Section 6.3.1,
10796 “Configuration”</a>). After creating
10797 the binary package, the sources, the just-installed
10798 package and its required packages are removed,
10799 preserving free disk space.</p>
10801 <p><span class="emphasis"><em>Beware that this
10802 target may deinstall all packages installed on a
10803 system!</em></span></p>
10806 <dt><span class="term">bulk-install</span></dt>
10809 <p>Used during bulk-installs to install required
10810 packages. If an up-to-date binary package is
10811 available, it will be installed via <a href=
10812 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current">
10813 <span class="citerefentry"><span class=
10814 "refentrytitle">pkg_add</span>(1)</span></a>. If
10815 not, <span><strong class="command">make
10816 bulk-package</strong></span> will be executed, but
10817 the installed binary won't be removed.</p>
10819 <p>A binary package is considered
10820 “<span class="quote">up-to-date</span>”
10821 to be installed via <a href=
10822 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current">
10823 <span class="citerefentry"><span class=
10824 "refentrytitle">pkg_add</span>(1)</span></a>
10827 <div class="itemizedlist">
10830 <p>None of the package's files (<code xmlns=
10831 "http://www.w3.org/TR/xhtml1/transitional"
10832 class="filename">Makefile</code>, ...) were
10833 modified since it was built.</p>
10837 <p>None of the package's required (binary)
10838 packages were modified since it was
10844 <p><span class="emphasis"><em>Beware that this
10845 target may deinstall all packages installed on a
10846 system!</em></span></p>
10853 <div class="chapter" lang="en" xml:lang="en">
10854 <div class="titlepage">
10857 <h2 class="title"><a name="fixes" id=
10858 "fixes"></a>Chapter 15. Notes on fixes for
10865 <p><b>Table of Contents</b></p>
10868 <dt><span class="sect1"><a href=
10869 "#general-operation">15.1. General
10870 operation</a></span></dt>
10874 <dt><span class="sect2"><a href=
10875 "#pulling-vars-from-etc-mk.conf">15.1.1. How to
10876 pull in variables from /etc/mk.conf</a></span></dt>
10878 <dt><span class="sect2"><a href=
10879 "#where-to-install-documentation">15.1.2. Where to
10880 install documentation</a></span></dt>
10882 <dt><span class="sect2"><a href=
10883 "#restricted-packages">15.1.3. Restricted
10884 packages</a></span></dt>
10886 <dt><span class="sect2"><a href=
10887 "#dependencies">15.1.4. Handling
10888 dependencies</a></span></dt>
10890 <dt><span class="sect2"><a href=
10891 "#conflicts">15.1.5. Handling conflicts with other
10892 packages</a></span></dt>
10894 <dt><span class="sect2"><a href=
10895 "#not-building-packages">15.1.6. Packages that
10896 cannot or should not be built</a></span></dt>
10898 <dt><span class="sect2"><a href=
10899 "#undeletable-packages">15.1.7. Packages which
10900 should not be deleted, once
10901 installed</a></span></dt>
10903 <dt><span class="sect2"><a href=
10904 "#security-handling">15.1.8. Handling packages with
10905 security problems</a></span></dt>
10907 <dt><span class="sect2"><a href=
10908 "#compiler-bugs">15.1.9. How to handle compiler
10909 bugs</a></span></dt>
10911 <dt><span class="sect2"><a href=
10912 "#bumping-pkgrevision">15.1.10. How to handle
10913 incrementing versions when fixing an existing
10914 package</a></span></dt>
10916 <dt><span class="sect2"><a href=
10917 "#portability-of-packages">15.1.11. Portability of
10918 packages</a></span></dt>
10922 <dt><span class="sect1"><a href=
10923 "#downloading-issues">15.2. Possible downloading
10924 issues</a></span></dt>
10928 <dt><span class="sect2"><a href=
10929 "#no-plain-download">15.2.1. Packages whose
10930 distfiles aren't available for plain
10931 downloading</a></span></dt>
10933 <dt><span class="sect2"><a href=
10934 "#modified-distfiles-same-name">15.2.2. How to
10935 handle modified distfiles with the 'old'
10936 name</a></span></dt>
10940 <dt><span class="sect1"><a href=
10941 "#configuration-gotchas">15.3. Configuration
10942 gotchas</a></span></dt>
10946 <dt><span class="sect2"><a href=
10947 "#fixes.libtool">15.3.1. Shared libraries -
10948 libtool</a></span></dt>
10950 <dt><span class="sect2"><a href=
10951 "#using-libtool">15.3.2. Using libtool on GNU
10952 packages that already support
10953 libtool</a></span></dt>
10955 <dt><span class="sect2"><a href=
10956 "#autoconf-automake">15.3.3. GNU
10957 Autoconf/Automake</a></span></dt>
10961 <dt><span class="sect1"><a href=
10962 "#building-considerations">15.4. Building
10963 considerations</a></span></dt>
10967 <dt><span class="sect2"><a href=
10968 "#cpp-defines">15.4.1. CPP defines</a></span></dt>
10970 <dt><span class="sect2"><a href="#cpp-list">15.4.2.
10971 Getting a list of CPP defines</a></span></dt>
10975 <dt><span class="sect1"><a href=
10976 "#package-specific-actions">15.5. Package specific
10977 actions</a></span></dt>
10981 <dt><span class="sect2"><a href=
10982 "#user-interaction">15.5.1. User
10983 interaction</a></span></dt>
10985 <dt><span class="sect2"><a href=
10986 "#handling-licenses">15.5.2. Handling
10987 licenses</a></span></dt>
10989 <dt><span class="sect2"><a href=
10990 "#installing-score-files">15.5.3. Installing score
10991 files</a></span></dt>
10993 <dt><span class="sect2"><a href=
10994 "#perl-scripts">15.5.4. Packages containing perl
10995 scripts</a></span></dt>
10997 <dt><span class="sect2"><a href=
10998 "#hardcoded-paths">15.5.5. Packages with hardcoded
10999 paths to other interpreters</a></span></dt>
11001 <dt><span class="sect2"><a href=
11002 "#perl-modules">15.5.6. Packages installing perl
11003 modules</a></span></dt>
11005 <dt><span class="sect2"><a href=
11006 "#faq.info-files">15.5.7. Packages installing info
11007 files</a></span></dt>
11009 <dt><span class="sect2"><a href=
11010 "#gconf2-data-files">15.5.8. Packages installing
11011 GConf2 data files</a></span></dt>
11013 <dt><span class="sect2"><a href=
11014 "#scrollkeeper-data-files">15.5.9. Packages
11015 installing scrollkeeper data files</a></span></dt>
11017 <dt><span class="sect2"><a href=
11018 "#x11-fonts">15.5.10. Packages installing X11
11019 fonts</a></span></dt>
11021 <dt><span class="sect2"><a href=
11022 "#gtk2-modules">15.5.11. Packages installing GTK2
11023 modules</a></span></dt>
11025 <dt><span class="sect2"><a href=
11026 "#sgml-xml-data">15.5.12. Packages installing SGML
11027 or XML data</a></span></dt>
11029 <dt><span class="sect2"><a href=
11030 "#mime-database">15.5.13. Packages installing
11031 extensions to the MIME database</a></span></dt>
11033 <dt><span class="sect2"><a href=
11034 "#intltool">15.5.14. Packages using
11035 intltool</a></span></dt>
11037 <dt><span class="sect2"><a href=
11038 "#startup-scripts">15.5.15. Packages installing
11039 startup scripts</a></span></dt>
11043 <dt><span class="sect1"><a href=
11044 "#feedback-to-author">15.6. Feedback to the
11045 author</a></span></dt>
11049 <div class="sect1" lang="en" xml:lang="en">
11050 <div class="titlepage">
11053 <h2 class="title" style="clear: both"><a name=
11054 "general-operation" id=
11055 "general-operation"></a>15.1. General
11061 <div class="sect2" lang="en" xml:lang="en">
11062 <div class="titlepage">
11065 <h3 class="title"><a name=
11066 "pulling-vars-from-etc-mk.conf" id=
11067 "pulling-vars-from-etc-mk.conf"></a>15.1.1. How
11068 to pull in variables from /etc/mk.conf</h3>
11073 <p>The problem with package-defined variables that can
11074 be overridden via <code class="varname">MAKECONF</code>
11076 "http://www.w3.org/TR/xhtml1/transitional" class=
11077 "filename">/etc/mk.conf</code> is that <a href=
11078 "http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current">
11079 <span class="citerefentry"><span class=
11080 "refentrytitle">make</span>(1)</span></a> expands a
11081 variable as it is used, but evaluates preprocessor-like
11082 statements (.if, .ifdef and .ifndef) as they are read.
11083 So, to use any variable (which may be set in
11084 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
11085 class="filename">/etc/mk.conf</code>) in one of the
11086 .if* statements, the file <code xmlns=
11087 "http://www.w3.org/TR/xhtml1/transitional" class=
11088 "filename">/etc/mk.conf</code> must be included before
11089 that .if* statement.</p>
11091 <p>Rather than having a number of ad-hoc ways of
11092 including <code xmlns=
11093 "http://www.w3.org/TR/xhtml1/transitional" class=
11094 "filename">/etc/mk.conf</code>, should it exist, or
11095 <code class="varname">MAKECONF</code>, should it exist,
11096 include the <code xmlns=
11097 "http://www.w3.org/TR/xhtml1/transitional" class=
11098 "filename">pkgsrc/mk/bsd.prefs.mk</code> file in the
11099 package Makefile before any preprocessor-like .if,
11100 .ifdef, or .ifndef statements:</p>
11101 <pre class="programlisting">
11102 .include "../../mk/bsd.prefs.mk"
11104 .if defined(USE_MENUS)
11109 <p>If you wish to set the <code class=
11110 "varname">CFLAGS</code> variable in <code xmlns=
11111 "http://www.w3.org/TR/xhtml1/transitional" class=
11112 "filename">/etc/mk.conf</code>, please make sure to
11114 <pre class="programlisting">
11115 CFLAGS+= -your -flags
11118 <p>Using <code class="varname">CFLAGS=</code> (i.e.
11119 without the “<span class="quote">+</span>”)
11120 may lead to problems with packages that need to add
11121 their own flags. Also, you may want to take a look at
11122 the <a xmlns="http://www.w3.org/TR/xhtml1/transitional"
11124 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/cpuflags/README.html"
11125 target="_top"><code xmlns="" class=
11126 "filename">devel/cpuflags</code></a> package if you're
11127 interested in optimization for the current CPU.</p>
11130 <div class="sect2" lang="en" xml:lang="en">
11131 <div class="titlepage">
11134 <h3 class="title"><a name=
11135 "where-to-install-documentation" id=
11136 "where-to-install-documentation"></a>15.1.2. Where
11137 to install documentation</h3>
11142 <p>Documentation should be installed into <code xmlns=
11143 "http://www.w3.org/TR/xhtml1/transitional" class=
11144 "filename">${PREFIX}/share/doc/${PKGBASE}</code> or
11145 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
11146 class="filename">${PREFIX}/share/doc/${PKGNAME}</code>
11147 (the latter includes the version number of the
11151 <div class="sect2" lang="en" xml:lang="en">
11152 <div class="titlepage">
11155 <h3 class="title"><a name="restricted-packages"
11157 "restricted-packages"></a>15.1.3. Restricted
11163 <p>Some licenses restrict how software may be
11164 re-distributed. In order to satisfy these restrictions,
11165 the package system defines five make variables that can
11166 be set to note these restrictions:</p>
11168 <div class="itemizedlist">
11171 <p><code class="varname">RESTRICTED</code></p>
11173 <p>This variable should be set whenever a
11174 restriction exists (regardless of its kind). Set
11175 this variable to a string containing the reason
11176 for the restriction.</p>
11181 "varname">NO_BIN_ON_CDROM</code></p>
11183 <p>Binaries may not be placed on CD-ROM. Set this
11184 variable to <code class=
11185 "varname">${RESTRICTED}</code> whenever a binary
11186 package may not be included on a CD-ROM.</p>
11190 <p><code class="varname">NO_BIN_ON_FTP</code></p>
11192 <p>Binaries may not be placed on an FTP server.
11193 Set this variable to <code class=
11194 "varname">${RESTRICTED}</code> whenever a binary
11195 package may not not be made available on the
11201 "varname">NO_SRC_ON_CDROM</code></p>
11203 <p>Distfiles may not be placed on CD-ROM. Set
11204 this variable to <code class=
11205 "varname">${RESTRICTED}</code> if re-distribution
11206 of the source code or other distfile(s) is not
11207 allowed on CD-ROMs.</p>
11211 <p><code class="varname">NO_SRC_ON_FTP</code></p>
11213 <p>Distfiles may not be placed on FTP. Set this
11214 variable to <code class=
11215 "varname">${RESTRICTED}</code> if re-distribution
11216 of the source code or other distfile(s) via the
11217 Internet is not allowed.</p>
11222 <p>Please note that the use of <code class=
11223 "varname">NO_PACKAGE</code>, <code class=
11224 "varname">IGNORE</code>, <code class=
11225 "varname">NO_CDROM</code>, or other generic make
11226 variables to denote restrictions is deprecated, because
11227 they unconditionally prevent users from generating
11228 binary packages!</p>
11231 <div class="sect2" lang="en" xml:lang="en">
11232 <div class="titlepage">
11235 <h3 class="title"><a name="dependencies" id=
11236 "dependencies"></a>15.1.4. Handling
11242 <p>Your package may depend on some other package being
11243 present - and there are various ways of expressing this
11244 dependency. pkgsrc supports the <code class=
11245 "varname">BUILD_DEPENDS</code> and <code class=
11246 "varname">DEPENDS</code> definitions, the <code class=
11247 "varname">USE_TOOLS</code> definition, as well as
11248 dependencies via <code xmlns=
11249 "http://www.w3.org/TR/xhtml1/transitional" class=
11250 "filename">buildlink3.mk</code>, which is the preferred
11251 way to handle dependencies, and which uses the
11252 variables named above. See <a href="#buildlink" title=
11253 "Chapter 11. Buildlink methodology">Chapter 11,
11254 <i>Buildlink methodology</i></a> for more
11257 <p>The basic difference between the two variables is as
11258 follows: The <code class="varname">DEPENDS</code>
11259 definition registers that pre-requisite in the binary
11260 package so it will be pulled in when the binary package
11261 is later installed, whilst the <code class=
11262 "varname">BUILD_DEPENDS</code> definition does not,
11263 marking a dependency that is only needed for building
11266 <p>This means that if you only need a package present
11267 whilst you are building, it should be noted as a
11268 <code class="varname">BUILD_DEPENDS</code>.</p>
11270 <p>The format for a <code class=
11271 "varname">BUILD_DEPENDS</code> and a <code class=
11272 "varname">DEPENDS</code> definition is:</p>
11273 <pre class="programlisting">
11274 <pre-req-package-name>:../../<category>/<pre-req-package>
11277 <p>Please note that the “<span class=
11278 "quote">pre-req-package-name</span>” may include
11279 any of the wildcard version numbers recognized by
11281 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_info+1+NetBSD-current">
11282 <span class="citerefentry"><span class=
11283 "refentrytitle">pkg_info</span>(1)</span></a>.</p>
11285 <div class="orderedlist">
11288 <p>If your package needs another package's
11289 binaries or libraries to build or run, and if
11290 that package has a <code xmlns=
11291 "http://www.w3.org/TR/xhtml1/transitional" class=
11292 "filename">buildlink3.mk</code> file available,
11294 <pre class="programlisting">
11295 .include "../../graphics/jpeg/buildlink3.mk"
11300 <p>If your package needs to use another package
11301 to build itself and there is no <code xmlns=
11302 "http://www.w3.org/TR/xhtml1/transitional" class=
11303 "filename">buildlink3.mk</code> file available,
11304 use the <code class=
11305 "varname">BUILD_DEPENDS</code> definition:</p>
11306 <pre class="programlisting">
11307 BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
11312 <p>If your package needs a library with which to
11313 link and again there is no <code xmlns=
11314 "http://www.w3.org/TR/xhtml1/transitional" class=
11315 "filename">buildlink3.mk</code> file available,
11316 this is specified using the <code class=
11317 "varname">DEPENDS</code> definition. An example
11318 of this is the <a xmlns=
11319 "http://www.w3.org/TR/xhtml1/transitional" href=
11320 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/lyx/README.html"
11321 target="_top"><code xmlns="" class=
11322 "filename">print/lyx</code></a> package, which
11323 uses the xpm library, version 3.4j to build:</p>
11324 <pre class="programlisting">
11325 DEPENDS+= xpm-3.4j:../../graphics/xpm
11328 <p>You can also use wildcards in package
11330 <pre class="programlisting">
11331 DEPENDS+= xpm-[0-9]*:../../graphics/xpm
11334 <p>Note that such wildcard dependencies are
11335 retained when creating binary packages. The
11336 dependency is checked when installing the binary
11337 package and any package which matches the pattern
11338 will be used. Wildcard dependencies should be
11339 used with care.</p>
11341 <p>The “<span class=
11342 "quote">-[0-9]*</span>” should be used
11343 instead of “<span class=
11344 "quote">-*</span>” to avoid potentially
11345 ambiguous matches such as “<span class=
11346 "quote">tk-postgresql</span>” matching a
11347 “<span class="quote">tk-*</span>”
11348 <code class="varname">DEPENDS</code>.</p>
11350 <p>Wildcards can also be used to specify that a
11351 package will only build against a certain minimum
11352 version of a pre-requisite:</p>
11353 <pre class="programlisting">
11354 DEPENDS+= tiff>=3.5.4:../../graphics/tiff
11357 <p>This means that the package will build against
11358 version 3.5.4 of the tiff library or newer. Such
11359 a dependency may be warranted if, for example,
11360 the API of the library has changed with version
11361 3.5.4 and a package would not compile against an
11362 earlier version of tiff.</p>
11364 <p>Please note that such dependencies should only
11365 be updated if a package requires a newer
11366 pre-requisite, but not to denote recommendations
11367 such as security updates or ABI changes that do
11368 not prevent a package from building correctly.
11369 Such recommendations can be expressed using
11370 <code class="varname">RECOMMENDED</code>:</p>
11371 <pre class="programlisting">
11372 RECOMMENDED+= tiff>=3.6.1:../../graphics/tiff
11375 <p>In addition to the above <code class=
11376 "varname">DEPENDS</code> line, this denotes that
11377 while a package will build against
11378 tiff>=3.5.4, at least version 3.6.1 is
11379 recommended. <code class=
11380 "varname">RECOMMENDED</code> entries will be
11381 turned into dependencies unless explicitly
11382 ignored (in which case a warning will be
11385 <p>To ignore these dependency recommendations and
11386 just use the required <code class=
11387 "varname">DEPENDS</code>, set <code class=
11388 "varname">IGNORE_RECOMMENDED=YES</code>. This may
11389 make it easier and faster to update packages
11390 built using pkgsrc, since older compatible
11391 dependencies can continue to be used. This is
11392 useful for people who watch their rebuilds very
11393 carefully; it is not very good as a
11394 general-purpose hammer. If you use it, you need
11395 to be mindful of possible ABI changes, including
11396 those from the underlying OS.</p>
11398 <p>Packages that are built with recommendations
11399 ignored may not be uploaded to ftp.NetBSD.org by
11400 developers and should not be used across
11401 different systems that may have different
11402 versions of binary packages installed.</p>
11404 <p>For security fixes, please update the package
11405 vulnerabilities file as well as setting
11406 <code class="varname">RECOMMENDED</code>, see
11407 <a href="#security-handling" title=
11408 "15.1.8. Handling packages with security problems">
11409 Section 15.1.8, “Handling packages with
11410 security problems”</a> for more
11415 <p>If your package needs some executable to be
11416 able to run correctly and if there's no
11418 "http://www.w3.org/TR/xhtml1/transitional" class=
11419 "filename">buildlink3.mk</code> file, this is
11420 specified using the <code class=
11421 "varname">DEPENDS</code> variable. The <a xmlns=
11422 "http://www.w3.org/TR/xhtml1/transitional" href=
11423 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/lyx/README.html"
11424 target="_top"><code xmlns="" class=
11425 "filename">print/lyx</code></a> package needs to
11426 be able to execute the latex binary from the
11427 teTeX package when it runs, and that is
11429 <pre class="programlisting">
11430 DEPENDS+= teTeX-[0-9]*:../../print/teTeX
11433 <p>The comment about wildcard dependencies from
11434 previous paragraph applies here, too.</p>
11439 <p>If your package needs files from another package to
11440 build, see the first part of the “<span class=
11441 "quote">do-configure</span>” target <a xmlns=
11442 "http://www.w3.org/TR/xhtml1/transitional" href=
11443 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/ghostscript5/README.html"
11444 target="_top"><code xmlns="" class=
11445 "filename">print/ghostscript5</code></a> package (it
11446 relies on the jpeg sources being present in source form
11447 during the build):</p>
11448 <pre class="programlisting">
11449 if [ ! -e ${_PKGSRCDIR}/graphics/jpeg/${WRKDIR:T}/jpeg-6b ]; then \
11450 cd ${_PKGSRCDIR}/../../graphics/jpeg && ${MAKE} extract; \
11454 <p>If you build any other packages that way, please
11455 make sure the working files are deleted too when this
11456 package's working files are cleaned up. The easiest way
11457 to do so is by adding a pre-clean target:</p>
11458 <pre class="programlisting">
11460 cd ${_PKGSRCDIR}/../../graphics/jpeg && ${MAKE} clean
11463 <p>Please also note the <code class=
11464 "varname">BUILD_USES_MSGFMT</code> and <code class=
11465 "varname">BUILD_USES_GETTEXT_M4</code> definitions,
11466 which are provided as convenience definitions. The
11467 former works out whether <a href=
11468 "http://netbsd.gw.com/cgi-bin/man-cgi?msgfmt+1+NetBSD-current">
11469 <span class="citerefentry"><span class=
11470 "refentrytitle">msgfmt</span>(1)</span></a> is part of
11471 the base system, and, if it isn't, installs the
11472 <a xmlns="http://www.w3.org/TR/xhtml1/transitional"
11474 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/gettext/README.html"
11475 target="_top"><code xmlns="" class=
11476 "filename">devel/gettext</code></a> package. The latter
11477 adds a build dependency on either an installed version
11478 of an older gettext package, or if it isn't, installs
11479 the <a xmlns="http://www.w3.org/TR/xhtml1/transitional"
11481 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/gettext-m4/README.html"
11482 target="_top"><code xmlns="" class=
11483 "filename">devel/gettext-m4</code></a> package.</p>
11486 <div class="sect2" lang="en" xml:lang="en">
11487 <div class="titlepage">
11490 <h3 class="title"><a name="conflicts" id=
11491 "conflicts"></a>15.1.5. Handling conflicts
11492 with other packages</h3>
11497 <p>Your package may conflict with other packages a user
11498 might already have installed on his system, e.g. if
11499 your package installs the same set of files like
11500 another package in our pkgsrc tree.</p>
11502 <p>In this case you can set <code class=
11503 "varname">CONFLICTS</code> to a space-separated list of
11504 packages (including version string) your package
11505 conflicts with.</p>
11507 <p>For example, <a xmlns=
11508 "http://www.w3.org/TR/xhtml1/transitional" href=
11509 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/Xaw3d/README.html"
11510 target="_top"><code xmlns="" class=
11511 "filename">x11/Xaw3d</code></a> and <a xmlns=
11512 "http://www.w3.org/TR/xhtml1/transitional" href=
11513 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/Xaw-Xpm/README.html"
11514 target="_top"><code xmlns="" class=
11515 "filename">x11/Xaw-Xpm</code></a> install the same
11516 shared library, thus you set in <code xmlns=
11517 "http://www.w3.org/TR/xhtml1/transitional" class=
11518 "filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
11519 <pre class="programlisting">
11520 CONFLICTS= Xaw-Xpm-[0-9]*
11523 <p>and in <code xmlns=
11524 "http://www.w3.org/TR/xhtml1/transitional" class=
11525 "filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:</p>
11526 <pre class="programlisting">
11527 CONFLICTS= Xaw3d-[0-9]*
11530 <p>Packages will automatically conflict with other
11531 packages with the name prefix and a different version
11532 string. “<span class=
11533 "quote">Xaw3d-1.5</span>” e.g. will automatically
11534 conflict with the older version “<span class=
11535 "quote">Xaw3d-1.3</span>”.</p>
11538 <div class="sect2" lang="en" xml:lang="en">
11539 <div class="titlepage">
11542 <h3 class="title"><a name="not-building-packages"
11544 "not-building-packages"></a>15.1.6. Packages
11545 that cannot or should not be built</h3>
11550 <p>There are several reasons why a package might be
11551 instructed to not build under certain circumstances. If
11552 the package builds and runs on most platforms, the
11553 exceptions should be noted with <code class=
11554 "varname">NOT_FOR_PLATFORM</code>. If the package
11555 builds and runs on a small handful of platforms, set
11556 <code class="varname">ONLY_FOR_PLATFORM</code> instead.
11557 Both <code class="varname">ONLY_FOR_PLATFORM</code> and
11558 <code class="varname">NOT_FOR_PLATFORM</code> are OS
11559 triples (OS-version-platform) that can use glob-style
11562 <p>If the package should be skipped (for example,
11563 because it provides functionality already provided by
11564 the system), set <code class=
11565 "varname">PKG_SKIP_REASON</code> to a descriptive
11566 message. If the package should fail because some
11567 preconditions are not met, set <code class=
11568 "varname">PKG_FAIL_REASON</code> to a descriptive
11572 <div class="sect2" lang="en" xml:lang="en">
11573 <div class="titlepage">
11576 <h3 class="title"><a name="undeletable-packages"
11578 "undeletable-packages"></a>15.1.7. Packages
11579 which should not be deleted, once installed</h3>
11584 <p>To ensure that a package may not be deleted, once it
11585 has been installed, the <code class=
11586 "varname">PKG_PRESERVE</code> definition should be set
11587 in the package Makefile. This will be carried into any
11588 binary package that is made from this pkgsrc entry. A
11589 “<span class="quote">preserved</span>”
11590 package will not be deleted using <a href=
11591 "http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current">
11592 <span class="citerefentry"><span class=
11593 "refentrytitle">pkg_delete</span>(1)</span></a> unless
11594 the “<span class="quote">-f</span>” option
11598 <div class="sect2" lang="en" xml:lang="en">
11599 <div class="titlepage">
11602 <h3 class="title"><a name="security-handling" id=
11603 "security-handling"></a>15.1.8. Handling
11604 packages with security problems</h3>
11609 <p>When a vulnerability is found, this should be noted
11611 "http://www.w3.org/TR/xhtml1/transitional" class=
11612 "filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
11613 and after committing that file, use
11614 <span><strong class="command">make
11615 upload</strong></span> in the same directory to update
11616 the file on ftp.NetBSD.org.</p>
11618 <p>After fixing the vulnerability by a patch, its
11619 <code class="varname">PKGREVISION</code> should be
11620 increased (this is of course not necessary if the
11621 problem is fixed by using a newer release of the
11622 software). In addition, if a <code xmlns=
11623 "http://www.w3.org/TR/xhtml1/transitional" class=
11624 "filename">buildlink3.mk</code> file exists for an
11625 affected package, a corresponding <code class=
11626 "varname">BUILDLINK_RECOMMENDED.<em class=
11627 "replaceable"><code>pkg</code></em></code> entry should
11628 be added or updated in it.</p>
11630 <p>Also, if the fix should be applied to the stable
11631 pkgsrc branch, be sure to submit a pullup request!</p>
11633 <p>Binary packages already on ftp.NetBSD.org will be
11634 handled semi-automatically by a weekly cron job.</p>
11637 <div class="sect2" lang="en" xml:lang="en">
11638 <div class="titlepage">
11641 <h3 class="title"><a name="compiler-bugs" id=
11642 "compiler-bugs"></a>15.1.9. How to handle
11648 <p>Some source files trigger bugs in the compiler,
11649 based on combinations of compiler version and
11650 architecture and almost always relation to optimisation
11651 being enabled. Common symptoms are gcc internal errors
11652 or never finishing compiling a file.</p>
11654 <p>Typically, a workaround involves testing the
11655 <code class="varname">MACHINE_ARCH</code> and compiler
11656 version, disabling optimisation for that
11657 file/<code class="varname">MACHINE_ARCH</code>/compiler
11658 combination, and documenting it in <code xmlns=
11659 "http://www.w3.org/TR/xhtml1/transitional" class=
11660 "filename">pkgsrc/doc/HACKS</code>. See that file for a
11661 number of examples!</p>
11664 <div class="sect2" lang="en" xml:lang="en">
11665 <div class="titlepage">
11668 <h3 class="title"><a name="bumping-pkgrevision"
11669 id="bumping-pkgrevision"></a>15.1.10. How to
11670 handle incrementing versions when fixing an
11671 existing package</h3>
11676 <p>When making fixes to an existing package it can be
11677 useful to change the version number in <code class=
11678 "varname">PKGNAME</code>. To avoid conflicting with
11679 future versions by the original author, a
11680 “<span class="quote">nb1</span>”,
11681 “<span class="quote">nb2</span>”, ...
11682 suffix can be used on package versions by setting
11683 <code class="varname">PKGREVISION=1</code> (2, ...).
11684 The “<span class="quote">nb</span>” is
11685 treated like a “<span class=
11686 "quote">.</span>” by the pkg tools. e.g.</p>
11687 <pre class="programlisting">
11688 DISTNAME= foo-17.42
11692 <p>will result in a <code class=
11693 "varname">PKGNAME</code> of “<span class=
11694 "quote">foo-17.42nb9</span>”.</p>
11696 <p>When a new release of the package is released, the
11697 <code class="varname">PKGREVISION</code> should be
11698 removed, e.g. on a new minor release of the above
11699 package, things should be like:</p>
11700 <pre class="programlisting">
11701 DISTNAME= foo-17.43
11705 <div class="sect2" lang="en" xml:lang="en">
11706 <div class="titlepage">
11709 <h3 class="title"><a name=
11710 "portability-of-packages" id=
11711 "portability-of-packages"></a>15.1.11. Portability
11717 <p>One appealing feature of pkgsrc is that it runs on
11718 many different platforms. As a result, it is important
11719 to ensure, where possible, that packages in pkgsrc are
11720 portable. There are some particular details you should
11721 pay attention to while working on pkgsrc.</p>
11723 <div class="sect3" lang="en" xml:lang="en">
11724 <div class="titlepage">
11727 <h4 class="title"><a name="install-scripts" id=
11728 "install-scripts"></a>15.1.11.1. ${INSTALL},
11729 ${INSTALL_DATA_DIR}, ...</h4>
11734 <p>The BSD-compatible <span><strong class=
11735 "command">install</strong></span> supplied with some
11736 operating systems will not perform more than one
11737 operation at a time. As such, you should call
11738 “<span class="quote">${INSTALL}</span>”,
11739 etc. like this:</p>
11740 <pre class="programlisting">
11741 ${INSTALL_DATA_DIR} ${PREFIX}/dir1
11742 ${INSTALL_DATA_DIR} ${PREFIX}/dir2
11748 <div class="sect1" lang="en" xml:lang="en">
11749 <div class="titlepage">
11752 <h2 class="title" style="clear: both"><a name=
11753 "downloading-issues" id=
11754 "downloading-issues"></a>15.2. Possible
11755 downloading issues</h2>
11760 <div class="sect2" lang="en" xml:lang="en">
11761 <div class="titlepage">
11764 <h3 class="title"><a name="no-plain-download" id=
11765 "no-plain-download"></a>15.2.1. Packages
11766 whose distfiles aren't available for plain
11772 <p>If you need to download from a dynamic URL you can
11773 set <code class="varname">DYNAMIC_MASTER_SITES</code>
11774 and a <span><strong class="command">make
11775 fetch</strong></span> will call <code xmlns=
11776 "http://www.w3.org/TR/xhtml1/transitional" class=
11777 "filename">files/getsite.sh</code> with the name of
11778 each file to download as an argument, expecting it to
11779 output the URL of the directory from which to download
11780 it. <a xmlns="http://www.w3.org/TR/xhtml1/transitional"
11782 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/ns-cult3d/README.html"
11783 target="_top"><code xmlns="" class=
11784 "filename">graphics/ns-cult3d</code></a> is an example
11787 <p>If the download can't be automated, because the user
11788 must submit personal information to apply for a
11789 password, or must pay for the source, or whatever, you
11790 can set <code class="varname">_FETCH_MESSAGE</code> to
11791 a macro which displays a message explaining the
11792 situation. <code class="varname">_FETCH_MESSAGE</code>
11793 must be executable shell commands, not just a message.
11794 (Generally, it executes <code class=
11795 "varname">${ECHO}</code>). As of this writing, the
11796 following packages use this: <a xmlns=
11797 "http://www.w3.org/TR/xhtml1/transitional" href=
11798 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/cad/simian/README.html"
11799 target="_top"><code xmlns="" class=
11800 "filename">cad/simian</code></a>, <a xmlns=
11801 "http://www.w3.org/TR/xhtml1/transitional" href=
11802 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/ipv6socket/README.html"
11803 target="_top"><code xmlns="" class=
11804 "filename">devel/ipv6socket</code></a>, <a xmlns=
11805 "http://www.w3.org/TR/xhtml1/transitional" href=
11806 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/emulators/vmware-module/README.html"
11807 target="_top"><code xmlns="" class=
11808 "filename">emulators/vmware-module</code></a>,
11809 <a xmlns="http://www.w3.org/TR/xhtml1/transitional"
11811 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/fonts/acroread-jpnfont/README.html"
11812 target="_top"><code xmlns="" class=
11813 "filename">fonts/acroread-jpnfont</code></a>, <a xmlns=
11814 "http://www.w3.org/TR/xhtml1/transitional" href=
11815 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/multimedia/realplayer/README.html"
11816 target="_top"><code xmlns="" class=
11817 "filename">multimedia/realplayer</code></a>, <a xmlns=
11818 "http://www.w3.org/TR/xhtml1/transitional" href=
11819 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/sysutils/storage-manager/README.html"
11820 target="_top"><code xmlns="" class=
11821 "filename">sysutils/storage-manager</code></a>,
11822 <a xmlns="http://www.w3.org/TR/xhtml1/transitional"
11824 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/ap-aolserver/README.html"
11825 target="_top"><code xmlns="" class=
11826 "filename">www/ap-aolserver</code></a>, <a xmlns=
11827 "http://www.w3.org/TR/xhtml1/transitional" href=
11828 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/openacs/README.html"
11829 target="_top"><code xmlns="" class=
11830 "filename">www/openacs</code></a>. Try to be consistent
11834 <div class="sect2" lang="en" xml:lang="en">
11835 <div class="titlepage">
11838 <h3 class="title"><a name=
11839 "modified-distfiles-same-name" id=
11840 "modified-distfiles-same-name"></a>15.2.2. How
11841 to handle modified distfiles with the 'old'
11847 <p>Sometimes authors of a software package make some
11848 modifications after the software was released, and they
11849 put up a new distfile without changing the package's
11850 version number. If a package is already in pkgsrc at
11851 that time, the checksum will no longer match. The
11852 contents of the new distfile should be compared against
11853 the old one before changing anything, to make sure the
11854 distfile was really updated on purpose, and that no
11855 trojan horse or so crept in. Then, the correct way to
11856 work around this is to set <code class=
11857 "varname">DIST_SUBDIR</code> to a unique directory
11858 name, usually based on <code class=
11859 "varname">PKGNAME_NOREV</code>. In case this happens
11860 more often, <code class="varname">PKGNAME</code> can be
11861 used (thus including the <code xmlns=
11862 "http://www.w3.org/TR/xhtml1/transitional" class=
11863 "filename">nbX</code> suffix) or a date stamp can be
11864 appended, like <code class=
11865 "varname">${PKGNAME_NOREV}-YYYYMMDD</code>. Do not
11866 forget regenerating the <code xmlns=
11867 "http://www.w3.org/TR/xhtml1/transitional" class=
11868 "filename">distinfo</code> file after that, since it
11869 contains the <code class="varname">DIST_SUBDIR</code>
11870 path in the filenames. Furthermore, a mail to the
11871 package's authors seems appropriate telling them that
11872 changing distfiles after releases without changing the
11873 file names is not good practice.</p>
11877 <div class="sect1" lang="en" xml:lang="en">
11878 <div class="titlepage">
11881 <h2 class="title" style="clear: both"><a name=
11882 "configuration-gotchas" id=
11883 "configuration-gotchas"></a>15.3. Configuration
11889 <div class="sect2" lang="en" xml:lang="en">
11890 <div class="titlepage">
11893 <h3 class="title"><a name="fixes.libtool" id=
11894 "fixes.libtool"></a>15.3.1. Shared libraries
11900 <p>pkgsrc supports many different machines, with
11901 different object formats like a.out and ELF, and
11902 varying abilities to do shared library and dynamic
11903 loading at all. To accompany this, varying commands and
11904 options have to be passed to the compiler, linker, etc.
11905 to get the Right Thing, which can be pretty annoying
11906 especially if you don't have all the machines at your
11907 hand to test things. The <a xmlns=
11908 "http://www.w3.org/TR/xhtml1/transitional" href=
11909 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/libtool/README.html"
11910 target="_top"><code xmlns="" class=
11911 "filename">devel/libtool</code></a> pkg can help here,
11912 as it just “<span class=
11913 "quote">knows</span>” how to build both static
11914 and dynamic libraries from a set of source files, thus
11915 being platform-independent.</p>
11917 <p>Here's how to use libtool in a pkg in seven simple
11920 <div class="orderedlist">
11923 <p>Add <code class=
11924 "varname">USE_LIBTOOL=yes</code> to the package
11929 <p>For library objects, use “<span class=
11930 "quote">${LIBTOOL} --mode=compile
11931 ${CC}</span>” in place of
11932 “<span class="quote">${CC}</span>”.
11933 You could even add it to the definition of
11934 <code class="varname">CC</code>, if only
11935 libraries are being built in a given Makefile.
11936 This one command will build both PIC and non-PIC
11937 library objects, so you need not have separate
11938 shared and non-shared library rules.</p>
11942 <p>For the linking of the library, remove any
11943 “<span class="quote">ar</span>”,
11944 “<span class="quote">ranlib</span>”,
11945 and “<span class="quote">ld
11946 -Bshareable</span>” commands, and instead
11948 <pre class="programlisting">
11949 ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
11950 -rpath ${PREFIX}/lib -version-info major:minor
11953 <p>Note that the library is changed to have a
11955 "http://www.w3.org/TR/xhtml1/transitional" class=
11956 "filename">.la</code> extension, and the objects
11957 are changed to have a <code xmlns=
11958 "http://www.w3.org/TR/xhtml1/transitional" class=
11959 "filename">.lo</code> extension. Change
11960 <code class="varname">OBJS</code> as necessary.
11961 This automatically creates all of the
11962 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
11963 class="filename">.a</code>, <code xmlns=
11964 "http://www.w3.org/TR/xhtml1/transitional" class=
11965 "filename">.so.major.minor</code>, and ELF
11966 symlinks (if necessary) in the build directory.
11967 Be sure to include “<span class=
11968 "quote">-version-info</span>”, especially
11969 when major and minor are zero, as libtool will
11970 otherwise strip off the shared library
11973 <p>From the libtool manual:</p>
11974 <pre class="programlisting">
11975 So, libtool library versions are described by three integers:
11978 The most recent interface number that this library implements.
11981 The implementation number of the CURRENT interface.
11984 The difference between the newest and oldest interfaces that
11985 this library implements. In other words, the library implements
11986 all the interface numbers in the range from number `CURRENT -
11989 If two libraries have identical CURRENT and AGE numbers, then the
11990 dynamic linker chooses the library with the greater REVISION number.
11993 <p>The “<span class=
11994 "quote">-release</span>” option will
11995 produce different results for a.out and ELF
11996 (excluding symlinks) in only one case. An ELF
11997 library of the form “<span class=
11998 "quote">libfoo-release.so.<span class=
11999 "emphasis"><em>x</em></span>.<span class=
12000 "emphasis"><em>y</em></span></span>” will
12001 have a symlink of “<span class=
12002 "quote">libfoo.so.<span class=
12003 "emphasis"><em>x</em></span>.<span class=
12004 "emphasis"><em>y</em></span></span>” on an
12005 a.out platform. This is handled
12008 <p>The “<span class="quote">-rpath
12009 argument</span>” is the install directory
12010 of the library being built.</p>
12012 <p>In the <code xmlns=
12013 "http://www.w3.org/TR/xhtml1/transitional" class=
12014 "filename">PLIST</code>, include only the
12016 "http://www.w3.org/TR/xhtml1/transitional" class=
12017 "filename">.la</code> file, the other files will
12018 be added automatically.</p>
12022 <p>When linking shared object (<code xmlns=
12023 "http://www.w3.org/TR/xhtml1/transitional" class=
12024 "filename">.so</code>) files, i.e. files that are
12025 loaded via <a href=
12026 "http://netbsd.gw.com/cgi-bin/man-cgi?dlopen+3+NetBSD-current">
12027 <span class="citerefentry"><span class=
12028 "refentrytitle">dlopen</span>(3)</span></a>, NOT
12029 shared libraries, use “<span class=
12030 "quote">-module -avoid-version</span>” to
12031 prevent them getting version tacked on.</p>
12033 <p>The <code xmlns=
12034 "http://www.w3.org/TR/xhtml1/transitional" class=
12035 "filename">PLIST</code> file gets the
12036 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
12037 class="filename">foo.so</code> entry.</p>
12041 <p>When linking programs that depend on these
12042 libraries <span class=
12043 "emphasis"><em>before</em></span> they are
12044 installed, preface the <a href=
12045 "http://netbsd.gw.com/cgi-bin/man-cgi?cc+1+NetBSD-current">
12046 <span class="citerefentry"><span class=
12047 "refentrytitle">cc</span>(1)</span></a> or
12049 "http://netbsd.gw.com/cgi-bin/man-cgi?ld+1+NetBSD-current">
12050 <span class="citerefentry"><span class=
12051 "refentrytitle">ld</span>(1)</span></a> line with
12052 “<span class="quote">${LIBTOOL}
12053 --mode=link</span>”, and it will find the
12054 correct libraries (static or shared), but please
12055 be aware that libtool will not allow you to
12056 specify a relative path in -L (such as
12057 “<span class=
12058 "quote">-L../somelib</span>”), because it
12059 expects you to change that argument to be the
12061 "http://www.w3.org/TR/xhtml1/transitional" class=
12062 "filename">.la</code> file. e.g.</p>
12063 <pre class="programlisting">
12064 ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
12067 <p>should be changed to:</p>
12068 <pre class="programlisting">
12069 ${LIBTOOL} --mode=link ${CC} -o <em class=
12070 "replaceable"><code>someprog</code></em> <em class=
12071 "replaceable"><code>../somelib/somelib.la</code></em>
12074 <p>and it will do the right thing with the
12079 <p>When installing libraries, preface the
12080 <a href="http://netbsd.gw.com/cgi-bin/man-cgi?install+1+NetBSD-current">
12081 <span class="citerefentry"><span class=
12082 "refentrytitle">install</span>(1)</span></a> or
12084 "http://netbsd.gw.com/cgi-bin/man-cgi?cp+1+NetBSD-current">
12085 <span class="citerefentry"><span class=
12086 "refentrytitle">cp</span>(1)</span></a> command
12087 with “<span class="quote">${LIBTOOL}
12088 --mode=install</span>”, and change the
12089 library name to <code xmlns=
12090 "http://www.w3.org/TR/xhtml1/transitional" class=
12091 "filename">.la</code>. e.g.</p>
12092 <pre class="programlisting">
12093 ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
12096 <p>This will install the static <code xmlns=
12097 "http://www.w3.org/TR/xhtml1/transitional" class=
12098 "filename">.a</code>, shared library, any needed
12099 symlinks, and run <a href=
12100 "http://netbsd.gw.com/cgi-bin/man-cgi?ldconfig+8+NetBSD-current">
12101 <span class="citerefentry"><span class=
12102 "refentrytitle">ldconfig</span>(8)</span></a>.</p>
12106 <p>In your <code xmlns=
12107 "http://www.w3.org/TR/xhtml1/transitional" class=
12108 "filename">PLIST</code>, include only the
12110 "http://www.w3.org/TR/xhtml1/transitional" class=
12111 "filename">.la</code> file (this is a change from
12112 previous behaviour).</p>
12118 <div class="sect2" lang="en" xml:lang="en">
12119 <div class="titlepage">
12122 <h3 class="title"><a name="using-libtool" id=
12123 "using-libtool"></a>15.3.2. Using libtool on
12124 GNU packages that already support libtool</h3>
12129 <p>Add <code class="varname">USE_LIBTOOL=yes</code> to
12130 the package Makefile. This will override the package's
12131 own libtool in most cases. For older libtool using
12132 packages, libtool is made by ltconfig script during the
12133 do-configure step; you can check the libtool script
12134 location by doing <span><strong class="command">make
12135 configure; find work*/ -name
12136 libtool</strong></span>.</p>
12138 <p><code class="varname">LIBTOOL_OVERRIDE</code>
12139 specifies which libtool scripts, relative to
12140 <code class="varname">WRKSRC</code>, to override. By
12141 default, it is set to “<span class=
12142 "quote">libtool */libtool */*/libtool</span>”. If
12143 this does not match the location of the package's
12144 libtool script(s), set it as appropriate.</p>
12146 <p>If you do not need <code xmlns=
12147 "http://www.w3.org/TR/xhtml1/transitional" class=
12148 "filename">*.a</code> static libraries built and
12149 installed, then use <code class=
12150 "varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
12152 <p>If your package makes use of the
12153 platform-independent library for loading dynamic shared
12154 objects, that comes with libtool (libltdl), you should
12155 include devel/libltdl/buildlink3.mk.</p>
12157 <p>Some packages use libtool incorrectly so that the
12158 package may not work or build in some circumstances.
12159 Some of the more common errors are:</p>
12161 <div class="itemizedlist">
12164 <p>The inclusion of a shared object (-module) as
12165 a dependent library in an executable or library.
12166 This in itself isn't a problem if one of two
12167 things has been done:</p>
12169 <div class="orderedlist">
12172 <p>The shared object is named correctly,
12174 "http://www.w3.org/TR/xhtml1/transitional"
12175 class="filename">libfoo.la</code>, not
12177 "http://www.w3.org/TR/xhtml1/transitional"
12178 class="filename">foo.la</code></p>
12182 <p>The -dlopen option is used when linking
12190 <p>The use of libltdl without the correct calls
12191 to initialisation routines. The function
12192 lt_dlinit() should be called and the macro
12194 "varname">LTDL_SET_PRELOADED_SYMBOLS</code>
12195 included in executables.</p>
12201 <div class="sect2" lang="en" xml:lang="en">
12202 <div class="titlepage">
12205 <h3 class="title"><a name="autoconf-automake" id=
12206 "autoconf-automake"></a>15.3.3. GNU
12207 Autoconf/Automake</h3>
12212 <p>If a package needs GNU autoconf or automake to be
12213 executed to regenerate the configure script and
12214 Makefile.in makefile templates, then they should be
12215 executed in a pre-configure target.</p>
12217 <p>For packages that need only autoconf:</p>
12218 <pre class="programlisting">
12219 AUTOCONF_REQD= 2.50 # if default version is not good enough
12220 USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
12224 cd ${WRKSRC}; autoconf
12229 <p>and for packages that need automake and
12231 <pre class="programlisting">
12232 AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
12233 USE_TOOLS+= automake # use "automake14" for automake-1.4
12238 aclocal; autoheader; \
12239 automake -a --foreign -i; autoconf
12244 <p>Packages which use GNU Automake will almost
12245 certainly require GNU Make.</p>
12247 <p>There are times when the configure process makes
12248 additional changes to the generated files, which then
12249 causes the build process to try to re-execute the
12250 automake sequence. This is prevented by touching
12251 various files in the configure stage. If this causes
12252 problems with your package you can set <code class=
12253 "varname">AUTOMAKE_OVERRIDE=NO</code> in the package
12258 <div class="sect1" lang="en" xml:lang="en">
12259 <div class="titlepage">
12262 <h2 class="title" style="clear: both"><a name=
12263 "building-considerations" id=
12264 "building-considerations"></a>15.4. Building
12265 considerations</h2>
12270 <div class="sect2" lang="en" xml:lang="en">
12271 <div class="titlepage">
12274 <h3 class="title"><a name="cpp-defines" id=
12275 "cpp-defines"></a>15.4.1. CPP defines</h3>
12280 <p>To port an application to NetBSD, it's usually
12281 necessary for the compiler to be able to judge the
12282 system on which it's compiling, and we use definitions
12283 so that the C pre-processor can do this.</p>
12285 <p>To test whether you are working on a 4.4 BSD-derived
12286 system, you should use the BSD definition, which is
12287 defined in <code xmlns=
12288 "http://www.w3.org/TR/xhtml1/transitional" class=
12289 "filename"><sys/param.h></code> on said
12291 <pre class="programlisting">
12292 #include <sys/param.h>
12295 <p>and then you can surround the BSD-specific parts of
12296 your package's C/C++ code using this conditional:</p>
12297 <pre class="programlisting">
12298 #if (defined(BSD) && BSD >= 199306)
12303 <p>Please use the “<span class=
12304 "quote">__NetBSD__</span>” definition sparingly -
12305 it should only apply to features of NetBSD that are not
12306 present in other 4.4-lite-derived BSDs.</p>
12309 <div class="sect2" lang="en" xml:lang="en">
12310 <div class="titlepage">
12313 <h3 class="title"><a name="cpp-list" id=
12314 "cpp-list"></a>15.4.2. Getting a list of CPP
12320 <p>When your system uses the GNU C Compiler, you can
12321 get a list of symbols that are defined by default, e.g.
12322 to identify the platform, with the following
12324 <pre class="programlisting">
12325 gcc -E -dM - < /dev/null
12330 <div class="sect1" lang="en" xml:lang="en">
12331 <div class="titlepage">
12334 <h2 class="title" style="clear: both"><a name=
12335 "package-specific-actions" id=
12336 "package-specific-actions"></a>15.5. Package
12337 specific actions</h2>
12342 <div class="sect2" lang="en" xml:lang="en">
12343 <div class="titlepage">
12346 <h3 class="title"><a name="user-interaction" id=
12347 "user-interaction"></a>15.5.1. User
12353 <p>Occasionally, packages require interaction from the
12354 user, and this can be in a number of ways:</p>
12356 <div class="itemizedlist">
12359 <p>help in fetching the distfiles</p>
12363 <p>help to configure the package before it is
12368 <p>help during the build process</p>
12372 <p>help during the installation of a package</p>
12377 <p>The <code class="varname">INTERACTIVE_STAGE</code>
12378 definition is provided to notify the pkgsrc mechanism
12379 of an interactive stage which will be needed, and this
12380 should be set in the package's <code xmlns=
12381 "http://www.w3.org/TR/xhtml1/transitional" class=
12382 "filename">Makefile</code>, e.g.:</p>
12383 <pre class="programlisting">
12384 INTERACTIVE_STAGE= build
12387 <p>Multiple interactive stages can be specified:</p>
12388 <pre class="programlisting">
12389 INTERACTIVE_STAGE= configure install
12393 <div class="sect2" lang="en" xml:lang="en">
12394 <div class="titlepage">
12397 <h3 class="title"><a name="handling-licenses" id=
12398 "handling-licenses"></a>15.5.2. Handling
12404 <p>A package may be covered by a license which the user
12405 has or has not agreed to accept. For these cases,
12406 pkgsrc contains a mechanism to note that a package is
12407 covered by a particular license, and the package cannot
12408 be built unless the user has accepted the license.
12409 (Installation of binary packages are not currently
12410 subject to this mechanism.) Packages with licenses that
12411 are either Open Source according to the Open Source
12412 Initiative or Free according to the Free Software
12413 Foundation will not be marked with a license tag.
12414 Packages with licenses that have not been determined to
12415 meet either definition will be marked with a license
12416 tag referring to the license. This will prevent
12417 building unless pkgsrc is informed that the license is
12418 acceptable, and enables displaying the license.</p>
12420 <p>The license tag mechanism is intended to address
12421 copyright-related issues surrounding building,
12422 installing and using a package, and not to address
12423 redistribution issues (see <code class=
12424 "varname">RESTRICTED</code> and <code class=
12425 "varname">NO_SRC_ON_FTP</code>, etc.). However, the
12426 above definition of licenses for which tags are not
12427 needed implies that packages with redistribution
12428 restrictions should have tags.</p>
12430 <p>Denoting that a package is covered by a particular
12431 license is done by placing the license in <code xmlns=
12432 "http://www.w3.org/TR/xhtml1/transitional" class=
12433 "filename">pkgsrc/licenses</code> and setting the
12434 <code class="varname">LICENSE</code> variable to a
12435 string identifying the license, e.g. in <a xmlns=
12436 "http://www.w3.org/TR/xhtml1/transitional" href=
12437 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html"
12438 target="_top"><code xmlns="" class=
12439 "filename">graphics/xv</code></a>:</p>
12440 <pre class="programlisting">
12441 LICENSE= xv-license
12444 <p>When trying to build, the user will get a notice
12445 that the package is covered by a license which has not
12447 <pre class="programlisting">
12448 <code class="prompt">%</code> <strong class=
12449 "userinput"><code>make</code></strong>
12450 ===> xv-3.10anb9 has an unacceptable license: xv-license.
12451 ===> To view the license, enter "/usr/bin/make show-license".
12452 ===> To indicate acceptance, add this line to your /etc/mk.conf:
12453 ===> ACCEPTABLE_LICENSES+=xv-license
12457 <p>The license can be viewed with <span><strong class=
12458 "command">make show-license</strong></span>, and if it
12459 is considered appropriate, the line printed above can
12460 be added to <code xmlns=
12461 "http://www.w3.org/TR/xhtml1/transitional" class=
12462 "filename">/etc/mk.conf</code> to indicate acceptance
12463 of the particular license:</p>
12464 <pre class="programlisting">
12465 ACCEPTABLE_LICENSES+=xv-license
12468 <p>When adding a package with a new license, the
12469 license text should be added to <code xmlns=
12470 "http://www.w3.org/TR/xhtml1/transitional" class=
12471 "filename">pkgsrc/licenses</code> for displaying. A
12472 list of known licenses can be seen in this directory as
12473 well as by looking at the list of (commented out)
12474 <code class="varname">ACCEPTABLE_LICENSES</code>
12475 variable settings in <code xmlns=
12476 "http://www.w3.org/TR/xhtml1/transitional" class=
12477 "filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
12479 <p>The use of <code class=
12480 "varname">LICENSE=shareware</code>, <code class=
12481 "varname">LICENSE=no-commercial-use</code>, and similar
12482 language is deprecated because it does not crisply
12483 refer to a particular license text. Another problem
12484 with such usage is that it does not enable a user to
12485 denote acceptance of the license for a single package
12486 without accepting the same license text for another
12487 package. In particular, this can be inappropriate when
12488 e.g. one accepts a particular license to indicate to
12489 pkgsrc that a fee has been paid.</p>
12492 <div class="sect2" lang="en" xml:lang="en">
12493 <div class="titlepage">
12496 <h3 class="title"><a name=
12497 "installing-score-files" id=
12498 "installing-score-files"></a>15.5.3. Installing
12504 <p>Certain packages, most of them in the games
12505 category, install a score file that allows all users on
12506 the system to record their highscores. In order for
12507 this to work, the binaries need to be installed setgid
12508 and the score files owned by the appropriate group
12509 and/or owner (traditionally the "games" user/group).
12510 The following variables, documented in more detail in
12511 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
12512 class="filename">mk/defaults/mk.conf</code>, control
12513 this behaviour: <code class=
12514 "varname">SETGIDGAME</code>, <code class=
12515 "varname">GAMEDATAMODE</code>, <code class=
12516 "varname">GAMEGRP</code>, <code class=
12517 "varname">GAMEMODE</code>, <code class=
12518 "varname">GAMEOWN</code>.</p>
12520 <p>Note that per default, setgid installation of games
12521 is disabled; setting <code class=
12522 "varname">SETGIDGAME=YES</code> will set all the other
12523 variables accordingly.</p>
12525 <p>A package should therefor never hard code file
12526 ownership or access permissions but rely on
12527 <code class="varname">INSTALL_GAME</code> and
12528 <code class="varname">INSTALL_GAME_DATA</code> to set
12529 these correctly.</p>
12532 <div class="sect2" lang="en" xml:lang="en">
12533 <div class="titlepage">
12536 <h3 class="title"><a name="perl-scripts" id=
12537 "perl-scripts"></a>15.5.4. Packages
12538 containing perl scripts</h3>
12543 <p>If your package contains interpreted perl scripts,
12544 set <code class="varname">REPLACE_PERL</code> to ensure
12545 that the proper interpreter path is set. <code class=
12546 "varname">REPLACE_PERL</code> should contain a list of
12547 scripts, relative to <code class=
12548 "varname">WRKSRC</code>, that you want adjusted.</p>
12551 <div class="sect2" lang="en" xml:lang="en">
12552 <div class="titlepage">
12555 <h3 class="title"><a name="hardcoded-paths" id=
12556 "hardcoded-paths"></a>15.5.5. Packages with
12557 hardcoded paths to other interpreters</h3>
12562 <p>Your package may also contain scripts with hardcoded
12563 paths to other interpreters besides (or as well as)
12564 perl. To correct the full pathname to the script
12565 interpreter, you need to set the following definitions
12566 in your <code xmlns=
12567 "http://www.w3.org/TR/xhtml1/transitional" class=
12568 "filename">Makefile</code> (we shall use
12569 <span><strong class="command">tclsh</strong></span> in
12571 <pre class="programlisting">
12572 REPLACE_INTERPRETER+= tcl
12573 _REPLACE.tcl.old= .*/bin/tclsh
12574 _REPLACE.tcl.new= ${PREFIX}/bin/tclsh
12575 _REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
12576 # relative to ${WRKSRC}, just as in REPLACE_PERL
12580 <div class="sect2" lang="en" xml:lang="en">
12581 <div class="titlepage">
12584 <h3 class="title"><a name="perl-modules" id=
12585 "perl-modules"></a>15.5.6. Packages
12586 installing perl modules</h3>
12591 <p>Makefiles of packages providing perl5 modules should
12592 include the Makefile fragment <code xmlns=
12593 "http://www.w3.org/TR/xhtml1/transitional" class=
12594 "filename">../../lang/perl5/module.mk</code>. It
12595 provides a <span><strong class=
12596 "command">do-configure</strong></span> target for the
12597 standard perl configuration for such modules as well as
12598 various hooks to tune this configuration. See comments
12599 in this file for details.</p>
12601 <p>Perl5 modules will install into different places
12602 depending on the version of perl used during the build
12603 process. To address this, pkgsrc will append lines to
12605 "http://www.w3.org/TR/xhtml1/transitional" class=
12606 "filename">PLIST</code> corresponding to the files
12607 listed in the installed <code xmlns=
12608 "http://www.w3.org/TR/xhtml1/transitional" class=
12609 "filename">.packlist</code> file generated by most
12610 perl5 modules. This is invoked by defining <code class=
12611 "varname">PERL5_PACKLIST</code> to a space-separated
12612 list of paths to packlist files, e.g.:</p>
12613 <pre class="programlisting">
12614 PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
12617 <p>The variables <code class=
12618 "varname">PERL5_SITELIB</code>, <code class=
12619 "varname">PERL5_SITEARCH</code>, and <code class=
12620 "varname">PERL5_ARCHLIB</code> represent the three
12621 locations in which perl5 modules may be installed, and
12622 may be used by perl5 packages that don't have a
12623 packlist. These three variables are also substituted
12624 for in the <code xmlns=
12625 "http://www.w3.org/TR/xhtml1/transitional" class=
12626 "filename">PLIST</code>.</p>
12629 <div class="sect2" lang="en" xml:lang="en">
12630 <div class="titlepage">
12633 <h3 class="title"><a name="faq.info-files" id=
12634 "faq.info-files"></a>15.5.7. Packages
12635 installing info files</h3>
12640 <p>Some packages install info files or use the
12641 “<span class="quote">makeinfo</span>” or
12642 “<span class="quote">install-info</span>”
12643 commands. Each of the info files:</p>
12645 <div class="itemizedlist">
12648 <p>is considered to be installed in the directory
12650 "http://www.w3.org/TR/xhtml1/transitional" class=
12651 "filename">${PREFIX}/${INFO_DIR}</code>,</p>
12655 <p>is registered in the Info directory file
12657 "http://www.w3.org/TR/xhtml1/transitional" class=
12658 "filename">${PREFIX}/${INFO_DIR}/dir</code>,</p>
12662 <p>and must be listed as a filename in the
12663 <code class="varname">INFO_FILES</code> variable
12664 in the package Makefile.</p>
12669 <p><code class="varname">INFO_DIR</code> defaults to
12670 “<span class="quote">info</span>” and can
12671 be overridden in the package Makefile. <code xmlns=
12672 "http://www.w3.org/TR/xhtml1/transitional" class=
12673 "filename">INSTALL</code> and <code xmlns=
12674 "http://www.w3.org/TR/xhtml1/transitional" class=
12675 "filename">DEINSTALL</code> scripts will be generated
12676 to handle registration of the info files in the Info
12677 directory file. The “<span class=
12678 "quote">install-info</span>” command used for the
12679 info files registration is either provided by the
12680 system, or by a special purpose package automatically
12681 added as dependency if needed.</p>
12683 <p>A package which needs the “<span class=
12684 "quote">makeinfo</span>” command at build time
12685 must define the variable <code class=
12686 "varname">USE_MAKEINFO</code> in its Makefile. If a
12687 minimum version of the “<span class=
12688 "quote">makeinfo</span>” command is needed it
12689 should be noted with the <code class=
12690 "varname">TEXINFO_REQD</code> variable in the package
12691 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
12692 class="filename">Makefile</code>. By default, a minimum
12693 version of 3.12 is required. If the system does not
12694 provide a <span><strong class=
12695 "command">makeinfo</strong></span> command or if it
12696 does not match the required minimum, a build dependency
12698 "http://www.w3.org/TR/xhtml1/transitional" href=
12699 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/gtexinfo/README.html"
12700 target="_top"><code xmlns="" class=
12701 "filename">devel/gtexinfo</code></a> package will be
12702 added automatically.</p>
12704 <p>The build and installation process of the software
12705 provided by the package should not use the
12706 <span><strong class=
12707 "command">install-info</strong></span> command as the
12708 registration of info files is the task of the package
12709 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
12710 class="filename">INSTALL</code> script, and it must use
12711 the appropriate <span><strong class=
12712 "command">makeinfo</strong></span> command.</p>
12714 <p>To achieve this goal, the pkgsrc infrastructure
12715 creates overriding scripts for the <span><strong class=
12716 "command">install-info</strong></span> and
12717 <span><strong class="command">makeinfo</strong></span>
12718 commands in a directory listed early in <code class=
12719 "varname">PATH</code>.</p>
12721 <p>The script overriding <span><strong class=
12722 "command">install-info</strong></span> has no effect
12723 except the logging of a message. The script overriding
12724 <span><strong class="command">makeinfo</strong></span>
12725 logs a message and according to the value of
12726 <code class="varname">USE_MAKEINFO</code> and
12727 <code class="varname">TEXINFO_REQD</code> either run
12728 the appropriate <span><strong class=
12729 "command">makeinfo</strong></span> command or exit on
12733 <div class="sect2" lang="en" xml:lang="en">
12734 <div class="titlepage">
12737 <h3 class="title"><a name="gconf2-data-files" id=
12738 "gconf2-data-files"></a>15.5.8. Packages
12739 installing GConf2 data files</h3>
12744 <p>If a package installs <code xmlns=
12745 "http://www.w3.org/TR/xhtml1/transitional" class=
12746 "filename">.schemas</code> or <code xmlns=
12747 "http://www.w3.org/TR/xhtml1/transitional" class=
12748 "filename">.entries</code> files, used by GConf2, you
12749 need to take some extra steps to make sure they get
12750 registered in the database:</p>
12752 <div class="orderedlist">
12755 <p>Include <code xmlns=
12756 "http://www.w3.org/TR/xhtml1/transitional" class=
12757 "filename">../../devel/GConf2/schemas.mk</code>
12758 instead of its <code xmlns=
12759 "http://www.w3.org/TR/xhtml1/transitional" class=
12760 "filename">buildlink3.mk</code> file. This takes
12761 care of rebuilding the GConf2 database at
12762 installation and deinstallation time, and tells
12763 the package where to install GConf2 data files
12764 using some standard configure arguments. It also
12765 disallows any access to the database directly
12766 from the package.</p>
12770 <p>Ensure that the package installs its
12772 "http://www.w3.org/TR/xhtml1/transitional" class=
12773 "filename">.schemas</code> files under
12775 "http://www.w3.org/TR/xhtml1/transitional" class=
12776 "filename">${PREFIX}/share/gconf/schemas</code>.
12777 If they get installed under <code xmlns=
12778 "http://www.w3.org/TR/xhtml1/transitional" class=
12779 "filename">${PREFIX}/etc</code>, you will need to
12780 manually patch the package.</p>
12784 <p>Check the PLIST and remove any entries under
12785 the etc/gconf directory, as they will be handled
12786 automatically. See <a href="#faq.conf" title=
12787 "7.14. How do I change the location of configuration files?">
12788 Section 7.14, “How do I change the
12789 location of configuration files?”</a> for
12790 more information.</p>
12794 <p>Define the <code class=
12795 "varname">GCONF2_SCHEMAS</code> variable in your
12797 "http://www.w3.org/TR/xhtml1/transitional" class=
12798 "filename">Makefile</code> with a list of all
12800 "http://www.w3.org/TR/xhtml1/transitional" class=
12801 "filename">.schemas</code> files installed by the
12802 package, if any. Names must not contain any
12803 directories in them.</p>
12807 <p>Define the <code class=
12808 "varname">GCONF2_ENTRIES</code> variable in your
12810 "http://www.w3.org/TR/xhtml1/transitional" class=
12811 "filename">Makefile</code> with a list of all
12813 "http://www.w3.org/TR/xhtml1/transitional" class=
12814 "filename">.entries</code> files installed by the
12815 package, if any. Names must not contain any
12816 directories in them.</p>
12822 <div class="sect2" lang="en" xml:lang="en">
12823 <div class="titlepage">
12826 <h3 class="title"><a name=
12827 "scrollkeeper-data-files" id=
12828 "scrollkeeper-data-files"></a>15.5.9. Packages
12829 installing scrollkeeper data files</h3>
12834 <p>If a package installs <code xmlns=
12835 "http://www.w3.org/TR/xhtml1/transitional" class=
12836 "filename">.omf</code> files, used by scrollkeeper, you
12837 need to take some extra steps to make sure they get
12838 registered in the database:</p>
12840 <div class="orderedlist">
12843 <p>Include <code xmlns=
12844 "http://www.w3.org/TR/xhtml1/transitional" class=
12845 "filename">../../textproc/scrollkeeper/omf.mk</code>
12846 instead of its <code xmlns=
12847 "http://www.w3.org/TR/xhtml1/transitional" class=
12848 "filename">buildlink3.mk</code> file. This takes
12849 care of rebuilding the scrollkeeper database at
12850 installation and deinstallation time, and
12851 disallows any access to it directly from the
12856 <p>Check the PLIST and remove any entries under
12858 "http://www.w3.org/TR/xhtml1/transitional" class=
12859 "filename">libdata/scrollkeeper</code> directory,
12860 as they will be handled automatically.</p>
12864 <p>Remove the <code xmlns=
12865 "http://www.w3.org/TR/xhtml1/transitional" class=
12866 "filename">share/omf</code> directory from the
12867 PLIST. It will be handled by scrollkeeper.</p>
12873 <div class="sect2" lang="en" xml:lang="en">
12874 <div class="titlepage">
12877 <h3 class="title"><a name="x11-fonts" id=
12878 "x11-fonts"></a>15.5.10. Packages installing
12884 <p>If a package installs font files, you will need to
12885 rebuild the fonts database in the directory where they
12886 get installed at installation and deinstallation time.
12887 This can be automatically done by using <code xmlns=
12888 "http://www.w3.org/TR/xhtml1/transitional" class=
12889 "filename">mk/fonts.mk</code>, which you need to
12890 include in your <code xmlns=
12891 "http://www.w3.org/TR/xhtml1/transitional" class=
12892 "filename">Makefile</code>.</p>
12894 <p>When the file is included, you can list the
12895 directories where fonts are installed in the
12896 <code class="varname">FONTS_<em class=
12897 "replaceable"><code>type</code></em>_DIRS</code>
12898 variables, where <em class=
12899 "replaceable"><code>type</code></em> can be one of
12900 “<span class="quote">TTF</span>”,
12901 “<span class="quote">TYPE1</span>” or
12902 “<span class="quote">X11</span>”. Also make
12903 sure that the database file <code xmlns=
12904 "http://www.w3.org/TR/xhtml1/transitional" class=
12905 "filename">fonts.dir</code> is not listed in the
12908 <p>Note that you should not create new directories for
12909 fonts; instead use the standard ones to avoid that the
12910 user needs to manually configure his X server to find
12914 <div class="sect2" lang="en" xml:lang="en">
12915 <div class="titlepage">
12918 <h3 class="title"><a name="gtk2-modules" id=
12919 "gtk2-modules"></a>15.5.11. Packages
12920 installing GTK2 modules</h3>
12925 <p>If a package installs GTK2 immodules or loaders, you
12926 need to take some extra steps to get them registered in
12927 the GTK2 database properly:</p>
12929 <div class="orderedlist">
12932 <p>Include <code xmlns=
12933 "http://www.w3.org/TR/xhtml1/transitional" class=
12934 "filename">../../x11/gtk2/modules.mk</code>
12935 instead of its <code xmlns=
12936 "http://www.w3.org/TR/xhtml1/transitional" class=
12937 "filename">buildlink3.mk</code> file. This takes
12938 care of rebuilding the database at installation
12939 and deinstallation time.</p>
12943 <p>Set <code class=
12944 "varname">GTK2_IMMODULES=YES</code> if your
12945 package installs GTK2 immodules.</p>
12949 <p>Set <code class=
12950 "varname">GTK2_LOADERS=YES</code> if your package
12951 installs GTK2 loaders.</p>
12955 <p>Patch the package to not touch any of the GTK2
12956 databases directly. These are:</p>
12958 <div class="itemizedlist">
12962 "http://www.w3.org/TR/xhtml1/transitional"
12964 "filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p>
12969 "http://www.w3.org/TR/xhtml1/transitional"
12971 "filename">libdata/gtk-2.0/gtk.immodules</code></p>
12978 <p>Check the PLIST and remove any entries under
12980 "http://www.w3.org/TR/xhtml1/transitional" class=
12981 "filename">libdata/gtk-2.0</code> directory, as
12982 they will be handled automatically.</p>
12988 <div class="sect2" lang="en" xml:lang="en">
12989 <div class="titlepage">
12992 <h3 class="title"><a name="sgml-xml-data" id=
12993 "sgml-xml-data"></a>15.5.12. Packages
12994 installing SGML or XML data</h3>
12999 <p>If a package installs SGML or XML data files that
13000 need to be registered in system-wide catalogs (like
13001 DTDs, sub-catalogs, etc.), you need to take some extra
13004 <div class="orderedlist">
13007 <p>Include <code xmlns=
13008 "http://www.w3.org/TR/xhtml1/transitional" class=
13009 "filename">../../textproc/xmlcatmgr/catalogs.mk</code>
13010 in your <code xmlns=
13011 "http://www.w3.org/TR/xhtml1/transitional" class=
13012 "filename">Makefile</code>, which takes care of
13013 registering those files in system-wide catalogs
13014 at installation and deinstallation time.</p>
13018 <p>Set <code class="varname">SGML_CATALOGS</code>
13019 to the full path of any SGML catalogs installed
13020 by the package.</p>
13024 <p>Set <code class="varname">XML_CATALOGS</code>
13025 to the full path of any XML catalogs installed by
13030 <p>Set <code class="varname">SGML_ENTRIES</code>
13031 to individual entries to be added to the SGML
13032 catalog. These come in groups of three strings;
13033 see xmlcatmgr(1) for more information
13034 (specifically, arguments recognized by the 'add'
13035 action). Note that you will normally not use this
13040 <p>Set <code class="varname">XML_ENTRIES</code>
13041 to individual entries to be added to the XML
13042 catalog. These come in groups of three strings;
13043 see xmlcatmgr(1) for more information
13044 (specifically, arguments recognized by the 'add'
13045 action). Note that you will normally not use this
13052 <div class="sect2" lang="en" xml:lang="en">
13053 <div class="titlepage">
13056 <h3 class="title"><a name="mime-database" id=
13057 "mime-database"></a>15.5.13. Packages
13058 installing extensions to the MIME database</h3>
13063 <p>If a package provides extensions to the MIME
13064 database by installing <code xmlns=
13065 "http://www.w3.org/TR/xhtml1/transitional" class=
13066 "filename">.xml</code> files inside <code xmlns=
13067 "http://www.w3.org/TR/xhtml1/transitional" class=
13068 "filename">${PREFIX}/share/mime/packages</code>, you
13069 need to take some extra steps to ensure that the
13070 database is kept consistent with respect to these new
13073 <div class="orderedlist">
13076 <p>Include <code xmlns=
13077 "http://www.w3.org/TR/xhtml1/transitional" class=
13078 "filename">../../databases/shared-mime-info/mimedb.mk</code>
13079 (avoid using the <code xmlns=
13080 "http://www.w3.org/TR/xhtml1/transitional" class=
13081 "filename">buildlink3.mk</code> file from this
13082 same directory, which is reserved for inclusion
13083 from other <code xmlns=
13084 "http://www.w3.org/TR/xhtml1/transitional" class=
13085 "filename">buildlink3.mk</code> files). It takes
13086 care of rebuilding the MIME database at
13087 installation and deinstallation time, and
13088 disallows any access to it directly from the
13093 <p>Check the PLIST and remove any entries under
13095 "http://www.w3.org/TR/xhtml1/transitional" class=
13096 "filename">share/mime</code> directory,
13097 <span class="emphasis"><em>except</em></span> for
13098 files saved under <code xmlns=
13099 "http://www.w3.org/TR/xhtml1/transitional" class=
13100 "filename">share/mime/packages</code>. The former
13101 are handled automatically by the
13102 update-mime-database program, but the latter are
13103 package-dependent and must be removed by the
13104 package that installed them in the first
13109 <p>Remove any <code xmlns=
13110 "http://www.w3.org/TR/xhtml1/transitional" class=
13111 "filename">share/mime/*</code> directories from
13112 the PLIST. They will be handled by the
13113 shared-mime-info package.</p>
13119 <div class="sect2" lang="en" xml:lang="en">
13120 <div class="titlepage">
13123 <h3 class="title"><a name="intltool" id=
13124 "intltool"></a>15.5.14. Packages using
13130 <p>If a package uses intltool during its build, include
13132 "http://www.w3.org/TR/xhtml1/transitional" class=
13133 "filename">../../textproc/intltool/buildlink3.mk</code>
13134 file, which forces it to use the intltool package
13135 provided by pkgsrc, instead of the one bundled with the
13136 distribution file.</p>
13138 <p>This tracks intltool's build-time dependencies and
13139 uses the latest available version; this way, the
13140 package benefits of any bug fixes that may have
13141 appeared since it was released.</p>
13144 <div class="sect2" lang="en" xml:lang="en">
13145 <div class="titlepage">
13148 <h3 class="title"><a name="startup-scripts" id=
13149 "startup-scripts"></a>15.5.15. Packages
13150 installing startup scripts</h3>
13155 <p>If a package contains a rc.d script, it won't be
13156 copied into the startup directory by default, but you
13157 can enable it, by adding the option <code class=
13158 "varname">PKG_RCD_SCRIPTS=YES</code> in <code xmlns=
13159 "http://www.w3.org/TR/xhtml1/transitional" class=
13160 "filename">/etc/mk.conf</code>. This option will copy
13161 the scripts into <code xmlns=
13162 "http://www.w3.org/TR/xhtml1/transitional" class=
13163 "filename">/etc/rc.d</code> when a package is
13164 installed, and it will automatically remove the scripts
13165 when the package is deinstalled.</p>
13169 <div class="sect1" lang="en" xml:lang="en">
13170 <div class="titlepage">
13173 <h2 class="title" style="clear: both"><a name=
13174 "feedback-to-author" id=
13175 "feedback-to-author"></a>15.6. Feedback to the
13181 <p>If you have found any bugs in the package you make
13182 available, if you had to do special steps to make it run
13183 under NetBSD or if you enhanced the software in various
13184 other ways, be sure to report these changes back to the
13185 original author of the program! With that kind of
13186 support, the next release of the program can incorporate
13187 these fixes, and people not using the NetBSD packages
13188 system can win from your efforts.</p>
13190 <p>Support the idea of free software!</p>
13194 <div class="chapter" lang="en" xml:lang="en">
13195 <div class="titlepage">
13198 <h2 class="title"><a name="debug" id=
13199 "debug"></a>Chapter 16. Debugging</h2>
13204 <p>To check out all the gotchas when building a package,
13205 here are the steps that I do in order to get a package
13206 working. Please note this is basically the same as what was
13207 explained in the previous sections, only with some
13208 debugging aids.</p>
13210 <div class="itemizedlist">
13213 <p>Be sure to set <code class=
13214 "varname">PKG_DEVELOPER=1</code> in <code xmlns=
13215 "http://www.w3.org/TR/xhtml1/transitional" class=
13216 "filename">/etc/mk.conf</code></p>
13220 <p>Install <a xmlns=
13221 "http://www.w3.org/TR/xhtml1/transitional" href=
13222 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/url2pkg/README.html"
13223 target="_top"><code xmlns="" class=
13224 "filename">pkgtools/url2pkg</code></a>, create a
13225 directory for a new package, change into it, then run
13226 <span><strong class=
13227 "command">url2pkg</strong></span>:</p>
13228 <pre class="screen">
13229 <code class="prompt">%</code> <strong class=
13230 "userinput"><code>mkdir /usr/pkgsrc/<em class=
13231 "replaceable"><code>category</code></em>/<em class=
13232 "replaceable"><code>examplepkg</code></em></code></strong>
13233 <code class="prompt">%</code> <strong class=
13234 "userinput"><code>cd /usr/pkgsrc/<em class=
13235 "replaceable"><code>category</code></em>/<em class=
13236 "replaceable"><code>examplepkg</code></em></code></strong>
13237 <code class="prompt">%</code> <strong class=
13238 "userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong>
13243 <p>Edit the <code xmlns=
13244 "http://www.w3.org/TR/xhtml1/transitional" class=
13245 "filename">Makefile</code> as requested.</p>
13249 <p>Fill in the <code xmlns=
13250 "http://www.w3.org/TR/xhtml1/transitional" class=
13251 "filename">DESCR</code> file</p>
13255 <p>Run <span><strong class="command">make
13256 configure</strong></span></p>
13260 <p>Add any dependencies glimpsed from documentation
13261 and the configure step to the package's <code xmlns=
13262 "http://www.w3.org/TR/xhtml1/transitional" class=
13263 "filename">Makefile</code>.</p>
13267 <p>Make the package compile, doing multiple rounds
13269 <pre class="screen">
13270 <code class="prompt">%</code> <strong class=
13271 "userinput"><code>make</code></strong>
13272 <code class="prompt">%</code> <strong class=
13273 "userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
13274 <code class="prompt">%</code> <strong class=
13275 "userinput"><code>mkpatches</code></strong>
13276 <code class="prompt">%</code> <strong class=
13277 "userinput"><code>patchdiff</code></strong>
13278 <code class="prompt">%</code> <strong class=
13279 "userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
13280 <code class="prompt">%</code> <strong class=
13281 "userinput"><code>make mps</code></strong>
13282 <code class="prompt">%</code> <strong class=
13283 "userinput"><code>make clean</code></strong>
13286 <p>Doing as non-root user will ensure that no files
13287 are modified that shouldn't be, especially during the
13288 build phase. <span><strong class=
13289 "command">mkpatches</strong></span>,
13290 <span><strong class=
13291 "command">patchdiff</strong></span> and
13292 <span><strong class="command">pkgvi</strong></span>
13293 are from the <a xmlns=
13294 "http://www.w3.org/TR/xhtml1/transitional" href=
13295 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html"
13296 target="_top"><code xmlns="" class=
13297 "filename">pkgtools/pkgdiff</code></a> package.</p>
13301 <p>Look at the <code xmlns=
13302 "http://www.w3.org/TR/xhtml1/transitional" class=
13303 "filename">Makefile</code>, fix if necessary; see
13304 <a href="#components.Makefile" title=
13305 "8.1. Makefile">Section 8.1,
13306 “<code xmlns=
13307 "http://www.w3.org/TR/xhtml1/transitional" class=
13308 "filename">Makefile</code>”</a>.</p>
13312 <p>Generate a <code xmlns=
13313 "http://www.w3.org/TR/xhtml1/transitional" class=
13314 "filename">PLIST</code>:</p>
13315 <pre class="screen">
13316 <code class="prompt">#</code> <strong class=
13317 "userinput"><code>make install</code></strong>
13318 <code class="prompt">#</code> <strong class=
13319 "userinput"><code>make print-PLIST >PLIST</code></strong>
13320 <code class="prompt">#</code> <strong class=
13321 "userinput"><code>make deinstall</code></strong>
13322 <code class="prompt">#</code> <strong class=
13323 "userinput"><code>make install</code></strong>
13324 <code class="prompt">#</code> <strong class=
13325 "userinput"><code>make deinstall</code></strong>
13328 <p>You usually need to be <code xmlns=
13329 "http://www.w3.org/TR/xhtml1/transitional" class=
13330 "username">root</code> to do this. Look if there are
13331 any files left:</p>
13332 <pre class="screen">
13333 <code class="prompt">#</code> <strong class=
13334 "userinput"><code>make print-PLIST</code></strong>
13337 <p>If this reveals any files that are missing in
13339 "http://www.w3.org/TR/xhtml1/transitional" class=
13340 "filename">PLIST</code>, add them.</p>
13344 <p>Now that the <code xmlns=
13345 "http://www.w3.org/TR/xhtml1/transitional" class=
13346 "filename">PLIST</code> is OK, install the package
13347 again and make a binary package:</p>
13348 <pre class="screen">
13349 <code class="prompt">#</code> <strong class=
13350 "userinput"><code>make reinstall</code></strong>
13351 <code class="prompt">#</code> <strong class=
13352 "userinput"><code>make package</code></strong>
13357 <p>Delete the installed package:</p>
13358 <pre class="screen">
13359 <code class="prompt">#</code> <strong class=
13360 "userinput"><code>pkg_delete blub</code></strong>
13365 <p>Repeat the above <span><strong class=
13366 "command">make print-PLIST</strong></span> command,
13367 which shouldn't find anything now:</p>
13368 <pre class="screen">
13369 <code class="prompt">#</code> <strong class=
13370 "userinput"><code>make print-PLIST</code></strong>
13375 <p>Reinstall the binary package:</p>
13376 <pre class="screen">
13377 <code class="prompt">#</code> <strong class=
13378 "userinput"><code>pkgadd .../blub.tgz</code></strong>
13383 <p>Play with it. Make sure everything works.</p>
13387 <p>Run <span><strong class=
13388 "command">pkglint</strong></span> from <a xmlns=
13389 "http://www.w3.org/TR/xhtml1/transitional" href=
13390 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html"
13391 target="_top"><code xmlns="" class=
13392 "filename">pkgtools/pkglint</code></a>, and fix the
13393 problems it reports:</p>
13394 <pre class="screen">
13395 <code class="prompt">#</code> <strong class=
13396 "userinput"><code>pkglint</code></strong>
13401 <p>Submit (or commit, if you have cvs access); see
13402 <a href="#submit" title=
13403 "Chapter 17. Submitting and Committing">Chapter 17,
13404 <i>Submitting and Committing</i></a>.</p>
13410 <div class="chapter" lang="en" xml:lang="en">
13411 <div class="titlepage">
13414 <h2 class="title"><a name="submit" id=
13415 "submit"></a>Chapter 17. Submitting and
13422 <p><b>Table of Contents</b></p>
13425 <dt><span class="sect1"><a href=
13426 "#submitting-your-package">17.1. Submitting your
13427 packages</a></span></dt>
13429 <dt><span class="sect1"><a href=
13430 "#general-notes-for-changes">17.2. General notes when
13431 adding, updating, or removing packages</a></span></dt>
13433 <dt><span class="sect1"><a href=
13434 "#committing-importing">17.3. Committing: Importing a
13435 package into CVS</a></span></dt>
13437 <dt><span class="sect1"><a href=
13438 "#updating-package">17.4. Updating a package to a newer
13439 version</a></span></dt>
13441 <dt><span class="sect1"><a href="#moving-package">17.5.
13442 Moving a package in pkgsrc</a></span></dt>
13446 <div class="sect1" lang="en" xml:lang="en">
13447 <div class="titlepage">
13450 <h2 class="title" style="clear: both"><a name=
13451 "submitting-your-package" id=
13452 "submitting-your-package"></a>17.1. Submitting
13458 <p>You have to separate between binary and
13459 “<span class="quote">normal</span>” (source)
13462 <div class="itemizedlist">
13465 <p>precompiled binary packages</p>
13467 <p>Our policy is that we accept binaries only from
13468 pkgsrc developers to guarantee that the packages
13469 don't contain any trojan horses etc. This is not to
13470 annoy anyone but rather to protect our users!
13471 You're still free to put up your home-made binary
13472 packages and tell the world where to get them.
13473 NetBSD developers doing bulk builds and wanting to
13474 upload them please see <a href="#bulk-upload"
13475 title="6.3.8. Uploading results of a bulk build">
13476 Section 6.3.8, “Uploading results of a
13477 bulk build”</a>.</p>
13483 <p>First, check that your package is complete,
13484 compiles and runs well; see <a href="#debug" title=
13485 "Chapter 16. Debugging">Chapter 16,
13486 <i>Debugging</i></a> and the rest of this document.
13487 Next, generate an uuencoded gzipped <a href=
13488 "http://netbsd.gw.com/cgi-bin/man-cgi?tar+1+NetBSD-current">
13489 <span class="citerefentry"><span class=
13490 "refentrytitle">tar</span>(1)</span></a> archive,
13491 preferably with all files in a single directory.
13492 Finally, <span><strong class=
13493 "command">send-pr</strong></span> with category
13494 “<span class="quote">pkg</span>”, a
13495 synopsis which includes the package name and
13496 version number, a short description of your package
13497 (contents of the COMMENT variable or DESCR file are
13498 OK) and attach the archive to your PR.</p>
13500 <p>If you want to submit several packages, please
13501 send a separate PR for each one, it's easier for us
13502 to track things that way.</p>
13504 <p>Alternatively, you can also import new packages
13505 into pkgsrc-wip (“<span class="quote">pkgsrc
13506 work-in-progress</span>”); see the homepage
13507 at <a href="http://pkgsrc-wip.sourceforge.net/"
13509 "_top">http://pkgsrc-wip.sourceforge.net/</a> for
13516 <div class="sect1" lang="en" xml:lang="en">
13517 <div class="titlepage">
13520 <h2 class="title" style="clear: both"><a name=
13521 "general-notes-for-changes" id=
13522 "general-notes-for-changes"></a>17.2. General
13523 notes when adding, updating, or removing
13529 <p>Please note all package additions, updates, moves, and
13530 removals in <code xmlns=
13531 "http://www.w3.org/TR/xhtml1/transitional" class=
13532 "filename">pkgsrc/doc/CHANGES</code>. It's very important
13533 to keep this file up to date and conforming to the
13534 existing format, because it will be used by scripts to
13535 automatically update pages on <a href=
13536 "http://www.NetBSD.org/" target="_top">www.NetBSD.org</a>
13537 and other sites. Additionally, check the <code xmlns=
13538 "http://www.w3.org/TR/xhtml1/transitional" class=
13539 "filename">pkgsrc/doc/TODO</code> file and remove the
13540 entry for the package you updated or removed, in case it
13541 was mentioned there.</p>
13543 <p>There is a make target that helps in creating proper
13544 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
13545 class="filename">CHANGES</code> entries:
13546 <span><strong class="command">make
13547 changes-entry</strong></span>. It uses the optional
13548 <code class="varname">CTYPE</code> and <code class=
13549 "varname">NETBSD_LOGIN_NAME</code> variables. The general
13550 usage is to first make sure that your <code xmlns=
13551 "http://www.w3.org/TR/xhtml1/transitional" class=
13552 "filename">CHANGES</code> file is up-to-date (to avoid
13553 having to resolve conflicts later-on) and then to
13554 <span><strong class="command">cd</strong></span> to the
13555 package directory. For package updates,
13556 <span><strong class="command">make
13557 changes-entry</strong></span> is enough. For new
13558 packages, or package moves or removals, set the
13559 <code class="varname">CTYPE</code> variable on the
13560 command line to "Added", "Moved", or "Removed". You can
13561 set <code class="varname">NETBSD_LOGIN_NAME</code> in
13562 <code xmlns="http://www.w3.org/TR/xhtml1/transitional"
13563 class="filename">/etc/mk.conf</code> if your local login
13564 name is not the same as your NetBSD login name. Don't
13565 forget to commit the changes to <code xmlns=
13566 "http://www.w3.org/TR/xhtml1/transitional" class=
13567 "filename">pkgsrc/doc/CHANGES</code>!</p>
13570 <div class="sect1" lang="en" xml:lang="en">
13571 <div class="titlepage">
13574 <h2 class="title" style="clear: both"><a name=
13575 "committing-importing" id=
13576 "committing-importing"></a>17.3. Committing:
13577 Importing a package into CVS</h2>
13582 <p>This section is only of interest for pkgsrc developers
13583 with write access to the pkgsrc repository. Please
13584 remember that cvs imports files relative to the current
13585 working directory, and that the pathname that you give
13586 the <span><strong class="command">cvs
13587 import</strong></span> command is so that it knows where
13588 to place the files in the repository. Newly created
13589 packages should be imported with a vendor tag of
13590 “<span class="quote">TNF</span>” and a
13591 release tag of “<span class=
13592 "quote">pkgsrc-base</span>”, e.g:</p>
13593 <pre class="programlisting">
13594 <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
13596 "prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
13599 <p>Remember to move the directory from which you imported
13600 out of the way, or cvs will complain the next time you
13601 “<span class="quote">cvs update</span>” your
13602 source tree. Also don't forget to add the new package to
13603 the category's <code xmlns=
13604 "http://www.w3.org/TR/xhtml1/transitional" class=
13605 "filename">Makefile</code>.</p>
13607 <p>The commit message of the initial import should
13608 include part of the <code xmlns=
13609 "http://www.w3.org/TR/xhtml1/transitional" class=
13610 "filename">DESCR</code> file, so people reading the
13611 mailing lists know what the package is/does.</p>
13613 <p>For new packages, “<span class="quote">cvs
13614 import</span>” is preferred to “<span class=
13615 "quote">cvs add</span>” because the former gets
13616 everything with a single command, and provides a
13617 consistent tag.</p>
13620 <div class="sect1" lang="en" xml:lang="en">
13621 <div class="titlepage">
13624 <h2 class="title" style="clear: both"><a name=
13625 "updating-package" id=
13626 "updating-package"></a>17.4. Updating a
13627 package to a newer version</h2>
13632 <p>Please always put a concise, appropriate and relevant
13633 summary of the changes between old and new versions into
13634 the commit log when updating a package. There are various
13635 reasons for this:</p>
13637 <div class="itemizedlist">
13640 <p>A URL is volatile, and can change over time. It
13641 may go away completely or its information may be
13642 overwritten by newer information.</p>
13646 <p>Having the change information between old and
13647 new versions in our CVS repository is very useful
13648 for people who use either cvs or anoncvs.</p>
13652 <p>Having the change information between old and
13653 new versions in our CVS repository is very useful
13654 for people who read the pkgsrc-changes mailing
13655 list, so that they can make tactical decisions
13656 about when to upgrade the package.</p>
13661 <p>Please also recognize that, just because a new version
13662 of a package has been released, it should not
13663 automatically be upgraded in the CVS repository. We
13664 prefer to be conservative in the packages that are
13665 included in pkgsrc - development or beta packages are not
13666 really the best thing for most places in which pkgsrc is
13667 used. Please use your judgement about what should go into
13668 pkgsrc, and bear in mind that stability is to be
13669 preferred above new and possibly untested features.</p>
13672 <div class="sect1" lang="en" xml:lang="en">
13673 <div class="titlepage">
13676 <h2 class="title" style="clear: both"><a name=
13677 "moving-package" id=
13678 "moving-package"></a>17.5. Moving a package in
13684 <div class="orderedlist">
13687 <p>Make a copy of the directory somewhere else.</p>
13691 <p>Remove all CVS dirs.</p>
13693 <p>Alternatively to the first two steps you can
13695 <pre class="screen">
13696 <code class="prompt">%</code> <strong class=
13697 "userinput"><code>cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package</code></strong>
13700 <p>and use that for further work.</p>
13704 <p>Fix <code class="varname">CATEGORIES</code> and
13705 any <code class="varname">DEPENDS</code> paths that
13706 just did “<span class=
13707 "quote">../package</span>” instead of
13708 “<span class=
13709 "quote">../../category/package</span>”.</p>
13713 <p><span><strong class="command">cvs
13714 import</strong></span> the modified package in the
13719 <p>Check if any package depends on it:</p>
13720 <pre class="screen">
13721 <code class="prompt">%</code> <strong class=
13722 "userinput"><code>cd /usr/pkgsrc</code></strong>
13723 <code class="prompt">%</code> <strong class=
13724 "userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong>
13729 <p>Fix paths in packages from step 5 to point to
13734 <p><span><strong class="command">cvs rm
13735 (-f)</strong></span> the package at the old
13740 <p>Remove from <code xmlns=
13741 "http://www.w3.org/TR/xhtml1/transitional" class=
13742 "filename">oldcategory/Makefile</code>.</p>
13746 <p>Add to <code xmlns=
13747 "http://www.w3.org/TR/xhtml1/transitional" class=
13748 "filename">newcategory/Makefile</code>.</p>
13752 <p>Commit the changed and removed files:</p>
13753 <pre class="screen">
13754 <code class="prompt">%</code> <strong class=
13755 "userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong>
13758 <p>(and any packages from step 5, of course).</p>
13766 <div class="appendix" lang="en" xml:lang="en">
13767 <div class="titlepage">
13770 <h2 class="title"><a name="examples" id=
13771 "examples"></a>Appendix A. A simple example
13772 package: bison</h2>
13778 <p><b>Table of Contents</b></p>
13781 <dt><span class="sect1"><a href="#example-files">A.1.
13782 files</a></span></dt>
13786 <dt><span class="sect2"><a href=
13787 "#example-Makefile">A.1.1. Makefile</a></span></dt>
13789 <dt><span class="sect2"><a href=
13790 "#example-descr">A.1.2. DESCR</a></span></dt>
13792 <dt><span class="sect2"><a href=
13793 "#example-plist">A.1.3. PLIST</a></span></dt>
13795 <dt><span class="sect2"><a href=
13796 "#checking-package-with-pkglint">A.1.4. Checking a
13797 package with <span><strong class=
13798 "command">pkglint</strong></span></a></span></dt>
13802 <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2.
13803 Steps for building, installing, packaging</a></span></dt>
13807 <p>We checked to find a piece of software that wasn't in the
13808 packages collection, and picked GNU bison. Quite why someone
13809 would want to have <span><strong class=
13810 "command">bison</strong></span> when Berkeley
13811 <span><strong class="command">yacc</strong></span> is already
13812 present in the tree is beyond us, but it's useful for the
13813 purposes of this exercise.</p>
13815 <div class="sect1" lang="en" xml:lang="en">
13816 <div class="titlepage">
13819 <h2 class="title" style="clear: both"><a name=
13820 "example-files" id=
13821 "example-files"></a>A.1. files</h2>
13826 <div class="sect2" lang="en" xml:lang="en">
13827 <div class="titlepage">
13830 <h3 class="title"><a name="example-Makefile" id=
13831 "example-Makefile"></a>A.1.1. Makefile</h3>
13835 <pre class="programlisting">
13839 DISTNAME= bison-1.25
13841 MASTER_SITES= ${MASTER_SITE_GNU}
13843 MAINTAINER= thorpej@NetBSD.org
13844 HOMEPAGE= http://www.gnu.org/software/bison/bison.html
13845 COMMENT= GNU yacc clone
13848 INFO_FILES= bison.info
13850 .include "../../mk/bsd.pkg.mk"
13854 <div class="sect2" lang="en" xml:lang="en">
13855 <div class="titlepage">
13858 <h3 class="title"><a name="example-descr" id=
13859 "example-descr"></a>A.1.2. DESCR</h3>
13863 <pre class="programlisting">
13864 GNU version of yacc. Can make re-entrant parsers, and numerous other
13865 improvements. Why you would want this when Berkeley <a href=
13866 "http://netbsd.gw.com/cgi-bin/man-cgi?yacc+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">yacc</span>(1)</span></a> is part
13867 of the NetBSD source tree is beyond me.
13871 <div class="sect2" lang="en" xml:lang="en">
13872 <div class="titlepage">
13875 <h3 class="title"><a name="example-plist" id=
13876 "example-plist"></a>A.1.3. PLIST</h3>
13880 <pre class="programlisting">
13883 man/man1/bison.1.gz
13889 <div class="sect2" lang="en" xml:lang="en">
13890 <div class="titlepage">
13893 <h3 class="title"><a name=
13894 "checking-package-with-pkglint" id=
13895 "checking-package-with-pkglint"></a>A.1.4. Checking
13896 a package with <span><strong class=
13897 "command">pkglint</strong></span></h3>
13902 <p>The NetBSD package system comes with <a xmlns=
13903 "http://www.w3.org/TR/xhtml1/transitional" href=
13904 "ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html"
13905 target="_top"><code xmlns="" class=
13906 "filename">pkgtools/pkglint</code></a> which helps to
13907 check the contents of these files. After installation it
13908 is quite easy to use, just change to the directory of the
13909 package you wish to examine and execute
13910 <span><strong class=
13911 "command">pkglint</strong></span>:</p>
13912 <pre class="screen">
13913 <code class="prompt">$</code> <strong class=
13914 "userinput"><code>pkglint</code></strong>
13918 <p>Depending on the supplied command line arguments (see
13919 pkglint(1)), more verbose checks will be performed. Use
13920 e.g. <span><strong class="command">pkglint
13921 -v</strong></span> for a very verbose check.</p>
13925 <div class="sect1" lang="en" xml:lang="en">
13926 <div class="titlepage">
13929 <h2 class="title" style="clear: both"><a name=
13930 "steps-for-b-i-p" id=
13931 "steps-for-b-i-p"></a>A.2. Steps for building,
13932 installing, packaging</h2>
13937 <p>Create the directory where the package lives, plus any
13938 auxiliary directories:</p>
13939 <pre class="screen">
13940 <code class="prompt">#</code> <strong class=
13941 "userinput"><code>cd /usr/pkgsrc/lang</code></strong>
13942 <code class="prompt">#</code> <strong class=
13943 "userinput"><code>mkdir bison</code></strong>
13944 <code class="prompt">#</code> <strong class=
13945 "userinput"><code>cd bison</code></strong>
13946 <code class="prompt">#</code> <strong class=
13947 "userinput"><code>mkdir patches</code></strong>
13950 <p>Create <code xmlns=
13951 "http://www.w3.org/TR/xhtml1/transitional" class=
13952 "filename">Makefile</code>, <code xmlns=
13953 "http://www.w3.org/TR/xhtml1/transitional" class=
13954 "filename">DESCR</code> and <code xmlns=
13955 "http://www.w3.org/TR/xhtml1/transitional" class=
13956 "filename">PLIST</code> (see <a href="#components" title=
13957 "Chapter 8. Package components - files, directories and contents">
13958 Chapter 8, <i>Package components - files, directories and
13959 contents</i></a>) then continue with fetching the
13961 <pre class="screen">
13962 <code class="prompt">#</code> <strong class=
13963 "userinput"><code>make fetch</code></strong>
13964 >> bison-1.25.tar.gz doesn't seem to exist on this system.
13965 >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
13966 Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
13967 ftp: Error retrieving file: 500 Internal error
13969 >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
13970 Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
13971 ftp: Error retrieving file: 500 Internal error
13973 >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
13974 Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
13975 Successfully retrieved file.
13978 <p>Generate the checksum of the distfile into <code xmlns=
13979 "http://www.w3.org/TR/xhtml1/transitional" class=
13980 "filename">distinfo</code>:</p>
13981 <pre class="screen">
13982 <code class="prompt">#</code> <strong class=
13983 "userinput"><code>make makesum</code></strong>
13986 <p>Now compile:</p>
13987 <pre class="screen">
13988 <code class="prompt">#</code> <strong class=
13989 "userinput"><code>make</code></strong>
13990 >> Checksum OK for bison-1.25.tar.gz.
13991 ===> Extracting for bison-1.25
13992 ===> Patching for bison-1.25
13993 ===> Ignoring empty patch directory
13994 ===> Configuring for bison-1.25
13995 creating cache ./config.cache
13996 checking for gcc... cc
13997 checking whether we are using GNU C... yes
13998 checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
13999 checking how to run the C preprocessor... cc -E
14000 checking for minix/config.h... no
14001 checking for POSIXized ISC... no
14002 checking whether cross-compiling... no
14003 checking for ANSI C header files... yes
14004 checking for string.h... yes
14005 checking for stdlib.h... yes
14006 checking for memory.h... yes
14007 checking for working const... yes
14008 checking for working alloca.h... no
14009 checking for alloca... yes
14010 checking for strerror... yes
14011 updating cache ./config.cache
14012 creating ./config.status
14014 ===> Building for bison-1.25
14015 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
14016 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
14017 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
14018 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
14019 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
14020 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
14021 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
14022 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
14023 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
14024 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
14025 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
14026 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
14027 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
14028 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
14029 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
14030 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
14031 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
14032 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
14033 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
14034 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
14035 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
14036 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
14037 ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
14039 sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
14042 <p>Everything seems OK, so install the files:</p>
14043 <pre class="screen">
14044 <code class="prompt">#</code> <strong class=
14045 "userinput"><code>make install</code></strong>
14046 >> Checksum OK for bison-1.25.tar.gz.
14047 ===> Installing for bison-1.25
14048 sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
14049 rm -f /usr/pkg/bin/bison
14050 cd /usr/pkg/share; rm -f bison.simple bison.hairy
14051 rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
14052 install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
14053 /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
14054 /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
14055 cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
14056 /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
14057 ===> Registering installation for bison-1.25
14060 <p>You can now use bison, and also - if you decide so -
14061 remove it with <span><strong class="command">pkg_delete
14062 bison</strong></span>. Should you decide that you want a
14063 binary package, do this now:</p>
14064 <pre class="screen">
14065 <code class="prompt">#</code> <strong class=
14066 "userinput"><code>make package</code></strong>
14067 >> Checksum OK for bison-1.25.tar.gz.
14068 ===> Building package for bison-1.25
14069 Creating package bison-1.25.tgz
14070 Registering depends:.
14071 Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
14074 <p>Now that you don't need the source and object files any
14075 more, clean up:</p>
14076 <pre class="screen">
14077 <code class="prompt">#</code> <strong class=
14078 "userinput"><code>make clean</code></strong>
14079 ===> Cleaning for bison-1.25
14084 <div class="appendix" lang="en" xml:lang="en">
14085 <div class="titlepage">
14088 <h2 class="title"><a name="logs" id=
14089 "logs"></a>Appendix B. Build logs</h2>
14095 <p><b>Table of Contents</b></p>
14098 <dt><span class="sect1"><a href="#logs.building">B.1.
14099 Building figlet</a></span></dt>
14101 <dt><span class="sect1"><a href="#logs.package">B.2.
14102 Packaging figlet</a></span></dt>
14106 <div class="sect1" lang="en" xml:lang="en">
14107 <div class="titlepage">
14110 <h2 class="title" style="clear: both"><a name=
14111 "logs.building" id=
14112 "logs.building"></a>B.1. Building figlet</h2>
14116 <pre class="screen">
14117 <code class="prompt">#</code> <strong class=
14118 "userinput"><code>make</code></strong>
14119 ===> Checking for vulnerabilities in figlet-2.2.1nb2
14120 => figlet221.tar.gz doesn't seem to exist on this system.
14121 => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
14122 => [172219 bytes]
14123 Connected to ftp.plig.net.
14124 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
14125 331 Guest login ok, send your complete e-mail address as password.
14126 230-You are user #5 of 500 simultaneous users allowed.
14129 230- | _| |_ ___ ___| |_|___ ___ ___ ___
14130 230- | _| _| . |_| . | | | . |_| . | _| . |
14131 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
14132 230- |_| |_| |___| |___|
14134 230-** Welcome to ftp.plig.org **
14136 230-Please note that all transfers from this FTP site are logged. If you
14137 230-do not like this, please disconnect now.
14139 230-This arhive is available via
14141 230-HTTP: http://ftp.plig.org/
14142 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
14143 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
14145 230-Please email comments, bug reports and requests for packages to be
14146 230-mirrored to ftp-admin@plig.org.
14149 230 Logged in anonymously.
14150 Remote system type is UNIX.
14151 Using binary mode to transfer files.
14153 250 "/pub" is new cwd.
14154 250-"/pub/figlet" is new cwd.
14156 250-Welcome to the figlet archive at ftp.figlet.org
14158 250- ftp://ftp.figlet.org/pub/figlet/
14160 250-The official FIGlet web page is:
14161 250- http://www.figlet.org/
14163 250-If you have questions, please mailto:info@figlet.org. If you want to
14164 250-contribute a font or something else, you can email us.
14166 250 "/pub/figlet/program" is new cwd.
14167 250 "/pub/figlet/program/unix" is new cwd.
14168 local: figlet221.tar.gz remote: figlet221.tar.gz
14169 502 Unimplemented command.
14170 227 Entering Passive Mode (195,40,6,41,246,104)
14171 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
14172 38% |************** | 65800 64.16 KB/s 00:01 ETA
14173 226 Transfer completed.
14174 172219 bytes received in 00:02 (75.99 KB/s)
14176 => Checksum OK for figlet221.tar.gz.
14177 ===> Extracting for figlet-2.2.1nb2
14178 ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
14179 ===> Patching for figlet-2.2.1nb2
14180 ===> Applying pkgsrc patches for figlet-2.2.1nb2
14181 ===> Overriding tools for figlet-2.2.1nb2
14182 ===> Creating toolchain wrappers for figlet-2.2.1nb2
14183 ===> Configuring for figlet-2.2.1nb2
14184 ===> Building for figlet-2.2.1nb2
14185 gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
14187 gcc -O2 -o chkfont chkfont.c
14188 => Unwrapping files-to-be-installed.
14189 <code class="prompt">#</code>
14190 <code class="prompt">#</code> <strong class=
14191 "userinput"><code>make install</code></strong>
14192 ===> Checking for vulnerabilities in figlet-2.2.1nb2
14193 ===> Installing for figlet-2.2.1nb2
14194 install -d -o root -g wheel -m 755 /usr/pkg/bin
14195 install -d -o root -g wheel -m 755 /usr/pkg/man/man6
14196 mkdir -p /usr/pkg/share/figlet
14197 cp figlet /usr/pkg/bin
14198 cp chkfont /usr/pkg/bin
14199 chmod 555 figlist showfigfonts
14200 cp figlist /usr/pkg/bin
14201 cp showfigfonts /usr/pkg/bin
14202 cp fonts/*.flf /usr/pkg/share/figlet
14203 cp fonts/*.flc /usr/pkg/share/figlet
14204 cp figlet.6 /usr/pkg/man/man6
14205 ===> Registering installation for figlet-2.2.1nb2
14206 <code class="prompt">#</code>
14210 <div class="sect1" lang="en" xml:lang="en">
14211 <div class="titlepage">
14214 <h2 class="title" style="clear: both"><a name=
14216 "logs.package"></a>B.2. Packaging figlet</h2>
14220 <pre class="screen">
14221 <code class="prompt">#</code> <strong class=
14222 "userinput"><code>make package</code></strong>
14223 ===> Checking for vulnerabilities in figlet-2.2.1nb2
14224 ===> Packaging figlet-2.2.1nb2
14225 ===> Building binary package for figlet-2.2.1nb2
14226 Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
14227 Using SrcDir value of /usr/pkg
14228 Registering depends:.
14229 <code class="prompt">#</code>
14234 <div class="appendix" lang="en" xml:lang="en">
14235 <div class="titlepage">
14238 <h2 class="title"><a name="ftp-layout" id=
14239 "ftp-layout"></a>Appendix C. Layout of the
14240 FTP server's package archive</h2>
14245 <p>Layout for precompiled binary packages on
14246 ftp.NetBSD.org:</p>
14247 <pre class="programlisting">
14248 /pub/NetBSD/packages/
14251 # Unpacked pkgsrc trees
14252 pkgsrc-current -> /pub/NetBSD/NetBSD-current/pkgsrc
14253 pkgsrc-2003Q4 -> N/A
14254 pkgsrc-2004Q1/pkgsrc
14257 pkgsrc-current.tar.gz -> ../NetBSD-current/tar_files/pkgsrc.tar.gz
14258 pkgsrc-2003Q4.tar.gz -> N/A
14259 pkgsrc-2004Q1.tar.gz -> N/A
14261 # Per pkgsrc-release/OS-release/arch package archives
14267 foo -> ../All/foo
14286 # Per os-release package archive convenience links
14287 NetBSD-1.6.2 -> 1.6.2
14289 i386 -> ../pkgsrc-2004Q1/NetBSD-1.6.2/i386
14293 foo -> ../All/foo
14299 2.0 -> NetBSD-2.0 # backward compat, historic
14301 i386 -> ../pkgsrc-2004Q1/NetBSD-2.0/i386
14303 sparc -> ../pkgsrc-2004Q1/SunOS-5.9/sparc
14304 x86 -> ../pkgsrc-2004Q1/SunOS-5.9/x86
14309 <div class="orderedlist">
14312 <p>Run bulk build, see <a href="#bulkbuild" title=
14313 "6.3. Doing a bulk build of all packages">Section
14314 6.3, “Doing a bulk build of all
14315 packages”</a></p>
14319 <p>Upload /usr/pkgsrc/packages to</p>
14320 <pre class="programlisting">
14321 ftp://ftp.NetBSD.org/pub/NetBSD/packages/\
14322 pkgsrc-2004Q4/\ # pkgsrc-branch
14323 `uname -s`-`uname -r`/\ # OS & version
14324 `uname -p` # architecture
14329 <p>If necessary, create a symlink <span><strong class=
14330 "command">ln -s `uname -m` `uname -p`</strong></span>
14331 (amiga -> m68k, ...)</p>
14337 <div class="appendix" lang="en" xml:lang="en">
14338 <div class="titlepage">
14341 <h2 class="title"><a name="editing" id=
14342 "editing"></a>Appendix D. Editing guidelines
14343 for the pkgsrc guide</h2>
14349 <p><b>Table of Contents</b></p>
14352 <dt><span class="sect1"><a href="#targets">D.1.
14353 Targets</a></span></dt>
14355 <dt><span class="sect1"><a href="#procedure">D.2.
14356 Procedure</a></span></dt>
14360 <p>This section contains information on editing the pkgsrc
14363 <div class="sect1" lang="en" xml:lang="en">
14364 <div class="titlepage">
14367 <h2 class="title" style="clear: both"><a name=
14368 "targets" id="targets"></a>D.1. Targets</h2>
14373 <p>The pkgsrc guide's source code is stored in <code xmlns=
14374 "http://www.w3.org/TR/xhtml1/transitional" class=
14375 "filename">pkgsrc/doc/guide/files</code>, and several files
14376 are created from it:</p>
14378 <div class="itemizedlist">
14382 "http://www.w3.org/TR/xhtml1/transitional" class=
14383 "filename">pkgsrc/doc/pkgsrc.txt</code></p>
14388 "http://www.w3.org/TR/xhtml1/transitional" class=
14389 "filename">pkgsrc/doc/pkgsrc.html</code></p>
14394 "http://www.w3.org/TR/xhtml1/transitional" class=
14395 "filename">http://www.NetBSD.org/Documentation/pkgsrc/</code>:
14396 the documentation on the NetBSD website will be built
14397 from pkgsrc and kept up to date on the web server
14398 itself. This means you <span class=
14399 "emphasis"><em>must</em></span> make sure that your
14400 changes haven't broken the build!</p>
14405 "http://www.w3.org/TR/xhtml1/transitional" class=
14406 "filename">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</code>:
14407 PDF version of the pkgsrc guide.</p>
14412 "http://www.w3.org/TR/xhtml1/transitional" class=
14413 "filename">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</code>:
14414 PostScript version of the pkgsrc guide.</p>
14420 <div class="sect1" lang="en" xml:lang="en">
14421 <div class="titlepage">
14424 <h2 class="title" style="clear: both"><a name=
14426 "procedure"></a>D.2. Procedure</h2>
14431 <p>The procedure to edit the pkgsrc guide is:</p>
14433 <div class="itemizedlist">
14436 <p>Make sure you have the packages needed to
14437 re-generate the pkgsrc guide (and other XML-based
14438 NetBSD documentation) installed. These are
14439 “<span class="quote">netbsd-doc</span>”
14440 for creating the ASCII and HTML versions, and
14441 “<span class=
14442 "quote">netbsd-doc-print</span>” for the
14443 PostScript and PDF versions. You will need both
14444 packages installed, to make sure documentation is
14445 consistent across all formats. The packages can be
14446 found in <code xmlns=
14447 "http://www.w3.org/TR/xhtml1/transitional" class=
14448 "filename">pkgsrc/meta-pkgs/netbsd-doc</code> and
14450 "http://www.w3.org/TR/xhtml1/transitional" class=
14451 "filename">pkgsrc/meta-pkgs/netbsd-doc-print</code>.</p>
14455 <p>Edit the XML file(s) in <code xmlns=
14456 "http://www.w3.org/TR/xhtml1/transitional" class=
14457 "filename">pkgsrc/doc/guide/files</code>.</p>
14461 <p>Run <span><strong class="command">make extract
14462 && make do-lint</strong></span> in
14464 "http://www.w3.org/TR/xhtml1/transitional" class=
14465 "filename">pkgsrc/doc/guide</code> to check the XML
14466 syntax, and fix it if needed.</p>
14470 <p>Run <span><strong class=
14471 "command">make</strong></span> in <code xmlns=
14472 "http://www.w3.org/TR/xhtml1/transitional" class=
14473 "filename">pkgsrc/doc/guide</code> to build the HTML
14474 and ASCII version.</p>
14478 <p>If all is well, run <span><strong class=
14479 "command">make install-doc</strong></span> to put the
14480 generated files into <code xmlns=
14481 "http://www.w3.org/TR/xhtml1/transitional" class=
14482 "filename">pkgsrc/doc</code>.</p>
14486 <p><span><strong class="command">cvs commit
14487 pkgsrc/doc/guide/files</strong></span></p>
14491 <p><span><strong class="command">cvs commit -m
14493 pkgsrc/doc/pkgsrc.{html,txt}</strong></span></p>
14497 <p>Until the webserver on www.NetBSD.org is really
14498 updated automatically to pick up changes to the
14499 pkgsrc guide automatically, also run
14500 <span><strong class="command">make install-htdocs
14501 HTDOCSDIR=../../../htdocs</strong></span> (or
14502 similar, adjust <code class=
14503 "varname">HTDOCSDIR</code>!).</p>
14507 <p><span><strong class="command">cvs commit
14508 htdocs/Documentation/pkgsrc</strong></span></p>