Annotation of pkgsrc/doc/pkgsrc.html, revision 1.92

1.75      rillig      1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
                      2: <html>
1.1       grant       3: <head>
1.75      rillig      4: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
                      5: <title>The pkgsrc guide</title>
                      6: <link rel="stylesheet" href="/NetBSD.css" type="text/css">
                      7: <meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
1.91      rillig      8: <meta name="description" content="pkgsrc is a centralized package management system for Unix-like operating systems. This guide provides information for users and developers of pkgsrc. It covers installation of binary and source packages, creation of binary and source packages and a high-level overview about the infrastructure.">
1.75      rillig      9: </head>
                     10: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en">
                     11: <div class="titlepage">
                     12: <div>
                     13: <div><h1 class="title">
                     14: <a name="the-pkgsrc-guide"></a>The pkgsrc guide</h1></div>
                     15: <div><h2 class="subtitle">Documentation on the NetBSD packages system</h2></div>
                     16: <div><div class="authorgroup">
                     17: <div class="author">
                     18: <h3 class="author">
                     19: <span class="firstname">Alistair</span> <span class="surname">Crooks</span>
                     20: </h3>
                     21: <div class="affiliation"><div class="address"><p><code class="email">&lt;<a href="mailto:agc@NetBSD.org">agc@NetBSD.org</a>&gt;</code></p></div></div>
                     22: </div>
                     23: <div class="author">
                     24: <h3 class="author">
                     25: <span class="firstname">Hubert</span> <span class="surname">Feyrer</span>
                     26: </h3>
                     27: <div class="affiliation"><div class="address"><p><code class="email">&lt;<a href="mailto:hubertf@NetBSD.org">hubertf@NetBSD.org</a>&gt;</code></p></div></div>
                     28: </div>
                     29: <h3 class="corpauthor">
                     30:         The pkgsrc Developers
                     31:       </h3>
                     32: </div></div>
                     33: <div><p class="copyright">Copyright © 1994-2006 The NetBSD Foundation, Inc</p></div>
1.92    ! rillig     34: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.24 2006/11/11 05:39:09 rillig Exp $</p></div>
1.76      rillig     35: <div><div class="abstract">
1.75      rillig     36: <p class="title"><b>Abstract</b></p>
                     37: <p>pkgsrc is a centralized package management system for
                     38:        Unix-like operating systems. This guide provides information for
                     39:        users and developers of pkgsrc. It covers installation of binary
                     40:        and source packages, creation of binary and source packages and
                     41:        a high-level overview about the infrastructure.</p>
                     42: </div></div>
                     43: </div>
                     44: <hr>
                     45: </div>
                     46: <div class="toc">
                     47: <p><b>Table of Contents</b></p>
                     48: <dl>
                     49: <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
                     50: <dd><dl>
                     51: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82      rillig     52: <dd><dl>
                     53: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
                     54: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
                     55: </dl></dd>
1.75      rillig     56: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
                     57: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.88      wiz        58: <dd><dl><dt><span class="sect2"><a href="#term.roles">1.3.1. Roles involved in pkgsrc</a></span></dt></dl></dd>
1.75      rillig     59: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
                     60: </dl></dd>
                     61: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
                     62: <dd><dl>
                     63: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
                     64: <dd><dl>
                     65: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                     66: <dd><dl>
                     67: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                     68: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                     69: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                     70: </dl></dd>
                     71: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                     72: <dd><dl>
                     73: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                     74: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                     75: </dl></dd>
                     76: </dl></dd>
                     77: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
                     78: <dd><dl>
1.82      rillig     79: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
                     80: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
                     81: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
                     82: <dd><dl>
                     83: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
                     84: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
                     85: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
                     86: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
                     87: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
                     88: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
                     89: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75      rillig     90: </dl></dd>
                     91: </dl></dd>
                     92: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
                     93: <dd><dl>
                     94: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                     95: <dd><dl>
                     96: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                     97: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82      rillig     98: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
                     99: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
                    100: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
                    101: <dt><span class="sect2"><a href="#pkg_versions">4.1.6. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
                    102: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
                    103: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75      rillig    104: </dl></dd>
                    105: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                    106: <dd><dl>
                    107: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                    108: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                    109: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                    110: </dl></dd>
                    111: </dl></dd>
                    112: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
                    113: <dd><dl>
                    114: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                    115: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78      rillig    116: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88      wiz       117: <dd><dl>
1.89      rillig    118: <dt><span class="sect2"><a href="#selecting-the-compiler">5.3.1. Selecting the compiler</a></span></dt>
                    119: <dt><span class="sect2"><a href="#conf.cflags">5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
                    120: <dt><span class="sect2"><a href="#conf.ldflags">5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.88      wiz       121: </dl></dd>
1.78      rillig    122: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
                    123: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75      rillig    124: </dl></dd>
                    125: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
                    126: <dd><dl>
                    127: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                    128: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                    129: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                    130: <dd><dl>
                    131: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                    132: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                    133: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                    134: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                    135: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                    136: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                    137: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                    138: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                    139: </dl></dd>
                    140: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                    141: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                    142: </dl></dd>
1.90      rillig    143: <dt><span class="chapter"><a href="#files">7. Directory layout of the installed files</a></span></dt>
1.75      rillig    144: <dd><dl>
1.91      rillig    145: <dt><span class="sect1"><a href="#files.localbase">7.1. File system layout in <code class="literal">${LOCALBASE}</code></a></span></dt>
1.90      rillig    146: <dt><span class="sect1"><a href="#files.varbase">7.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
                    147: </dl></dd>
                    148: <dt><span class="chapter"><a href="#faq">8. Frequently Asked Questions</a></span></dt>
                    149: <dd><dl>
                    150: <dt><span class="sect1"><a href="#mailing-list-pointers">8.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                    151: <dt><span class="sect1"><a href="#pkgviews-docs">8.2. Where's the pkgviews documentation?</a></span></dt>
                    152: <dt><span class="sect1"><a href="#faq-pkgtools">8.3. Utilities for package management (pkgtools)</a></span></dt>
                    153: <dt><span class="sect1"><a href="#non-root-pkgsrc">8.4. How to use pkgsrc as non-root</a></span></dt>
                    154: <dt><span class="sect1"><a href="#resume-transfers">8.5. How to resume transfers when fetching distfiles?</a></span></dt>
                    155: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">8.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                    156: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">8.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                    157: <dt><span class="sect1"><a href="#fetch-behind-firewall">8.8. How to fetch files from behind a firewall</a></span></dt>
                    158: <dt><span class="sect1"><a href="#passive-ftp">8.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
                    159: <dt><span class="sect1"><a href="#fetching-all-distfiles">8.10. How to fetch all distfiles at once</a></span></dt>
                    160: <dt><span class="sect1"><a href="#tmac.andoc-missing">8.11. What does &#8220;<span class="quote">Don't know how to make
1.75      rillig    161: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
1.90      rillig    162: <dt><span class="sect1"><a href="#bsd.own.mk-missing">8.12. What does &#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221; mean?</a></span></dt>
                    163: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">8.13. Using 'sudo' with pkgsrc</a></span></dt>
                    164: <dt><span class="sect1"><a href="#faq.conf">8.14. How do I change the location of configuration files?</a></span></dt>
                    165: <dt><span class="sect1"><a href="#audit-packages">8.15. Automated security checks</a></span></dt>
                    166: <dt><span class="sect1"><a href="#ufaq-cflags">8.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
                    167: <dt><span class="sect1"><a href="#ufaq-fail">8.17. A package does not build.  What shall I do?</a></span></dt>
                    168: <dt><span class="sect1"><a href="#faq.rcs-conflicts">8.18. What does &#8220;<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>&#8221; mean?</a></span></dt>
1.75      rillig    169: </dl></dd>
                    170: </dl></dd>
                    171: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
                    172: <dd><dl>
1.90      rillig    173: <dt><span class="chapter"><a href="#creating">9. Creating a new pkgsrc package from scratch</a></span></dt>
1.91      rillig    174: <dd><dl>
                    175: <dt><span class="sect1"><a href="#creating.common">9.1. Common types of packages</a></span></dt>
                    176: <dd><dl>
                    177: <dt><span class="sect2"><a href="#creating.perl-module">9.1.1. Perl modules</a></span></dt>
                    178: <dt><span class="sect2"><a href="#creating.kde-app">9.1.2. KDE applications</a></span></dt>
                    179: </dl></dd>
                    180: <dt><span class="sect1"><a href="#creating.examples">9.2. Examples</a></span></dt>
                    181: <dd><dl><dt><span class="sect2"><a href="#creating.nvu">9.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
                    182: </dl></dd>
1.90      rillig    183: <dt><span class="chapter"><a href="#components">10. Package components - files, directories and contents</a></span></dt>
1.75      rillig    184: <dd><dl>
1.90      rillig    185: <dt><span class="sect1"><a href="#components.Makefile">10.1. <code class="filename">Makefile</code></a></span></dt>
                    186: <dt><span class="sect1"><a href="#components.distinfo">10.2. <code class="filename">distinfo</code></a></span></dt>
                    187: <dt><span class="sect1"><a href="#components.patches">10.3. patches/*</a></span></dt>
                    188: <dd><dl>
                    189: <dt><span class="sect2"><a href="#components.patches.guidelines">10.3.1. Patching guidelines</a></span></dt>
                    190: <dt><span class="sect2"><a href="#components.patches.feedback">10.3.2. Feedback to the author</a></span></dt>
                    191: </dl></dd>
                    192: <dt><span class="sect1"><a href="#other-mandatory-files">10.4. Other mandatory files</a></span></dt>
                    193: <dt><span class="sect1"><a href="#components.optional">10.5. Optional files</a></span></dt>
                    194: <dd><dl>
                    195: <dt><span class="sect2"><a href="#components.optional.bin">10.5.1. Files affecting the binary package</a></span></dt>
                    196: <dt><span class="sect2"><a href="#components.optional.build">10.5.2. Files affecting the build process</a></span></dt>
                    197: <dt><span class="sect2"><a href="#components.optional.none">10.5.3. Files affecting nothing at all</a></span></dt>
                    198: </dl></dd>
                    199: <dt><span class="sect1"><a href="#work-dir">10.6. <code class="filename">work*</code></a></span></dt>
                    200: <dt><span class="sect1"><a href="#files-dir">10.7. <code class="filename">files/*</code></a></span></dt>
                    201: </dl></dd>
                    202: <dt><span class="chapter"><a href="#makefile">11. Programming in <code class="filename">Makefile</code>s</a></span></dt>
                    203: <dd><dl>
                    204: <dt><span class="sect1"><a href="#makefile.variables">11.1. <code class="filename">Makefile</code> variables</a></span></dt>
                    205: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">11.1.1. Naming conventions</a></span></dt></dl></dd>
                    206: <dt><span class="sect1"><a href="#makefile.code">11.2. Code snippets</a></span></dt>
                    207: <dd><dl>
                    208: <dt><span class="sect2"><a href="#adding-to-list">11.2.1. Adding things to a list</a></span></dt>
                    209: <dt><span class="sect2"><a href="#converting-internal-to-external">11.2.2. Converting an internal list into an external list</a></span></dt>
                    210: <dt><span class="sect2"><a href="#passing-variable-to-shell">11.2.3. Passing variables to a shell command</a></span></dt>
                    211: <dt><span class="sect2"><a href="#quoting-guideline">11.2.4. Quoting guideline</a></span></dt>
                    212: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">11.2.5. Workaround for a bug in BSD Make</a></span></dt>
                    213: </dl></dd>
                    214: </dl></dd>
                    215: <dt><span class="chapter"><a href="#plist">12. PLIST issues</a></span></dt>
                    216: <dd><dl>
                    217: <dt><span class="sect1"><a href="#rcs-id">12.1. RCS ID</a></span></dt>
                    218: <dt><span class="sect1"><a href="#automatic-plist-generation">12.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
                    219: <dt><span class="sect1"><a href="#print-PLIST">12.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
                    220: <dt><span class="sect1"><a href="#plist.misc">12.4. Variable substitution in PLIST</a></span></dt>
                    221: <dt><span class="sect1"><a href="#manpage-compression">12.5. Man page compression</a></span></dt>
                    222: <dt><span class="sect1"><a href="#using-PLIST_SRC">12.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
                    223: <dt><span class="sect1"><a href="#platform-specific-plist">12.7. Platform-specific and differing PLISTs</a></span></dt>
                    224: <dt><span class="sect1"><a href="#faq.common-dirs">12.8. Sharing directories between packages</a></span></dt>
                    225: </dl></dd>
                    226: <dt><span class="chapter"><a href="#buildlink">13. Buildlink methodology</a></span></dt>
                    227: <dd><dl>
                    228: <dt><span class="sect1"><a href="#converting-to-buildlink3">13.1. Converting packages to use buildlink3</a></span></dt>
                    229: <dt><span class="sect1"><a href="#creating-buildlink3.mk">13.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
                    230: <dd><dl>
                    231: <dt><span class="sect2"><a href="#anatomy-of-bl3">13.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
                    232: <dt><span class="sect2"><a href="#updating-buildlink-depends">13.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</a></span></dt>
                    233: </dl></dd>
                    234: <dt><span class="sect1"><a href="#writing-builtin.mk">13.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
                    235: <dd><dl>
                    236: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">13.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
                    237: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">13.3.2. Global preferences for native or pkgsrc software</a></span></dt>
                    238: </dl></dd>
                    239: </dl></dd>
                    240: <dt><span class="chapter"><a href="#pkginstall">14. The pkginstall framework</a></span></dt>
                    241: <dd><dl>
                    242: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">14.1. Files and directories outside the installation prefix</a></span></dt>
                    243: <dd><dl>
                    244: <dt><span class="sect2"><a href="#dirs-outside-prefix">14.1.1. Directory manipulation</a></span></dt>
                    245: <dt><span class="sect2"><a href="#files-outside-prefix">14.1.2. File manipulation</a></span></dt>
                    246: </dl></dd>
                    247: <dt><span class="sect1"><a href="#conf-files">14.2. Configuration files</a></span></dt>
                    248: <dd><dl>
                    249: <dt><span class="sect2"><a href="#conf-files-sysconfdir">14.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
                    250: <dt><span class="sect2"><a href="#conf-files-configure">14.2.2. Telling the software where configuration files are</a></span></dt>
                    251: <dt><span class="sect2"><a href="#conf-files-patching">14.2.3. Patching installations</a></span></dt>
                    252: <dt><span class="sect2"><a href="#conf-files-disable">14.2.4. Disabling handling of configuration files</a></span></dt>
                    253: </dl></dd>
                    254: <dt><span class="sect1"><a href="#rcd-scripts">14.3. System startup scripts</a></span></dt>
                    255: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">14.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
                    256: <dt><span class="sect1"><a href="#users-and-groups">14.4. System users and groups</a></span></dt>
                    257: <dt><span class="sect1"><a href="#shells">14.5. System shells</a></span></dt>
                    258: <dd><dl><dt><span class="sect2"><a href="#shells-disable">14.5.1. Disabling shell registration</a></span></dt></dl></dd>
                    259: <dt><span class="sect1"><a href="#fonts">14.6. Fonts</a></span></dt>
                    260: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">14.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
                    261: </dl></dd>
                    262: <dt><span class="chapter"><a href="#options">15. Options handling</a></span></dt>
                    263: <dd><dl>
                    264: <dt><span class="sect1"><a href="#global-default-options">15.1. Global default options</a></span></dt>
                    265: <dt><span class="sect1"><a href="#converting-to-options">15.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
                    266: <dt><span class="sect1"><a href="#option-names">15.3. Option Names</a></span></dt>
                    267: </dl></dd>
                    268: <dt><span class="chapter"><a href="#build">16. The build process</a></span></dt>
                    269: <dd><dl>
                    270: <dt><span class="sect1"><a href="#build.intro">16.1. Introduction</a></span></dt>
                    271: <dt><span class="sect1"><a href="#build.prefix">16.2. Program location</a></span></dt>
                    272: <dt><span class="sect1"><a href="#build.builddirs">16.3. Directories used during the build process</a></span></dt>
                    273: <dt><span class="sect1"><a href="#build.running">16.4. Running a phase</a></span></dt>
                    274: <dt><span class="sect1"><a href="#build.fetch">16.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
                    275: <dd><dl>
                    276: <dt><span class="sect2"><a href="#build.fetch.what">16.5.1. What to fetch and where to get it from</a></span></dt>
                    277: <dt><span class="sect2"><a href="#build.fetch.how">16.5.2. How are the files fetched?</a></span></dt>
                    278: </dl></dd>
                    279: <dt><span class="sect1"><a href="#build.checksum">16.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
                    280: <dt><span class="sect1"><a href="#build.extract">16.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
                    281: <dt><span class="sect1"><a href="#build.patch">16.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
                    282: <dt><span class="sect1"><a href="#build.tools">16.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
                    283: <dt><span class="sect1"><a href="#build.wrapper">16.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
                    284: <dt><span class="sect1"><a href="#build.configure">16.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                    285: <dt><span class="sect1"><a href="#build.build">16.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                    286: <dt><span class="sect1"><a href="#build.test">16.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
                    287: <dt><span class="sect1"><a href="#build.install">16.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                    288: <dt><span class="sect1"><a href="#build.package">16.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
                    289: <dt><span class="sect1"><a href="#build.clean">16.16. Cleaning up</a></span></dt>
                    290: <dt><span class="sect1"><a href="#build.helpful-targets">16.17. Other helpful targets</a></span></dt>
                    291: </dl></dd>
                    292: <dt><span class="chapter"><a href="#tools">17. Tools needed for building or running</a></span></dt>
                    293: <dd><dl>
                    294: <dt><span class="sect1"><a href="#pkgsrc-tools">17.1. Tools for pkgsrc builds</a></span></dt>
                    295: <dt><span class="sect1"><a href="#package-tools">17.2. Tools needed by packages</a></span></dt>
                    296: <dt><span class="sect1"><a href="#platform-tools">17.3. Tools provided by platforms</a></span></dt>
                    297: </dl></dd>
                    298: <dt><span class="chapter"><a href="#fixes">18. Making your package work</a></span></dt>
                    299: <dd><dl>
                    300: <dt><span class="sect1"><a href="#general-operation">18.1. General operation</a></span></dt>
                    301: <dd><dl>
                    302: <dt><span class="sect2"><a href="#portability-of-packages">18.1.1. Portability of packages</a></span></dt>
                    303: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">18.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
                    304: <dt><span class="sect2"><a href="#user-interaction">18.1.3. User interaction</a></span></dt>
                    305: <dt><span class="sect2"><a href="#handling-licenses">18.1.4. Handling licenses</a></span></dt>
                    306: <dt><span class="sect2"><a href="#restricted-packages">18.1.5. Restricted packages</a></span></dt>
                    307: <dt><span class="sect2"><a href="#dependencies">18.1.6. Handling dependencies</a></span></dt>
                    308: <dt><span class="sect2"><a href="#conflicts">18.1.7. Handling conflicts with other packages</a></span></dt>
                    309: <dt><span class="sect2"><a href="#not-building-packages">18.1.8. Packages that cannot or should not be built</a></span></dt>
                    310: <dt><span class="sect2"><a href="#undeletable-packages">18.1.9. Packages which should not be deleted, once installed</a></span></dt>
                    311: <dt><span class="sect2"><a href="#security-handling">18.1.10. Handling packages with security problems</a></span></dt>
                    312: <dt><span class="sect2"><a href="#bumping-pkgrevision">18.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
                    313: <dt><span class="sect2"><a href="#fixes.subst">18.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
                    314: </dl></dd>
                    315: <dt><span class="sect1"><a href="#fixes.fetch">18.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
                    316: <dd><dl>
                    317: <dt><span class="sect2"><a href="#no-plain-download">18.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
                    318: <dt><span class="sect2"><a href="#modified-distfiles-same-name">18.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
                    319: </dl></dd>
                    320: <dt><span class="sect1"><a href="#fixes.configure">18.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                    321: <dd><dl>
                    322: <dt><span class="sect2"><a href="#fixes.libtool">18.3.1. Shared libraries - libtool</a></span></dt>
                    323: <dt><span class="sect2"><a href="#using-libtool">18.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
                    324: <dt><span class="sect2"><a href="#autoconf-automake">18.3.3. GNU Autoconf/Automake</a></span></dt>
                    325: </dl></dd>
                    326: <dt><span class="sect1"><a href="#programming-languages">18.4. Programming languages</a></span></dt>
                    327: <dd><dl>
                    328: <dt><span class="sect2"><a href="#basic-programming-languages">18.4.1. C, C++, and Fortran</a></span></dt>
                    329: <dt><span class="sect2"><a href="#java-programming-language">18.4.2. Java</a></span></dt>
                    330: <dt><span class="sect2"><a href="#perl-scripts">18.4.3. Packages containing perl scripts</a></span></dt>
                    331: <dt><span class="sect2"><a href="#other-programming-languages">18.4.4. Other programming languages</a></span></dt>
                    332: </dl></dd>
                    333: <dt><span class="sect1"><a href="#fixes.build">18.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                    334: <dd><dl>
                    335: <dt><span class="sect2"><a href="#fixes.build.cpp">18.5.1. Compiling C and C++ code conditionally</a></span></dt>
                    336: <dt><span class="sect2"><a href="#compiler-bugs">18.5.2. How to handle compiler bugs</a></span></dt>
                    337: <dt><span class="sect2"><a href="#undefined-reference">18.5.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
                    338: <dt><span class="sect2"><a href="#out-of-memory">18.5.4. Running out of memory</a></span></dt>
                    339: </dl></dd>
                    340: <dt><span class="sect1"><a href="#fixes.install">18.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                    341: <dd><dl>
                    342: <dt><span class="sect2"><a href="#install-scripts">18.6.1. Creating needed directories</a></span></dt>
                    343: <dt><span class="sect2"><a href="#where-to-install-documentation">18.6.2. Where to install documentation</a></span></dt>
                    344: <dt><span class="sect2"><a href="#installing-score-files">18.6.3. Installing score files</a></span></dt>
                    345: <dt><span class="sect2"><a href="#hardcoded-paths">18.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
                    346: <dt><span class="sect2"><a href="#perl-modules">18.6.5. Packages installing perl modules</a></span></dt>
                    347: <dt><span class="sect2"><a href="#faq.info-files">18.6.6. Packages installing info files</a></span></dt>
                    348: <dt><span class="sect2"><a href="#manpages">18.6.7. Packages installing man pages</a></span></dt>
                    349: <dt><span class="sect2"><a href="#gconf2-data-files">18.6.8. Packages installing GConf2 data files</a></span></dt>
                    350: <dt><span class="sect2"><a href="#scrollkeeper-data-files">18.6.9. Packages installing scrollkeeper data files</a></span></dt>
                    351: <dt><span class="sect2"><a href="#x11-fonts">18.6.10. Packages installing X11 fonts</a></span></dt>
                    352: <dt><span class="sect2"><a href="#gtk2-modules">18.6.11. Packages installing GTK2 modules</a></span></dt>
                    353: <dt><span class="sect2"><a href="#sgml-xml-data">18.6.12. Packages installing SGML or XML data</a></span></dt>
                    354: <dt><span class="sect2"><a href="#mime-database">18.6.13. Packages installing extensions to the MIME database</a></span></dt>
                    355: <dt><span class="sect2"><a href="#intltool">18.6.14. Packages using intltool</a></span></dt>
                    356: <dt><span class="sect2"><a href="#startup-scripts">18.6.15. Packages installing startup scripts</a></span></dt>
                    357: <dt><span class="sect2"><a href="#tex-packages">18.6.16. Packages installing TeX modules</a></span></dt>
                    358: <dt><span class="sect2"><a href="#emulation-packages">18.6.17. Packages supporting running binaries in
1.87      wiz       359:     emulation</a></span></dt>
1.90      rillig    360: <dt><span class="sect2"><a href="#hicolor-theme">18.6.18. Packages installing hicolor theme icons</a></span></dt>
                    361: <dt><span class="sect2"><a href="#desktop-files">18.6.19. Packages installing desktop files</a></span></dt>
1.77      rillig    362: </dl></dd>
1.90      rillig    363: <dt><span class="sect1"><a href="#punting">18.7. Marking packages as having problems</a></span></dt>
1.77      rillig    364: </dl></dd>
1.90      rillig    365: <dt><span class="chapter"><a href="#debug">19. Debugging</a></span></dt>
                    366: <dt><span class="chapter"><a href="#submit">20. Submitting and Committing</a></span></dt>
1.77      rillig    367: <dd><dl>
1.90      rillig    368: <dt><span class="sect1"><a href="#submitting-binary-packages">20.1. Submitting binary packages</a></span></dt>
                    369: <dt><span class="sect1"><a href="#submitting-your-package">20.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                    370: <dt><span class="sect1"><a href="#general-notes-for-changes">20.3. General notes when adding, updating, or removing packages</a></span></dt>
                    371: <dt><span class="sect1"><a href="#committing-importing">20.4. Committing: Importing a package into CVS</a></span></dt>
                    372: <dt><span class="sect1"><a href="#updating-package">20.5. Updating a package to a newer version</a></span></dt>
                    373: <dt><span class="sect1"><a href="#moving-package">20.6. Moving a package in pkgsrc</a></span></dt>
                    374: </dl></dd>
                    375: <dt><span class="chapter"><a href="#devfaq">21. Frequently Asked Questions</a></span></dt>
                    376: <dt><span class="chapter"><a href="#gnome">22. GNOME packaging and porting</a></span></dt>
                    377: <dd><dl>
                    378: <dt><span class="sect1"><a href="#meta-packages">22.1. Meta packages</a></span></dt>
                    379: <dt><span class="sect1"><a href="#new-package">22.2. Packaging a GNOME application</a></span></dt>
                    380: <dt><span class="sect1"><a href="#full-update">22.3. Updating GNOME to a newer version</a></span></dt>
                    381: <dt><span class="sect1"><a href="#patching">22.4. Patching guidelines</a></span></dt>
1.85      jmmv      382: </dl></dd>
1.75      rillig    383: </dl></dd>
                    384: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
                    385: <dd><dl>
1.90      rillig    386: <dt><span class="chapter"><a href="#infr.design">23. Design of the pkgsrc infrastructure</a></span></dt>
1.75      rillig    387: <dd><dl>
1.90      rillig    388: <dt><span class="sect1"><a href="#infr.vardef">23.1. The meaning of variable definitions</a></span></dt>
                    389: <dt><span class="sect1"><a href="#infr.vardef.problems">23.2. Avoiding problems before they arise</a></span></dt>
                    390: <dt><span class="sect1"><a href="#infr.var">23.3. Variable evaluation</a></span></dt>
1.81      rillig    391: <dd><dl>
1.90      rillig    392: <dt><span class="sect2"><a href="#infr.var.load">23.3.1. At load time</a></span></dt>
                    393: <dt><span class="sect2"><a href="#infr.var.run">23.3.2. At runtime</a></span></dt>
1.81      rillig    394: </dl></dd>
1.90      rillig    395: <dt><span class="sect1"><a href="#infr.varspec">23.4. How can variables be specified?</a></span></dt>
                    396: <dt><span class="sect1"><a href="#infr.design.intf">23.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig    397: <dd><dl>
1.90      rillig    398: <dt><span class="sect2"><a href="#infr.design.intf.proc">23.5.1. Procedures with parameters</a></span></dt>
                    399: <dt><span class="sect2"><a href="#infr.design.intf.action">23.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75      rillig    400: </dl></dd>
1.90      rillig    401: <dt><span class="sect1"><a href="#infr.order">23.6. The order in which files are loaded</a></span></dt>
1.75      rillig    402: <dd><dl>
1.90      rillig    403: <dt><span class="sect2"><a href="#infr.order.prefs">23.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
                    404: <dt><span class="sect2"><a href="#infr.order.pkg">23.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75      rillig    405: </dl></dd>
                    406: </dl></dd>
1.90      rillig    407: <dt><span class="chapter"><a href="#regression">24. Regression tests</a></span></dt>
1.75      rillig    408: <dd><dl>
1.90      rillig    409: <dt><span class="sect1"><a href="#regression.descr">24.1. The regression tests framework</a></span></dt>
                    410: <dt><span class="sect1"><a href="#regression.run">24.2. Running the regression tests</a></span></dt>
                    411: <dt><span class="sect1"><a href="#regression.new">24.3. Adding a new regression test</a></span></dt>
1.75      rillig    412: <dd><dl>
1.90      rillig    413: <dt><span class="sect2"><a href="#regression.fun.override">24.3.1. Overridable functions</a></span></dt>
                    414: <dt><span class="sect2"><a href="#regression.fun.helper">24.3.2. Helper functions</a></span></dt>
1.75      rillig    415: </dl></dd>
                    416: </dl></dd>
1.90      rillig    417: <dt><span class="chapter"><a href="#porting">25. Porting pkgsrc</a></span></dt>
1.75      rillig    418: <dd><dl>
1.90      rillig    419: <dt><span class="sect1"><a href="#porting.opsys">25.1. Porting pkgsrc to a new operating system</a></span></dt>
                    420: <dt><span class="sect1"><a href="#porting.compiler">25.2. Adding support for a new compiler</a></span></dt>
1.75      rillig    421: </dl></dd>
                    422: </dl></dd>
                    423: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
                    424: <dd><dl>
                    425: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
                    426: <dd><dl>
                    427: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
                    428: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
                    429: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
                    430: <dt><span class="sect2"><a href="#checking-package-with-pkglint">A.1.4. Checking a package with <span><strong class="command">pkglint</strong></span></a></span></dt>
                    431: </dl></dd>
                    432: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
                    433: </dl></dd>
                    434: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
                    435: <dd><dl>
                    436: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
                    437: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
                    438: </dl></dd>
1.76      rillig    439: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
                    440: <dd><dl>
                    441: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
                    442: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
                    443: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
                    444: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
                    445: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
                    446: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
                    447: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                    448: source packages</a></span></dt>
                    449: </dl></dd>
1.75      rillig    450: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
                    451: <dd><dl>
1.79      rillig    452: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75      rillig    453: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
                    454: </dl></dd>
                    455: </dl>
                    456: </div>
1.82      rillig    457: <div class="list-of-tables">
                    458: <p><b>List of Tables</b></p>
                    459: <dl>
                    460: <dt>1.1. <a href="#supported-platforms">Platforms supported by pkgsrc</a>
                    461: </dt>
                    462: <dt>3.1. <a href="#binary-kits">Binary kits and available packages</a>
                    463: </dt>
1.90      rillig    464: <dt>10.1. <a href="#patch-examples">Patching examples</a>
1.85      jmmv      465: </dt>
1.90      rillig    466: <dt>22.1. <a href="#plist-handling">PLIST handling for GNOME packages</a>
1.85      jmmv      467: </dt>
1.82      rillig    468: </dl>
                    469: </div>
1.75      rillig    470: <div class="chapter" lang="en">
                    471: <div class="titlepage"><div><div><h2 class="title">
                    472: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
                    473: <div class="toc">
                    474: <p><b>Table of Contents</b></p>
                    475: <dl>
                    476: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82      rillig    477: <dd><dl>
                    478: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
                    479: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
                    480: </dl></dd>
1.75      rillig    481: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
                    482: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.88      wiz       483: <dd><dl><dt><span class="sect2"><a href="#term.roles">1.3.1. Roles involved in pkgsrc</a></span></dt></dl></dd>
1.75      rillig    484: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
                    485: </dl>
                    486: </div>
                    487: <div class="sect1" lang="en">
                    488: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    489: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
1.82      rillig    490: <p>There is a lot of software freely available for Unix-based
                    491: systems, which is usually available in form of the source code. Before
                    492: such software can be used, it needs to be configured to the local
                    493: system, compiled and installed, and this is exactly what The NetBSD
                    494: Packages Collection (pkgsrc) does. pkgsrc also has some basic commands
                    495: to handle binary packages, so that not every user has to build the
                    496: packages for himself, which is a time-costly task.</p>
1.75      rillig    497: <p>pkgsrc currently contains several thousand packages,
                    498:       including:</p>
                    499: <div class="itemizedlist"><ul type="disc">
1.91      rillig    500: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/apache/README.html" target="_top"><code class="filename">www/apache</code></a> - The Apache
1.75      rillig    501:          web server</p></li>
1.91      rillig    502: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> - The Firefox
1.75      rillig    503:          web browser</p></li>
1.91      rillig    504: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome/README.html" target="_top"><code class="filename">meta-pkgs/gnome</code></a> - The GNOME
1.75      rillig    505:          Desktop Environment</p></li>
1.91      rillig    506: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a> - The K
1.75      rillig    507:          Desktop Environment</p></li>
                    508: </ul></div>
                    509: <p>...just to name a few.</p>
                    510: <p>pkgsrc has built-in support for handling varying dependencies,
                    511:       such as pthreads and X11, and extended features such as IPv6 support on
                    512:       a range of platforms.</p>
1.82      rillig    513: <div class="sect2" lang="en">
                    514: <div class="titlepage"><div><div><h3 class="title">
                    515: <a name="why-pkgsrc"></a>1.1.1. Why pkgsrc?</h3></div></div></div>
                    516: <p>
                    517: pkgsrc provides the following key features:
                    518: </p>
                    519: <div class="itemizedlist"><ul type="disc">
                    520: <li><p>Easy building of software from source as well as the creation
                    521:   and installation of binary packages. The source and latest
                    522:   patches are retrieved from a master or mirror download site, checksum
                    523:   verified, then built on your system. Support for binary-only
                    524:   distributions is available for both native platforms and NetBSD
                    525:   emulated platforms.</p></li>
                    526: <li><p>All packages are installed in a consistent directory tree,
                    527:   including binaries, libraries, man pages and other
                    528:   documentation.</p></li>
                    529: <li><p>Package dependencies, including when performing package updates,
                    530:   are handled automatically. The configuration files of various
                    531:   packages are handled automatically during updates, so local changes
                    532:   are preserved.</p></li>
                    533: <li><p>Like NetBSD, pkgsrc is designed with portability in mind and
                    534:   consists of highly portable code. This allows the greatest speed of
                    535:   development when porting to new a platform. This portability also
                    536:   ensures that pkgsrc is <span class="emphasis"><em>consistent across all
                    537:   platforms</em></span>.</p></li>
                    538: <li><p>The installation prefix, acceptable software licenses,
                    539:   international encryption requirements and build-time options for a
                    540:   large number of packages are all set in a simple, central
                    541:   configuration file.</p></li>
                    542: <li><p>The entire source (not including the distribution files) is
                    543:   freely available under a BSD license, so you may extend and adapt
                    544:   pkgsrc to your needs. Support for local packages and patches is
                    545:   available right out of the box, so you can configure it specifically
                    546:   for your environment.</p></li>
                    547: </ul></div>
1.91      rillig    548: <p>The following principles are basic to pkgsrc:</p>
                    549: <div class="itemizedlist"><ul type="disc">
                    550: <li><p>&#8220;<span class="quote">It should only work if it's right.</span>&#8221;
                    551: &mdash; That means, if a package contains bugs, it's better to find
                    552: them and to complain about them rather than to just install the package
                    553: and hope that it works. There are numerous checks in pkgsrc that try to
                    554: find such bugs: Static analysis tools (<a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>), build-time checks (portability
                    555: of shell scripts), and post-installation checks (installed files,
                    556: references to shared libraries, script interpreters).</p></li>
                    557: <li><p>&#8220;<span class="quote">If it works, it should work everywhere</span>&#8221;
                    558: &mdash; Like NetBSD has been ported to many hardware architectures,
                    559: pkgsrc has been ported to many operating systems. Care is taken that
                    560: packages behave the same on all platforms.</p></li>
                    561: </ul></div>
1.82      rillig    562: </div>
                    563: <div class="sect2" lang="en">
                    564: <div class="titlepage"><div><div><h3 class="title">
                    565: <a name="intro.platforms"></a>1.1.2. Supported platforms</h3></div></div></div>
                    566: <p>pkgsrc consists of both a source distribution and a binary
                    567: distribution for these operating systems. After retrieving the required
                    568: source or binaries, you can be up and running with pkgsrc in just
                    569: minutes!</p>
1.75      rillig    570: <p>pkgsrc was derived from FreeBSD's ports system, and
                    571:       initially developed for NetBSD only. Since then, pkgsrc has
                    572:       grown a lot, and now supports the following platforms:</p>
1.82      rillig    573: <div class="table">
                    574: <a name="supported-platforms"></a><p class="title"><b>Table 1.1. Platforms supported by pkgsrc</b></p>
1.91      rillig    575: <div class="table-contents"><table summary="Platforms supported by pkgsrc" border="1">
1.82      rillig    576: <colgroup>
                    577: <col>
                    578: <col>
                    579: </colgroup>
                    580: <thead><tr>
                    581: <th>Platform</th>
                    582: <th>Date Support Added</th>
                    583: </tr></thead>
                    584: <tbody>
                    585: <tr>
                    586: <td><a href="http://www.NetBSD.org/" target="_top">NetBSD</a></td>
                    587: <td align="center">Aug 1997</td>
                    588: </tr>
                    589: <tr>
                    590: <td><a href="http://wwws.sun.com/software/solaris/" target="_top">Solaris</a></td>
                    591: <td align="center">Mar 1999</td>
                    592: </tr>
                    593: <tr>
                    594: <td><a href="http://www.kernel.org/" target="_top">Linux</a></td>
                    595: <td align="center">Jun 1999</td>
                    596: </tr>
                    597: <tr>
                    598: <td>
                    599:           <a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
                    600:           (<a href="http://developer.apple.com/macosx/" target="_top">Mac OS X</a>)
                    601:         </td>
                    602: <td align="center">Oct 2001</td>
                    603: </tr>
                    604: <tr>
                    605: <td><a href="http://www.freebsd.org/" target="_top">FreeBSD</a></td>
                    606: <td align="center">Nov 2002</td>
                    607: </tr>
                    608: <tr>
                    609: <td><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></td>
                    610: <td align="center">Nov 2002</td>
                    611: </tr>
                    612: <tr>
                    613: <td><a href="http://www.sgi.com/software/irix/" target="_top">IRIX</a></td>
                    614: <td align="center">Dec 2002</td>
                    615: </tr>
                    616: <tr>
                    617: <td>BSD/OS</td>
                    618: <td align="center">Dec 2003</td>
                    619: </tr>
                    620: <tr>
                    621: <td><a href="http://www-1.ibm.com/servers/aix/" target="_top">AIX</a></td>
                    622: <td align="center">Dec 2003</td>
                    623: </tr>
                    624: <tr>
                    625: <td>
                    626:           <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a>
                    627:           (Microsoft Windows Services for Unix)
                    628:         </td>
                    629: <td align="center">Mar 2004</td>
                    630: </tr>
                    631: <tr>
                    632: <td><a href="http://www.dragonflybsd.org/" target="_top">DragonFlyBSD</a></td>
                    633: <td align="center">Oct 2004</td>
                    634: </tr>
                    635: <tr>
                    636: <td><a href="http://www.tru64.org/" target="_top">OSF/1</a></td>
                    637: <td align="center">Nov 2004</td>
                    638: </tr>
                    639: </tbody>
1.91      rillig    640: </table></div>
1.82      rillig    641: </div>
1.91      rillig    642: <br class="table-break">
1.82      rillig    643: </div>
1.75      rillig    644: </div>
                    645: <div class="sect1" lang="en">
                    646: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    647: <a name="overview"></a>1.2. Overview</h2></div></div></div>
                    648: <p>This document is divided into three parts. The first,
                    649:        <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
                    650:        describes how one can use one of the packages in the Package
                    651:        Collection, either by installing a precompiled binary package,
                    652:        or by building one's own copy using the NetBSD package system. 
                    653:        The second part, <a href="#developers-guide" title="Part II. The pkgsrc developer's guide">The pkgsrc developer's guide</a>, explains how to prepare a
                    654:        package so it can be easily built by other NetBSD users without
                    655:        knowing about the package's building details. The third part,
                    656:        <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
                    657:        is intended for those who want to understand how pkgsrc is
                    658:        implemented.</p>
                    659: <p>This document is available in various formats:
                    660:        <span class="simplelist"><a href="index.html" target="_top">HTML</a>, <a href="pkgsrc.pdf" target="_top">PDF</a>, <a href="pkgsrc.ps" target="_top">PS</a>, <a href="pkgsrc.txt" target="_top">TXT</a></span>.</p>
                    661: </div>
                    662: <div class="sect1" lang="en">
                    663: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    664: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
                    665: <p>There has been a lot of talk about &#8220;<span class="quote">ports</span>&#8221;,
                    666:       &#8220;<span class="quote">packages</span>&#8221;, etc. so far. Here is a description of all the
                    667:       terminology used within this document.</p>
                    668: <div class="variablelist"><dl>
                    669: <dt><span class="term">Package</span></dt>
                    670: <dd><p>A set of files and building instructions
                    671:            that describe what's necessary
                    672:            to build a certain piece of software using
                    673:             pkgsrc. Packages are traditionally stored under
1.76      rillig    674:            <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75      rillig    675: <dt><span class="term">The NetBSD package system</span></dt>
1.87      wiz       676: <dd><p>This is the former name of &#8220;<span class="quote">pkgsrc</span>&#8221;.  It
                    677:          is part of the NetBSD operating system and can be bootstrapped
                    678:          to run on non-NetBSD operating systems as well.  It handles
                    679:          building (compiling), installing, and removing of
                    680:          packages.</p></dd>
1.75      rillig    681: <dt><span class="term">Distfile</span></dt>
                    682: <dd><p>This term describes the file or files that are
                    683:            provided by the author of the piece of software to
                    684:            distribute his work. All the changes necessary to build on
                    685:            NetBSD are reflected in the corresponding package. Usually
                    686:            the distfile is in the form of a compressed tar-archive,
                    687:            but other types are possible, too. Distfiles are usually
                    688:            stored below
1.76      rillig    689:            <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75      rillig    690: <dt><span class="term">Port</span></dt>
                    691: <dd><p>This is the term used by FreeBSD and OpenBSD people
                    692:            for what we call a package.
                    693:            In NetBSD terminology, &#8220;<span class="quote">port</span>&#8221; refers to a different
                    694:            architecture.</p></dd>
                    695: <dt><span class="term">Precompiled/binary package</span></dt>
                    696: <dd>
                    697: <p>A set of binaries built with pkgsrc from a distfile
1.76      rillig    698:            and stuffed together in a single <code class="filename">.tgz</code>
1.75      rillig    699:            file so it can be installed on machines of the same
                    700:            machine architecture without the need to
                    701:            recompile. Packages are usually generated in
1.76      rillig    702:            <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75      rillig    703:            an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
                    704: <p>Sometimes, this is referred to by the term &#8220;<span class="quote">package</span>&#8221; too,
                    705:            especially in the context of precompiled packages.</p>
                    706: </dd>
                    707: <dt><span class="term">Program</span></dt>
1.88      wiz       708: <dd><p>The piece of software to be installed which will be
                    709:          constructed from all the files in the distfile by the
                    710:          actions defined in the corresponding package.</p></dd>
1.75      rillig    711: </dl></div>
                    712: <div class="sect2" lang="en">
                    713: <div class="titlepage"><div><div><h3 class="title">
1.88      wiz       714: <a name="term.roles"></a>1.3.1. Roles involved in pkgsrc</h3></div></div></div>
1.75      rillig    715: <div class="variablelist"><dl>
                    716: <dt><span class="term">pkgsrc users</span></dt>
                    717: <dd>
                    718: <p>The
                    719:        pkgsrc users are people who use the packages provided by pkgsrc.
                    720:        Typically they are system administrators. The people using the
                    721:        software that is inside the packages (maybe called &#8220;<span class="quote">end
                    722:        users</span>&#8221;) are not covered by the pkgsrc guide.</p>
                    723: <p>There are two kinds of pkgsrc users: Some only want to
                    724:        install pre-built binary packages. Others build the pkgsrc
                    725:        packages from source, either for installing them directly or for
                    726:        building binary packages themselves. For pkgsrc users <a href="#users-guide" title="Part I. The pkgsrc user's guide">Part I, &#8220;The pkgsrc user's guide&#8221;</a> should provide all necessary
                    727:        documentation.</p>
                    728: </dd>
                    729: <dt><span class="term">package maintainers</span></dt>
                    730: <dd><p>A
                    731:        package maintainer creates packages as described in <a href="#developers-guide" title="Part II. The pkgsrc developer's guide">Part II, &#8220;The pkgsrc developer's guide&#8221;</a>.</p></dd>
                    732: <dt><span class="term">infrastructure developers</span></dt>
                    733: <dd><p>These people are involved in all those files
1.76      rillig    734:        that live in the <code class="filename">mk/</code> directory and below.
1.75      rillig    735:        Only these people should need to read through <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">Part III, &#8220;The pkgsrc infrastructure internals&#8221;</a>, though others might be curious,
                    736:        too.</p></dd>
                    737: </dl></div>
                    738: </div>
                    739: </div>
                    740: <div class="sect1" lang="en">
                    741: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    742: <a name="typography"></a>1.4. Typography</h2></div></div></div>
                    743: <p>When giving examples for commands, shell prompts are used to
                    744:       show if the command should/can be issued as root, or if
                    745:       &#8220;<span class="quote">normal</span>&#8221; user privileges are sufficient. We use a
                    746:       <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
                    747:       shell prompt, assuming they use the C-shell or tcsh.</p>
                    748: </div>
                    749: </div>
                    750: <div class="part" lang="en">
                    751: <div class="titlepage"><div><div><h1 class="title">
                    752: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
                    753: <div class="toc">
                    754: <p><b>Table of Contents</b></p>
                    755: <dl>
                    756: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
                    757: <dd><dl>
                    758: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                    759: <dd><dl>
                    760: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                    761: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                    762: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                    763: </dl></dd>
                    764: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                    765: <dd><dl>
                    766: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                    767: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                    768: </dl></dd>
                    769: </dl></dd>
                    770: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
                    771: <dd><dl>
1.82      rillig    772: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
                    773: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
                    774: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
                    775: <dd><dl>
                    776: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
                    777: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
                    778: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
                    779: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
                    780: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
                    781: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
                    782: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75      rillig    783: </dl></dd>
                    784: </dl></dd>
                    785: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
                    786: <dd><dl>
                    787: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                    788: <dd><dl>
                    789: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                    790: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82      rillig    791: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
                    792: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
                    793: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
                    794: <dt><span class="sect2"><a href="#pkg_versions">4.1.6. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
                    795: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
                    796: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75      rillig    797: </dl></dd>
                    798: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                    799: <dd><dl>
                    800: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                    801: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                    802: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                    803: </dl></dd>
                    804: </dl></dd>
                    805: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
                    806: <dd><dl>
                    807: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                    808: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78      rillig    809: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88      wiz       810: <dd><dl>
1.89      rillig    811: <dt><span class="sect2"><a href="#selecting-the-compiler">5.3.1. Selecting the compiler</a></span></dt>
                    812: <dt><span class="sect2"><a href="#conf.cflags">5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
                    813: <dt><span class="sect2"><a href="#conf.ldflags">5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.88      wiz       814: </dl></dd>
1.78      rillig    815: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
                    816: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75      rillig    817: </dl></dd>
                    818: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
                    819: <dd><dl>
                    820: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                    821: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                    822: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                    823: <dd><dl>
                    824: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                    825: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                    826: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                    827: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                    828: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                    829: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                    830: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                    831: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                    832: </dl></dd>
                    833: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                    834: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                    835: </dl></dd>
1.90      rillig    836: <dt><span class="chapter"><a href="#files">7. Directory layout of the installed files</a></span></dt>
                    837: <dd><dl>
1.91      rillig    838: <dt><span class="sect1"><a href="#files.localbase">7.1. File system layout in <code class="literal">${LOCALBASE}</code></a></span></dt>
1.90      rillig    839: <dt><span class="sect1"><a href="#files.varbase">7.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
                    840: </dl></dd>
                    841: <dt><span class="chapter"><a href="#faq">8. Frequently Asked Questions</a></span></dt>
1.75      rillig    842: <dd><dl>
1.90      rillig    843: <dt><span class="sect1"><a href="#mailing-list-pointers">8.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                    844: <dt><span class="sect1"><a href="#pkgviews-docs">8.2. Where's the pkgviews documentation?</a></span></dt>
                    845: <dt><span class="sect1"><a href="#faq-pkgtools">8.3. Utilities for package management (pkgtools)</a></span></dt>
                    846: <dt><span class="sect1"><a href="#non-root-pkgsrc">8.4. How to use pkgsrc as non-root</a></span></dt>
                    847: <dt><span class="sect1"><a href="#resume-transfers">8.5. How to resume transfers when fetching distfiles?</a></span></dt>
                    848: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">8.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                    849: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">8.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                    850: <dt><span class="sect1"><a href="#fetch-behind-firewall">8.8. How to fetch files from behind a firewall</a></span></dt>
                    851: <dt><span class="sect1"><a href="#passive-ftp">8.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
                    852: <dt><span class="sect1"><a href="#fetching-all-distfiles">8.10. How to fetch all distfiles at once</a></span></dt>
                    853: <dt><span class="sect1"><a href="#tmac.andoc-missing">8.11. What does &#8220;<span class="quote">Don't know how to make
1.75      rillig    854: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
1.90      rillig    855: <dt><span class="sect1"><a href="#bsd.own.mk-missing">8.12. What does &#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221; mean?</a></span></dt>
                    856: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">8.13. Using 'sudo' with pkgsrc</a></span></dt>
                    857: <dt><span class="sect1"><a href="#faq.conf">8.14. How do I change the location of configuration files?</a></span></dt>
                    858: <dt><span class="sect1"><a href="#audit-packages">8.15. Automated security checks</a></span></dt>
                    859: <dt><span class="sect1"><a href="#ufaq-cflags">8.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
                    860: <dt><span class="sect1"><a href="#ufaq-fail">8.17. A package does not build.  What shall I do?</a></span></dt>
                    861: <dt><span class="sect1"><a href="#faq.rcs-conflicts">8.18. What does &#8220;<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>&#8221; mean?</a></span></dt>
1.75      rillig    862: </dl></dd>
                    863: </dl>
                    864: </div>
                    865: <div class="chapter" lang="en">
                    866: <div class="titlepage"><div><div><h2 class="title">
                    867: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
                    868: <div class="toc">
                    869: <p><b>Table of Contents</b></p>
                    870: <dl>
                    871: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                    872: <dd><dl>
                    873: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                    874: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                    875: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                    876: </dl></dd>
                    877: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                    878: <dd><dl>
                    879: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                    880: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                    881: </dl></dd>
                    882: </dl>
                    883: </div>
1.91      rillig    884: <p>Before you download and extract the files, you need to decide
                    885: where you want to extract them. When using pkgsrc as root user, pkgsrc
                    886: is usually installed in <code class="filename">/usr/pkgsrc</code>. You are though
                    887: free to install the sources and binary packages wherever you want in
                    888: your filesystem, provided that the pathname does not contain white-space
                    889: or other characters that are interpreted specially by the shell and some
                    890: other programs. A safe bet is to use only letters, digits, underscores
                    891: and dashes.</p>
1.75      rillig    892: <div class="sect1" lang="en">
                    893: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    894: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
                    895: <p>Before you download any pkgsrc files, you should decide
                    896:        whether you want the <span class="emphasis"><em>current</em></span> branch or the
                    897:        <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
                    898:        quarterly basis from the current branch and only gets modified
                    899:        for security updates. The names of the stable branches are built
                    900:        from the year and the quarter, for example
                    901:        <code class="literal">2006Q1</code>.</p>
                    902: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
                    903:        want to download pkgsrc. You can get it as a tar file, via SUP,
                    904:        or via CVS. All three ways are described here.</p>
                    905: <div class="sect2" lang="en">
                    906: <div class="titlepage"><div><div><h3 class="title">
                    907: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
                    908: <p>The primary download location for all pkgsrc files is
                    909:        <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
                    910:        number of subdirectories for different purposes, which are
1.76      rillig    911:        described in detail in <a href="#ftp-layout" title="Appendix C. Directory layout of the pkgsrc FTP server">Appendix C, <i>Directory layout of the pkgsrc FTP server</i></a>.</p>
1.75      rillig    912: <p>The tar file for the current branch is in the directory
1.76      rillig    913:        <code class="filename">current</code> and is called <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz" target="_top"><code class="filename">pkgsrc.tar.gz</code></a>.
1.75      rillig    914:        It is autogenerated daily.</p>
                    915: <p>The tar file for the stable branch 2006Q1 is in the
1.76      rillig    916:        directory <code class="filename">2006Q1</code> and is also called <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/2006Q1/pkgsrc.tar.gz" target="_top"><code class="filename">pkgsrc.tar.gz</code></a>.</p>
1.75      rillig    917: <p>After downloading the tar file, change to the directory
                    918:        where you want to have pkgsrc. This is usually
1.91      rillig    919:        <code class="filename">/usr</code>. Then, run <span><strong class="command">gzcat
                    920:        pkgsrc.tar.gz | tar xf -</strong></span> to extract the files.</p>
1.75      rillig    921: </div>
                    922: <div class="sect2" lang="en">
                    923: <div class="titlepage"><div><div><h3 class="title">
                    924: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
                    925: <p>As an alternative to the tar file, you can get pkgsrc via
                    926:        the Software Update Protocol, SUP. To do so, make sure your
                    927:        supfile has a line
1.1       grant     928: 
1.75      rillig    929: </p>
                    930: <pre class="programlisting">
1.51      rillig    931:     release=pkgsrc
1.1       grant     932: </pre>
1.75      rillig    933: <p>
1.1       grant     934: 
1.75      rillig    935:        in it, see the examples in
1.76      rillig    936:        <code class="filename">/usr/share/examples/supfiles</code>, and that the
                    937:        <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75      rillig    938:        run <span><strong class="command">sup -v
                    939:        <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
                    940: </div>
                    941: <div class="sect2" lang="en">
                    942: <div class="titlepage"><div><div><h3 class="title">
                    943: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
                    944: <p>To get pkgsrc via CVS, make sure you have <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cvs+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cvs</span>(1)</span></a>
                    945:        installed. To do an initial (full) checkout of pkgsrc, you first
                    946:        have to set some environment variables. For the C-Shell,
                    947:        type:</p>
                    948: <pre class="screen">
                    949:     <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
                    950:     <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
                    951: </pre>
                    952: <p>Or, the same for the bourne shell:</p>
                    953: <pre class="screen">
                    954:     <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
                    955:     <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
                    956:     <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
                    957: </pre>
                    958: <p>Then, you change to the directory where you want to have
                    959:        your copy of pkgsrc. In most cases this is
1.76      rillig    960:        <code class="filename">/usr</code>. In that directory you run the
1.75      rillig    961:        checkout command, which is <span><strong class="command">cvs -q checkout -P
                    962:        pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
                    963:        checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
                    964:        branch. This command will create a directory called
1.76      rillig    965:        <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75      rillig    966:        it.</p>
                    967: </div>
                    968: </div>
                    969: <div class="sect1" lang="en">
                    970: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    971: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
                    972: <p>The preferred way to keep pkgsrc up-to-date is via CVS
                    973:        (which also works if you have first installed it via a tar
                    974:        file). It saves bandwidth and hard disk activity, compared to
                    975:        downloading the tar file again.</p>
                    976: <div class="sect2" lang="en">
                    977: <div class="titlepage"><div><div><h3 class="title">
                    978: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
                    979: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
                    980: <h3 class="title">Warning</h3>
1.77      rillig    981: <p>When updating from a tar file, you first need to
                    982:        completely remove the old pkgsrc directory. Otherwise those
                    983:        files that have been removed from pkgsrc in the mean time will
                    984:        not be removed on your local disk, resulting in inconsistencies.
                    985:        When removing the old files, any changes that you have done to
                    986:        the pkgsrc files will be lost after updating. Therefore updating
                    987:        via CVS is strongly recommended.</p>
1.75      rillig    988: </div>
1.82      rillig    989: <p>Note that by default the distfiles and the binary packages
                    990:        are saved in the pkgsrc tree, so don't forget to rescue them
                    991:        before updating. You can also configure pkgsrc to use other than
                    992:        the default directories by setting the
                    993:        <code class="varname">DISTDIR</code> and <code class="varname">PACKAGES</code>
                    994:        variables. See <a href="#configuring" title="Chapter 5. Configuring pkgsrc">Chapter 5, <i>Configuring pkgsrc</i></a> for the details.</p>
1.75      rillig    995: <p>To update pkgsrc from a tar file, download the tar file as
                    996:        explained above. Then, make sure that you have not made any
                    997:        changes to the files in the pkgsrc directory. Remove the pkgsrc
                    998:        directory and extract the new tar file. Done.</p>
                    999: </div>
                   1000: <div class="sect2" lang="en">
                   1001: <div class="titlepage"><div><div><h3 class="title">
                   1002: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
                   1003: <p>To update pkgsrc via CVS, make sure the environment
                   1004:        variable <code class="varname">CVS_RSH</code> is set as above. Then,
                   1005:        change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77      rillig   1006:        -dP</strong></span>.</p>
1.75      rillig   1007: <div class="sect3" lang="en">
                   1008: <div class="titlepage"><div><div><h4 class="title">
                   1009: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
                   1010: <p>When updating pkgsrc, the CVS program keeps track of the
                   1011:        branch you selected. But if you, for whatever reason, want to
                   1012:        switch from the stable branch to the current one, you can do it
                   1013:        by adding the option &#8220;<span class="quote">-A</span>&#8221; after the
                   1014:        &#8220;<span class="quote">update</span>&#8221; keyword. To switch from the current branch
                   1015:        back to the stable branch, add the
                   1016:        &#8220;<span class="quote">-rpkgsrc-2006Q1</span>&#8221; option.</p>
                   1017: </div>
                   1018: <div class="sect3" lang="en">
                   1019: <div class="titlepage"><div><div><h4 class="title">
                   1020: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
                   1021: <p>When you update pkgsrc, the CVS program will only touch
                   1022:        those files that are registered in the CVS repository. That
                   1023:        means that any packages that you created on your own will stay
                   1024:        unmodified. If you change files that are managed by CVS, later
                   1025:        updates will try to merge your changes with those that have been
                   1026:        done by others. See the CVS manual, chapter
                   1027:        &#8220;<span class="quote">update</span>&#8221; for details.</p>
                   1028: </div>
                   1029: </div>
                   1030: </div>
                   1031: </div>
                   1032: <div class="chapter" lang="en">
                   1033: <div class="titlepage"><div><div><h2 class="title">
                   1034: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
                   1035: <div class="toc">
                   1036: <p><b>Table of Contents</b></p>
                   1037: <dl>
1.82      rillig   1038: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
                   1039: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
                   1040: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
                   1041: <dd><dl>
                   1042: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
                   1043: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
                   1044: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
                   1045: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
                   1046: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
                   1047: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
                   1048: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75      rillig   1049: </dl></dd>
                   1050: </dl>
                   1051: </div>
                   1052: <div class="sect1" lang="en">
                   1053: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82      rillig   1054: <a name="binarydist"></a>3.1. Binary distribution</h2></div></div></div>
                   1055: <p>
                   1056: We provide a bootstrap kit in both source and binary form for other
                   1057: platforms than NetBSD, consisting of the pkg administration tools and other
                   1058: tools required to use pkgsrc and build packages.
                   1059: </p>
                   1060: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1061: <h3 class="title">Note</h3>
                   1062: <p>
                   1063: Older binary snapshots are available in the
                   1064: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/archive/" target="_top">bootstrap-pkgsrc/archive</a>
                   1065: directory on ftp.NetBSD.org.</p>
                   1066: </div>
                   1067: <div class="table">
                   1068: <a name="binary-kits"></a><p class="title"><b>Table 3.1. Binary kits and available packages</b></p>
1.91      rillig   1069: <div class="table-contents"><table summary="Binary kits and available packages" border="1">
1.82      rillig   1070: <colgroup>
                   1071: <col>
                   1072: <col>
                   1073: <col>
                   1074: <col>
                   1075: </colgroup>
                   1076: <thead><tr>
                   1077: <th>Platform</th>
                   1078: <th>Latest snapshot</th>
                   1079: <th>Binary kit</th>
                   1080: <th>Binary packages</th>
                   1081: </tr></thead>
                   1082: <tbody>
                   1083: <tr>
                   1084: <td class="osname">Darwin 5.5/powerpc (Mac OS X 10.1.5)</td>
                   1085: <td class="date">20021209</td>
                   1086: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-5.5-powerpc-20021209.tar.gz" target="_top">binary kit</a></td>
                   1087: <td class="binary-pkgs-url"> </td>
                   1088: </tr>
                   1089: <tr>
                   1090: <td class="osname">Darwin 6.6/powerpc (Mac OS X 10.2.6)</td>
                   1091: <td class="date">20030623</td>
                   1092: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-6.6-powerpc-20030623.tar.gz" target="_top">binary kit</a></td>
                   1093: <td class="binary-pkgs-url"> </td>
                   1094: </tr>
                   1095: <tr>
                   1096: <td class="osname">Darwin 7.6/powerpc (Mac OS X 10.3.6)</td>
                   1097: <td class="date">20041219</td>
                   1098: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-7.6.0-powerpc-20041219.tar.gz" target="_top">binary kit</a></td>
                   1099: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Darwin-7.6/" target="_top">binary packages</a></td>
                   1100: </tr>
                   1101: <tr>
                   1102: <td class="osname">Darwin 7.8/powerpc (Mac OS X 10.3.8)</td>
                   1103: <td class="date">20050320</td>
                   1104: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-7.8.0-powerpc-20050320.tar.gz" target="_top">binary kit</a></td>
                   1105: <td class="binary-pkgs-url"> </td>
                   1106: </tr>
                   1107: <tr>
                   1108: <td class="osname">Darwin 8.1/powerpc (Mac OS X 10.4.1)</td>
                   1109: <td class="date">20050625</td>
                   1110: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-8.1.0-powerpc-20050625.tar.gz" target="_top">binary kit</a></td>
                   1111: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Darwin-8.1/powerpc/current/" target="_top">binary packages</a></td>
                   1112: </tr>
                   1113: <tr>
                   1114: <td class="osname">Debian GNU Linux/i386</td>
                   1115: <td class="date">20031023</td>
                   1116: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.4.22-debian-i386-20031023.tar.gz" target="_top">binary kit</a></td>
                   1117: <td class="binary-pkgs-url"> </td>
                   1118: </tr>
                   1119: <tr>
                   1120: <td class="osname">Fedora Core 2 Linux/i386</td>
                   1121: <td class="date">20050618</td>
                   1122: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.6.10-i386-fc2-20050618.tar.gz" target="_top">binary kit</a></td>
                   1123: <td class="binary-pkgs-url"> </td>
                   1124: </tr>
                   1125: <tr>
                   1126: <td class="osname">Fedora Core 4 Linux/i386</td>
                   1127: <td class="date">20060105</td>
                   1128: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.6.11-i386-fc4-20060105.tar.gz" target="_top">binary kit</a></td>
                   1129: <td class="binary-pkgs-url"> </td>
                   1130: </tr>
                   1131: <tr>
                   1132: <td class="osname">FreeBSD 3.5/i386</td>
                   1133: <td class="date">20030411</td>
                   1134: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-3.5-STABLE-i386-20030411.tar.gz" target="_top">binary kit</a></td>
                   1135: <td class="binary-pkgs-url"> </td>
                   1136: </tr>
                   1137: <tr>
                   1138: <td class="osname">FreeBSD 4.7/i386</td>
                   1139: <td class="date">20021211</td>
                   1140: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-4.7-RELEASE-i386-20021211.tar.gz" target="_top">binary kit</a></td>
                   1141: <td class="binary-pkgs-url"> </td>
                   1142: </tr>
                   1143: <tr>
                   1144: <td class="osname">FreeBSD 5.0/i386</td>
                   1145: <td class="date">20030411</td>
                   1146: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.0-RELEASE-i386-20030411.tar.gz" target="_top">binary kit</a></td>
                   1147: <td class="binary-pkgs-url"> </td>
                   1148: </tr>
                   1149: <tr>
                   1150: <td class="osname">FreeBSD 5.1/i386</td>
                   1151: <td class="date">20030630</td>
                   1152: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.1-RELEASE-i386-20030630.tar.gz" target="_top">binary kit</a></td>
                   1153: <td class="binary-pkgs-url"> </td>
                   1154: </tr>
                   1155: <tr>
                   1156: <td class="osname">FreeBSD 5.2.1/i386</td>
                   1157: <td class="date">20040227</td>
                   1158: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.2.1-RELEASE-i386-20040227.tar.gz" target="_top">binary kit</a></td>
                   1159: <td class="binary-pkgs-url"> </td>
                   1160: </tr>
                   1161: <tr>
                   1162: <td class="osname">FreeBSD 5.3/i386</td>
                   1163: <td class="date">20050119</td>
                   1164: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.3-RELEASE-i386-20050119.tar" target="_top">binary kit</a></td>
                   1165: <td class="binary-pkgs-url"> </td>
                   1166: </tr>
                   1167: <tr>
                   1168: <td class="osname">Interix 3.5</td>
                   1169: <td class="date">20051010</td>
                   1170: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Interix-3.5-i386-20051010.tar.gz" target="_top">binary kit</a></td>
                   1171: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Interix-3.5/i386/current/" target="_top">binary packages</a></td>
                   1172: </tr>
                   1173: <tr>
                   1174: <td class="osname">IRIX 6.5 n32-bit ABI</td>
                   1175: <td class="date">20040911</td>
                   1176: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-IRIX-6.5-mips-20040911.tar.gz" target="_top">binary kit</a></td>
                   1177: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/n32/" target="_top">binary packages</a></td>
                   1178: </tr>
                   1179: <tr>
                   1180: <td class="osname">IRIX 6.5 64-bit ABI</td>
                   1181: <td class="date">20040912</td>
                   1182: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-IRIX64-6.5-mips-20040912.tar.gz" target="_top">binary kit</a></td>
                   1183: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/64/" target="_top">binary packages</a></td>
                   1184: </tr>
                   1185: <tr>
                   1186: <td class="osname">OpenBSD 3.2/i386</td>
                   1187: <td class="date">20030420</td>
                   1188: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-OpenBSD-3.2-i386-20030420.tar.gz" target="_top">binary kit</a></td>
                   1189: <td class="binary-pkgs-url"> </td>
                   1190: </tr>
                   1191: <tr>
                   1192: <td class="osname">OpenBSD 3.3/i386</td>
                   1193: <td class="date">20030503</td>
                   1194: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-OpenBSD-3.3-i386-20030503.tar.gz" target="_top">binary kit</a></td>
                   1195: <td class="binary-pkgs-url"> </td>
                   1196: </tr>
                   1197: <tr>
                   1198: <td class="osname">OpenBSD 3.5/i386</td>
                   1199: <td class="date">20040507</td>
                   1200: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-OpenBSD-3.5-i386-20040703.tar.gz" target="_top">binary kit</a></td>
                   1201: <td class="binary-pkgs-url"> </td>
                   1202: </tr>
                   1203: <tr>
                   1204: <td class="osname">Slackware Linux 8.1/i386</td>
                   1205: <td class="date">20030417</td>
                   1206: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.4.18-slackware-20030417.tar.gz" target="_top">binary kit</a></td>
                   1207: <td class="binary-pkgs-url"> </td>
                   1208: </tr>
                   1209: <tr>
                   1210: <td class="osname">Slackware Linux 9/i386</td>
                   1211: <td class="date">20031023</td>
                   1212: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.4.22-i386-slackware9-20040703.tar.gz" target="_top">binary kit</a></td>
                   1213: <td class="binary-pkgs-url"> </td>
                   1214: </tr>
                   1215: <tr>
                   1216: <td class="osname">Solaris 8/sparc</td>
                   1217: <td class="date">20050220</td>
                   1218: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.8-sparc-20050220.tar.gz" target="_top">binary kit</a></td>
                   1219: <td class="binary-pkgs-url"> </td>
                   1220: </tr>
                   1221: <tr>
                   1222: <td class="osname">Solaris 8/i386</td>
                   1223: <td class="date">20050220</td>
                   1224: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.8-i386-20050220.tar.gz" target="_top">binary kit</a></td>
                   1225: <td class="binary-pkgs-url"> </td>
                   1226: </tr>
                   1227: <tr>
                   1228: <td class="osname">Solaris 9/sparc</td>
                   1229: <td class="date">20041208</td>
                   1230: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.9-sparc-20041208.tar.gz" target="_top">binary kit</a></td>
                   1231: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/SunOS-5.9/sparc/" target="_top">binary packages</a></td>
                   1232: </tr>
                   1233: <tr>
                   1234: <td class="osname">Solaris 9/i386</td>
                   1235: <td class="date">20030411</td>
                   1236: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.9-i386-20030411.tar.gz" target="_top">binary kit</a></td>
                   1237: <td class="binary-pkgs-url"> </td>
                   1238: </tr>
                   1239: </tbody>
1.91      rillig   1240: </table></div>
1.82      rillig   1241: </div>
1.91      rillig   1242: <br class="table-break"><p>
1.82      rillig   1243: Simply download the binary kit for your platform, and extract it into
                   1244: <code class="filename">/</code> e.g.
                   1245: </p>
                   1246: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
                   1247: <code class="prompt">#</code> <strong class="userinput"><code>gzip -c -d /tmp/bootstrap-pkgsrc-SunOS-5.9-sparc-20031023.tar.gz \
                   1248:   | tar -xpf -</code></strong></pre>
                   1249: <p>
                   1250: Of course, as with any binary distributions, you should verify the
                   1251: checksum against the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/SUM" target="_top">SUM</a>
                   1252: or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/CKSUM" target="_top">CKSUM</a>
                   1253: file and inspect the contents before extracting it.
                   1254: </p>
                   1255: </div>
                   1256: <div class="sect1" lang="en">
                   1257: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1258: <a name="bootstrapping-pkgsrc"></a>3.2. Bootstrapping pkgsrc</h2></div></div></div>
                   1259: <p>Installing the bootstrap kit from source should be as simple as:</p>
1.75      rillig   1260: <pre class="screen">
                   1261: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
                   1262: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1.87      wiz      1263: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong>
                   1264:     </pre>
1.75      rillig   1265: <p>See <a href="#getting" title="Chapter 2. Where to get pkgsrc and how to keep it up-to-date">Chapter 2, <i>Where to get pkgsrc and how to keep it up-to-date</i></a> for other ways to get
1.87      wiz      1266:     pkgsrc before bootstrapping. The given
                   1267:     <span><strong class="command">bootstrap</strong></span> command will use the defaults of
                   1268:     <code class="filename">/usr/pkg</code> for the
                   1269:     <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
                   1270:     and <code class="filename">/var/db/pkg</code> for the package database
                   1271:     directory where pkgsrc will do its internal bookkeeping.
                   1272:     However, these can also be set using command-line
                   1273:     arguments.</p>
1.75      rillig   1274: <p>Binary packages for the pkgsrc tools and an initial set of packages is
1.87      wiz      1275:     available for supported platforms. An up-to-date list of these can be
                   1276:     found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
                   1277:     Note that this only works for privileged builds that install
                   1278:     into <code class="filename">/usr/pkg</code>.</p>
1.75      rillig   1279: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1280: <h3 class="title">Note</h3>
                   1281: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
1.87      wiz      1282:       Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
                   1283:       For examples in this guide, use <span><strong class="command">bmake</strong></span>
                   1284:       instead of &#8220;<span class="quote">make</span>&#8221;.</p>
1.75      rillig   1285: </div>
                   1286: </div>
                   1287: <div class="sect1" lang="en">
                   1288: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82      rillig   1289: <a name="platform-specific-notes"></a>3.3. Platform-specific notes</h2></div></div></div>
1.75      rillig   1290: <p>Here are some platform-specific notes you should be aware of.</p>
                   1291: <div class="sect2" lang="en">
                   1292: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1293: <a name="darwin"></a>3.3.1. Darwin (Mac OS X)</h3></div></div></div>
1.85      jmmv     1294: <p>Darwin 5.x and up are supported. There are two methods of using
1.82      rillig   1295:        pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.3.1.1. Using a disk image">disk
1.89      rillig   1296:          image</a>, or a <a href="#platform.osx-part" title="3.3.1.2. Using a UFS or HFSX partition">UFS or HFSX
1.75      rillig   1297:          partition</a>.</p>
                   1298: <p>Before you start, you will need to download and install the Mac OS X Developer
1.87      wiz      1299:       Tools from Apple's Developer Connection.  See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
                   1300:       for details.  Also, make sure you install X11 for Mac OS X and the X11 SDK
                   1301:       from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
                   1302:       if you intend to build packages that use the X11 Window System.</p>
1.89      rillig   1303: <p>If you already have a UFS or HFSX partition, or have a spare partition
                   1304:       that you can format as UFS or HFSX, it is recommended to use that instead of
1.87      wiz      1305:       the disk image. It'll be somewhat faster and will mount automatically
                   1306:       at boot time, where you must manually mount a disk image.</p>
1.75      rillig   1307: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1308: <h3 class="title">Note</h3>
1.85      jmmv     1309: <p>You cannot use an ordinary HFS+ file system for pkgsrc, because pkgsrc currently
1.89      rillig   1310:          requires the file system to be case-sensitive. You can, however, use a case-sensitive HFS+ (aka HFSX) file system as found in Darwin 7.0 and newer.</p>
1.75      rillig   1311: </div>
                   1312: <div class="sect3" lang="en">
                   1313: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1314: <a name="platform.osx-image"></a>3.3.1.1. Using a disk image</h4></div></div></div>
1.75      rillig   1315: <p>Create the disk image:</p>
                   1316: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1.85      jmmv     1317: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
                   1318: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage mount ~/Documents/NetBSD</code></strong>
1.75      rillig   1319: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
1.85      jmmv     1320: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1321: <h3 class="title">Note</h3>
1.89      rillig   1322: <p>darwindiskimage will mount the filesystem nosuid, which will cause problems for packages that depend on setgid.  In the case of UFS, it will also mount the filesystem asynchronous, which is somewhat dangerous according to the mount(8) man page.  In the case of HFSX, it will disable journalling.</p>
1.85      jmmv     1323: </div>
1.89      rillig   1324: <p>Allow suid:</p>
                   1325: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sudo mount -u -o suid /Volumes/NetBSD</code></strong></pre>
1.75      rillig   1326: </div>
                   1327: <div class="sect3" lang="en">
                   1328: <div class="titlepage"><div><div><h4 class="title">
1.89      rillig   1329: <a name="platform.osx-part"></a>3.3.1.2. Using a UFS or HFSX partition</h4></div></div></div>
1.76      rillig   1330: <p>By default, <code class="filename">/usr</code> will be on your root file
1.87      wiz      1331:        system, normally HFS+. It is possible to use the default
                   1332:        <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
                   1333:        by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1.89      rillig   1334:        or HFSX file system. Obviously, another symlink is required if you want to
1.87      wiz      1335:        place the package database directory outside the
                   1336:        <span class="emphasis"><em>prefix</em></span>. e.g.</p>
1.75      rillig   1337: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
                   1338: <p>If you created your partitions at the time of installing Mac OS X
1.89      rillig   1339:        and formatted the target partition as UFS or HFSX, it should automatically
1.87      wiz      1340:        mount on <code class="filename">/Volumes/&lt;volume name&gt;</code> when the
1.89      rillig   1341:        machine boots. If you are (re)formatting a partition as UFS or HFSX, you need
1.87      wiz      1342:        to ensure that the partition map correctly reflects
1.89      rillig   1343:        &#8220;<span class="quote">Apple_UFS</span>&#8221; or &#8220;<span class="quote">Apple_HFSX</span>&#8221; and not &#8220;<span class="quote">Apple_HFS</span>&#8221;.</p>
1.75      rillig   1344: <p>The problem is that none of the disk tools will let you touch a
1.87      wiz      1345:        disk that is booted from. You can unmount the partition, but even if
                   1346:        you newfs it, the partition type will be incorrect and the
                   1347:        automounter won't mount it. It can be mounted manually, but it won't
                   1348:        appear in Finder.</p>
1.75      rillig   1349: <p>You'll need to boot off of the OS X Installation (User) CD.  When
1.87      wiz      1350:        the Installation program starts, go up to the menu and select Disk
                   1351:        Utility.  Now, you will be able to select the partition you want
1.89      rillig   1352:        to be UFS or HFSX, and Format it Apple UFS or HFSX. Quit the Disk Utility, quit the
                   1353:        installer which will reboot your machine. The new UFS or HFSX file system
1.87      wiz      1354:        will appear in Finder.</p>
1.75      rillig   1355: <p>Be aware that the permissions on the new file system will be writable
1.87      wiz      1356:        by root only.</p>
1.75      rillig   1357: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
1.87      wiz      1358:        Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
1.75      rillig   1359: </div>
                   1360: </div>
                   1361: <div class="sect2" lang="en">
                   1362: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1363: <a name="freebsd"></a>3.3.2. FreeBSD</h3></div></div></div>
1.87      wiz      1364: <p>FreeBSD 4.7 and 5.0 have been tested and are supported,
                   1365:       other versions may work.</p>
1.75      rillig   1366: <p>Care should be taken so that the tools that this kit installs do not conflict
1.87      wiz      1367:       with the FreeBSD userland tools. There are several steps:</p>
1.75      rillig   1368: <div class="orderedlist"><ol type="1">
                   1369: <li><p>FreeBSD stores its ports pkg database in
1.87      wiz      1370:          <code class="filename">/var/db/pkg</code>. It is therefore
                   1371:          recommended that you choose a different location (e.g.
                   1372:          <code class="filename">/usr/pkgdb</code>) by
                   1373:          using the --pkgdbdir option to the bootstrap script.</p></li>
1.75      rillig   1374: <li>
                   1375: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
1.87      wiz      1376:          good idea to move them out of the way to avoid confusion, e.g.</p>
                   1377: <pre class="screen">
                   1378: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1.75      rillig   1379: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
                   1380: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
                   1381: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1.87      wiz      1382: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
                   1383:          </pre>
1.75      rillig   1384: </li>
1.76      rillig   1385: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1.87      wiz      1386:          <code class="filename">/etc/mk.conf.example</code> file
                   1387:          when you use the bootstrap script.</p></li>
1.75      rillig   1388: </ol></div>
                   1389: </div>
                   1390: <div class="sect2" lang="en">
                   1391: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1392: <a name="interix"></a>3.3.3. Interix</h3></div></div></div>
1.75      rillig   1393: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
1.87      wiz      1394:       providing a Unix-like environment with a tighter kernel integration than
                   1395:       available with Cygwin.  It is part of the Windows Services for Unix
                   1396:       package, available for free for any licensed copy of Windows 2000, XP
                   1397:       (not including XP Home), or 2003.  SFU can be downloaded from <a href="http://www.microsoft.com/windows/sfu/" target="_top">http://www.microsoft.com/windows/sfu/</a>.</p>
1.75      rillig   1398: <p>Services for Unix 3.5, current as of this writing, has been tested.  3.0
1.87      wiz      1399:       or 3.1 may work, but are not officially supported.  (The main difference
                   1400:       in 3.0/3.1 is lack of pthreads.)</p>
1.75      rillig   1401: <div class="sect3" lang="en">
                   1402: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1403: <a name="platform.interix-sfu-install"></a>3.3.3.1. When installing Interix/SFU</h4></div></div></div>
1.75      rillig   1404: <p>At an absolute minimum, the following packages must be installed from
1.87      wiz      1405:        the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
1.75      rillig   1406: <div class="itemizedlist"><ul type="disc">
                   1407: <li><p>Utilities -&gt; Base Utilities</p></li>
                   1408: <li><p>Interix GNU Components -&gt; (all)</p></li>
                   1409: <li><p>Remote Connectivity</p></li>
                   1410: <li><p>Interix SDK</p></li>
                   1411: </ul></div>
                   1412: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1.87      wiz      1413:        "UNIX Perl".  That is Perl 5.6 without shared module support, installed to
                   1414:        /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
                   1415:        pkgsrc (or from a binary package).</p>
1.75      rillig   1416: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1.87      wiz      1417:        not need to be installed, but Remote Connectivity itself should be
                   1418:        installed in order to have a working inetd.</p>
1.75      rillig   1419: <p>During installation you may be asked whether to enable setuid
1.87      wiz      1420:        behavior for Interix programs, and whether to make pathnames default to
                   1421:        case-sensitive.  Setuid should be enabled, and case-sensitivity MUST be
                   1422:        enabled.  (Without case-sensitivity, a large number of packages including
                   1423:        perl will not build.)</p>
1.75      rillig   1424: <p>NOTE:  Newer Windows service packs change the way binary execution
1.87      wiz      1425:        works (via the Data Execution Prevention feature).  In order to use
                   1426:        pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
                   1427:        POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
                   1428:        must be installed.  Hotfixes are available from Microsoft through a
                   1429:        support contract; however, a NetBSD developer has made most Interix
                   1430:        hotfixes available for personal use from <a href="http://www.duh.org/interix/hotfixes.php" target="_top">http://www.duh.org/interix/hotfixes.php</a>.</p>
1.75      rillig   1431: </div>
                   1432: <div class="sect3" lang="en">
                   1433: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1434: <a name="platform.interix-sfu-postinstall"></a>3.3.3.2. What to do if Interix/SFU is already installed</h4></div></div></div>
1.75      rillig   1435: <p>If SFU is already installed and you wish to alter these settings to work
1.87      wiz      1436:        with pkgsrc, note the following things.</p>
1.75      rillig   1437: <div class="itemizedlist"><ul type="disc">
                   1438: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1.87      wiz      1439:            Windows Services for UNIX, then click Change.  In the installer, choose
                   1440:            Add or Remove, then uncheck Utilities-&gt;UNIX Perl.</p></li>
1.75      rillig   1441: <li>
                   1442: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1.87      wiz      1443:            change the following registry key:</p>
1.75      rillig   1444: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
                   1445: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
                   1446: </li>
                   1447: <li>
                   1448: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1.87      wiz      1449:            following registry key:</p>
1.75      rillig   1450: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
                   1451: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
                   1452: </li>
                   1453: </ul></div>
                   1454: </div>
                   1455: <div class="sect3" lang="en">
                   1456: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1457: <a name="platform.interix-notes"></a>3.3.3.3. Important notes for using pkgsrc</h4></div></div></div>
1.75      rillig   1458: <p>The package manager (either the pkgsrc "su" user, or the user
1.87      wiz      1459:        running "pkg_add") must be a member of the local Administrators
                   1460:        group.  Such a user must also be used to run the bootstrap.  This is
                   1461:        slightly relaxed from the normal pkgsrc requirement of "root".</p>
1.75      rillig   1462: <p>The package manager should use a umask of 002.  "make install" will
1.87      wiz      1463:        automatically complain if this is not the case.  This ensures that
                   1464:        directories written in /var/db/pkg are Administrators-group writeable.</p>
1.75      rillig   1465: <p>The popular Interix binary packages from http://www.interopsystems.com/
1.87      wiz      1466:        use an older version of pkgsrc's pkg_* tools.  Ideally, these should
                   1467:        NOT be used in conjunction with pkgsrc.  If you choose to use them at
                   1468:        the same time as the pkgsrc packages, ensure that you use the proper
                   1469:        pkg_* tools for each type of binary package.</p>
1.75      rillig   1470: <p>The TERM setting used for DOS-type console windows (including those
1.87      wiz      1471:        invoked by the csh and ksh startup shortcuts) is "interix".  Most systems
                   1472:        don't have a termcap/terminfo entry for it, but the following .termcap
                   1473:        entry provides adequate emulation in most cases:</p>
1.75      rillig   1474: <pre class="programlisting">
1.87      wiz      1475:          interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
                   1476:        </pre>
1.75      rillig   1477: </div>
                   1478: <div class="sect3" lang="en">
                   1479: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1480: <a name="platform.interix-limits"></a>3.3.3.4. Limitations of the Interix platform</h4></div></div></div>
1.75      rillig   1481: <p>Though Interix suffices as a familiar and flexible substitute
1.87      wiz      1482:        for a full Unix-like platform, it has some drawbacks that should
                   1483:        be noted for those desiring to make the most of Interix.</p>
1.75      rillig   1484: <div class="itemizedlist"><ul type="disc">
                   1485: <li>
                   1486: <p><span class="strong"><strong>X11:</strong></span></p>
                   1487: <p>Interix comes with the standard set of X11R6 client libraries,
1.87      wiz      1488:          and can run X11 based applications, but it does
                   1489:          <span class="emphasis"><em>not</em></span> come with an X server.  Some options are
                   1490:          <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
                   1491:          <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
                   1492:          (available in a trimmed version for Interix from Interop Systems as the
                   1493:          <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
                   1494:          and the free X11 server included with
                   1495:          <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1.75      rillig   1496: <p>Also, StarNet Communications has graciously provided a free
1.87      wiz      1497:          version of their X-Win32 product that accepts connections only
                   1498:          from localhost:
                   1499:          <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
                   1500:          recommended by the maintainer of Interix pkgsrc support.</p>
1.75      rillig   1501: </li>
                   1502: <li>
                   1503: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
                   1504: <p>Because Interix runs in a completely different NT subsystem from
1.87      wiz      1505:          Win32 applications, it does not currently support various X11
                   1506:          protocol extensions for acceleration (such as MIT-SHM or DGA).
                   1507:          Most interactive applications to a local X server will run
                   1508:          reasonably fast, but full motion video and other graphics
                   1509:          intensive applications may require a faster-than-expected CPU.</p>
1.75      rillig   1510: </li>
                   1511: <li>
                   1512: <p><span class="strong"><strong>Audio:</strong></span></p>
                   1513: <p>Interix has no native support for audio output.  For audio
1.87      wiz      1514:          support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
                   1515:          audio system on Interix.  Unlike on most platforms, the
1.91      rillig   1516:          <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/esound/README.html" target="_top"><code class="filename">audio/esound</code></a> package does
1.87      wiz      1517:          <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
                   1518:          server component.  To output audio via an Interix host, the
1.91      rillig   1519:          <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/emulators/cygwin_esound/README.html" target="_top"><code class="filename">emulators/cygwin_esound</code></a> package
1.87      wiz      1520:          must also be installed.</p>
1.75      rillig   1521: </li>
                   1522: <li>
                   1523: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
                   1524: <p>Direct device access is not currently supported in Interix, so it
1.87      wiz      1525:          is not currently possible to access CD/DVD drives, USB devices,
                   1526:          or SCSI devices through non-filesystem means.  Among other things,
                   1527:          this makes it impossible to use Interix directly for CD/DVD
                   1528:          burning.</p>
1.75      rillig   1529: </li>
                   1530: <li>
                   1531: <p><span class="strong"><strong>Tape drives:</strong></span></p>
                   1532: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1.87      wiz      1533:          drives are also not directly accessible in Interix.  However,
                   1534:          support is in work to make tape drive access possible by using
                   1535:          Cygwin as a bridge (similarly to audio bridged via Cygwin's
                   1536:          esound server).</p>
1.75      rillig   1537: </li>
                   1538: </ul></div>
                   1539: </div>
                   1540: <div class="sect3" lang="en">
                   1541: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1542: <a name="platform.interix-knownissues"></a>3.3.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1.75      rillig   1543: <p>It is not necessary, in general, to have a "root" user on the
1.87      wiz      1544:        Windows system; any member of the local Administrators group will
                   1545:        suffice.  However, some packages currently assume that the user
                   1546:        named "root" is the privileged user.  To accommodate these, you
                   1547:        may create such a user; make sure it is in the local group
                   1548:        Administrators (or your language equivalent).</p>
                   1549: <p><span><strong class="command">pkg_add</strong></span> creates directories of mode
                   1550:        0755, not 0775, in <code class="filename">$PKG_DBDIR</code>.  For the
                   1551:        time being, install packages as the local Administrator (or
                   1552:        your language equivalent), or run the following command after
                   1553:        installing a package to work around the issue:</p>
1.75      rillig   1554: <pre class="screen">
1.87      wiz      1555: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong>
                   1556:        </pre>
1.75      rillig   1557: </div>
                   1558: </div>
                   1559: <div class="sect2" lang="en">
                   1560: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1561: <a name="irix"></a>3.3.4. IRIX</h3></div></div></div>
1.75      rillig   1562: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1.87      wiz      1563:       compiler (cc/c89).  Please set the <code class="varname">CC</code> environment variable
                   1564:       according to your preference.  If you do not have a license for the MIPSpro
                   1565:       compiler suite, you can download a gcc tardist file from <a href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
1.75      rillig   1566: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1.87      wiz      1567:       version of IRIX providing support for <a href="http://netbsd.gw.com/cgi-bin/man-cgi?if_indextoname+3+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">if_indextoname</span>(3)</span></a>, <a href="http://netbsd.gw.com/cgi-bin/man-cgi?if_nametoindex+3+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">if_nametoindex</span>(3)</span></a>,
                   1568:       etc.</p>
1.86      schwarz  1569: <p>At this point in time, pkgsrc only supports one ABI at a time.  That is, you cannot
1.75      rillig   1570:        switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI.  If
                   1571:        you start out using "abi=n32", that's what all your packages will be built
                   1572:        with.</p>
                   1573: <p>Therefore, please make sure that you have no conflicting
1.87      wiz      1574:       <code class="varname">CFLAGS</code> in your environment or the
                   1575:       <code class="filename">/etc/mk.conf</code>.  Particularly, make sure that you do not
                   1576:       try to link n32 object files with lib64 or vice versa.  Check your
                   1577:       <code class="filename">/etc/compiler.defaults</code>!</p>
1.75      rillig   1578: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1.87      wiz      1579:       please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
                   1580:       as it appears that IRIX linker occasionally runs into issues when trying to
                   1581:       link over a network-mounted file system.</p>
1.75      rillig   1582: <p>The bootstrapping process should set all the right options for programs such
1.87      wiz      1583:       as imake(1), but you may want to set some options depending on your local
                   1584:       setup.  Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
                   1585:       course, your compiler's man pages for details.</p>
1.75      rillig   1586: <p>If you are using SGI's MIPSPro compiler, please set
1.1       grant    1587: 
1.87      wiz      1588:       </p>
1.75      rillig   1589: <pre class="programlisting">
1.87      wiz      1590:        PKGSRC_COMPILER=        mipspro
                   1591:       </pre>
1.75      rillig   1592: <p>
1.1       grant    1593: 
1.87      wiz      1594:       in <code class="filename">/etc/mk.conf</code>.  Otherwise, pkgsrc will assume you
                   1595:       are using gcc and may end up passing invalid flags to the compiler.  Note that
                   1596:       bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
                   1597:       default.</p>
1.75      rillig   1598: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1.87      wiz      1599:       but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
                   1600:       to <span class="emphasis"><em>not</em></span> include the location of gcc (often
                   1601:       <code class="filename">/usr/freeware/bin</code>), and (important) pass the
                   1602:       '--preserve-path' flag.</p>
1.75      rillig   1603: </div>
                   1604: <div class="sect2" lang="en">
                   1605: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1606: <a name="linux"></a>3.3.5. Linux</h3></div></div></div>
1.87      wiz      1607: <p>Some versions of Linux (for example Debian GNU/Linux) need
                   1608:       either libtermcap or libcurses (libncurses).  Installing the
                   1609:       distributions libncurses-dev package (or equivalent) should fix
                   1610:       the problem.</p>
                   1611: <p>pkgsrc supports both gcc (GNU Compiler Collection) and icc
                   1612:       (Intel C++ Compiler). gcc is the default. icc 8.0 and 8.1 on
                   1613:       i386 have been tested.</p>
1.75      rillig   1614: <p>To bootstrap using icc, assuming the default icc installation
1.87      wiz      1615:       directory:</p>
1.75      rillig   1616: <pre class="programlisting">
1.87      wiz      1617:        env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
                   1618:        ac_cv___attribute__=yes ./bootstrap
                   1619:       </pre>
1.75      rillig   1620: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1621: <h3 class="title">Note</h3>
                   1622: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
                   1623: </div>
                   1624: <p>icc supports __attribute__, but the GNU configure test uses a nested
1.87      wiz      1625:       function, which icc does not support. #undef'ing __attribute__ has the
                   1626:       unfortunate side-effect of breaking many of the Linux header files, which
                   1627:       cannot be compiled properly without __attribute__. The test must be
                   1628:       overridden so that __attribute__ is assumed supported by the
                   1629:       compiler.</p>
1.75      rillig   1630: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.87      wiz      1631:       in <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   1632: <pre class="programlisting">
1.87      wiz      1633:        PKGSRC_COMPILER=        icc
                   1634:       </pre>
1.75      rillig   1635: <p>The default installation directory for icc is
1.87      wiz      1636:       <code class="filename">/opt/intel_cc_80</code>, which
                   1637:       is also the pkgsrc default. If you have installed it into a different
                   1638:       directory, set <code class="varname">ICCBASE</code> in
                   1639:       <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   1640: <pre class="programlisting">
1.87      wiz      1641:        ICCBASE=                /opt/icc
                   1642:       </pre>
1.75      rillig   1643: <p>pkgsrc uses the static linking method of the runtime libraries
1.87      wiz      1644:       provided by icc, so binaries can be run on other systems which do not
                   1645:       have the shared libraries installed.</p>
                   1646: <p>Libtool, however, extracts a list of libraries from the
                   1647:       <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ld+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ld</span>(1)</span></a> command run when linking a C++ shared library and
                   1648:       records it, throwing away the -Bstatic and -Bdynamic options
                   1649:       interspersed between the libraries.  This means that
                   1650:       libtool-linked C++ shared libraries will have a runtime
                   1651:       dependency on the icc libraries until this is fixed in
                   1652:       libtool.</p>
1.75      rillig   1653: </div>
                   1654: <div class="sect2" lang="en">
                   1655: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1656: <a name="openbsd"></a>3.3.6. OpenBSD</h3></div></div></div>
1.75      rillig   1657: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
                   1658: <p>Care should be taken so that the tools that this kit installs do not conflict
1.87      wiz      1659:       with the OpenBSD userland tools. There are several steps:</p>
1.75      rillig   1660: <div class="orderedlist"><ol type="1">
                   1661: <li><p>OpenBSD stores its ports pkg database in
1.87      wiz      1662:          <code class="filename">/var/db/pkg</code>. It is therefore
                   1663:          recommended that you choose a different location (e.g.
                   1664:          <code class="filename">/usr/pkgdb</code>) by
                   1665:          using the --pkgdbdir option to the bootstrap script.</p></li>
1.75      rillig   1666: <li>
                   1667: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1.87      wiz      1668:          good idea to move them out of the way to avoid confusion, e.g.</p>
                   1669: <pre class="screen">
                   1670: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1.75      rillig   1671: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
                   1672: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
                   1673: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1.87      wiz      1674: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
                   1675:          </pre>
1.75      rillig   1676: </li>
                   1677: <li>
1.76      rillig   1678: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1.87      wiz      1679:          <code class="filename">/etc/mk.conf.example</code> file
                   1680:          when you use the bootstrap script. OpenBSD's make program uses
                   1681:          <code class="filename">/etc/mk.conf</code>
                   1682:          as well. You can work around this by enclosing all the pkgsrc-specific parts
                   1683:          of the file with:</p>
                   1684: <pre class="programlisting">
                   1685:            .ifdef BSD_PKG_MK
                   1686:            # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
                   1687:            .else
                   1688:            # OpenBSD stuff
                   1689:            .endif
                   1690:          </pre>
1.75      rillig   1691: </li>
                   1692: </ol></div>
                   1693: </div>
                   1694: <div class="sect2" lang="en">
                   1695: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1696: <a name="solaris"></a>3.3.7. Solaris</h3></div></div></div>
1.75      rillig   1697: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
1.87      wiz      1698:       You will need a working C compiler. Both gcc 2.95.3 and
                   1699:       Sun WorkShop 5 have been tested.</p>
1.75      rillig   1700: <p>The following packages are required on Solaris 8 for the bootstrap
1.87      wiz      1701:       process and to build packages.</p>
1.75      rillig   1702: <div class="itemizedlist"><ul type="disc">
                   1703: <li><p>SUNWsprot</p></li>
                   1704: <li><p>SUNWarc</p></li>
                   1705: <li><p>SUNWbtool</p></li>
                   1706: <li><p>SUNWtoo</p></li>
                   1707: <li><p>SUNWlibm</p></li>
                   1708: </ul></div>
1.78      rillig   1709: <p>Please note that the use of GNU binutils on Solaris is
1.87      wiz      1710:       <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1.75      rillig   1711: <p>Whichever compiler you use, please ensure the compiler tools and
1.87      wiz      1712:       your $prefix are in your <code class="varname">PATH</code>. This includes
                   1713:       <code class="filename">/usr/ccs/{bin,lib}</code>
                   1714:       and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75      rillig   1715: <div class="sect3" lang="en">
                   1716: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1717: <a name="solaris-gcc-note"></a>3.3.7.1. If you are using gcc</h4></div></div></div>
1.75      rillig   1718: <p>It makes life much simpler if you only use the same gcc consistently
1.87      wiz      1719:        for building all packages.</p>
1.75      rillig   1720: <p>It is recommended that an external gcc be used only for bootstrapping,
1.87      wiz      1721:        then either build gcc from
1.91      rillig   1722:        <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/lang/gcc/README.html" target="_top"><code class="filename">lang/gcc</code></a> or install a binary gcc
1.87      wiz      1723:        package, then remove gcc used during bootstrapping.</p>
1.75      rillig   1724: <p>Binary packages of gcc can be found through <a href="http://www.sun.com/bigadmin/common/freewareSearch.html" target="_top">http://www.sun.com/bigadmin/common/freewareSearch.html</a>.</p>
                   1725: </div>
                   1726: <div class="sect3" lang="en">
                   1727: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1728: <a name="solaris-sun-workshop-note"></a>3.3.7.2. If you are using Sun WorkShop</h4></div></div></div>
1.75      rillig   1729: <p>You will need at least the following packages installed (from WorkShop
1.87      wiz      1730:        5.0)</p>
1.75      rillig   1731: <div class="itemizedlist"><ul type="disc">
                   1732: <li><p>SPROcc
1.87      wiz      1733:          - Sun WorkShop Compiler C 5.0</p></li>
1.75      rillig   1734: <li><p>SPROcpl
1.87      wiz      1735:          - Sun WorkShop Compiler C++ 5.0</p></li>
1.75      rillig   1736: <li><p>SPROild
1.87      wiz      1737:          - Sun WorkShop Incremental Linker</p></li>
1.75      rillig   1738: <li><p>SPROlang
1.87      wiz      1739:          - Sun WorkShop Compilers common components</p></li>
1.75      rillig   1740: </ul></div>
                   1741: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.87      wiz      1742:        optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
                   1743:        e.g.:</p>
1.75      rillig   1744: <pre class="programlisting">
1.87      wiz      1745:          CC=     cc
                   1746:          CXX=    CC
                   1747:          CPP=    /usr/ccs/lib/cpp
                   1748:        </pre>
1.75      rillig   1749: </div>
                   1750: <div class="sect3" lang="en">
                   1751: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1752: <a name="solaris-sunpro-64"></a>3.3.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1.75      rillig   1753: <p>Building 64-bit binaries is a little trickier. First, you
                   1754:        need to bootstrap pkgsrc in 64-bit mode. One problem here is
                   1755:        that while building one of the programs in the bootstrap kit
1.76      rillig   1756:        (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75      rillig   1757:        variable is not honored, even if it is set in the environment.
                   1758:        To work around this bug, you can create a simple shell script
1.76      rillig   1759:        called <code class="filename">cc64</code> and put it somewhere in the
1.75      rillig   1760:        <code class="varname">PATH</code>:</p>
                   1761: <pre class="programlisting">
1.87      wiz      1762:          #! /bin/sh
                   1763:          exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
                   1764:        </pre>
1.75      rillig   1765: <p>Then, pass the definition for <code class="varname">CC</code> in the
                   1766:        environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
                   1767: <pre class="programlisting">
1.87      wiz      1768:          <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
                   1769:          <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
                   1770:        </pre>
1.75      rillig   1771: <p>After bootstrapping, there are two alternative ways,
                   1772:        depending on whether you want to find bugs in packages or get
                   1773:        your system ready quickly. If you just want a running system,
1.76      rillig   1774:        add the following lines to your <code class="filename">mk.conf</code>
1.75      rillig   1775:        file:</p>
                   1776: <pre class="programlisting">
1.87      wiz      1777:          CC=                     cc64
                   1778:          CXX=                    CC64
                   1779:          PKGSRC_COMPILER=        sunpro
                   1780:        </pre>
1.75      rillig   1781: <p>This way, all calls to the compiler will be intercepted by
                   1782:        the above wrapper and therefore get the necessary ABI options
                   1783:        automatically. (Don't forget to create the shell script
1.76      rillig   1784:        <code class="filename">CC64</code>, too.)</p>
1.75      rillig   1785: <p>To find packages that ignore the user-specified
                   1786:        <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76      rillig   1787:        the following lines to your <code class="filename">mk.conf</code>
1.75      rillig   1788:        file:</p>
                   1789: <pre class="programlisting">
1.87      wiz      1790:          CC=                     cc
                   1791:          CXX=                    CC
                   1792:          PKGSRC_COMPILER=        sunpro
                   1793:          CFLAGS=                 -xtarget=ultra -xarch=v9
                   1794:          CXXFLAGS=               -xtarget=ultra -xarch=v9
                   1795:          LDFLAGS=                -xtarget=ultra -xarch=v9
                   1796:        </pre>
1.75      rillig   1797: <p>Packages that don't use the flags provided in the
                   1798:        configuration file will try to build 32-bit binaries and fail
                   1799:        during linking. Detecting this is useful to prevent bugs on
                   1800:        other platforms where the error would not show up but pass
                   1801:        silently.</p>
                   1802: </div>
                   1803: <div class="sect3" lang="en">
                   1804: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1805: <a name="plat.sunos.problems"></a>3.3.7.4. Common problems</h4></div></div></div>
1.75      rillig   1806: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.87      wiz      1807:       <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
                   1808:       The workaround is to use another shell for the configure
1.91      rillig   1809:       scripts, for example by installing <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a> and adding the following lines
1.87      wiz      1810:       to your <code class="filename">mk.conf</code>:</p>
                   1811: <pre class="programlisting">
                   1812:        CONFIG_SHELL=   ${LOCALBASE}/bin/bash
                   1813:        WRAPPER_SHELL=  ${LOCALBASE}/bin/bash
                   1814:       </pre>
1.91      rillig   1815: <p>Then, rebuild the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/libtool-base/README.html" target="_top"><code class="filename">devel/libtool-base</code></a> package.</p>
1.75      rillig   1816: </div>
                   1817: </div>
                   1818: </div>
                   1819: </div>
                   1820: <div class="chapter" lang="en">
                   1821: <div class="titlepage"><div><div><h2 class="title">
                   1822: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
                   1823: <div class="toc">
                   1824: <p><b>Table of Contents</b></p>
                   1825: <dl>
                   1826: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                   1827: <dd><dl>
                   1828: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                   1829: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82      rillig   1830: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
                   1831: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
                   1832: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
                   1833: <dt><span class="sect2"><a href="#pkg_versions">4.1.6. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
                   1834: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
                   1835: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75      rillig   1836: </dl></dd>
                   1837: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                   1838: <dd><dl>
                   1839: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                   1840: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                   1841: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                   1842: </dl></dd>
                   1843: </dl>
                   1844: </div>
                   1845: <p>Basically, there are two ways of using pkgsrc. The first
1.88      wiz      1846: is to only install the package tools and to use binary packages
                   1847: that someone else has prepared. This is the &#8220;<span class="quote">pkg</span>&#8221;
                   1848: in pkgsrc. The second way is to install the &#8220;<span class="quote">src</span>&#8221;
                   1849: of pkgsrc, too. Then you are able to build your own packages,
                   1850: and you can still use binary packages from someone else.</p>
1.75      rillig   1851: <div class="sect1" lang="en">
                   1852: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1853: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
                   1854: <p>To use binary packages, you need some tools to manage
1.88      wiz      1855:   them. On NetBSD, these tools are already installed. On all other
                   1856:   operating systems, you need to install them first. For the
                   1857:   following platforms, prebuilt versions of the package tools
                   1858:   are available and can simply be downloaded and unpacked in the
                   1859:   <code class="filename">/</code> directory:</p>
1.75      rillig   1860: <div class="informaltable">
                   1861: <a name="binary-bootstrap-kits"></a><table border="1">
                   1862: <colgroup>
                   1863: <col>
                   1864: <col>
                   1865: </colgroup>
                   1866: <thead><tr>
                   1867: <th>Platform</th>
                   1868: <th>URL</th>
                   1869: </tr></thead>
                   1870: <tbody>
                   1871: <tr>
                   1872: <td>Solaris 9</td>
1.76      rillig   1873: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75      rillig   1874: </tr>
                   1875: <tr>
                   1876: <td>Solaris 10</td>
1.76      rillig   1877: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75      rillig   1878: </tr>
                   1879: </tbody>
                   1880: </table>
                   1881: </div>
1.82      rillig   1882: <p>These pre-built package tools use
1.88      wiz      1883:   <code class="filename">/usr/pkg</code> for the base directory, and
                   1884:   <code class="filename">/var/db/pkg</code> for the database of installed
                   1885:   packages. If you cannot use these directories for whatever
                   1886:   reasons (maybe because you're not root), you have to build the
                   1887:   package tools yourself, which is explained in <a href="#bootstrapping-pkgsrc" title="3.2. Bootstrapping pkgsrc">Section 3.2, &#8220;Bootstrapping pkgsrc&#8221;</a>.</p>
1.75      rillig   1888: <div class="sect2" lang="en">
                   1889: <div class="titlepage"><div><div><h3 class="title">
                   1890: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
                   1891: <p>To install binary packages, you first need to know from
1.88      wiz      1892:     where to get them. You can get them on CD-ROMs, DVDs, or via FTP
                   1893:     or HTTP.</p>
1.81      rillig   1894: <p>The binary packages can be found at the following
1.88      wiz      1895:     locations.</p>
1.75      rillig   1896: <div class="informaltable">
                   1897: <a name="binary-packages"></a><table border="1">
                   1898: <colgroup>
                   1899: <col>
                   1900: <col>
                   1901: </colgroup>
                   1902: <thead><tr>
                   1903: <th>Platform</th>
                   1904: <th>URL</th>
                   1905: </tr></thead>
                   1906: <tbody>
                   1907: <tr>
1.81      rillig   1908: <td>NetBSD</td>
                   1909: <td><code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/</code></td>
                   1910: </tr>
                   1911: <tr>
1.75      rillig   1912: <td>Solaris 9</td>
1.76      rillig   1913: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75      rillig   1914: </tr>
                   1915: <tr>
                   1916: <td>Solaris 10</td>
1.76      rillig   1917: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75      rillig   1918: </tr>
                   1919: </tbody>
                   1920: </table>
                   1921: </div>
1.81      rillig   1922: <p>Most of these directories contain binary packages for
1.88      wiz      1923:     multiple platforms. Select the appropriate subdirectories,
                   1924:     according to your machine architecture and operating system,
                   1925:     until you find a directory called <code class="filename">All</code>. This
                   1926:     directory contains all the binary packages. Further, there are
                   1927:     subdirectories for categories that contain symbolic links that
                   1928:     point to the actual binary package in
                   1929:     <code class="filename">../All</code>. This directory layout is used for
                   1930:     all package repositories, no matter if they are accessed via
                   1931:     HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
1.75      rillig   1932: </div>
                   1933: <div class="sect2" lang="en">
                   1934: <div class="titlepage"><div><div><h3 class="title">
                   1935: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1.87      wiz      1936: <p>If you have the files on a CD-ROM or downloaded them to
1.88      wiz      1937:     your hard disk, you can install them with the following command
                   1938:     (be sure to <span><strong class="command">su</strong></span> to root first):</p>
1.75      rillig   1939: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
1.87      wiz      1940: <p>If you have FTP access and you don't want to download the
1.88      wiz      1941:     packages via FTP prior to installation, you can do this
                   1942:     automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:</p>
1.82      rillig   1943: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add ftp://ftp.NetBSD.org/pub/NetBSD/packages/&lt;OSVERSION&gt;/&lt;ARCH&gt;/All/package</code></strong></pre>
1.75      rillig   1944: <p>Note that any prerequisite packages needed to run the
1.88      wiz      1945:     package in question will be installed, too, assuming they are
                   1946:     present where you install from.</p>
1.75      rillig   1947: <p>To save some typing, you can set the
1.88      wiz      1948:     <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
                   1949:     list of paths (including remote URLs); trailing slashes are not allowed.
                   1950:     </p>
1.76      rillig   1951: <p>Additionally to the <code class="filename">All</code> directory
1.88      wiz      1952:     there exists a <code class="filename">vulnerable</code> directory to
                   1953:     which binary packages with known vulnerabilities are
                   1954:     moved, since removing them could cause missing dependencies. To
                   1955:     use these packages, add the <code class="filename">vulnerable</code>
                   1956:     directory to your <code class="varname">PKG_PATH</code>. However, you should run
1.91      rillig   1957:     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> regularly,
1.88      wiz      1958:     especially after installing new packages, and verify that the
                   1959:     vulnerabilities are acceptable for your configuration. An example
                   1960:     <code class="varname">PKG_PATH</code> would be:
                   1961:     <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/&lt;OSVERSION&gt;/&lt;ARCH&gt;/All;ftp://ftp.NetBSD.org/pub/NetBSD/packages/&lt;OSVERSION&gt;/&lt;ARCH&gt;/vulnerable</code>
                   1962:     Please note that semicolon (';') is a shell meta-character, so
                   1963:     you'll probably have to quote it.</p>
1.75      rillig   1964: <p>After you've installed packages, be sure to have
1.88      wiz      1965:     <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
                   1966:     <code class="varname">PATH</code> so you can actually start the just
                   1967:     installed program.</p>
1.75      rillig   1968: </div>
                   1969: <div class="sect2" lang="en">
                   1970: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1971: <a name="using.pkg_delete"></a>4.1.3. Deinstalling packages</h3></div></div></div>
                   1972: <p>To deinstall a package, it does not matter whether it was
1.88      wiz      1973:     installed from source code or from a binary package. The
                   1974:     <span><strong class="command">pkg_delete</strong></span> command does not know it anyway.
                   1975:     To delete a package, you can just run <span><strong class="command">pkg_delete
                   1976:     <em class="replaceable"><code>package-name</code></em></strong></span>. The package
                   1977:     name can be given with or without version number. Wildcards can
                   1978:     also be used to deinstall a set of packages, for example
                   1979:     <code class="literal">*emacs*</code>. Be sure to include them in quotes,
                   1980:     so that the shell does not expand them before
                   1981:     <code class="literal">pkg_delete</code> sees them.</p>
1.82      rillig   1982: <p>The <code class="option">-r</code> option is very powerful: it
1.88      wiz      1983:     removes all the packages that require the package in question
                   1984:     and then removes the package itself. For example:
1.82      rillig   1985: 
1.88      wiz      1986:     </p>
1.82      rillig   1987: <pre class="screen">
1.88      wiz      1988: <code class="prompt">#</code> <strong class="userinput"><code>pkg_delete -r jpeg</code></strong>
                   1989:     </pre>
1.82      rillig   1990: <p>
                   1991: 
1.88      wiz      1992:     will remove jpeg and all the packages that used it; this allows
                   1993:     upgrading the jpeg package.</p>
1.82      rillig   1994: </div>
                   1995: <div class="sect2" lang="en">
                   1996: <div class="titlepage"><div><div><h3 class="title">
                   1997: <a name="using.pkg_info"></a>4.1.4. Getting information about installed packages</h3></div></div></div>
                   1998: <p>The <span><strong class="command">pkg_info</strong></span> shows information about
1.88      wiz      1999:     installed packages or binary package files.</p>
1.82      rillig   2000: </div>
                   2001: <div class="sect2" lang="en">
                   2002: <div class="titlepage"><div><div><h3 class="title">
                   2003: <a name="vulnerabilities"></a>4.1.5. Checking for security vulnerabilities in installed packages</h3></div></div></div>
                   2004: <p>
1.88      wiz      2005:       The NetBSD Security-Officer and Packages Groups maintain a list of
                   2006:       known security vulnerabilities to packages which are (or have been)
                   2007:       included in pkgsrc.  The list is available from the NetBSD
                   2008:       FTP site at <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities</a>.
                   2009:     </p>
1.82      rillig   2010: <p>
1.91      rillig   2011:       Through <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>, 
1.88      wiz      2012:       this list can be downloaded
                   2013:       automatically, and a security audit of all packages installed on a system
                   2014:       can take place.
                   2015:     </p>
1.82      rillig   2016: <p>
1.88      wiz      2017:       There are two components to 
1.91      rillig   2018:       <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>.  The first
1.88      wiz      2019:       component, &#8220;<span class="quote">download-vulnerability-list</span>&#8221;, is for downloading
                   2020:       the list of vulnerabilities from the NetBSD FTP site.  The second
                   2021:       component, &#8220;<span class="quote">audit-packages</span>&#8221;, checks to see if any of your
                   2022:       installed packages are vulnerable.  If a package is vulnerable, you
                   2023:       will see output similar to the following:
                   2024:     </p>
1.82      rillig   2025: <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
1.88      wiz      2026:     http://www.samba.org/samba/whatsnew/macroexploit.html</pre>
1.82      rillig   2027: <p>
1.91      rillig   2028:       One can set up <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> to download the
1.88      wiz      2029:       <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
                   2030:       file daily, and include a package audit in the daily security script.
                   2031:       Details on this are located in the <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/security/audit-packages/MESSAGE?rev=HEAD&amp;content-type=text/x-cvsweb-markup" target="_top">MESSAGE</a>
1.91      rillig   2032:       file for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>.
1.88      wiz      2033:     </p>
1.82      rillig   2034: </div>
                   2035: <div class="sect2" lang="en">
                   2036: <div class="titlepage"><div><div><h3 class="title">
                   2037: <a name="pkg_versions"></a>4.1.6. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
                   2038: <p>
1.91      rillig   2039:       Install <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a> and run 
1.88      wiz      2040:       <span><strong class="command">lintpkgsrc</strong></span> with the &#8220;<span class="quote">-i</span>&#8221;
                   2041:       argument to check if your packages are up-to-date, e.g.
                   2042:     </p>
                   2043: <pre class="screen">
                   2044: <code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
1.82      rillig   2045: ...
1.88      wiz      2046: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
                   2047:     </pre>
1.82      rillig   2048: <p>You can then use <span><strong class="command">make update</strong></span> to update the
1.88      wiz      2049:     package on your system and rebuild any dependencies.
                   2050:     </p>
1.82      rillig   2051: </div>
                   2052: <div class="sect2" lang="en">
                   2053: <div class="titlepage"><div><div><h3 class="title">
                   2054: <a name="using.pkg_admin"></a>4.1.7. Other administrative functions</h3></div></div></div>
                   2055: <p>The <span><strong class="command">pkg_admin</strong></span> executes various
1.88      wiz      2056:     administrative functions on the package system.</p>
1.82      rillig   2057: </div>
                   2058: <div class="sect2" lang="en">
                   2059: <div class="titlepage"><div><div><h3 class="title">
                   2060: <a name="a-word-of-warning"></a>4.1.8. A word of warning</h3></div></div></div>
1.75      rillig   2061: <p>Please pay very careful attention to the warnings
1.88      wiz      2062:     expressed in the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> manual page about the
                   2063:     inherent dangers of installing binary packages which you did
                   2064:     not create yourself, and the security holes that can be
                   2065:     introduced onto your system by indiscriminate adding of such
                   2066:     files.</p>
1.75      rillig   2067: <p>The same warning of course applies to every package you
1.88      wiz      2068:     install from source when you haven't completely read and
                   2069:     understood the source code of the package, the compiler that
                   2070:     is used to build the package and all the other tools that are
                   2071:     involved.</p>
1.75      rillig   2072: </div>
                   2073: </div>
                   2074: <div class="sect1" lang="en">
                   2075: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2076: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1.88      wiz      2077: <p>After obtaining pkgsrc, the <code class="filename">pkgsrc</code>
                   2078:   directory now contains a set of packages, organized into
                   2079:   categories. You can browse the online index of packages, or run
                   2080:   <span><strong class="command">make readme</strong></span> from the <code class="filename">pkgsrc</code>
                   2081:   directory to build local <code class="filename">README.html</code> files for
1.91      rillig   2082:   all packages, viewable with any web browser such as <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/lynx/README.html" target="_top"><code class="filename">www/lynx</code></a> or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a>.</p>
1.88      wiz      2083: <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages
                   2084:   is <code class="filename">/usr/pkg</code>. If you wish to change this, you
                   2085:   should do so by setting <code class="varname">LOCALBASE</code> in
                   2086:   <code class="filename">mk.conf</code>. You should not try to use multiple
                   2087:   different <code class="varname">LOCALBASE</code> definitions on the same
                   2088:   system (inside a chroot is an exception). </p>
                   2089: <p>The rest of this chapter assumes that the package is already
                   2090:   in pkgsrc. If it is not, see <a href="#developers-guide" title="Part II. The pkgsrc developer's guide">Part II, &#8220;The pkgsrc developer's guide&#8221;</a> for
                   2091:   instructions how to create your own packages.</p>
1.75      rillig   2092: <div class="sect2" lang="en">
                   2093: <div class="titlepage"><div><div><h3 class="title">
                   2094: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1.82      rillig   2095: <p>To build packages from source, you need a working C
1.88      wiz      2096:     compiler. On NetBSD, you need to install the
                   2097:     &#8220;<span class="quote">comp</span>&#8221; and the &#8220;<span class="quote">text</span>&#8221; distribution
                   2098:     sets. If you want to build X11-related packages, the
                   2099:     &#8220;<span class="quote">xbase</span>&#8221; and &#8220;<span class="quote">xcomp</span>&#8221; distribution
                   2100:     sets are required, too.</p>
1.75      rillig   2101: </div>
                   2102: <div class="sect2" lang="en">
                   2103: <div class="titlepage"><div><div><h3 class="title">
                   2104: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
                   2105: <p>The first step for building a package is downloading the
1.88      wiz      2106:     distfiles (i.e. the unmodified source). If they have not yet been
                   2107:     downloaded, pkgsrc will fetch them automatically.</p>
                   2108: <p>If you have all files that you need in the
                   2109:     <code class="filename">distfiles</code> directory,
                   2110:     you don't need to connect. If the distfiles are on CD-ROM, you can
                   2111:     mount the CD-ROM on <code class="filename">/cdrom</code> and add:
                   2112:     </p>
1.82      rillig   2113: <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
                   2114: <p>
1.88      wiz      2115:     to your <code class="filename">mk.conf</code>.</p>
1.91      rillig   2116: <p>By default a list of distribution sites will be randomly
                   2117:     intermixed to prevent huge load on servers which holding popular
                   2118:     packages (for example, SourceForge.net mirrors). Thus, every
                   2119:     time when you need to fetch yet another distfile all the mirrors
                   2120:     will be tried in new (random) order. You can turn this feature
                   2121:     off by setting <code class="varname">MASTER_SORT_RANDOM=NO</code> (for
                   2122:     <code class="varname">PKG_DEVELOPER</code>s it's already disabled).</p>
1.88      wiz      2123: <p>You can overwrite some of the major distribution sites to
                   2124:     fit to sites that are close to your own.  By setting one or two
                   2125:     variables you can modify the order in which the master sites are
                   2126:     accessed.  <code class="varname">MASTER_SORT</code> contains a whitespace
                   2127:     delimited list of domain suffixes.
                   2128:     <code class="varname">MASTER_SORT_REGEX</code> is even more flexible, it
                   2129:     contains a whitespace delimited list of regular expressions.  It
                   2130:     has higher priority than <code class="varname">MASTER_SORT</code>.  Have a
                   2131:     look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find
                   2132:     some examples.  This may save some of your bandwidth and
                   2133:     time.</p>
1.75      rillig   2134: <p>You can change these settings either in your shell's environment, or,
1.88      wiz      2135:     if you want to keep the settings, by editing the
                   2136:     <code class="filename">/etc/mk.conf</code> file,
                   2137:     and adding the definitions there.</p>
1.82      rillig   2138: <p>
1.88      wiz      2139:       If a package depends on many other packages (such as
1.91      rillig   2140:       <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a>), the build process may 
1.88      wiz      2141:       alternate between periods of
                   2142:       downloading source, and compiling. To ensure you have all the source
                   2143:       downloaded initially you can run the command:
                   2144:       </p>
1.82      rillig   2145: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
                   2146: <p>
1.88      wiz      2147:       which will output and run a set of shell commands to fetch the
                   2148:       necessary files into the <code class="filename">distfiles</code> directory.  You can
                   2149:       also choose to download the files manually.
                   2150:     </p>
1.75      rillig   2151: </div>
                   2152: <div class="sect2" lang="en">
                   2153: <div class="titlepage"><div><div><h3 class="title">
                   2154: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1.82      rillig   2155: <p>
1.88      wiz      2156:       Once the software has downloaded, any patches will be applied, then it
                   2157:       will be compiled for you. This may take some time depending on your
                   2158:       computer, and how many other packages the software depends on and their
                   2159:       compile time.
                   2160:     </p>
1.75      rillig   2161: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   2162: <h3 class="title">Note</h3>
                   2163: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
1.88      wiz      2164:     use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
                   2165:     &#8220;<span class="quote">make</span>&#8221; in the examples in this guide.</p>
1.75      rillig   2166: </div>
1.87      wiz      2167: <p>For example, type</p>
1.88      wiz      2168: <pre class="screen">
                   2169: <code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
                   2170: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
                   2171:     </pre>
1.75      rillig   2172: <p>at the shell prompt to build the various components of the
1.88      wiz      2173:     package.</p>
1.82      rillig   2174: <p>The next stage is to actually install the newly compiled
1.88      wiz      2175:     program onto your system. Do this by entering:
1.82      rillig   2176: 
1.88      wiz      2177:     </p>
1.82      rillig   2178: <pre class="screen">
1.88      wiz      2179: <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
                   2180:     </pre>
1.82      rillig   2181: <p>
                   2182: 
1.88      wiz      2183:     while you are still in the directory for whatever package you
                   2184:     are installing.</p>
1.82      rillig   2185: <p>Installing the package on your system may require you to
1.88      wiz      2186:     be root.  However, pkgsrc has a
                   2187:     <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
                   2188:     to only become root for the actual installation step.</p>
1.82      rillig   2189: <p>That's it, the software should now be installed and setup for use.
1.88      wiz      2190:     You can now enter:
1.82      rillig   2191: 
1.88      wiz      2192:     </p>
1.82      rillig   2193: <pre class="screen">
1.88      wiz      2194: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
                   2195:     </pre>
1.82      rillig   2196: <p>
                   2197: 
1.88      wiz      2198:     to remove the compiled files in the work directory, as you shouldn't need
                   2199:     them any more. If other packages were also added to your system
                   2200:     (dependencies) to allow your program to compile, you can tidy these up
                   2201:     also with the command:</p>
1.82      rillig   2202: <pre class="screen">
1.88      wiz      2203: <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
                   2204:     </pre>
1.75      rillig   2205: <p>Taking the figlet utility as an example, we can install it on our
1.88      wiz      2206:     system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
                   2207: <p>The program is installed under the default root of the
                   2208:     packages tree - <code class="filename">/usr/pkg</code>. Should this not
                   2209:     conform to your tastes, set the <code class="varname">LOCALBASE</code>
                   2210:     variable in your environment, and it will use that value as the
                   2211:     root of your packages tree. So, to use
                   2212:     <code class="filename">/usr/local</code>, set
                   2213:     <code class="varname">LOCALBASE=/usr/local</code> in your environment.
                   2214:     Please note that you should use a directory which is dedicated to
                   2215:     packages and not shared with other programs (i.e., do not try and
                   2216:     use <code class="varname">LOCALBASE=/usr</code>).  Also, you should not try
                   2217:     to add any of your own files or directories (such as
                   2218:     <code class="filename">src/</code>, <code class="filename">obj/</code>, or
                   2219:     <code class="filename">pkgsrc/</code>) below the
                   2220:     <code class="varname">LOCALBASE</code> tree.  This is to prevent possible
                   2221:     conflicts between programs and other files installed by the
                   2222:     package system and whatever else may have been installed
                   2223:     there.</p>
                   2224: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to
                   2225:     alter some configuration options at build time.  Have a look at
                   2226:     <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to get an overview
                   2227:     of what will be set there by default.  Environment variables such
                   2228:     as <code class="varname">LOCALBASE</code> can be set in
                   2229:     <code class="filename">/etc/mk.conf</code> to save having to remember to
                   2230:     set them each time you want to use pkgsrc.</p>
                   2231: <p>Occasionally, people want to &#8220;<span class="quote">look under the
                   2232:     covers</span>&#8221; to see what is going on when a package is building
                   2233:     or being installed. This may be for debugging purposes, or out of
                   2234:     simple curiosity. A number of utility values have been added to
                   2235:     help with this.</p>
1.75      rillig   2236: <div class="orderedlist"><ol type="1">
                   2237: <li>
1.88      wiz      2238: <p>If you invoke the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> command with
                   2239:        <code class="varname">PKG_DEBUG_LEVEL=2</code>, then a huge amount of
                   2240:        information will be displayed. For example,</p>
1.75      rillig   2241: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
1.88      wiz      2242: <p>will show all the commands that are invoked, up to and
                   2243:        including the &#8220;<span class="quote">patch</span>&#8221; stage.</p>
1.75      rillig   2244: </li>
                   2245: <li>
1.88      wiz      2246: <p>If you want to know the value of a certain <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
                   2247:        definition, then the <code class="varname">VARNAME</code> definition
                   2248:        should be used, in conjunction with the show-var
                   2249:        target. e.g. to show the expansion of the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
                   2250:        variable <code class="varname">LOCALBASE</code>:</p>
                   2251: <pre class="screen">
                   2252: <code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
1.75      rillig   2253: /usr/pkg
                   2254: <code class="prompt">%</code>
1.88      wiz      2255:        </pre>
1.75      rillig   2256: </li>
                   2257: </ol></div>
                   2258: <p>If you want to install a binary package that you've either
1.88      wiz      2259:     created yourself (see next section), that you put into
                   2260:     pkgsrc/packages manually or that is located on a remote FTP
                   2261:     server, you can use the "bin-install" target. This target will
                   2262:     install a binary package - if available - via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>,
                   2263:     else do a <span><strong class="command">make package</strong></span>.  The list of remote FTP
                   2264:     sites searched is kept in the variable
                   2265:     <code class="varname">BINPKG_SITES</code>, which defaults to
                   2266:     ftp.NetBSD.org. Any flags that should be added to <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>
                   2267:     can be put into <code class="varname">BIN_INSTALL_FLAGS</code>.  See
                   2268:     <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more
                   2269:     details.</p>
                   2270: <p>A final word of warning: If you set up a system that has a
                   2271:     non-standard setting for <code class="varname">LOCALBASE</code>, be sure to
                   2272:     set that before any packages are installed, as you cannot use
                   2273:     several directories for the same purpose. Doing so will result in
                   2274:     pkgsrc not being able to properly detect your installed packages,
                   2275:     and fail miserably. Note also that precompiled binary packages are
                   2276:     usually built with the default <code class="varname">LOCALBASE</code> of
                   2277:     <code class="filename">/usr/pkg</code>, and that you should
                   2278:     <span class="emphasis"><em>not</em></span> install any if you use a non-standard
                   2279:     <code class="varname">LOCALBASE</code>.</p>
1.75      rillig   2280: </div>
                   2281: </div>
                   2282: </div>
                   2283: <div class="chapter" lang="en">
                   2284: <div class="titlepage"><div><div><h2 class="title">
                   2285: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
                   2286: <div class="toc">
                   2287: <p><b>Table of Contents</b></p>
                   2288: <dl>
                   2289: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                   2290: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78      rillig   2291: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88      wiz      2292: <dd><dl>
1.89      rillig   2293: <dt><span class="sect2"><a href="#selecting-the-compiler">5.3.1. Selecting the compiler</a></span></dt>
                   2294: <dt><span class="sect2"><a href="#conf.cflags">5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
                   2295: <dt><span class="sect2"><a href="#conf.ldflags">5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.88      wiz      2296: </dl></dd>
1.78      rillig   2297: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
                   2298: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75      rillig   2299: </dl>
                   2300: </div>
1.89      rillig   2301: <p>The whole pkgsrc system is configured in a single file, usually
                   2302: called <code class="filename">mk.conf</code>. In which directory pkgsrc looks for
                   2303: that file depends on the installation. On NetBSD, when you use
                   2304: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> from the base system, it is in the directory
                   2305: <code class="filename">/etc/</code>. In all other cases the default location is
                   2306: <code class="literal">${PREFIX}/etc/</code>, depending on where you told the
                   2307: bootstrap program to install the binary packages.</p>
                   2308: <p>During the bootstrap, an example configuration file is created. To
                   2309: use that, you have to create the directory
                   2310: <code class="filename">${PREFIX}/etc</code> and copy the example file
                   2311: there.</p>
                   2312: <p>The format of the configuration file is that of the usual
                   2313: BSD-style <code class="filename">Makefile</code>s. The whole pkgsrc configuration
                   2314: is done by setting variables in this file. Note that you can define all
                   2315: kinds of variables, and no special error checking (for example for
                   2316: spelling mistakes) takes place, so you have to try it out to see if it
                   2317: works.</p>
1.75      rillig   2318: <div class="sect1" lang="en">
                   2319: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2320: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
                   2321: <p>In this section, you can find some variables that apply to all
1.89      rillig   2322:     pkgsrc packages. A complete list of the variables that can be
                   2323:     configured by the user is available in
                   2324:     <code class="filename">mk/defaults/mk.conf</code>, together with some
                   2325:     comments that describe each variable's intent.</p>
1.75      rillig   2326: <div class="itemizedlist"><ul type="disc">
                   2327: <li><p><code class="varname">LOCALBASE</code>: Where
                   2328:            packages will be installed. The default is
1.76      rillig   2329:            <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75      rillig   2330:            with different <code class="varname">LOCALBASE</code>s!</p></li>
                   2331: <li><p><code class="varname">CROSSBASE</code>: Where
                   2332:            &#8220;<span class="quote">cross</span>&#8221; category packages will be
                   2333:            installed. The default is
1.76      rillig   2334:            <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75      rillig   2335: <li><p><code class="varname">X11BASE</code>: Where
                   2336:            X11 is installed on the system. The default is
1.76      rillig   2337:            <code class="filename">/usr/X11R6</code>.</p></li>
1.75      rillig   2338: <li><p><code class="varname">DISTDIR</code>: Where to store the
                   2339:            downloaded copies of the original source distributions used
                   2340:            for building pkgsrc packages. The default is
1.76      rillig   2341:            <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75      rillig   2342: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
                   2343:            If set, override the packages'
                   2344:            <code class="varname">MASTER_SITES</code> with this value.</p></li>
                   2345: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
                   2346:            Backup location(s) for distribution files and patch files
                   2347:            if not found locally or in
1.76      rillig   2348:            <code class="filename">${MASTER_SITES}</code> or
                   2349:            <code class="filename">${PATCH_SITES}</code> respectively.
1.75      rillig   2350:            The defaults are
1.76      rillig   2351:            <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75      rillig   2352:            and
1.76      rillig   2353:            <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75      rillig   2354: <li><p><code class="varname">BINPKG_SITES</code>:
                   2355:            List of sites carrying binary pkgs.</p></li>
1.82      rillig   2356: <li><p><code class="varname">ACCEPTABLE_LICENSES</code>:
                   2357:            List of acceptable licenses. Whenever you try to build a package
                   2358:            whose license is not in this list, you will get an error message
                   2359:            that includes instructions on how to change this variable.</p></li>
1.75      rillig   2360: </ul></div>
                   2361: </div>
                   2362: <div class="sect1" lang="en">
                   2363: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2364: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
                   2365: <p>XXX
                   2366:       </p>
                   2367: <div class="itemizedlist"><ul type="disc">
                   2368: <li><p><code class="varname">PACKAGES</code>: The top level
                   2369:            directory for the binary packages. The default is
1.76      rillig   2370:            <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75      rillig   2371: <li><p><code class="varname">WRKOBJDIR</code>:
                   2372:            The top level directory where, if defined, the separate
                   2373:            working directories will get created, and symbolically
1.76      rillig   2374:            linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75      rillig   2375:            This is useful for building packages on several
1.76      rillig   2376:            architectures, then <code class="filename">${PKGSRCDIR}</code>
                   2377:            can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75      rillig   2378:            is local to every architecture. (It should be noted that
                   2379:            <code class="varname">PKGSRCDIR</code> should not be set by the user
1.89      rillig   2380:            &mdash; it is an internal definition which refers to the
1.75      rillig   2381:            root of the pkgsrc tree. It is possible to have many
                   2382:            pkgsrc tree instances.)</p></li>
                   2383: <li><p><code class="varname">LOCALPATCHES</code>:
                   2384:            Directory for local patches that aren't part of pkgsrc.
1.90      rillig   2385:            See <a href="#components.patches" title="10.3. patches/*">Section 10.3, &#8220;patches/*&#8221;</a> for more
1.75      rillig   2386:            information. <em class="replaceable"><code>rel</code></em> and
                   2387:            <em class="replaceable"><code>arch</code></em> are replaced with OS
                   2388:            release (&#8220;<span class="quote">2.0</span>&#8221;, etc.) and architecture
                   2389:            (&#8220;<span class="quote">mipsel</span>&#8221;, etc.).</p></li>
                   2390: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76      rillig   2391:            the <code class="filename">mk.conf</code> file used by a package's
1.75      rillig   2392:            BSD-style Makefile. If this is not set,
                   2393:            <code class="varname">MAKECONF</code> is set to
1.76      rillig   2394:            <code class="filename">/dev/null</code> to avoid picking up
                   2395:            settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.82      rillig   2396: <li><p><code class="varname">DEPENDS_TARGET</code>:
                   2397:            By default, dependencies are only installed, and no binary
                   2398:            package is created for them. You can set this variable to
                   2399:            <code class="literal">package</code> to automatically create binary
                   2400:            packages after installing dependencies.</p></li>
1.75      rillig   2401: </ul></div>
                   2402: </div>
                   2403: <div class="sect1" lang="en">
                   2404: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78      rillig   2405: <a name="conf.compiler"></a>5.3. Selecting and configuring the compiler</h2></div></div></div>
                   2406: <div class="sect2" lang="en">
                   2407: <div class="titlepage"><div><div><h3 class="title">
1.89      rillig   2408: <a name="selecting-the-compiler"></a>5.3.1. Selecting the compiler</h3></div></div></div>
                   2409: <p>By default, pkgsrc will use GCC to build packages.  This may be
                   2410:     overridden by setting the following variables in /etc/mk.conf:</p>
                   2411: <div class="variablelist"><dl>
                   2412: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
                   2413: <dd>
                   2414: <p>This is a list of values specifying the chain of
                   2415:          compilers to invoke when building packages.  Valid values
                   2416:          are:</p>
                   2417: <div class="itemizedlist"><ul type="disc">
                   2418: <li><p><code class="varname">distcc</code>:
                   2419:            distributed C/C++ (chainable)</p></li>
                   2420: <li><p><code class="varname">ccache</code>:
                   2421:            compiler cache (chainable)</p></li>
                   2422: <li><p><code class="varname">gcc</code>:
                   2423:            GNU C/C++ Compiler</p></li>
                   2424: <li><p><code class="varname">mipspro</code>:
                   2425:            Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
                   2426: <li><p><code class="varname">mipspro</code>:
                   2427:            Silicon Graphics, Inc. MIPSpro (o32)</p></li>
                   2428: <li><p><code class="varname">sunpro</code>:
                   2429:            Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
                   2430: </ul></div>
                   2431: <p>The default is
                   2432:          &#8220;<span class="quote"><code class="varname">gcc</code></span>&#8221;.  You can use
                   2433:          <code class="varname">ccache</code> and/or
                   2434:          <code class="varname">distcc</code> with an appropriate
                   2435:          <code class="varname">PKGSRC_COMPILER</code> setting,
                   2436:          e.g. &#8220;<span class="quote"><code class="varname">ccache gcc</code></span>&#8221;.  This
                   2437:          variable should always be
                   2438:          terminated with a value for a real compiler.</p>
                   2439: </dd>
                   2440: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
                   2441: <dd><p>This specifies the minimum version of GCC to use
                   2442:          when building packages.  If the system GCC doesn't
                   2443:          satisfy this requirement, then pkgsrc will build and
                   2444:          install one of the GCC packages to use instead.</p></dd>
                   2445: </dl></div>
                   2446: </div>
                   2447: <div class="sect2" lang="en">
                   2448: <div class="titlepage"><div><div><h3 class="title">
                   2449: <a name="conf.cflags"></a>5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
1.78      rillig   2450: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
                   2451:        please make sure to use the <code class="literal">+=</code> operator
                   2452:        instead of the <code class="literal">=</code> operator:</p>
                   2453: <pre class="programlisting">
                   2454:     CFLAGS+=        -your -flags
                   2455: </pre>
                   2456: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
                   2457:        &#8220;<span class="quote">+</span>&#8221;) may lead to problems with packages that need
                   2458:        to add their own flags.  Also, you may want to take a look at
1.91      rillig   2459:        the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a> package if
1.78      rillig   2460:        you're interested in optimization for the current CPU.</p>
                   2461: </div>
1.88      wiz      2462: <div class="sect2" lang="en">
                   2463: <div class="titlepage"><div><div><h3 class="title">
1.89      rillig   2464: <a name="conf.ldflags"></a>5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</h3></div></div></div>
1.88      wiz      2465: <p>If you want to pass flags to the linker, both in the configure
                   2466: step and the build step, you can do this in two ways.  Either set
                   2467: <code class="varname">LDFLAGS</code> or <code class="varname">LIBS</code>.  The difference
                   2468: between the two is that <code class="varname">LIBS</code> will be appended to
                   2469: the command line, while <code class="varname">LDFLAGS</code> come earlier.
                   2470: <code class="varname">LDFLAGS</code> is pre-loaded with rpath settings for ELF
                   2471: machines depending on the setting of <code class="varname">USE_IMAKE</code> or
                   2472: the inclusion of <code class="filename">mk/x11.buildlink3.mk</code>.  As with
                   2473: <code class="varname">CFLAGS</code>, if you do not wish to override these
                   2474: settings, use the <code class="literal">+=</code> operator:</p>
                   2475: <pre class="programlisting">
                   2476:     LDFLAGS+=        -your -linkerflags
                   2477: </pre>
                   2478: </div>
1.78      rillig   2479: </div>
                   2480: <div class="sect1" lang="en">
                   2481: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2482: <a name="developer-advanced-settings"></a>5.4. Developer/advanced settings</h2></div></div></div>
1.75      rillig   2483: <p>XXX
                   2484:       </p>
                   2485: <div class="itemizedlist"><ul type="disc">
                   2486: <li>
                   2487: <p><code class="varname">PKG_DEVELOPER</code>:
                   2488:            Run some sanity checks that package developers want:
                   2489:            </p>
                   2490: <div class="itemizedlist"><ul type="circle">
1.88      wiz      2491: <li><p>make sure patches apply with zero
                   2492:              fuzz</p></li>
                   2493: <li><p>run check-shlibs to see that all
                   2494:              binaries will find their shared libs.</p></li>
1.75      rillig   2495: </ul></div>
                   2496: <p>
1.87      wiz      2497:        </p>
1.75      rillig   2498: </li>
1.88      wiz      2499: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>: The level
                   2500:        of debugging output which is displayed whilst making and
                   2501:        installing the package.  The default value for this is 0,
                   2502:        which will not display the commands as they are executed
                   2503:        (normal, default, quiet operation); the value 1 will display
                   2504:        all shell commands before their invocation, and the value 2
                   2505:        will display both the shell commands before their invocation,
                   2506:        and their actual execution progress with <span><strong class="command">set
                   2507:        -x</strong></span> will be displayed.</p></li>
1.75      rillig   2508: </ul></div>
                   2509: <p>
                   2510:     </p>
                   2511: </div>
                   2512: <div class="sect1" lang="en">
                   2513: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78      rillig   2514: <a name="selecting-build-options"></a>5.5. Selecting Build Options</h2></div></div></div>
1.88      wiz      2515: <p>Some packages have build time options, usually to select
                   2516:     between different dependencies, enable optional support for big
                   2517:     dependencies or enable experimental features.</p>
1.75      rillig   2518: <p>To see which options, if any, a package supports, and which
1.88      wiz      2519:     options are mutually exclusive, run <span><strong class="command">make
                   2520:     show-options</strong></span>, for example:</p>
1.75      rillig   2521: <pre class="programlisting">
                   2522:     The following options are supported by this package:
                   2523:         ssl      Enable SSL support.
                   2524:     Exactly one of the following gecko options is required:
                   2525:         firefox  Use firefox as gecko rendering engine.
                   2526:         mozilla  Use mozilla as gecko rendering engine.
                   2527:     At most one of the following database options may be selected:
                   2528:         mysql    Enable support for MySQL database.
                   2529:         pgsql    Enable support for PostgreSQL database.
1.1       grant    2530: 
1.75      rillig   2531:     These options are enabled by default: firefox
                   2532:     These options are currently enabled: mozilla ssl
1.1       grant    2533: </pre>
1.75      rillig   2534: <p>The following variables can be defined in
1.88      wiz      2535:     <code class="filename">/etc/mk.conf</code> to select which options to
                   2536:     enable for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>,
                   2537:     which can be used to select or disable options for all packages
                   2538:     that support them, and
                   2539:     <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
                   2540:     which can be used to select or disable options specifically for
                   2541:     package <em class="replaceable"><code>pkgbase</code></em>.  Options listed in
                   2542:     these variables are selected, options preceded by &#8220;<span class="quote">-</span>&#8221;
                   2543:     are disabled. A few examples:</p>
1.75      rillig   2544: <pre class="screen">
                   2545: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
                   2546: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   2547: PKG_OPTIONS.kdebase=    debug -sasl
                   2548: PKG_OPTIONS.apache=     suexec </pre>
1.88      wiz      2549: <p>The following settings are consulted in the order given, and
                   2550:     the last setting that selects or disables an option is
                   2551:     used:</p>
1.75      rillig   2552: <div class="orderedlist"><ol type="1">
                   2553: <li><p>the default options as suggested by the package
1.88      wiz      2554:       maintainer</p></li>
1.75      rillig   2555: <li><p>the options implied by the settings of legacy
1.88      wiz      2556:       variables (see below)</p></li>
1.75      rillig   2557: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
                   2558: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
                   2559: </ol></div>
                   2560: <p>For groups of mutually exclusive options, the last option
1.88      wiz      2561:     selected is used, all others are automatically disabled.  If an
                   2562:     option of the group is explicitly disabled, the previously
                   2563:     selected option, if any, is used.  It is an error if no option
                   2564:     from a required group of options is selected, and building the
                   2565:     package will fail.</p>
                   2566: <p>Before the options framework was introduced, build options
                   2567:     were selected by setting a variable (often named
                   2568:     <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
                   2569:     <code class="filename">/etc/mk.conf</code> for each option.  To ease
                   2570:     transition to the options framework for the user, these legacy
                   2571:     variables are converted to the appropriate options setting
                   2572:     (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
                   2573:     automatically.  A warning is issued to prompt the user to update
                   2574:     <code class="filename">/etc/mk.conf</code> to use the options framework
                   2575:     directly.  Support for the legacy variables will be removed
                   2576:     eventually.</p>
1.75      rillig   2577: </div>
                   2578: </div>
                   2579: <div class="chapter" lang="en">
                   2580: <div class="titlepage"><div><div><h2 class="title">
                   2581: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
                   2582: <div class="toc">
                   2583: <p><b>Table of Contents</b></p>
                   2584: <dl>
                   2585: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                   2586: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                   2587: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                   2588: <dd><dl>
                   2589: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                   2590: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                   2591: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                   2592: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                   2593: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                   2594: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                   2595: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                   2596: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                   2597: </dl></dd>
                   2598: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                   2599: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                   2600: </dl>
                   2601: </div>
                   2602: <div class="sect1" lang="en">
                   2603: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2604: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
1.87      wiz      2605: <p>Once you have built and installed a package, you can create
                   2606:     a <span class="emphasis"><em>binary package</em></span> which can be installed on
                   2607:     another system with <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>. This saves having to build
                   2608:     the same package on a group of hosts and wasting CPU time. It also
                   2609:     provides a simple means for others to install your package, should
                   2610:     you distribute it.</p>
                   2611: <p>To create a binary package, change into the appropriate
                   2612:     directory in pkgsrc, and run <span><strong class="command">make
                   2613:     package</strong></span>:</p>
                   2614: <pre class="screen">
                   2615: <code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
                   2616: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
                   2617:     </pre>
                   2618: <p>This will build and install your package (if not already done),
                   2619:     and then build a binary package from what was installed. You can
                   2620:     then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
                   2621:     it. Binary packages are created by default in
                   2622:     <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
                   2623:     gzipped tar file. See <a href="#logs.package" title="B.2. Packaging figlet">Section B.2, &#8220;Packaging figlet&#8221;</a> for a
1.91      rillig   2624:     continuation of the above <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/misc/figlet/README.html" target="_top"><code class="filename">misc/figlet</code></a> example.</p>
1.90      rillig   2625: <p>See <a href="#submit" title="Chapter 20. Submitting and Committing">Chapter 20, <i>Submitting and Committing</i></a> for information on how to submit
1.87      wiz      2626:     such a binary package.</p>
1.75      rillig   2627: </div>
                   2628: <div class="sect1" lang="en">
                   2629: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2630: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.90      rillig   2631: <p>See <a href="#build.helpful-targets" title="16.17. Other helpful targets">Section 16.17, &#8220;Other helpful targets&#8221;</a>.</p>
1.75      rillig   2632: </div>
                   2633: <div class="sect1" lang="en">
                   2634: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2635: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
                   2636: <p>If you want to get a full set of precompiled binary
1.87      wiz      2637:     packages, this section describes how to get them. Beware that
                   2638:     the bulk build will remove all currently installed packages from
                   2639:     your system!</p>
1.75      rillig   2640: <p>Having an FTP server configured either on the
1.87      wiz      2641:     machine doing the bulk builds or on a nearby NFS server can help
                   2642:     to make the packages available to other machines that can then
                   2643:     save time by installing only the binary packages. See <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ftpd+8+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ftpd</span>(8)</span></a> for
                   2644:     more information. If you use a remote NFS server's storage, be
                   2645:     sure to not actually compile on NFS storage, as this slows
                   2646:     things down a lot.</p>
1.75      rillig   2647: <div class="sect2" lang="en">
                   2648: <div class="titlepage"><div><div><h3 class="title">
                   2649: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
                   2650: <div class="sect3" lang="en">
                   2651: <div class="titlepage"><div><div><h4 class="title">
1.76      rillig   2652: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
                   2653: <p>The <code class="filename">build.conf</code> file is the main
1.87      wiz      2654:        configuration file for bulk builds. You can configure how your
                   2655:        copy of pkgsrc is kept up to date, how the distfiles are
                   2656:        downloaded, how the packages are built and how the report is
                   2657:        generated. You can find an annotated example file in
                   2658:        <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
                   2659:        it, copy <code class="filename">build.conf-example</code> to
                   2660:        <code class="filename">build.conf</code> and edit it, following the
                   2661:        comments in that file.</p>
1.75      rillig   2662: </div>
                   2663: <div class="sect3" lang="en">
                   2664: <div class="titlepage"><div><div><h4 class="title">
                   2665: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
                   2666: <p>You may want to set variables in
1.87      wiz      2667:        <code class="filename">/etc/mk.conf</code>.
                   2668:        Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
                   2669:        details of the default settings. You will want to ensure that
                   2670:        <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
                   2671:        As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
                   2672:        accepts <span class="emphasis"><em>all</em></span> licenses.</p>
                   2673: <pre class="programlisting">
                   2674:          PACKAGES?=      ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
                   2675:          WRKOBJDIR?=     /usr/tmp/pkgsrc   # build here instead of in pkgsrc
                   2676:          BSDSRCDIR=      /usr/src
                   2677:          BSDXSRCDIR=     /usr/xsrc         # for x11/xservers
                   2678:          OBJHOSTNAME?=   yes               # use work.`hostname`
                   2679:          FAILOVER_FETCH= yes               # insist on the correct checksum
                   2680:          PKG_DEVELOPER?= yes
                   2681:          _ACCEPTABLE=    yes
                   2682:        </pre>
1.75      rillig   2683: <p>Some options that are especially useful for bulk builds
                   2684:        can be found at the top lines of the file
1.76      rillig   2685:        <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75      rillig   2686:        options of these are briefly described here.</p>
                   2687: <div class="itemizedlist"><ul type="disc">
                   2688: <li><p>If you are on a slow machine, you may want to
1.87      wiz      2689:          set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
                   2690:          &#8220;<span class="quote">no</span>&#8221;.</p></li>
1.75      rillig   2691: <li><p>If you are doing bulk builds from a read-only
1.87      wiz      2692:          copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
                   2693:          to the directory where all log files are created. Otherwise the
                   2694:          log files are created in the pkgsrc directory.</p></li>
1.75      rillig   2695: <li><p>Another important variable is
1.87      wiz      2696:          <code class="varname">BULK_PREREQ</code>, which is a list of packages that
                   2697:          should be always available while building other
                   2698:          packages.</p></li>
1.75      rillig   2699: </ul></div>
                   2700: <p>Some other options are scattered in the pkgsrc
                   2701:        infrastructure:</p>
                   2702: <div class="itemizedlist"><ul type="disc">
                   2703: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
1.87      wiz      2704:          should be set to <code class="literal">yes</code>. The purpose of the bulk
                   2705:          builds is creating binary packages, no matter if they are
                   2706:          vulnerable or not. When uploading the packages to a public
                   2707:          server, the vulnerable packages will be put into a directory of
                   2708:          their own. Leaving this variable unset would prevent the bulk
                   2709:          build system from even trying to build them, so possible
                   2710:          building errors would not show up.</p></li>
1.75      rillig   2711: <li><p><code class="varname">CHECK_FILES</code>
1.87      wiz      2712:          (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
                   2713:          &#8220;<span class="quote">yes</span>&#8221; to check that the installed set of files
                   2714:          matches the <code class="filename">PLIST</code>.</p></li>
1.75      rillig   2715: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.87      wiz      2716:          (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
                   2717:          &#8220;<span class="quote">yes</span>&#8221; to check that the installed
                   2718:          &#8220;<span class="quote">#!</span>&#8221;-scripts will find their
                   2719:          interpreter.</p></li>
1.91      rillig   2720: <li><p><code class="varname">PKGSRC_RUN_TEST</code> can be
                   2721:          set to &#8220;<span class="quote"><code class="literal">yes</code></span>&#8221; to run each
                   2722:          package's self-test before installing it. Note that some
                   2723:          packages make heavy use of &#8220;<span class="quote">good</span>&#8221; random
                   2724:          numbers, so you need to assure that the machine on which you
                   2725:          are doing the bulk builds is not completely idle. Otherwise
                   2726:          some test programs will seem to hang, while they are just
                   2727:          waiting for new random data to be
                   2728:          available.</p></li>
1.75      rillig   2729: </ul></div>
                   2730: </div>
                   2731: <div class="sect3" lang="en">
                   2732: <div class="titlepage"><div><div><h4 class="title">
1.76      rillig   2733: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75      rillig   2734: <p>It is possible to configure the bulk build to perform
1.87      wiz      2735:        certain site-specific tasks at the end of the pre-build
                   2736:        stage.  If the file
                   2737:        <code class="filename">pre-build.local</code> exists in
                   2738:        <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
                   2739:        (as a <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sh+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sh</span>(1)</span></a> script) at the end of the usual pre-build
                   2740:        stage.  An example use of
                   2741:        <code class="filename">pre-build.local</code> is to have the line:</p>
1.75      rillig   2742: <pre class="screen">echo "I do not have enough disk space to build this pig." \
1.87      wiz      2743:        &gt; misc/openoffice/$BROKENF</pre>
1.75      rillig   2744: <p>to prevent the system from trying to build a particular package
1.87      wiz      2745:        which requires nearly 3 GB of disk space.</p>
1.75      rillig   2746: </div>
                   2747: </div>
                   2748: <div class="sect2" lang="en">
                   2749: <div class="titlepage"><div><div><h3 class="title">
                   2750: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76      rillig   2751: <p>As <code class="filename">/usr/pkg</code> will be completely
1.87      wiz      2752:       deleted at the start of bulk builds, make sure your login
                   2753:       shell is placed somewhere else. Either drop it into
                   2754:       <code class="filename">/usr/local/bin</code> (and adjust your login
                   2755:       shell in the passwd file), or (re-)install it via
                   2756:       <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> from <code class="filename">/etc/rc.local</code>, so
                   2757:       you can login after a reboot (remember that your current
                   2758:       process won't die if the package is removed, you just can't
                   2759:       start any new instances of the shell any more).  Also, if you
                   2760:       use NetBSD earlier than 1.5, or you still want to use the pkgsrc
                   2761:       version of ssh for some reason, be sure to install ssh before
                   2762:       starting it from <code class="filename">rc.local</code>:</p>
                   2763: <pre class="programlisting">
                   2764:        ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
                   2765:        if [ -f /usr/pkg/etc/rc.d/sshd ]; then
                   2766:        /usr/pkg/etc/rc.d/sshd
                   2767:        fi
                   2768:       </pre>
1.75      rillig   2769: <p>Not doing so will result in you being not able to log in
1.87      wiz      2770:       via ssh after the bulk build is finished or if the machine
                   2771:       gets rebooted or crashes. You have been warned! :)</p>
1.75      rillig   2772: </div>
                   2773: <div class="sect2" lang="en">
                   2774: <div class="titlepage"><div><div><h3 class="title">
                   2775: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
                   2776: <p>Make sure you don't need any of the packages still
1.87      wiz      2777:       installed.</p>
1.75      rillig   2778: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
                   2779: <h3 class="title">Warning</h3>
                   2780: <p>During the bulk build, <span class="emphasis"><em>all packages will be
1.87      wiz      2781:        removed!</em></span></p>
1.75      rillig   2782: </div>
                   2783: <p>Be sure to remove all other things that might
1.87      wiz      2784:       interfere with builds, like some libs installed in
                   2785:       <code class="filename">/usr/local</code>, etc. then become root and type:</p>
                   2786: <pre class="screen">
                   2787: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   2788: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong>
                   2789:       </pre>
1.75      rillig   2790: <p>If for some reason your last build didn't complete (power
1.87      wiz      2791:       failure, system panic, ...), you can continue it by
                   2792:       running:</p>
1.75      rillig   2793: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
1.87      wiz      2794: <p>At the end of the bulk build, you will get a summary via mail,
                   2795:       and find build logs in the directory specified by
                   2796:       <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
                   2797:       file.</p>
1.75      rillig   2798: </div>
                   2799: <div class="sect2" lang="en">
                   2800: <div class="titlepage"><div><div><h3 class="title">
                   2801: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
                   2802: <p>The bulk builds consist of three steps:</p>
                   2803: <div class="variablelist"><dl>
                   2804: <dt><span class="term">1. pre-build</span></dt>
1.87      wiz      2805: <dd><p>The script updates your pkgsrc tree via (anon)cvs, then
                   2806:            cleans out any broken distfiles, and removes all
                   2807:            packages installed.</p></dd>
1.75      rillig   2808: <dt><span class="term">2. the bulk build</span></dt>
1.87      wiz      2809: <dd><p>This is basically &#8220;<span class="quote">make bulk-package</span>&#8221; with
                   2810:            an optimised order in which packages will be
                   2811:            built. Packages that don't require other packages will
                   2812:            be built first, and packages with many dependencies will
                   2813:            be built later.</p></dd>
1.75      rillig   2814: <dt><span class="term">3. post-build</span></dt>
1.87      wiz      2815: <dd><p>Generates a report that's placed in the directory
                   2816:            specified in the <code class="filename">build.conf</code> file
                   2817:            named <code class="filename">broken.html</code>, a short version
                   2818:            of that report will also be mailed to the build's
                   2819:            admin.</p></dd>
1.75      rillig   2820: </dl></div>
1.87      wiz      2821: <p>During the build, a list of broken packages will be compiled
                   2822:       in <code class="filename">/usr/pkgsrc/.broken</code> (or
                   2823:       <code class="filename">.../.broken.${MACHINE}</code> if
                   2824:       <code class="varname">OBJMACHINE</code> is set), individual build logs
                   2825:       of broken builds can be found in the package's
                   2826:       directory. These files are used by the bulk-targets to mark
                   2827:       broken builds to not waste time trying to rebuild them, and
                   2828:       they can be used to debug these broken package builds
                   2829:       later.</p>
1.75      rillig   2830: </div>
                   2831: <div class="sect2" lang="en">
                   2832: <div class="titlepage"><div><div><h3 class="title">
                   2833: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
                   2834: <p>Currently, roughly the following requirements are valid for
1.87      wiz      2835:       NetBSD 2.0/i386:</p>
1.75      rillig   2836: <div class="itemizedlist"><ul type="disc">
1.87      wiz      2837: <li><p>10 GB - distfiles (NFS ok)</p></li>
                   2838: <li><p>8 GB - full set of all binaries (NFS ok)</p></li>
                   2839: <li><p>5 GB - temp space for compiling (local disk recommended)</p></li>
                   2840: </ul></div>
                   2841: <p>Note that all pkgs will be de-installed as soon as they are
                   2842:       turned into a binary package, and that sources are removed,
                   2843:       so there is no excessively huge demand to disk
                   2844:       space. Afterwards, if the package is needed again, it will
                   2845:       be installed via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> instead of building again, so
                   2846:       there are no cycles wasted by recompiling.</p>
1.75      rillig   2847: </div>
                   2848: <div class="sect2" lang="en">
                   2849: <div class="titlepage"><div><div><h3 class="title">
                   2850: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
1.87      wiz      2851: <p>If you don't want all the packages nuked from a machine
                   2852:       (rendering it useless for anything but pkg compiling), there
                   2853:       is the possibility of doing the package bulk build inside a
                   2854:       chroot environment.</p>
                   2855: <p>The first step is to set up a chroot sandbox,
                   2856:       e.g. <code class="filename">/usr/sandbox</code>.  This can be done by
                   2857:       using null mounts, or manually.</p>
                   2858: <p>There is a shell script called
                   2859:       <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
                   2860:       up the sandbox environment using null mounts. It will also
                   2861:       create a script called <code class="filename">sandbox</code> in the
                   2862:       root of the sandbox environment, which will allow the null
                   2863:       mounts to be activated using the <span><strong class="command">sandbox
                   2864:       mount</strong></span> command and deactivated using the
                   2865:       <span><strong class="command">sandbox umount</strong></span> command.</p>
                   2866: <p>To set up a sandbox environment by hand, after extracting all
                   2867:       the sets from a NetBSD installation or doing a <span><strong class="command">make
                   2868:       distribution DESTDIR=/usr/sandbox</strong></span> in
                   2869:       <code class="filename">/usr/src/etc</code>, be sure the following items
                   2870:       are present and properly configured:</p>
1.75      rillig   2871: <div class="procedure"><ol type="1">
                   2872: <li>
                   2873: <p>Kernel</p>
                   2874: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
                   2875: </li>
                   2876: <li>
1.76      rillig   2877: <p><code class="filename">/dev/*</code></p>
1.75      rillig   2878: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
                   2879: </li>
                   2880: <li>
1.91      rillig   2881: <p><code class="filename">/etc/resolv.conf</code> (for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a> and mail):</p>
1.75      rillig   2882: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
                   2883: </li>
                   2884: <li>
                   2885: <p>Working(!) mail config (hostname, sendmail.cf):</p>
                   2886: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
                   2887: </li>
                   2888: <li>
1.91      rillig   2889: <p><code class="filename">/etc/localtime</code> (for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a>):</p>
1.75      rillig   2890: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
                   2891: </li>
                   2892: <li>
1.76      rillig   2893: <p><code class="filename">/usr/src</code> (system sources,
1.91      rillig   2894:          e.&nbsp;g. for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/sysutils/aperture/README.html" target="_top"><code class="filename">sysutils/aperture</code></a>):</p>
1.75      rillig   2895: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
1.87      wiz      2896:          <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
1.75      rillig   2897: </li>
                   2898: <li>
1.76      rillig   2899: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75      rillig   2900: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
                   2901: </li>
                   2902: <li>
1.76      rillig   2903: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75      rillig   2904: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
                   2905: </li>
                   2906: <li>
                   2907: <p>Checkout pkgsrc via cvs into
1.87      wiz      2908:          <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
                   2909: <pre class="screen">
                   2910: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
                   2911: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong>
                   2912:          </pre>
1.75      rillig   2913: <p>Do not mount/link this to the copy of your pkgsrc tree
1.87      wiz      2914:          you do development in, as this will likely cause problems!</p>
1.75      rillig   2915: </li>
                   2916: <li><p>Make
1.87      wiz      2917:          <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
                   2918:          <code class="filename">.../distfiles</code> point somewhere
                   2919:          appropriate. NFS- and/or nullfs-mounts may come in handy!</p></li>
1.76      rillig   2920: <li><p>Edit <code class="filename">/etc/mk.conf</code>, see <a href="#binary.mk.conf" title="6.3.1.2. /etc/mk.conf">Section 6.3.1.2, &#8220;/etc/mk.conf&#8221;</a>.</p></li>
                   2921: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75      rillig   2922: </ol></div>
                   2923: <p>When the chroot sandbox is set up, you can start
1.87      wiz      2924:       the build with the following steps:</p>
                   2925: <pre class="screen">
                   2926: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
                   2927: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong>
                   2928:       </pre>
                   2929: <p>This will just jump inside the sandbox and start building.  At
                   2930:        the end of the build, mail will be sent with the results of
                   2931:        the build. Created binary pkgs will be in
                   2932:        <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
                   2933:       (wherever that points/mounts to/from).</p>
1.75      rillig   2934: </div>
                   2935: <div class="sect2" lang="en">
                   2936: <div class="titlepage"><div><div><h3 class="title">
                   2937: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
1.87      wiz      2938: <p>In addition to building a complete set of all packages in
                   2939:       pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
                   2940:       may be used to build a subset of the packages contained in
                   2941:       pkgsrc.  By setting <code class="varname">SPECIFIC_PKGS</code>
                   2942:       in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75      rillig   2943: <div class="itemizedlist"><ul type="disc">
                   2944: <li><p>SITE_SPECIFIC_PKGS</p></li>
                   2945: <li><p>HOST_SPECIFIC_PKGS</p></li>
                   2946: <li><p>GROUP_SPECIFIC_PKGS</p></li>
                   2947: <li><p>USER_SPECIFIC_PKGS</p></li>
                   2948: </ul></div>
1.87      wiz      2949: <p>will define the set of packages which should be built.
                   2950:       The bulk build code will also include any packages which are
                   2951:       needed as dependencies for the explicitly listed packages.</p>
                   2952: <p>One use of this is to do a bulk build with
                   2953:       <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
                   2954:       periodically to have a complete set of the binary packages
                   2955:       needed for your site available without the overhead of
                   2956:       building extra packages that are not needed.</p>
1.75      rillig   2957: </div>
                   2958: <div class="sect2" lang="en">
                   2959: <div class="titlepage"><div><div><h3 class="title">
                   2960: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
1.87      wiz      2961: <p>This section describes how pkgsrc developers can upload binary
                   2962:       pkgs built by bulk builds to ftp.NetBSD.org.</p>
                   2963: <p>If you would like to automatically create checksum files for the
                   2964:       binary packages you intend to upload, remember to set
                   2965:       <code class="varname">MKSUMS=yes</code> in your
                   2966:       <code class="filename">mk/bulk/build.conf</code>.</p>
                   2967: <p>If you would like to PGP sign the checksum files (highly
                   2968:       recommended!), remember to set
                   2969:       <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
                   2970:       <code class="filename">mk/bulk/build.conf</code>.  This will prompt you for
                   2971:       your GPG password to sign the files before uploading everything.</p>
                   2972: <p>Then, make sure that you have <code class="varname">RSYNC_DST</code>
                   2973:       set properly in your <code class="filename">mk/bulk/build.conf</code>
                   2974:       file, i.e. adjust it to something like one of the following:</p>
1.75      rillig   2975: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
                   2976: <p>Please use appropriate values for "pkgsrc-200xQy",
1.87      wiz      2977:       "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
                   2978:       is different from your local login, write your login directly
                   2979:       into the variable, e.g. my local account is "feyrer", but for my
                   2980:       login "hubertf", I use:</p>
                   2981: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload</pre>
                   2982: <p>A separate <code class="filename">upload</code> directory is used
                   2983:       here to allow "closing" the directory during upload. To do
                   2984:       so, run the following command on ftp.NetBSD.org next:</p>
1.75      rillig   2985: <pre class="screen">nbftp% <strong class="userinput"><code>mkdir -p -m 750 /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload</code></strong></pre>
1.87      wiz      2986: <p>Please note that <code class="filename">/pub/NetBSD/packages</code> is
                   2987:       only appropriate for packages for the NetBSD operating
                   2988:       system. Binary packages for other operating systems should go
                   2989:       into <code class="filename">/pub/pkgsrc</code>.</p>
                   2990: <p>Before uploading the binary pkgs, ssh authentication needs
                   2991:       to be set up. This example shows how to set up temporary keys
                   2992:       for the root account <span class="emphasis"><em>inside the sandbox</em></span>
                   2993:       (assuming that no keys should be present there usually):</p>
                   2994: <pre class="screen">
                   2995: <code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
1.75      rillig   2996: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
                   2997: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
1.87      wiz      2998: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong>
                   2999:       </pre>
                   3000: <p>Now take the output of <code class="filename">id-dsa.pub</code> and
                   3001:       append it to your <code class="filename">~/.ssh/authorized_keys</code>
                   3002:       file on ftp.NetBSD.org. You can remove the key after the
                   3003:       upload is done!</p>
                   3004: <p>Next, test if your ssh connection really works:</p>
1.75      rillig   3005: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
1.87      wiz      3006: <p>Use "-l yourNetBSDlogin" here as appropriate!</p>
                   3007: <p>Now after all this works, you can exit the sandbox and start
                   3008:       the upload:</p>
                   3009: <pre class="screen">
                   3010: chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
1.75      rillig   3011: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
1.87      wiz      3012: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong>
                   3013:       </pre>
                   3014: <p>The upload process may take quite some time. Use <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ls+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ls</span>(1)</span></a> or
                   3015:       <a href="http://netbsd.gw.com/cgi-bin/man-cgi?du+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">du</span>(1)</span></a> on the FTP server to monitor progress of the
                   3016:       upload. The upload script will take care of not uploading
                   3017:       restricted packages and putting vulnerable packages into the
                   3018:       <code class="filename">vulnerable</code> subdirectory.</p>
                   3019: <p>After the upload has ended, first thing is to revoke ssh access:</p>
1.75      rillig   3020: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
1.87      wiz      3021:       Gdd:x! </pre>
                   3022: <p>Use whatever is needed to remove the key you've entered
                   3023:       before! Last, move the uploaded packages out of the
                   3024:       <code class="filename">upload</code> directory to have them accessible
                   3025:       to everyone:</p>
                   3026: <pre class="screen">
                   3027: nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
1.75      rillig   3028: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
                   3029: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
1.87      wiz      3030: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong>
                   3031:       </pre>
1.75      rillig   3032: </div>
                   3033: </div>
                   3034: <div class="sect1" lang="en">
                   3035: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3036: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
1.87      wiz      3037: <p>After your pkgsrc bulk-build has completed, you may wish to
                   3038:     create a CD-ROM set of the resulting binary packages to assist
                   3039:     in installing packages on other machines.  The
1.91      rillig   3040:     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/cdpack/README.html" target="_top"><code class="filename">pkgtools/cdpack</code></a> package provides
1.87      wiz      3041:     a simple tool for creating the ISO 9660 images.
                   3042:     <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
                   3043:     way that keeps all the dependencies for a given package on the same
                   3044:     CD as that package.</p>
1.75      rillig   3045: <div class="sect2" lang="en">
                   3046: <div class="titlepage"><div><div><h3 class="title">
                   3047: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
1.87      wiz      3048: <p>Complete documentation for cdpack is found in the cdpack(1)
                   3049:       man page. The following short example assumes that the binary
                   3050:       packages are left in
                   3051:       <code class="filename">/usr/pkgsrc/packages/All</code> and that
                   3052:       sufficient disk space exists in <code class="filename">/u2</code> to
                   3053:       hold the ISO 9660 images.</p>
                   3054: <pre class="screen">
                   3055: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
1.75      rillig   3056: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
1.87      wiz      3057: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong>
                   3058:       </pre>
                   3059: <p>If you wish to include a common set of files
                   3060:       (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
                   3061:       etc.) on each CD in the collection, then you need to create a
                   3062:       directory which contains these files. e.g.</p>
                   3063: <pre class="screen">
                   3064: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
1.75      rillig   3065: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" &gt; /tmp/common/README</code></strong>
                   3066: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" &gt; /tmp/common/COPYING</code></strong>
                   3067: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
                   3068: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" &gt; /tmp/common/bin/myscript</code></strong>
                   3069: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" &gt;&gt; /tmp/common/bin/myscript</code></strong>
1.87      wiz      3070: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong>
                   3071:       </pre>
1.75      rillig   3072: <p>Now create the images:</p>
                   3073: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
1.76      rillig   3074: <p>Each image will contain <code class="filename">README</code>,
1.87      wiz      3075:       <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
                   3076:       in their root directories.</p>
1.75      rillig   3077: </div>
                   3078: </div>
                   3079: </div>
                   3080: <div class="chapter" lang="en">
                   3081: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   3082: <a name="files"></a>Chapter 7. Directory layout of the installed files</h2></div></div></div>
                   3083: <div class="toc">
                   3084: <p><b>Table of Contents</b></p>
                   3085: <dl>
1.91      rillig   3086: <dt><span class="sect1"><a href="#files.localbase">7.1. File system layout in <code class="literal">${LOCALBASE}</code></a></span></dt>
1.90      rillig   3087: <dt><span class="sect1"><a href="#files.varbase">7.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
                   3088: </dl>
                   3089: </div>
                   3090: <p>The files that are installed by pkgsrc are organized in a way that
                   3091: is similar to what you find in the <code class="filename">/usr</code> directory
                   3092: of the base system. But some details are different. This is because
                   3093: pkgsrc initially came from FreeBSD and had adopted its file system
                   3094: hierarchy. Later it was largely influenced by NetBSD. But no matter
                   3095: which operating system you are using pkgsrc with, you can expect the
                   3096: same layout for pkgsrc.</p>
1.91      rillig   3097: <p>There are mainly four root directories for pkgsrc, which are all
                   3098: configurable in the <code class="filename">bootstrap/bootstrap</code> script.
                   3099: When pkgsrc has been installed as root, the default locations
                   3100: are:</p>
                   3101: <pre class="programlisting">
                   3102:     LOCALBASE=              /usr/pkg
                   3103:     PKG_SYSCONFBASE=        /usr/pkg/etc
                   3104:     VARBASE=                /var
                   3105:     PKGDBDIR=               /var/db/pkg
                   3106: </pre>
                   3107: <p>In unprivileged mode (when pkgsrc has been installed as any other
                   3108: user), the default locations are:</p>
                   3109: <pre class="programlisting">
                   3110:     LOCALBASE=              ${HOME}/pkg
                   3111:     PKG_SYSCONFBASE=        ${HOME}/pkg/etc
                   3112:     VARBASE=                ${HOME}/pkg/var
                   3113:     PKGDBDIR=               ${HOME}/pkg/var/db/pkg
                   3114: </pre>
                   3115: <p>What these four directories are for, and what they look like is
                   3116: explained below.</p>
1.90      rillig   3117: <div class="itemizedlist"><ul type="disc">
                   3118: <li><p><code class="varname">LOCALBASE</code> corresponds to the
                   3119: <code class="filename">/usr</code> directory in the base system. It is the
                   3120: &#8220;<span class="quote">main</span>&#8221; directory where the files are installed and contains
                   3121: the well-known subdirectories like <code class="filename">bin</code>,
                   3122: <code class="filename">include</code>, <code class="filename">lib</code>,
                   3123: <code class="filename">share</code> and
                   3124: <code class="filename">sbin</code>.</p></li>
                   3125: <li><p><code class="varname">VARBASE</code> corresponds to
                   3126: <code class="filename">/var</code> in the base system. Some programs (especially
                   3127: games, network daemons) need write access to it during normal
                   3128: operation.</p></li>
                   3129: <li><p><code class="varname">PKG_SYSCONFDIR</code> corresponds to
                   3130: <code class="filename">/etc</code> in the base system. It contains configuration
                   3131: files of the packages, as well as pkgsrc's <code class="filename">mk.conf</code>
                   3132: itself.</p></li>
                   3133: </ul></div>
                   3134: <div class="sect1" lang="en">
                   3135: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.91      rillig   3136: <a name="files.localbase"></a>7.1. File system layout in <code class="literal">${LOCALBASE}</code></h2></div></div></div>
1.90      rillig   3137: <p>The following directories exist in a typical pkgsrc installation
1.91      rillig   3138: in <code class="filename">${LOCALBASE}</code>.</p>
1.90      rillig   3139: <div class="variablelist"><dl>
                   3140: <dt><span class="term"><code class="filename">bin</code></span></dt>
                   3141: <dd><p>Contains executable programs that are intended to be
                   3142: directly used by the end user.</p></dd>
                   3143: <dt><span class="term"><code class="filename">emul</code></span></dt>
                   3144: <dd><p>Contains files for the emulation layers of various other
                   3145: operating systems, especially for
                   3146: NetBSD.</p></dd>
                   3147: <dt><span class="term"><code class="filename">etc</code> (the usual location of
                   3148: <code class="filename">${PKG_SYSCONFDIR}</code>)</span></dt>
                   3149: <dd><p>Contains
                   3150: the configuration files.</p></dd>
                   3151: <dt><span class="term"><code class="filename">include</code></span></dt>
                   3152: <dd><p>Contains headers for the C and C++ programming
                   3153: languages.</p></dd>
                   3154: <dt><span class="term"><code class="filename">info</code></span></dt>
                   3155: <dd><p>Contains GNU info files of various
                   3156: packages.</p></dd>
                   3157: <dt><span class="term"><code class="filename">lib</code></span></dt>
                   3158: <dd><p>Contains shared and static
                   3159: libraries.</p></dd>
                   3160: <dt><span class="term"><code class="filename">libdata</code></span></dt>
                   3161: <dd><p>Contains data files that don't change after
                   3162: installation. Other data files belong into
                   3163: <code class="filename">${VARBASE}</code>.</p></dd>
                   3164: <dt><span class="term"><code class="filename">libexec</code></span></dt>
                   3165: <dd><p>Contains programs that are not intended to be used by
                   3166: end users, such as helper programs or network
                   3167: daemons.</p></dd>
                   3168: <dt><span class="term"><code class="filename">libexec/cgi-bin</code></span></dt>
                   3169: <dd><p>Contains programs that are intended to be executed as
                   3170: CGI scripts by a web server.</p></dd>
                   3171: <dt><span class="term"><code class="filename">man</code> (the usual value of
                   3172: <code class="filename">${PKGMANDIR}</code>)</span></dt>
                   3173: <dd><p>Contains brief
                   3174: documentation in form of manual pages.</p></dd>
                   3175: <dt><span class="term"><code class="filename">sbin</code></span></dt>
                   3176: <dd><p>Contains programs that are intended to be used only by
                   3177: the super-user.</p></dd>
                   3178: <dt><span class="term"><code class="filename">share</code></span></dt>
                   3179: <dd><p>Contains platform-independent data files that don't
                   3180: change after installation.</p></dd>
                   3181: <dt><span class="term"><code class="filename">share/doc</code></span></dt>
                   3182: <dd><p>Contains documentation files provided by the
                   3183: packages.</p></dd>
                   3184: <dt><span class="term"><code class="filename">share/examples</code></span></dt>
                   3185: <dd><p>Contains example files provided by the packages. Among
                   3186: others, the original configuration files are saved here and copied to
                   3187: <code class="filename">${PKG_SYSCONFDIR}</code> during
                   3188: installation.</p></dd>
                   3189: <dt><span class="term"><code class="filename">share/examples/rc.d</code></span></dt>
                   3190: <dd><p>Contains the original files for rc.d
                   3191: scripts.</p></dd>
                   3192: <dt><span class="term"><code class="filename">var</code> (the usual location of
                   3193: <code class="filename">${VARBASE}</code>)</span></dt>
                   3194: <dd><p>Contains files
                   3195: that may be modified after
                   3196: installation.</p></dd>
                   3197: </dl></div>
                   3198: </div>
                   3199: <div class="sect1" lang="en">
                   3200: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3201: <a name="files.varbase"></a>7.2. File system layout in <code class="literal">${VARBASE}</code></h2></div></div></div>
                   3202: <div class="variablelist"><dl>
                   3203: <dt><span class="term"><code class="filename">db/pkg</code> (the usual location of
                   3204: <code class="filename">${PKG_DBDIR}</code>)</span></dt>
                   3205: <dd><p>Contains
                   3206: information about the currently installed
                   3207: packages.</p></dd>
                   3208: <dt><span class="term"><code class="filename">games</code></span></dt>
                   3209: <dd><p>Contains highscore
                   3210: files.</p></dd>
                   3211: <dt><span class="term"><code class="filename">log</code></span></dt>
                   3212: <dd><p>Contains log files.</p></dd>
                   3213: <dt><span class="term"><code class="filename">run</code></span></dt>
                   3214: <dd><p>Contains informational files about daemons that are
                   3215: currently running.</p></dd>
                   3216: </dl></div>
                   3217: </div>
                   3218: </div>
                   3219: <div class="chapter" lang="en">
                   3220: <div class="titlepage"><div><div><h2 class="title">
                   3221: <a name="faq"></a>Chapter 8. Frequently Asked Questions</h2></div></div></div>
1.75      rillig   3222: <div class="toc">
                   3223: <p><b>Table of Contents</b></p>
                   3224: <dl>
1.90      rillig   3225: <dt><span class="sect1"><a href="#mailing-list-pointers">8.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                   3226: <dt><span class="sect1"><a href="#pkgviews-docs">8.2. Where's the pkgviews documentation?</a></span></dt>
                   3227: <dt><span class="sect1"><a href="#faq-pkgtools">8.3. Utilities for package management (pkgtools)</a></span></dt>
                   3228: <dt><span class="sect1"><a href="#non-root-pkgsrc">8.4. How to use pkgsrc as non-root</a></span></dt>
                   3229: <dt><span class="sect1"><a href="#resume-transfers">8.5. How to resume transfers when fetching distfiles?</a></span></dt>
                   3230: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">8.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                   3231: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">8.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                   3232: <dt><span class="sect1"><a href="#fetch-behind-firewall">8.8. How to fetch files from behind a firewall</a></span></dt>
                   3233: <dt><span class="sect1"><a href="#passive-ftp">8.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
                   3234: <dt><span class="sect1"><a href="#fetching-all-distfiles">8.10. How to fetch all distfiles at once</a></span></dt>
                   3235: <dt><span class="sect1"><a href="#tmac.andoc-missing">8.11. What does &#8220;<span class="quote">Don't know how to make
1.75      rillig   3236: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
1.90      rillig   3237: <dt><span class="sect1"><a href="#bsd.own.mk-missing">8.12. What does &#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221; mean?</a></span></dt>
                   3238: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">8.13. Using 'sudo' with pkgsrc</a></span></dt>
                   3239: <dt><span class="sect1"><a href="#faq.conf">8.14. How do I change the location of configuration files?</a></span></dt>
                   3240: <dt><span class="sect1"><a href="#audit-packages">8.15. Automated security checks</a></span></dt>
                   3241: <dt><span class="sect1"><a href="#ufaq-cflags">8.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
                   3242: <dt><span class="sect1"><a href="#ufaq-fail">8.17. A package does not build.  What shall I do?</a></span></dt>
                   3243: <dt><span class="sect1"><a href="#faq.rcs-conflicts">8.18. What does &#8220;<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>&#8221; mean?</a></span></dt>
1.75      rillig   3244: </dl>
                   3245: </div>
                   3246: <p>This section contains hints, tips &amp; tricks on special things in
                   3247: pkgsrc that we didn't find a better place for in the previous chapters, and
                   3248: it contains items for both pkgsrc users and developers.</p>
                   3249: <div class="sect1" lang="en">
                   3250: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3251: <a name="mailing-list-pointers"></a>8.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
1.75      rillig   3252: <p>The following mailing lists may be of interest to pkgsrc users:</p>
                   3253: <div class="itemizedlist"><ul type="disc">
1.78      rillig   3254: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
                   3255:          This is a general purpose list for most issues regarding
                   3256:          pkgsrc, regardless of platform, e.g. soliciting user help
                   3257:          for pkgsrc configuration, unexpected build failures, using
                   3258:          particular packages, upgrading pkgsrc installations,
                   3259:          questions regarding the pkgsrc release branches, etc.  General announcements or
                   3260:          proposals for changes that impact the pkgsrc user community,
                   3261:          e.g. major infrastructure changes, new features, package
                   3262:          removals, etc., may also be posted.</p></li>
1.75      rillig   3263: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
                   3264:          A list where the results of pkgsrc bulk builds are sent and
                   3265:          discussed.</p></li>
                   3266: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
                   3267:          This list is for those who are interested in getting a
                   3268:          commit message for every change committed to pkgsrc. It is
                   3269:          also available in digest form, meaning one daily message
                   3270:          containing all commit messages for changes to the package
                   3271:          source tree in that 24 hour period.</p></li>
                   3272: </ul></div>
                   3273: <p>To subscribe, do:</p>
                   3274: <pre class="programlisting">
                   3275:     <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
                   3276: </pre>
                   3277: <p>Archives for all these mailing lists are available from
                   3278: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
                   3279: </div>
                   3280: <div class="sect1" lang="en">
                   3281: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3282: <a name="pkgviews-docs"></a>8.2. Where's the pkgviews documentation?</h2></div></div></div>
1.75      rillig   3283: <p>Pkgviews is tightly integrated with buildlink.  You can find a
                   3284: pkgviews User's guide in
1.76      rillig   3285: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75      rillig   3286: </div>
                   3287: <div class="sect1" lang="en">
                   3288: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3289: <a name="faq-pkgtools"></a>8.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.80      rillig   3290: <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
1.75      rillig   3291: a number of useful utilities for both users and developers of pkgsrc.  This
                   3292: section attempts only to make the reader aware of the utilities and when
                   3293: they might be useful, and not to duplicate the documentation that comes
                   3294: with each package.</p>
                   3295: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.91      rillig   3296: <div class="itemizedlist"><ul type="disc"><li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/x11-links/README.html" target="_top"><code class="filename">pkgtools/x11-links</code></a>:
1.75      rillig   3297:       Symlinks for use by buildlink.</p></li></ul></div>
                   3298: <p>OS tool augmentation (automatically installed when needed):</p>
                   3299: <div class="itemizedlist"><ul type="disc">
1.91      rillig   3300: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/digest/README.html" target="_top"><code class="filename">pkgtools/digest</code></a>:
1.75      rillig   3301:       Calculates various kinds of checksums (including SHA1).</p></li>
1.91      rillig   3302: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/libnbcompat/README.html" target="_top"><code class="filename">pkgtools/libnbcompat</code></a>:
1.75      rillig   3303:       Compatibility library for pkgsrc tools.</p></li>
1.91      rillig   3304: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/mtree/README.html" target="_top"><code class="filename">pkgtools/mtree</code></a>: Installed on
1.87      wiz      3305:       non-BSD systems due to lack of native mtree.</p></li>
1.91      rillig   3306: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>:
1.75      rillig   3307:       Up-to-date replacement for
1.76      rillig   3308:       <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75      rillig   3309:       systems where pkg_install is not present.</p></li>
                   3310: </ul></div>
                   3311: <p>Utilities used by pkgsrc (not automatically installed):</p>
                   3312: <div class="itemizedlist"><ul type="disc">
1.91      rillig   3313: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgtools/pkg_tarup</code></a>:
1.75      rillig   3314:       Create a binary package from an
                   3315:       already-installed package.  Used by <span><strong class="command">make replace</strong></span> to
                   3316:       save the old package.</p></li>
1.91      rillig   3317: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/dfdisk/README.html" target="_top"><code class="filename">pkgtools/dfdisk</code></a>:
1.75      rillig   3318:       Adds extra functionality to pkgsrc, allowing it to fetch distfiles
                   3319:       from multiple locations. It currently supports the following
                   3320:       methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.91      rillig   3321: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a>: Put X11
1.75      rillig   3322:       packages someplace else (enabled by default).</p></li>
1.91      rillig   3323: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a>: Determine the
1.75      rillig   3324:       best compiler flags to optimise code for your current CPU and
                   3325:       compiler.</p></li>
                   3326: </ul></div>
                   3327: <p>Utilities for keeping track of installed packages, being up to date,
                   3328: etc:</p>
                   3329: <div class="itemizedlist"><ul type="disc">
1.91      rillig   3330: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_chk/README.html" target="_top"><code class="filename">pkgtools/pkg_chk</code></a>: Reports on
1.75      rillig   3331:       packages whose installed versions do not match the latest pkgsrc
                   3332:       entries.</p></li>
1.91      rillig   3333: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a>: Makes
1.75      rillig   3334:       dependency graphs of packages, to aid in choosing a strategy for
                   3335:       updating.</p></li>
1.91      rillig   3336: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdepgraph/README.html" target="_top"><code class="filename">pkgtools/pkgdepgraph</code></a>: Makes
                   3337:       graphs from the output of <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a> (uses graphviz).</p></li>
                   3338: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>: The
1.75      rillig   3339:       pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
                   3340:       does various checks on the complete pkgsrc system.</p></li>
1.91      rillig   3341: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgsurvey/README.html" target="_top"><code class="filename">pkgtools/pkgsurvey</code></a>: Report what
1.75      rillig   3342:       packages you have installed.</p></li>
                   3343: </ul></div>
                   3344: <p>Utilities for people maintaining or creating individual packages:</p>
                   3345: <div class="itemizedlist"><ul type="disc">
1.91      rillig   3346: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>: Automate
1.75      rillig   3347:       making and maintaining patches for a package (includes pkgdiff,
                   3348:       pkgvi, mkpatches, etc.).</p></li>
1.91      rillig   3349: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>,
                   3350:       <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>: Aids in
1.75      rillig   3351:       converting to pkgsrc.</p></li>
1.91      rillig   3352: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>: Convert
1.75      rillig   3353:       pkgsrc to a Solaris package.</p></li>
                   3354: </ul></div>
                   3355: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
                   3356: utilities)</p>
                   3357: <div class="itemizedlist"><ul type="disc">
1.91      rillig   3358: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_comp/README.html" target="_top"><code class="filename">pkgtools/pkg_comp</code></a>: Build
1.75      rillig   3359:       packages in a chrooted area.</p></li>
1.91      rillig   3360: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/libkver/README.html" target="_top"><code class="filename">pkgtools/libkver</code></a>: Spoof
1.75      rillig   3361:       kernel version for chrooted cross builds.</p></li>
                   3362: </ul></div>
                   3363: </div>
                   3364: <div class="sect1" lang="en">
                   3365: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3366: <a name="non-root-pkgsrc"></a>8.4. How to use pkgsrc as non-root</h2></div></div></div>
1.75      rillig   3367: <p>If you want to use pkgsrc as non-root user, you can set some
                   3368: variables to make pkgsrc work under these conditions.  At the very least,
                   3369: you need to set <code class="varname">UNPRIVILEGED</code> to &#8220;<span class="quote">yes</span>&#8221;; this
                   3370: will turn on unprivileged mode and set multiple related variables to allow
                   3371: installation of packages as non-root.</p>
                   3372: <p>In case the defaults are not enough, you may want to tune some other
                   3373: variables used.  For example, if the automatic user/group detection leads
                   3374: to incorrect values (or not the ones you would like to use), you can change
                   3375: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
                   3376: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
                   3377: <p>As regards bootstrapping, please note that the
                   3378: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
                   3379: given the &#8220;<span class="quote">--ignore-user-check</span>&#8221; flag, as it will choose and
1.76      rillig   3380: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75      rillig   3381: installation targets.  These directories can be overriden by the
                   3382: &#8220;<span class="quote">--prefix</span>&#8221; flag provided by the script, as well as some others
                   3383: that allow finer tuning of the tree layout.</p>
                   3384: </div>
                   3385: <div class="sect1" lang="en">
                   3386: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3387: <a name="resume-transfers"></a>8.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
1.75      rillig   3388: <p>By default, resuming transfers in pkgsrc is disabled, but you can
                   3389: enable this feature by adding the option
                   3390: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76      rillig   3391: <code class="filename">/etc/mk.conf</code>.  If, during a fetch step, an incomplete
1.75      rillig   3392: distfile is found, pkgsrc will try to resume it.</p>
                   3393: <p>You can also
                   3394: use a different program than the default <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ftp+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ftp</span>(1)</span></a> by changing the
                   3395: <code class="varname">FETCH_CMD</code> variable.  Don't forget to set
                   3396: <code class="varname">FETCH_RESUME_ARGS</code> and
                   3397: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
                   3398: values.</p>
                   3399: <p>For example, if you want to use
1.76      rillig   3400: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75      rillig   3401: like:</p>
                   3402: <pre class="programlisting">
                   3403:     FETCH_CMD=             wget
                   3404:     FETCH_BEFORE_ARGS=     --passive-ftp
                   3405:     FETCH_RESUME_ARGS=     -c
                   3406:     FETCH_OUTPUT_ARGS=     -O
1.1       grant    3407: </pre>
1.75      rillig   3408: </div>
                   3409: <div class="sect1" lang="en">
                   3410: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3411: <a name="XFree86-from-pkgsrc"></a>8.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
1.75      rillig   3412: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76      rillig   3413: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75      rillig   3414: ...), you will have to add the following line into
1.76      rillig   3415: <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3416: <pre class="programlisting">
                   3417:     X11_TYPE=XFree86
1.1       grant    3418: </pre>
1.75      rillig   3419: </div>
                   3420: <div class="sect1" lang="en">
                   3421: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3422: <a name="x.org-from-pkgsrc"></a>8.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
1.75      rillig   3423: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76      rillig   3424: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75      rillig   3425: you will have to add the following line into
1.76      rillig   3426: <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3427: <pre class="programlisting">
                   3428:     X11_TYPE=xorg
1.1       grant    3429: </pre>
1.75      rillig   3430: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   3431: <h3 class="title">Note</h3>
                   3432: <p>The DragonFly operating system defaults to using
1.87      wiz      3433: this X.org X11 implementation from pkgsrc.</p>
1.75      rillig   3434: </div>
                   3435: </div>
                   3436: <div class="sect1" lang="en">
                   3437: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3438: <a name="fetch-behind-firewall"></a>8.8. How to fetch files from behind a firewall</h2></div></div></div>
1.75      rillig   3439: <p>If you are sitting behind a firewall which does not allow direct
                   3440: connections to Internet hosts (i.e. non-NAT), you may specify the
                   3441: relevant proxy hosts.  This is done using an environment variable in the
                   3442: form of a URL, e.g. in Amdahl, the machine
                   3443: &#8220;<span class="quote">orpheus.amdahl.com</span>&#8221; is one of the firewalls, and it uses
                   3444: port 80 as the proxy port number.  So the proxy environment variables
                   3445: are:</p>
                   3446: <pre class="programlisting">
                   3447:     ftp_proxy=ftp://orpheus.amdahl.com:80/
                   3448:     http_proxy=http://orpheus.amdahl.com:80/
1.1       grant    3449: </pre>
1.75      rillig   3450: </div>
                   3451: <div class="sect1" lang="en">
                   3452: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3453: <a name="passive-ftp"></a>8.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</h2></div></div></div>
1.75      rillig   3454: <p>This depends on which utility is used to retrieve distfiles.  From
1.76      rillig   3455: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75      rillig   3456: the first available command from the following list:</p>
                   3457: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3458: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
                   3459: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75      rillig   3460: </ul></div>
                   3461: <p>On a default NetBSD installation, this will be
1.76      rillig   3462: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75      rillig   3463: connections first, and falls back to active connections if the server
                   3464: refuses to do passive.  For the other tools, add the following to your
1.76      rillig   3465: <code class="filename">/etc/mk.conf</code> file:
1.75      rillig   3466: <code class="varname">PASSIVE_FETCH=1</code>.</p>
                   3467: <p>Having that option present will prevent
1.76      rillig   3468: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75      rillig   3469: transfers.</p>
                   3470: </div>
                   3471: <div class="sect1" lang="en">
                   3472: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3473: <a name="fetching-all-distfiles"></a>8.10. How to fetch all distfiles at once</h2></div></div></div>
1.88      wiz      3474: <p>You would like to download all the distfiles in a single batch
                   3475: from work or university, where you can't run a <span><strong class="command">make
                   3476: fetch</strong></span>.  There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
1.75      rillig   3477: but downloading the entire directory may not be appropriate.</p>
                   3478: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76      rillig   3479: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75      rillig   3480: resulting list to your machine at work/school and use it there.  If you
                   3481: don't have a NetBSD-compatible <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ftp+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ftp</span>(1)</span></a> (like tnftp) at work, don't
                   3482: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
                   3483: URL:</p>
                   3484: <p>At home:</p>
                   3485: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   3486: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles &gt;/tmp/fetch.sh</code></strong>
                   3487: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
                   3488: <p>At work:</p>
                   3489: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76      rillig   3490: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75      rillig   3491: home.</p>
                   3492: <p>If you have a machine running NetBSD, and you want to get
1.88      wiz      3493: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your
                   3494: machine architecture), you can do so by using the above-mentioned
                   3495: <span><strong class="command">make fetch-list</strong></span> approach, or fetch the distfiles
                   3496: directly by running:</p>
1.75      rillig   3497: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
                   3498: <p>If you even decide to ignore
                   3499: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
                   3500: by running:</p>
                   3501: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
                   3502: </div>
                   3503: <div class="sect1" lang="en">
                   3504: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3505: <a name="tmac.andoc-missing"></a>8.11. What does &#8220;<span class="quote">Don't know how to make
1.75      rillig   3506: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</h2></div></div></div>
1.91      rillig   3507: <p>When compiling the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>
1.75      rillig   3508: package, you get the error from make that it doesn't know how to make
1.76      rillig   3509: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75      rillig   3510: you don't have installed the &#8220;<span class="quote">text</span>&#8221; set (nroff, ...) from
                   3511: the NetBSD base distribution on your machine.  It is recommended to do
                   3512: that to format man pages.</p>
1.91      rillig   3513: <p>In the case of the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a> package, you
1.75      rillig   3514: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76      rillig   3515: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75      rillig   3516: </div>
                   3517: <div class="sect1" lang="en">
                   3518: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3519: <a name="bsd.own.mk-missing"></a>8.12. What does &#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221; mean?</h2></div></div></div>
1.87      wiz      3520: <p>You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75      rillig   3521: when you installed your NetBSD machine.  Please get and install it, by
1.76      rillig   3522: extracting it in <code class="filename">/</code>:</p>
1.75      rillig   3523: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
                   3524: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76      rillig   3525: <p><code class="filename">comp.tgz</code> is part of every NetBSD release.  Get
1.75      rillig   3526: the one that corresponds to your release (determine via <span><strong class="command">uname
                   3527: -r</strong></span>).</p>
                   3528: </div>
                   3529: <div class="sect1" lang="en">
                   3530: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3531: <a name="using-sudo-with-pkgsrc"></a>8.13. Using 'sudo' with pkgsrc</h2></div></div></div>
1.75      rillig   3532: <p>When installing packages as non-root user and using the just-in-time
                   3533: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?su+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">su</span>(1)</span></a> feature of pkgsrc, it can become annoying to type in the root
                   3534: password for each required package installed.  To avoid this, the sudo
                   3535: package can be used, which does password caching over a limited time.  To
                   3536: use it, install sudo (either as binary package or from
1.91      rillig   3537: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/sudo/README.html" target="_top"><code class="filename">security/sudo</code></a>) and then put the following
1.76      rillig   3538: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3539: <pre class="programlisting">
                   3540:     .if exists(${LOCALBASE}/bin/sudo)
                   3541:     SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   3542:     .endif
1.1       grant    3543: </pre>
1.75      rillig   3544: </div>
                   3545: <div class="sect1" lang="en">
                   3546: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3547: <a name="faq.conf"></a>8.14. How do I change the location of configuration files?</h2></div></div></div>
1.75      rillig   3548: <p>As the system administrator, you can choose where configuration files
                   3549: are installed.  The default settings make all these files go into
1.76      rillig   3550: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75      rillig   3551: be suboptimal depending on your expectations (e.g., a read-only,
                   3552: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
                   3553: configuration of the provided packages).</p>
                   3554: <p>In order to change the defaults, you can modify the
                   3555: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76      rillig   3556: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
                   3557: directory; some common examples include <code class="filename">/etc</code> or
                   3558: <code class="filename">/etc/pkg</code>.</p>
1.75      rillig   3559: <p>Furthermore, you can change this value on a per-package basis by
                   3560: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
                   3561: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
                   3562: package you would like to modify, that is, the contents of
                   3563: <code class="varname">PKGBASE</code>.</p>
                   3564: <p>Note that after changing these settings, you must rebuild and
                   3565: reinstall any affected packages.</p>
                   3566: </div>
                   3567: <div class="sect1" lang="en">
                   3568: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3569: <a name="audit-packages"></a>8.15. Automated security checks</h2></div></div></div>
1.75      rillig   3570: <p>Please be aware that there can often be bugs in third-party software,
                   3571: and some of these bugs can leave a machine vulnerable to exploitation by
                   3572: attackers.  In an effort to lessen the exposure, the NetBSD packages team
                   3573: maintains a database of known-exploits to packages which have at one time
                   3574: been included in pkgsrc.  The database can be downloaded automatically, and
                   3575: a security audit of all packages installed on a system can take place.  To
1.91      rillig   3576: do this, install the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> package.  It has two
1.75      rillig   3577: components:</p>
                   3578: <div class="orderedlist"><ol type="1">
                   3579: <li>
                   3580: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
                   3581:     download a list of the security vulnerabilities information.  This list
                   3582:     is kept up to date by the NetBSD security officer and the NetBSD
                   3583:     packages team, and is distributed from the NetBSD ftp server:</p>
                   3584: <p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/pkg-vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/pkg-vulnerabilities</a></p>
                   3585: </li>
                   3586: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
                   3587:     current machine, checking each vulnerability which is known.  If a
                   3588:     vulnerable package is installed, it will be shown by output to stdout,
                   3589:     including a description of the type of vulnerability, and a URL
                   3590:     containing more information.</p></li>
                   3591: </ol></div>
1.91      rillig   3592: <p>Use of the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>
1.75      rillig   3593: package is strongly recommended!  After
                   3594: &#8220;<span class="quote">audit-packages</span>&#8221; is installed, please read
                   3595: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
                   3596: audit-packages</code></strong>.</p>
1.87      wiz      3597: <p>If this package is installed, pkgsrc builds will use it to
                   3598: perform a security check before building any package.  See <a href="#variables-affecting-build" title="5.2. Variables affecting the build process">Section 5.2, &#8220;Variables affecting the build process&#8221;</a> for ways to control this
                   3599: check.</p>
1.75      rillig   3600: </div>
                   3601: <div class="sect1" lang="en">
                   3602: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3603: <a name="ufaq-cflags"></a>8.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
1.75      rillig   3604: <p>When you add your own preferences to the
                   3605:        <code class="varname">CFLAGS</code> variable in your
1.76      rillig   3606:        <code class="filename">mk.conf</code>, these flags are passed in
                   3607:        environment variables to the <code class="filename">./configure</code>
1.75      rillig   3608:        scripts and to <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>. Some package authors ignore the
                   3609:        <code class="varname">CFLAGS</code> from the environment variable by
1.76      rillig   3610:        overriding them in the <code class="filename">Makefile</code>s of their
1.75      rillig   3611:        package.</p>
                   3612: <p>Currently there is no solution to this problem. If you
                   3613:        really need the package to use your <code class="varname">CFLAGS</code>
                   3614:        you should run <span><strong class="command">make patch</strong></span> in the package
1.76      rillig   3615:        directory and then inspect any <code class="filename">Makefile</code> and
                   3616:        <code class="filename">Makefile.in</code> for whether they define
1.75      rillig   3617:        <code class="varname">CFLAGS</code> explicitly. Usually you can remove
                   3618:        these lines. But be aware that some &#8220;<span class="quote">smart</span>&#8221;
                   3619:        programmers write so bad code that it only works for the
                   3620:        specific combination of <code class="varname">CFLAGS</code> they have
                   3621:        chosen.</p>
                   3622: </div>
1.80      rillig   3623: <div class="sect1" lang="en">
                   3624: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3625: <a name="ufaq-fail"></a>8.17. A package does not build.  What shall I do?</h2></div></div></div>
1.80      rillig   3626: <div class="procedure"><ol type="1">
                   3627: <li><p>Make sure that your copy of pkgsrc is consistent. A
                   3628:        case that occurs often is that people only update pkgsrc in
                   3629:        parts, because of performance reasons. Since pkgsrc is one large
                   3630:        system, not a collection of many small systems, there are
                   3631:        sometimes changes that only work when the whole pkgsrc tree is
                   3632:        updated.</p></li>
                   3633: <li><p>Make sure that you don't have any CVS conflicts.
                   3634:        Search for &#8220;<span class="quote">&lt;&lt;&lt;&lt;&lt;&lt;</span>&#8221; or
                   3635:        &#8220;<span class="quote">&gt;&gt;&gt;&gt;&gt;&gt;</span>&#8221; in all your pkgsrc
                   3636:        files.</p></li>
                   3637: <li><p>Make sure that you don't have old copies of the packages
                   3638:        extracted. Run <span><strong class="command">make clean clean-depends</strong></span> to
                   3639:        verify this.</p></li>
                   3640: <li><p>If the problem still exists, write a mail to the
                   3641:        <code class="literal">pkgsrc-users</code> mailing list.</p></li>
                   3642: </ol></div>
                   3643: </div>
1.88      wiz      3644: <div class="sect1" lang="en">
                   3645: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   3646: <a name="faq.rcs-conflicts"></a>8.18. What does &#8220;<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>&#8221; mean?</h2></div></div></div>
1.89      rillig   3647: <p>You have modified a file from pkgsrc, and someone else has
                   3648: modified that same file afterwards in the CVS repository. Both changes
                   3649: are in the same region of the file, so when you updated pkgsrc, the
                   3650: <code class="literal">cvs</code> command marked the conflicting changes in the
                   3651: file. Because of these markers, the file is no longer a valid
                   3652: <code class="filename">Makefile</code>.</p>
                   3653: <p>Have a look at that file, and if you don't need your local changes
                   3654: anymore, you can remove that file and run <span><strong class="command">cvs -q update
                   3655: -dP</strong></span> in that directory to download the current version.</p>
                   3656: </div>
1.75      rillig   3657: </div>
                   3658: </div>
                   3659: <div class="part" lang="en">
                   3660: <div class="titlepage"><div><div><h1 class="title">
                   3661: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77      rillig   3662: <div class="partintro" lang="en">
                   3663: <div></div>
                   3664: <p>This part of the book deals with creating and
                   3665:        modifying packages. It starts with a &#8220;<span class="quote">HOWTO</span>&#8221;-like
                   3666:        guide on creating a new package. The remaining chapters are more
                   3667:        like a reference manual for pkgsrc.</p>
1.75      rillig   3668: <div class="toc">
                   3669: <p><b>Table of Contents</b></p>
                   3670: <dl>
1.90      rillig   3671: <dt><span class="chapter"><a href="#creating">9. Creating a new pkgsrc package from scratch</a></span></dt>
1.91      rillig   3672: <dd><dl>
                   3673: <dt><span class="sect1"><a href="#creating.common">9.1. Common types of packages</a></span></dt>
                   3674: <dd><dl>
                   3675: <dt><span class="sect2"><a href="#creating.perl-module">9.1.1. Perl modules</a></span></dt>
                   3676: <dt><span class="sect2"><a href="#creating.kde-app">9.1.2. KDE applications</a></span></dt>
                   3677: </dl></dd>
                   3678: <dt><span class="sect1"><a href="#creating.examples">9.2. Examples</a></span></dt>
                   3679: <dd><dl><dt><span class="sect2"><a href="#creating.nvu">9.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
                   3680: </dl></dd>
1.90      rillig   3681: <dt><span class="chapter"><a href="#components">10. Package components - files, directories and contents</a></span></dt>
1.75      rillig   3682: <dd><dl>
1.90      rillig   3683: <dt><span class="sect1"><a href="#components.Makefile">10.1. <code class="filename">Makefile</code></a></span></dt>
                   3684: <dt><span class="sect1"><a href="#components.distinfo">10.2. <code class="filename">distinfo</code></a></span></dt>
                   3685: <dt><span class="sect1"><a href="#components.patches">10.3. patches/*</a></span></dt>
                   3686: <dd><dl>
                   3687: <dt><span class="sect2"><a href="#components.patches.guidelines">10.3.1. Patching guidelines</a></span></dt>
                   3688: <dt><span class="sect2"><a href="#components.patches.feedback">10.3.2. Feedback to the author</a></span></dt>
                   3689: </dl></dd>
                   3690: <dt><span class="sect1"><a href="#other-mandatory-files">10.4. Other mandatory files</a></span></dt>
                   3691: <dt><span class="sect1"><a href="#components.optional">10.5. Optional files</a></span></dt>
                   3692: <dd><dl>
                   3693: <dt><span class="sect2"><a href="#components.optional.bin">10.5.1. Files affecting the binary package</a></span></dt>
                   3694: <dt><span class="sect2"><a href="#components.optional.build">10.5.2. Files affecting the build process</a></span></dt>
                   3695: <dt><span class="sect2"><a href="#components.optional.none">10.5.3. Files affecting nothing at all</a></span></dt>
                   3696: </dl></dd>
                   3697: <dt><span class="sect1"><a href="#work-dir">10.6. <code class="filename">work*</code></a></span></dt>
                   3698: <dt><span class="sect1"><a href="#files-dir">10.7. <code class="filename">files/*</code></a></span></dt>
                   3699: </dl></dd>
                   3700: <dt><span class="chapter"><a href="#makefile">11. Programming in <code class="filename">Makefile</code>s</a></span></dt>
                   3701: <dd><dl>
                   3702: <dt><span class="sect1"><a href="#makefile.variables">11.1. <code class="filename">Makefile</code> variables</a></span></dt>
                   3703: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">11.1.1. Naming conventions</a></span></dt></dl></dd>
                   3704: <dt><span class="sect1"><a href="#makefile.code">11.2. Code snippets</a></span></dt>
                   3705: <dd><dl>
                   3706: <dt><span class="sect2"><a href="#adding-to-list">11.2.1. Adding things to a list</a></span></dt>
                   3707: <dt><span class="sect2"><a href="#converting-internal-to-external">11.2.2. Converting an internal list into an external list</a></span></dt>
                   3708: <dt><span class="sect2"><a href="#passing-variable-to-shell">11.2.3. Passing variables to a shell command</a></span></dt>
                   3709: <dt><span class="sect2"><a href="#quoting-guideline">11.2.4. Quoting guideline</a></span></dt>
                   3710: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">11.2.5. Workaround for a bug in BSD Make</a></span></dt>
                   3711: </dl></dd>
                   3712: </dl></dd>
                   3713: <dt><span class="chapter"><a href="#plist">12. PLIST issues</a></span></dt>
                   3714: <dd><dl>
                   3715: <dt><span class="sect1"><a href="#rcs-id">12.1. RCS ID</a></span></dt>
                   3716: <dt><span class="sect1"><a href="#automatic-plist-generation">12.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
                   3717: <dt><span class="sect1"><a href="#print-PLIST">12.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
                   3718: <dt><span class="sect1"><a href="#plist.misc">12.4. Variable substitution in PLIST</a></span></dt>
                   3719: <dt><span class="sect1"><a href="#manpage-compression">12.5. Man page compression</a></span></dt>
                   3720: <dt><span class="sect1"><a href="#using-PLIST_SRC">12.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
                   3721: <dt><span class="sect1"><a href="#platform-specific-plist">12.7. Platform-specific and differing PLISTs</a></span></dt>
                   3722: <dt><span class="sect1"><a href="#faq.common-dirs">12.8. Sharing directories between packages</a></span></dt>
                   3723: </dl></dd>
                   3724: <dt><span class="chapter"><a href="#buildlink">13. Buildlink methodology</a></span></dt>
                   3725: <dd><dl>
                   3726: <dt><span class="sect1"><a href="#converting-to-buildlink3">13.1. Converting packages to use buildlink3</a></span></dt>
                   3727: <dt><span class="sect1"><a href="#creating-buildlink3.mk">13.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
                   3728: <dd><dl>
                   3729: <dt><span class="sect2"><a href="#anatomy-of-bl3">13.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
                   3730: <dt><span class="sect2"><a href="#updating-buildlink-depends">13.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</a></span></dt>
                   3731: </dl></dd>
                   3732: <dt><span class="sect1"><a href="#writing-builtin.mk">13.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
                   3733: <dd><dl>
                   3734: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">13.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
                   3735: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">13.3.2. Global preferences for native or pkgsrc software</a></span></dt>
                   3736: </dl></dd>
                   3737: </dl></dd>
                   3738: <dt><span class="chapter"><a href="#pkginstall">14. The pkginstall framework</a></span></dt>
                   3739: <dd><dl>
                   3740: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">14.1. Files and directories outside the installation prefix</a></span></dt>
                   3741: <dd><dl>
                   3742: <dt><span class="sect2"><a href="#dirs-outside-prefix">14.1.1. Directory manipulation</a></span></dt>
                   3743: <dt><span class="sect2"><a href="#files-outside-prefix">14.1.2. File manipulation</a></span></dt>
                   3744: </dl></dd>
                   3745: <dt><span class="sect1"><a href="#conf-files">14.2. Configuration files</a></span></dt>
                   3746: <dd><dl>
                   3747: <dt><span class="sect2"><a href="#conf-files-sysconfdir">14.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
                   3748: <dt><span class="sect2"><a href="#conf-files-configure">14.2.2. Telling the software where configuration files are</a></span></dt>
                   3749: <dt><span class="sect2"><a href="#conf-files-patching">14.2.3. Patching installations</a></span></dt>
                   3750: <dt><span class="sect2"><a href="#conf-files-disable">14.2.4. Disabling handling of configuration files</a></span></dt>
                   3751: </dl></dd>
                   3752: <dt><span class="sect1"><a href="#rcd-scripts">14.3. System startup scripts</a></span></dt>
                   3753: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">14.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
                   3754: <dt><span class="sect1"><a href="#users-and-groups">14.4. System users and groups</a></span></dt>
                   3755: <dt><span class="sect1"><a href="#shells">14.5. System shells</a></span></dt>
                   3756: <dd><dl><dt><span class="sect2"><a href="#shells-disable">14.5.1. Disabling shell registration</a></span></dt></dl></dd>
                   3757: <dt><span class="sect1"><a href="#fonts">14.6. Fonts</a></span></dt>
                   3758: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">14.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
                   3759: </dl></dd>
                   3760: <dt><span class="chapter"><a href="#options">15. Options handling</a></span></dt>
                   3761: <dd><dl>
                   3762: <dt><span class="sect1"><a href="#global-default-options">15.1. Global default options</a></span></dt>
                   3763: <dt><span class="sect1"><a href="#converting-to-options">15.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
                   3764: <dt><span class="sect1"><a href="#option-names">15.3. Option Names</a></span></dt>
                   3765: </dl></dd>
                   3766: <dt><span class="chapter"><a href="#build">16. The build process</a></span></dt>
                   3767: <dd><dl>
                   3768: <dt><span class="sect1"><a href="#build.intro">16.1. Introduction</a></span></dt>
                   3769: <dt><span class="sect1"><a href="#build.prefix">16.2. Program location</a></span></dt>
                   3770: <dt><span class="sect1"><a href="#build.builddirs">16.3. Directories used during the build process</a></span></dt>
                   3771: <dt><span class="sect1"><a href="#build.running">16.4. Running a phase</a></span></dt>
                   3772: <dt><span class="sect1"><a href="#build.fetch">16.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
                   3773: <dd><dl>
                   3774: <dt><span class="sect2"><a href="#build.fetch.what">16.5.1. What to fetch and where to get it from</a></span></dt>
                   3775: <dt><span class="sect2"><a href="#build.fetch.how">16.5.2. How are the files fetched?</a></span></dt>
                   3776: </dl></dd>
                   3777: <dt><span class="sect1"><a href="#build.checksum">16.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
                   3778: <dt><span class="sect1"><a href="#build.extract">16.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
                   3779: <dt><span class="sect1"><a href="#build.patch">16.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
                   3780: <dt><span class="sect1"><a href="#build.tools">16.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
                   3781: <dt><span class="sect1"><a href="#build.wrapper">16.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
                   3782: <dt><span class="sect1"><a href="#build.configure">16.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   3783: <dt><span class="sect1"><a href="#build.build">16.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   3784: <dt><span class="sect1"><a href="#build.test">16.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
                   3785: <dt><span class="sect1"><a href="#build.install">16.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   3786: <dt><span class="sect1"><a href="#build.package">16.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
                   3787: <dt><span class="sect1"><a href="#build.clean">16.16. Cleaning up</a></span></dt>
                   3788: <dt><span class="sect1"><a href="#build.helpful-targets">16.17. Other helpful targets</a></span></dt>
                   3789: </dl></dd>
                   3790: <dt><span class="chapter"><a href="#tools">17. Tools needed for building or running</a></span></dt>
                   3791: <dd><dl>
                   3792: <dt><span class="sect1"><a href="#pkgsrc-tools">17.1. Tools for pkgsrc builds</a></span></dt>
                   3793: <dt><span class="sect1"><a href="#package-tools">17.2. Tools needed by packages</a></span></dt>
                   3794: <dt><span class="sect1"><a href="#platform-tools">17.3. Tools provided by platforms</a></span></dt>
                   3795: </dl></dd>
                   3796: <dt><span class="chapter"><a href="#fixes">18. Making your package work</a></span></dt>
                   3797: <dd><dl>
                   3798: <dt><span class="sect1"><a href="#general-operation">18.1. General operation</a></span></dt>
                   3799: <dd><dl>
                   3800: <dt><span class="sect2"><a href="#portability-of-packages">18.1.1. Portability of packages</a></span></dt>
                   3801: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">18.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
                   3802: <dt><span class="sect2"><a href="#user-interaction">18.1.3. User interaction</a></span></dt>
                   3803: <dt><span class="sect2"><a href="#handling-licenses">18.1.4. Handling licenses</a></span></dt>
                   3804: <dt><span class="sect2"><a href="#restricted-packages">18.1.5. Restricted packages</a></span></dt>
                   3805: <dt><span class="sect2"><a href="#dependencies">18.1.6. Handling dependencies</a></span></dt>
                   3806: <dt><span class="sect2"><a href="#conflicts">18.1.7. Handling conflicts with other packages</a></span></dt>
                   3807: <dt><span class="sect2"><a href="#not-building-packages">18.1.8. Packages that cannot or should not be built</a></span></dt>
                   3808: <dt><span class="sect2"><a href="#undeletable-packages">18.1.9. Packages which should not be deleted, once installed</a></span></dt>
                   3809: <dt><span class="sect2"><a href="#security-handling">18.1.10. Handling packages with security problems</a></span></dt>
                   3810: <dt><span class="sect2"><a href="#bumping-pkgrevision">18.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
                   3811: <dt><span class="sect2"><a href="#fixes.subst">18.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
                   3812: </dl></dd>
                   3813: <dt><span class="sect1"><a href="#fixes.fetch">18.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
                   3814: <dd><dl>
                   3815: <dt><span class="sect2"><a href="#no-plain-download">18.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
                   3816: <dt><span class="sect2"><a href="#modified-distfiles-same-name">18.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
                   3817: </dl></dd>
                   3818: <dt><span class="sect1"><a href="#fixes.configure">18.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   3819: <dd><dl>
                   3820: <dt><span class="sect2"><a href="#fixes.libtool">18.3.1. Shared libraries - libtool</a></span></dt>
                   3821: <dt><span class="sect2"><a href="#using-libtool">18.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
                   3822: <dt><span class="sect2"><a href="#autoconf-automake">18.3.3. GNU Autoconf/Automake</a></span></dt>
                   3823: </dl></dd>
                   3824: <dt><span class="sect1"><a href="#programming-languages">18.4. Programming languages</a></span></dt>
                   3825: <dd><dl>
                   3826: <dt><span class="sect2"><a href="#basic-programming-languages">18.4.1. C, C++, and Fortran</a></span></dt>
                   3827: <dt><span class="sect2"><a href="#java-programming-language">18.4.2. Java</a></span></dt>
                   3828: <dt><span class="sect2"><a href="#perl-scripts">18.4.3. Packages containing perl scripts</a></span></dt>
                   3829: <dt><span class="sect2"><a href="#other-programming-languages">18.4.4. Other programming languages</a></span></dt>
                   3830: </dl></dd>
                   3831: <dt><span class="sect1"><a href="#fixes.build">18.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   3832: <dd><dl>
                   3833: <dt><span class="sect2"><a href="#fixes.build.cpp">18.5.1. Compiling C and C++ code conditionally</a></span></dt>
                   3834: <dt><span class="sect2"><a href="#compiler-bugs">18.5.2. How to handle compiler bugs</a></span></dt>
                   3835: <dt><span class="sect2"><a href="#undefined-reference">18.5.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
                   3836: <dt><span class="sect2"><a href="#out-of-memory">18.5.4. Running out of memory</a></span></dt>
                   3837: </dl></dd>
                   3838: <dt><span class="sect1"><a href="#fixes.install">18.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   3839: <dd><dl>
                   3840: <dt><span class="sect2"><a href="#install-scripts">18.6.1. Creating needed directories</a></span></dt>
                   3841: <dt><span class="sect2"><a href="#where-to-install-documentation">18.6.2. Where to install documentation</a></span></dt>
                   3842: <dt><span class="sect2"><a href="#installing-score-files">18.6.3. Installing score files</a></span></dt>
                   3843: <dt><span class="sect2"><a href="#hardcoded-paths">18.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
                   3844: <dt><span class="sect2"><a href="#perl-modules">18.6.5. Packages installing perl modules</a></span></dt>
                   3845: <dt><span class="sect2"><a href="#faq.info-files">18.6.6. Packages installing info files</a></span></dt>
                   3846: <dt><span class="sect2"><a href="#manpages">18.6.7. Packages installing man pages</a></span></dt>
                   3847: <dt><span class="sect2"><a href="#gconf2-data-files">18.6.8. Packages installing GConf2 data files</a></span></dt>
                   3848: <dt><span class="sect2"><a href="#scrollkeeper-data-files">18.6.9. Packages installing scrollkeeper data files</a></span></dt>
                   3849: <dt><span class="sect2"><a href="#x11-fonts">18.6.10. Packages installing X11 fonts</a></span></dt>
                   3850: <dt><span class="sect2"><a href="#gtk2-modules">18.6.11. Packages installing GTK2 modules</a></span></dt>
                   3851: <dt><span class="sect2"><a href="#sgml-xml-data">18.6.12. Packages installing SGML or XML data</a></span></dt>
                   3852: <dt><span class="sect2"><a href="#mime-database">18.6.13. Packages installing extensions to the MIME database</a></span></dt>
                   3853: <dt><span class="sect2"><a href="#intltool">18.6.14. Packages using intltool</a></span></dt>
                   3854: <dt><span class="sect2"><a href="#startup-scripts">18.6.15. Packages installing startup scripts</a></span></dt>
                   3855: <dt><span class="sect2"><a href="#tex-packages">18.6.16. Packages installing TeX modules</a></span></dt>
                   3856: <dt><span class="sect2"><a href="#emulation-packages">18.6.17. Packages supporting running binaries in
1.87      wiz      3857:     emulation</a></span></dt>
1.90      rillig   3858: <dt><span class="sect2"><a href="#hicolor-theme">18.6.18. Packages installing hicolor theme icons</a></span></dt>
                   3859: <dt><span class="sect2"><a href="#desktop-files">18.6.19. Packages installing desktop files</a></span></dt>
1.77      rillig   3860: </dl></dd>
1.90      rillig   3861: <dt><span class="sect1"><a href="#punting">18.7. Marking packages as having problems</a></span></dt>
1.77      rillig   3862: </dl></dd>
1.90      rillig   3863: <dt><span class="chapter"><a href="#debug">19. Debugging</a></span></dt>
                   3864: <dt><span class="chapter"><a href="#submit">20. Submitting and Committing</a></span></dt>
1.77      rillig   3865: <dd><dl>
1.90      rillig   3866: <dt><span class="sect1"><a href="#submitting-binary-packages">20.1. Submitting binary packages</a></span></dt>
                   3867: <dt><span class="sect1"><a href="#submitting-your-package">20.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                   3868: <dt><span class="sect1"><a href="#general-notes-for-changes">20.3. General notes when adding, updating, or removing packages</a></span></dt>
                   3869: <dt><span class="sect1"><a href="#committing-importing">20.4. Committing: Importing a package into CVS</a></span></dt>
                   3870: <dt><span class="sect1"><a href="#updating-package">20.5. Updating a package to a newer version</a></span></dt>
                   3871: <dt><span class="sect1"><a href="#moving-package">20.6. Moving a package in pkgsrc</a></span></dt>
                   3872: </dl></dd>
                   3873: <dt><span class="chapter"><a href="#devfaq">21. Frequently Asked Questions</a></span></dt>
                   3874: <dt><span class="chapter"><a href="#gnome">22. GNOME packaging and porting</a></span></dt>
                   3875: <dd><dl>
                   3876: <dt><span class="sect1"><a href="#meta-packages">22.1. Meta packages</a></span></dt>
                   3877: <dt><span class="sect1"><a href="#new-package">22.2. Packaging a GNOME application</a></span></dt>
                   3878: <dt><span class="sect1"><a href="#full-update">22.3. Updating GNOME to a newer version</a></span></dt>
                   3879: <dt><span class="sect1"><a href="#patching">22.4. Patching guidelines</a></span></dt>
1.85      jmmv     3880: </dl></dd>
1.75      rillig   3881: </dl>
                   3882: </div>
1.77      rillig   3883: </div>
                   3884: <div class="chapter" lang="en">
                   3885: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   3886: <a name="creating"></a>Chapter 9. Creating a new pkgsrc package from scratch</h2></div></div></div>
1.91      rillig   3887: <div class="toc">
                   3888: <p><b>Table of Contents</b></p>
                   3889: <dl>
                   3890: <dt><span class="sect1"><a href="#creating.common">9.1. Common types of packages</a></span></dt>
                   3891: <dd><dl>
                   3892: <dt><span class="sect2"><a href="#creating.perl-module">9.1.1. Perl modules</a></span></dt>
                   3893: <dt><span class="sect2"><a href="#creating.kde-app">9.1.2. KDE applications</a></span></dt>
                   3894: </dl></dd>
                   3895: <dt><span class="sect1"><a href="#creating.examples">9.2. Examples</a></span></dt>
                   3896: <dd><dl><dt><span class="sect2"><a href="#creating.nvu">9.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
                   3897: </dl>
                   3898: </div>
1.77      rillig   3899: <p>When you find a package that is not yet in pkgsrc, you
1.91      rillig   3900: most likely have a URL from where you can download the source
                   3901: code. Starting with this URL, creating a package involves only a
                   3902: few steps.</p>
1.77      rillig   3903: <div class="procedure"><ol type="1">
1.91      rillig   3904: <li><p>First, install the packages <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a> and <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>.</p></li>
1.77      rillig   3905: <li><p>Then, choose one of the top-level directories as the
1.91      rillig   3906: category in which you want to place your package. You can also create a
                   3907: directory of your own (maybe called <code class="filename">local</code>). In that
                   3908: category directory, create another directory for your package and change
                   3909: into it.</p></li>
                   3910: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which will ask
                   3911: you for a URL. Enter the URL of the distribution file (in most cases a
                   3912: <code class="filename">.tar.gz</code> file) and watch how the basic ingredients
                   3913: of your package are created automatically. The distribution file is
                   3914: extracted automatically to fill in some details in the
                   3915: <code class="filename">Makefile</code> that would otherwise have to be done
                   3916: manually.</p></li>
                   3917: <li>
                   3918: <p>Examine the extracted files to determine the dependencies of
                   3919: your package. Ideally, this is mentioned in some
                   3920: <code class="filename">README</code> file, but things may differ. For each of
                   3921: these dependencies, look where it exists in pkgsrc, and if there is a
                   3922: file called <code class="filename">buildlink3.mk</code> in that directory, add a
                   3923: line to your package <code class="filename">Makefile</code> which includes that
                   3924: file just before the last line. If the
                   3925: <code class="filename">buildlink3.mk</code> file does not exist, add a
                   3926: <code class="varname">DEPENDS</code> line to the Makefile, which specifies the
                   3927: version of the dependency and where it can be found in pkgsrc. This line
                   3928: should be placed in the third paragraph. If the dependency is only
                   3929: needed for building the package, but not when using it, use
                   3930: <code class="varname">BUILD_DEPENDS</code> instead of <code class="varname">DEPENDS</code>.
                   3931: Your package may then look like this:</p>
1.77      rillig   3932: <pre class="programlisting">
                   3933:     [...]
                   3934: 
                   3935:     BUILD_DEPENDS+= lua&gt;=5.0:../../lang/lua
                   3936:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   3937:     DEPENDS+=       screen&gt;=4.0:../../misc/screen
                   3938: 
                   3939:     [...]
                   3940: 
                   3941:     .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
                   3942:     .include "../../devel/glib2/buildlink3.mk"
                   3943:     .include "../../mk/bsd.pkg.mk"
                   3944: </pre>
                   3945: </li>
1.91      rillig   3946: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things still need
                   3947: to be done to make your package a &#8220;<span class="quote">good</span>&#8221; one. If you don't
                   3948: know what pkglint's warnings want to tell you, try <span><strong class="command">pkglint
                   3949: --explain</strong></span> or <span><strong class="command">pkglint
                   3950: -e</strong></span>, which outputs additional
                   3951: explanations.</p></li>
                   3952: <li><p>In many cases the package is not yet ready to build. You can
                   3953: find instructions for the most common cases in the next section, <a href="#creating.common" title="9.1. Common types of packages">Section 9.1, &#8220;Common types of packages&#8221;</a>. After you have followed the instructions
                   3954: over there, you can hopefully continue here.</p></li>
                   3955: <li><p>Run <span><strong class="command">bmake clean</strong></span> to clean the working
                   3956: directory from the extracted files. Besides these files, a lot of cache
                   3957: files and other system information has been saved in the working
                   3958: directory, which may become wrong after you edited the
                   3959: <code class="filename">Makefile</code>.</p></li>
                   3960: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the package. For
                   3961: the various things that can go wrong in this phase, consult <a href="#fixes" title="Chapter 18. Making your package work">Chapter 18, <i>Making your package work</i></a>.</p></li>
                   3962: <li><p>When the package builds fine, the next step is to install
                   3963: the package. Run <span><strong class="command">bmake install</strong></span> and hope that
                   3964: everything works.</p></li>
                   3965: <li><p>Up to now, the file <code class="filename">PLIST</code>, which
                   3966: contains a list of the files that are installed by the package, is
                   3967: nearly empty. Run <span><strong class="command">bmake print-PLIST
                   3968: &gt;PLIST</strong></span> to generate a probably correct list. Check
                   3969: the file using your preferred text editor to see if the list of
                   3970: files looks plausible.</p></li>
                   3971: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the generated
                   3972: <code class="filename">PLIST</code> contains garbage or not.</p></li>
                   3973: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the package
                   3974: has been registered in the database of installed files, but with an
                   3975: empty list of files. To fix this, run <span><strong class="command">bmake deinstall</strong></span>
                   3976: and <span><strong class="command">bmake install</strong></span> again. Now the package is
                   3977: registered with the list of files from
                   3978: <code class="filename">PLIST</code>.</p></li>
                   3979: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a binary
                   3980: package from the set of installed files.</p></li>
1.77      rillig   3981: </ol></div>
1.91      rillig   3982: <div class="sect1" lang="en">
                   3983: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3984: <a name="creating.common"></a>9.1. Common types of packages</h2></div></div></div>
                   3985: <div class="sect2" lang="en">
                   3986: <div class="titlepage"><div><div><h3 class="title">
                   3987: <a name="creating.perl-module"></a>9.1.1. Perl modules</h3></div></div></div>
                   3988: <p>Simple Perl modules are handled automatically by
                   3989: <span><strong class="command">url2pkg</strong></span>, including dependencies.</p>
                   3990: </div>
                   3991: <div class="sect2" lang="en">
                   3992: <div class="titlepage"><div><div><h3 class="title">
                   3993: <a name="creating.kde-app"></a>9.1.2. KDE applications</h3></div></div></div>
                   3994: <p>KDE applications should always include
                   3995: <code class="filename">meta-pkgs/kde3/kde3.mk</code>, which contains numerous
                   3996: settings that are typical of KDE packages.</p>
                   3997: </div>
                   3998: </div>
                   3999: <div class="sect1" lang="en">
                   4000: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   4001: <a name="creating.examples"></a>9.2. Examples</h2></div></div></div>
                   4002: <div class="sect2" lang="en">
                   4003: <div class="titlepage"><div><div><h3 class="title">
                   4004: <a name="creating.nvu"></a>9.2.1. How the www/nvu package came into pkgsrc</h3></div></div></div>
                   4005: <div class="sect3" lang="en">
                   4006: <div class="titlepage"><div><div><h4 class="title">
                   4007: <a name="creating.nvu.init"></a>9.2.1.1. The initial package</h4></div></div></div>
                   4008: <p>Looking at the file <code class="filename">pkgsrc/doc/TODO</code>, I saw
                   4009: that the &#8220;<span class="quote">nvu</span>&#8221; package has not yet been imported into
                   4010: pkgsrc. As the description says it has to do with the web, the obvious
                   4011: choice for the category is &#8220;<span class="quote">www</span>&#8221;.</p>
                   4012: <pre class="programlisting">
                   4013:     <code class="prompt">$</code> mkdir www/nvu
                   4014:     <code class="prompt">$</code> cd www/nvu
                   4015: </pre>
                   4016: <p>The web site says that the sources are available as a tar file, so
                   4017: I fed that URL to the <span><strong class="command">url2pkg</strong></span> program:</p>
                   4018: <pre class="programlisting">
                   4019:     <code class="prompt">$</code> url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   4020: </pre>
                   4021: <p>My editor popped up, and I added a <code class="varname">PKGNAME</code> line
                   4022: below the <code class="varname">DISTNAME</code> line, as the package name should
                   4023: not have the word &#8220;<span class="quote">sources</span>&#8221; in it. I also filled in the
                   4024: <code class="varname">MAINTAINER</code>, <code class="varname">HOMEPAGE</code> and
                   4025: <code class="varname">COMMENT</code> fields. Then the package
                   4026: <code class="filename">Makefile</code> looked like that:</p>
                   4027: <pre class="programlisting">
                   4028:     # $NetBSD$
                   4029:     #
                   4030: 
                   4031:     DISTNAME=       nvu-1.0-sources
                   4032:     PKGNAME=        nvu-1.0
                   4033:     CATEGORIES=     www
                   4034:     MASTER_SITES=   http://cvs.nvu.com/download/
                   4035:     EXTRACT_SUFX=   .tar.bz2
                   4036: 
                   4037:     MAINTAINER=     rillig@NetBSD.org
                   4038:     HOMEPAGE=       http://cvs.nvu.com/
                   4039:     COMMENT=        Web Authoring System
                   4040: 
                   4041:     # url2pkg-marker (please do not remove this line.)
                   4042:     .include "../../mk/bsd.pkg.mk"
                   4043: </pre>
                   4044: <p>Then, I quit the editor and watched pkgsrc downloading a large
                   4045: source archive:</p>
                   4046: <pre class="programlisting">
                   4047:     url2pkg&gt; Running "make makesum" ...
                   4048:     =&gt; Required installed package digest&gt;=20010302: digest-20060826 found
                   4049:     =&gt; Fetching nvu-1.0-sources.tar.bz2
                   4050:     Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   4051:     100% |*************************************| 28992 KB  150.77 KB/s    00:00 ETA
                   4052:     29687976 bytes retrieved in 03:12 (150.77 KB/s)
                   4053:     url2pkg&gt; Running "make extract" ...
                   4054:     =&gt; Required installed package digest&gt;=20010302: digest-20060826 found
                   4055:     =&gt; Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4056:     =&gt; Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4057:     work.bacc -&gt; /tmp/roland/pkgsrc/www/nvu/work.bacc
                   4058:     ===&gt; Installing dependencies for nvu-1.0
                   4059:     ===&gt; Overriding tools for nvu-1.0
                   4060:     ===&gt; Extracting for nvu-1.0
                   4061:     url2pkg&gt; Adjusting the Makefile.
                   4062: 
                   4063:     Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
                   4064: 
                   4065:     Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
                   4066: </pre>
                   4067: </div>
                   4068: <div class="sect3" lang="en">
                   4069: <div class="titlepage"><div><div><h4 class="title">
                   4070: <a name="creating.nvu.problems"></a>9.2.1.2. Fixing all kinds of problems to make the package work</h4></div></div></div>
                   4071: <p>Now that the package has been extracted, let's see what's inside
                   4072: it. The package has a <code class="filename">README.txt</code>, but that only
                   4073: says something about mozilla, so it's probably useless for seeing what
                   4074: dependencies this package has. But since there is a GNU configure script
                   4075: in the package, let's hope that it will complain about everything it
                   4076: needs.</p>
                   4077: <pre class="programlisting">
                   4078:     <code class="prompt">$</code> bmake
                   4079:     =&gt; Required installed package digest&gt;=20010302: digest-20060826 found
                   4080:     =&gt; Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4081:     =&gt; Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4082:     ===&gt; Patching for nvu-1.0
                   4083:     ===&gt; Creating toolchain wrappers for nvu-1.0
                   4084:     ===&gt; Configuring for nvu-1.0
                   4085:     [...]
                   4086:     configure: error: Perl 5.004 or higher is required.
                   4087:     [...]
                   4088:     WARNING: Please add USE_TOOLS+=perl to the package Makefile.
                   4089:     [...]
                   4090: </pre>
                   4091: <p>That worked quite well. So I opened the package Makefile in my
                   4092: editor, and since it already has a <code class="varname">USE_TOOLS</code> line, I
                   4093: just appended &#8220;<span class="quote">perl</span>&#8221; to it. Since the dependencies of the
                   4094: package have changed now, and since a perl wrapper is automatically
                   4095: installed in the &#8220;<span class="quote">tools</span>&#8221; phase, I need to build the package
                   4096: from scratch.</p>
                   4097: <pre class="programlisting">
                   4098:     <code class="prompt">$</code> bmake clean
                   4099:     ===&gt; Cleaning for nvu-1.0
                   4100:     <code class="prompt">$</code> bmake
                   4101:     [...]
                   4102:     *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
                   4103:     GNU Make.  You will not be able to build Mozilla without GNU Make.
                   4104:     [...]
                   4105: </pre>
                   4106: <p>So I added &#8220;<span class="quote">gmake</span>&#8221; to the
                   4107: <code class="varname">USE_TOOLS</code> line and tried again (from scratch).</p>
                   4108: <pre class="programlisting">
                   4109:     [...]
                   4110:     checking for GTK - version &gt;= 1.2.0... no
                   4111:     *** Could not run GTK test program, checking why...
                   4112:     [...]
                   4113: </pre>
                   4114: <p>Now to the other dependencies. The first question is: Where is the
                   4115: GTK package hidden in pkgsrc?</p>
                   4116: <pre class="programlisting">
                   4117:     <code class="prompt">$</code> echo ../../*/gtk*
                   4118:     [many packages ...]
                   4119:     <code class="prompt">$</code> echo ../../*/gtk
                   4120:     ../../x11/gtk
                   4121:     <code class="prompt">$</code> echo ../../*/gtk2
                   4122:     ../../x11/gtk2
                   4123:     <code class="prompt">$</code> echo ../../*/gtk2/bui*
                   4124:     ../../x11/gtk2/buildlink3.mk
                   4125: </pre>
                   4126: <p>The first try was definitely too broad. The second one had exactly
                   4127: one result, which is very good. But there is one pitfall with GNOME
                   4128: packages. Before GNOME 2 had been released, there were already many
                   4129: GNOME 1 packages in pkgsrc. To be able to continue to use these
                   4130: packages, the GNOME 2 packages were imported as separate packages, and
                   4131: their names usually have a &#8220;<span class="quote">2</span>&#8221; appended. So I checked
                   4132: whether this was the case here, and indeed it was.</p>
                   4133: <p>Since the GTK2 package has a <code class="filename">buildlink3.mk</code>
                   4134: file, adding the dependency is very easy. I just inserted an
                   4135: <code class="literal">.include</code> line before the last line of the package
                   4136: <code class="filename">Makefile</code>, so that it now looks like this:</p>
                   4137: <pre class="programlisting">
                   4138:     [...]
                   4139:     .include "../../x11/gtk2/buildlink3.mk"
                   4140:     .include "../../mk/bsd.pkg.mk
                   4141: </pre>
                   4142: <p>After another <span><strong class="command">bmake clean &amp;&amp; bmake</strong></span>, the answer
                   4143: was:</p>
                   4144: <pre class="programlisting">
                   4145:     [...]
                   4146:     checking for gtk-config... /home/roland/pkg/bin/gtk-config
                   4147:     checking for GTK - version &gt;= 1.2.0... no
                   4148:     *** Could not run GTK test program, checking why...
                   4149:     *** The test program failed to compile or link. See the file config.log for the
                   4150:     *** exact error that occured. This usually means GTK was incorrectly installed
                   4151:     *** or that you have moved GTK since it was installed. In the latter case, you
                   4152:     *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
                   4153:     configure: error: Test for GTK failed.
                   4154:     [...]
                   4155: </pre>
                   4156: <p>In this particular case, the assumption that &#8220;<span class="quote">every package
                   4157: prefers GNOME 2</span>&#8221; had been wrong. The first of the lines above
                   4158: told me that this package really wanted to have the GNOME 1 version of
                   4159: GTK. If the package had looked for GTK2, it would have looked for
                   4160: <span><strong class="command">pkg-config</strong></span> instead of <span><strong class="command">gtk-config</strong></span>.
                   4161: So I changed the <code class="literal">x11/gtk2</code> to
                   4162: <code class="literal">x11/gtk</code> in the package <code class="filename">Makefile</code>,
                   4163: and tried again.</p>
                   4164: <pre class="programlisting">
                   4165:     [...]
                   4166:     cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"   -I../../../dist/include/xpcom -I../../../dist/include -I/tmp/roland/pkgsrc/www/nvu/work.bacc/mozilla/dist/include/nspr     -I/usr/X11R6/include   -fPIC -DPIC -I/home/roland/pkg/include -I/usr/include  -I/usr/X11R6/include -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -Wno-long-long -pedantic -O2 -I/home/roland/pkg/include -I/usr/include -Dunix -pthread -pipe  -DDEBUG -D_DEBUG -DDEBUG_roland -DTRACING -g -I/home/roland/pkg/include/glib/glib-1.2 -I/home/roland/pkg/lib/glib/include -I/usr/pkg/include/orbit-1.0   -I/home/roland/pkg/include -I/usr/include  -I/usr/X11R6/include -include ../../../mozilla-config.h -DMOZILLA_CLIENT -Wp,-MD,.deps/xpidl.pp xpidl.c
                   4167:     In file included from xpidl.c:42:
                   4168:     xpidl.h:53:24: libIDL/IDL.h: No such file or directory
                   4169:     In file included from xpidl.c:42:
                   4170:     xpidl.h:132: error: parse error before "IDL_ns"
                   4171:     [...]
                   4172: </pre>
                   4173: <p>The package still does not find all of its dependencies. Now the
                   4174: question is: Which package provides the
                   4175: <code class="filename">libIDL/IDL.h</code> header file?</p>
                   4176: <pre class="programlisting">
                   4177:     <code class="prompt">$</code> echo ../../*/*idl*
                   4178:     ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
                   4179:     <code class="prompt">$</code> echo ../../*/*IDL*
                   4180:     ../../net/libIDL
                   4181: </pre>
                   4182: <p>Let's take the one from the second try. So I included the
                   4183: <code class="filename">../../net/libIDL/buildlink3.mk</code> file and tried
                   4184: again. But the error didn't change. After digging through some of the
                   4185: code, I concluded that the build process of the package was broken and
                   4186: couldn't have ever worked, but since the Mozilla source tree is quite
                   4187: large, I didn't want to fix it. So I added the following to the package
                   4188: <code class="filename">Makefile</code> and tried again:</p>
                   4189: <pre class="programlisting">
                   4190:     CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
                   4191:     BUILDLINK_TRANSFORM+=   -l:IDL:IDL-2
                   4192: </pre>
                   4193: <p>The latter line is needed because the package expects the library
                   4194: <code class="filename">libIDL.so</code>, but only
                   4195: <code class="filename">libIDL-2.so</code> is available. So I told the compiler
                   4196: wrapper to rewrite that on the fly.</p>
                   4197: <p>The next problem was related to a recent change of the FreeType
                   4198: interface. I looked up in <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/seamonkey/README.html" target="_top"><code class="filename">www/seamonkey</code></a>
                   4199: which patch files were relevant for this issue and copied them to the
                   4200: <code class="filename">patches</code> directory. Then I retried, fixed the
                   4201: patches so that they applied cleanly and retried again. This time,
                   4202: everything worked.</p>
                   4203: </div>
                   4204: <div class="sect3" lang="en">
                   4205: <div class="titlepage"><div><div><h4 class="title">
                   4206: <a name="creating.nvu.inst"></a>9.2.1.3. Installing the package</h4></div></div></div>
                   4207: <pre class="programlisting">
                   4208:     <code class="prompt">$</code> bmake CHECK_FILES=no install
                   4209:     [...]
                   4210:     <code class="prompt">$</code> bmake print-PLIST &gt;PLIST
                   4211:     <code class="prompt">$</code> bmake deinstall
                   4212:     <code class="prompt">$</code> bmake install
                   4213: </pre>
                   4214: </div>
                   4215: </div>
                   4216: </div>
1.77      rillig   4217: </div>
1.75      rillig   4218: <div class="chapter" lang="en">
                   4219: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   4220: <a name="components"></a>Chapter 10. Package components - files, directories and contents</h2></div></div></div>
1.75      rillig   4221: <div class="toc">
                   4222: <p><b>Table of Contents</b></p>
                   4223: <dl>
1.90      rillig   4224: <dt><span class="sect1"><a href="#components.Makefile">10.1. <code class="filename">Makefile</code></a></span></dt>
                   4225: <dt><span class="sect1"><a href="#components.distinfo">10.2. <code class="filename">distinfo</code></a></span></dt>
                   4226: <dt><span class="sect1"><a href="#components.patches">10.3. patches/*</a></span></dt>
                   4227: <dd><dl>
                   4228: <dt><span class="sect2"><a href="#components.patches.guidelines">10.3.1. Patching guidelines</a></span></dt>
                   4229: <dt><span class="sect2"><a href="#components.patches.feedback">10.3.2. Feedback to the author</a></span></dt>
                   4230: </dl></dd>
                   4231: <dt><span class="sect1"><a href="#other-mandatory-files">10.4. Other mandatory files</a></span></dt>
                   4232: <dt><span class="sect1"><a href="#components.optional">10.5. Optional files</a></span></dt>
                   4233: <dd><dl>
                   4234: <dt><span class="sect2"><a href="#components.optional.bin">10.5.1. Files affecting the binary package</a></span></dt>
                   4235: <dt><span class="sect2"><a href="#components.optional.build">10.5.2. Files affecting the build process</a></span></dt>
                   4236: <dt><span class="sect2"><a href="#components.optional.none">10.5.3. Files affecting nothing at all</a></span></dt>
1.78      rillig   4237: </dl></dd>
1.90      rillig   4238: <dt><span class="sect1"><a href="#work-dir">10.6. <code class="filename">work*</code></a></span></dt>
                   4239: <dt><span class="sect1"><a href="#files-dir">10.7. <code class="filename">files/*</code></a></span></dt>
1.75      rillig   4240: </dl>
                   4241: </div>
1.87      wiz      4242: <p>Whenever you're preparing a package, there are a number of
                   4243: files involved which are described in the following
                   4244: sections.</p>
1.75      rillig   4245: <div class="sect1" lang="en">
                   4246: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   4247: <a name="components.Makefile"></a>10.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75      rillig   4248: <p>Building, installation and creation of a binary package are all
1.87      wiz      4249:   controlled by the package's <code class="filename">Makefile</code>.
                   4250:   The <code class="filename">Makefile</code> describes various things about
                   4251:   a package, for example from where to get it, how to configure,
                   4252:   build, and install it.</p>
1.76      rillig   4253: <p>A package <code class="filename">Makefile</code> contains several
1.87      wiz      4254:   sections that describe the package.</p>
1.75      rillig   4255: <p>In the first section there are the following variables, which
1.87      wiz      4256:   should appear exactly in the order given here.  The order and
                   4257:   grouping of the variables is mostly historical and has no further
                   4258:   meaning.</p>
1.75      rillig   4259: <div class="itemizedlist"><ul type="disc">
                   4260: <li><p><code class="varname">DISTNAME</code> is the basename of the
1.87      wiz      4261:     distribution file to be downloaded from the package's
                   4262:     website.</p></li>
1.75      rillig   4263: <li><p><code class="varname">PKGNAME</code> is the name of the
1.87      wiz      4264:     package, as used by pkgsrc. You only need to provide it if
                   4265:     <code class="varname">DISTNAME</code> (which is the default) is not a good
                   4266:     name for the package in pkgsrc.  Usually it is the pkgsrc
                   4267:     directory name together with the version number. It must match the
                   4268:     regular expression
                   4269:     <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
                   4270:     starts with a letter or digit, and contains only letters, digits,
                   4271:     dashes, underscores, dots and plus signs.</p></li>
                   4272: <li><p><code class="varname">SVR4_PKGNAME</code> is the name of
                   4273:     the package file to create if the <code class="varname">PKGNAME</code>
                   4274:     isn't unique on a SVR4 system. The default is
                   4275:     <code class="varname">PKGNAME</code>, which may be shortened when you use
1.91      rillig   4276:     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>. Only add
1.87      wiz      4277:     <code class="varname">SVR4_PKGNAME</code> if <code class="varname">PKGNAME</code>
                   4278:     does not produce an unique package name on a SVR4 system.
                   4279:     The length of <code class="varname">SVR4_PKGNAME</code> is limited to 5
                   4280:     characters.</p></li>
1.75      rillig   4281: <li>
                   4282: <p><code class="varname">CATEGORIES</code> is a list of categories
1.87      wiz      4283:     which the package fits in. You can choose any of the top-level
                   4284:     directories of pkgsrc for it.</p>
1.75      rillig   4285: <p>Currently the following values are available for
1.87      wiz      4286:     <code class="varname">CATEGORIES</code>. If more than
                   4287:     one is used, they need to be separated by spaces:</p>
1.75      rillig   4288: <pre class="programlisting">
1.87      wiz      4289:       archivers     cross         geography     meta-pkgs     security
                   4290:       audio         databases     graphics      misc          shells
                   4291:       benchmarks    devel         ham           multimedia    sysutils
                   4292:       biology       editors       inputmethod   net           textproc
                   4293:       cad           emulators     lang          news          time
                   4294:       chat          finance       mail          parallel      wm
                   4295:       comms         fonts         math          pkgtools      www
                   4296:       converters    games         mbone         print         x11
                   4297:     </pre>
1.75      rillig   4298: </li>
1.81      rillig   4299: <li><p><code class="varname">MASTER_SITES</code>,
1.87      wiz      4300:     <code class="varname">DYNAMIC_MASTER_SITES</code>,
                   4301:     <code class="varname">DIST_SUBDIR</code>, <code class="varname">EXTRACT_SUFX</code>
                   4302:     and <code class="varname">DISTFILES</code> are discussed in detail in
1.90      rillig   4303:     <a href="#build.fetch" title="16.5. The fetch phase">Section 16.5, &#8220;The <span class="emphasis"><em>fetch</em></span> phase&#8221;</a>.</p></li>
1.75      rillig   4304: </ul></div>
                   4305: <p>The second section contains information about separately
1.87      wiz      4306:   downloaded patches, if any.
                   4307:   </p>
1.75      rillig   4308: <div class="itemizedlist"><ul type="disc">
                   4309: <li><p><code class="varname">PATCHFILES:</code>
1.87      wiz      4310:     Name(s) of additional files that contain distribution patches.
                   4311:     There is no default. pkgsrc will look for them at
                   4312:     <code class="varname">PATCH_SITES</code>.
                   4313:     They will automatically be uncompressed before patching if
                   4314:     the names end with <code class="filename">.gz</code> or
                   4315:     <code class="filename">.Z</code>.</p></li>
1.75      rillig   4316: <li><p><code class="varname">PATCH_SITES</code>:
1.87      wiz      4317:     Primary location(s) for distribution patch files (see
                   4318:     <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
1.75      rillig   4319: </ul></div>
                   4320: <p>The third section contains the following variables.
1.87      wiz      4321:   </p>
1.75      rillig   4322: <div class="itemizedlist"><ul type="disc">
                   4323: <li><p><code class="varname">MAINTAINER</code> is the email address
1.87      wiz      4324:     of the person who feels responsible for this package, and who is
                   4325:     most likely to look at problems or questions regarding this
                   4326:     package which have been reported with <a href="http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">send-pr</span>(1)</span></a>. Other
                   4327:     developers should contact the <code class="varname">MAINTAINER</code> before
                   4328:     making major changes to the package. When packaging a new program,
                   4329:     set <code class="varname">MAINTAINER</code> to yourself. If you really can't
                   4330:     maintain the package for future updates, set it to
                   4331:     <code class="email">&lt;<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>&gt;</code>.</p></li>
1.75      rillig   4332: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
1.87      wiz      4333:     find more information about the package.</p></li>
1.75      rillig   4334: <li><p><code class="varname">COMMENT</code> is a one-line
1.87      wiz      4335:     description of the package (should not include the package
                   4336:     name).</p></li>
1.75      rillig   4337: </ul></div>
                   4338: <p>Other variables that affect the build:
1.87      wiz      4339:   </p>
1.75      rillig   4340: <div class="itemizedlist"><ul type="disc"><li>
                   4341: <p><code class="varname">WRKSRC</code>: The directory where the
1.87      wiz      4342:       interesting distribution files of the package are found. The
                   4343:       default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
                   4344:       works for most packages.</p>
1.75      rillig   4345: <p>If a package doesn't create a subdirectory for itself
1.87      wiz      4346:       (most GNU software does, for instance), but extracts itself in
                   4347:       the current directory, you should set
                   4348:       <code class="varname">WRKSRC=${WRKDIR}</code>.</p>
                   4349: <p>If a package doesn't create a subdirectory with the
                   4350:       name of <code class="varname">DISTNAME</code> but some different name,
                   4351:       set <code class="varname">WRKSRC</code> to point to the proper name in
                   4352:       <code class="filename">${WRKDIR}</code>, for example
                   4353:       <code class="varname">WRKSRC=${WRKDIR}/${DISTNAME}/unix</code>. See
1.91      rillig   4354:       <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/lang/tcl/README.html" target="_top"><code class="filename">lang/tcl</code></a> and <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/tk/README.html" target="_top"><code class="filename">x11/tk</code></a> for other examples.</p>
1.75      rillig   4355: <p>The name of the working directory created by pkgsrc is
1.87      wiz      4356:       taken from the <code class="varname">WRKDIR_BASENAME</code>
                   4357:       variable. By default, its value is
                   4358:       <code class="filename">work</code>. If you want to use the same
                   4359:       pkgsrc tree for building different kinds of binary packages,
                   4360:       you can change the variable according to your needs. Two
                   4361:       other variables handle common cases of setting
                   4362:       <code class="varname">WRKDIR_BASENAME</code> individually. If
                   4363:       <code class="varname">OBJHOSTNAME</code> is defined in
                   4364:       <code class="filename">/etc/mk.conf</code>, the first component of
                   4365:       the host's name is attached to the directory name. If
                   4366:       <code class="varname">OBJMACHINE</code> is defined, the platform name
                   4367:       is attached, which might look like
                   4368:       <code class="filename">work.i386</code> or
                   4369:       <code class="filename">work.sparc</code>.</p>
1.75      rillig   4370: </li></ul></div>
                   4371: <p>Please pay attention to the following gotchas:</p>
                   4372: <div class="itemizedlist"><ul type="disc">
1.87      wiz      4373: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are
1.88      wiz      4374:       installed in compressed form by the package.  For packages using
                   4375:       BSD-style makefiles which honor MANZ, there is
                   4376:       <code class="varname">MANCOMPRESSED_IF_MANZ</code>.</p></li>
1.76      rillig   4377: <li><p>Replace <code class="filename">/usr/local</code> with
1.88      wiz      4378:       &#8220;<span class="quote">${PREFIX}</span>&#8221; in all files (see patches,
                   4379:       below).</p></li>
1.90      rillig   4380: <li><p>If the package installs any info files, see <a href="#faq.info-files" title="18.6.6. Packages installing info files">Section 18.6.6, &#8220;Packages installing info files&#8221;</a>.</p></li>
1.75      rillig   4381: </ul></div>
                   4382: </div>
                   4383: <div class="sect1" lang="en">
                   4384: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   4385: <a name="components.distinfo"></a>10.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76      rillig   4386: <p>The <code class="filename">distinfo</code> file contains the message
1.87      wiz      4387:   digest, or checksum, of each distfile needed for the package. This
                   4388:   ensures that the distfiles retrieved from the Internet have not been
                   4389:   corrupted during transfer or altered by a malign force to introduce
                   4390:   a security hole. Due to recent rumor about weaknesses of digest
                   4391:   algorithms, all distfiles are protected using both SHA1 and RMD160
                   4392:   message digests, as well as the file size.</p>
1.76      rillig   4393: <p>The <code class="filename">distinfo</code> file also contains the
1.87      wiz      4394:   checksums for all the patches found in the
1.90      rillig   4395:   <code class="filename">patches</code> directory (see <a href="#components.patches" title="10.3. patches/*">Section 10.3, &#8220;patches/*&#8221;</a>).</p>
1.76      rillig   4396: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.87      wiz      4397:   <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
                   4398:   command.</p>
1.75      rillig   4399: <p>Some packages have different sets of distfiles depending on
1.91      rillig   4400:   the platform, for example <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/navigator/README.html" target="_top"><code class="filename">www/navigator</code></a>). These are kept in the same
1.87      wiz      4401:   <code class="filename">distinfo</code> file and care should be taken when
                   4402:   upgrading such a package to ensure distfile information is not
                   4403:   lost.</p>
1.75      rillig   4404: </div>
                   4405: <div class="sect1" lang="en">
                   4406: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   4407: <a name="components.patches"></a>10.3. patches/*</h2></div></div></div>
1.75      rillig   4408: <p>This directory contains files that are used by the
1.87      wiz      4409:   <a href="http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span></a> command to
                   4410:   modify the sources as distributed in the distribution file into a form
                   4411:   that will compile and run perfectly on NetBSD. The files are applied
                   4412:   successively in alphabetic order (as returned by a shell
                   4413:   &#8220;<span class="quote">patches/patch-*</span>&#8221; glob expansion), so
                   4414:   <code class="filename">patch-aa</code> is applied before
                   4415:   <code class="filename">patch-ab</code>, etc.</p>
1.76      rillig   4416: <p>The <code class="filename">patch-*</code> files should be in
1.87      wiz      4417:   <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
                   4418:   problems. (To force patches to apply
                   4419:   with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
                   4420:   Furthermore, do not put changes for more than one file into a single
                   4421:   patch file, as this will make future modifications more difficult.</p>
1.75      rillig   4422: <p>Similar, a file should be patched at most once, not several times by
1.87      wiz      4423:   several different patches. If a file needs several patches, they should
                   4424:   be combined into one file.</p>
1.75      rillig   4425: <p>One important thing to mention is to pay attention that no RCS IDs
1.87      wiz      4426:   get stored in the patch files, as these will cause problems when
                   4427:   later checked into the NetBSD CVS tree. Use the
                   4428:   <span><strong class="command">pkgdiff</strong></span> from the
1.91      rillig   4429:   <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a> package to avoid
1.87      wiz      4430:   these problems.</p>
                   4431: <p>For even more automation, we recommend using
                   4432:   <span><strong class="command">mkpatches</strong></span> from the same package to make a
                   4433:   whole set of patches. You just have to backup files before you
                   4434:   edit them to <code class="filename">filename.orig</code>, e.g. with
                   4435:   <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by
                   4436:   using <span><strong class="command">pkgvi</strong></span> again from the same package. If
                   4437:   you upgrade a package this way, you can easily compare the new
                   4438:   set of patches with the previously existing one with
                   4439:   <span><strong class="command">patchdiff</strong></span>. Copy the patches you want to use
                   4440:   or update from the <code class="filename">work/.newpatches</code>
                   4441:   directory to <code class="filename">patches/</code>.</p>
                   4442: <p>When you have finished a package, remember to generate
                   4443:   the checksums for the patch files by using the <span><strong class="command">make
1.90      rillig   4444:   makepatchsum</strong></span> command, see <a href="#components.distinfo" title="10.2. distinfo">Section 10.2, &#8220;<code class="filename">distinfo</code>&#8221;</a>.</p>
1.87      wiz      4445: <p>When adding a patch that corrects a problem in the
                   4446:   distfile (rather than e.g. enforcing pkgsrc's view of where
                   4447:   man pages should go), send the patch as a bug report to the
                   4448:   maintainer.  This benefits non-pkgsrc users of the package,
                   4449:   and usually makes it possible to remove the patch in future
                   4450:   version.</p>
                   4451: <p>If you want to share patches between multiple packages
                   4452:   in pkgsrc, e.g. because they use the same distfiles, set
                   4453:   <code class="varname">PATCHDIR</code> to the path where the patch files
                   4454:   can be found, e.g.:</p>
                   4455: <pre class="programlisting">
                   4456:     PATCHDIR= ${.CURDIR}/../xemacs/patches
                   4457:   </pre>
1.75      rillig   4458: <p>Patch files that are distributed by the author or other
1.87      wiz      4459:     maintainers can be listed in
                   4460:     <code class="varname">PATCHFILES</code>.</p>
                   4461: <p>If it is desired to store any patches that should not be
                   4462:     committed into pkgsrc, they can be kept outside the pkgsrc
                   4463:     tree in the <code class="filename">$LOCALPATCHES</code> directory. The
                   4464:     directory tree there is expected to have the same
                   4465:     &#8220;<span class="quote">category/package</span>&#8221; structure as pkgsrc, and
                   4466:     patches are expected to be stored inside these dirs (also
                   4467:     known as <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
                   4468:     example, if you want to keep a private patch for
                   4469:     <code class="filename">pkgsrc/graphics/png</code>, keep it in
                   4470:     <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
                   4471:     files in the named directory are expected to be patch files,
                   4472:     and <span class="emphasis"><em>they are applied after pkgsrc patches are
                   4473:     applied</em></span>.</p>
1.85      jmmv     4474: <div class="sect2" lang="en">
                   4475: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   4476: <a name="components.patches.guidelines"></a>10.3.1. Patching guidelines</h3></div></div></div>
1.85      jmmv     4477: <p>When fixing a portability issue in the code do not use
                   4478:       preprocessor magic to check for the current operating system nor
                   4479:       platform.  Doing so hurts portability to other platforms because
                   4480:       the OS-specific details are not abstracted appropriately.</p>
                   4481: <p>The general rule to follow is: instead of checking for the
                   4482:       operating system the application is being built on, check for the
                   4483:       specific <span class="emphasis"><em>features</em></span> you need.  For example,
                   4484:       instead of assuming that kqueue is available under NetBSD and
                   4485:       using the <code class="varname">__NetBSD__</code> macro to conditionalize
1.89      rillig   4486:       kqueue support, add a check that detects kqueue itself &mdash;
1.85      jmmv     4487:       yes, this generally involves patching the
                   4488:       <span><strong class="command">configure</strong></span> script.  There is absolutely nothing
                   4489:       that prevents some OSes from adopting interfaces from other OSes
                   4490:       (e.g. Linux implementing kqueue), something that the above checks
                   4491:       cannot take into account.</p>
                   4492: <p>Of course, checking for features generally involves more
                   4493:       work on the developer's side, but the resulting changes are
1.87      wiz      4494:       cleaner and there are chances they will work on many other
1.85      jmmv     4495:       platforms.  Not to mention that there are higher chances of being
                   4496:       later integrated into the mainstream sources.  Remember:
                   4497:       <span class="emphasis"><em>It doesn't work unless it is right!</em></span></p>
                   4498: <p>Some typical examples:</p>
                   4499: <div class="table">
1.90      rillig   4500: <a name="patch-examples"></a><p class="title"><b>Table 10.1. Patching examples</b></p>
1.91      rillig   4501: <div class="table-contents"><table summary="Patching examples" border="1">
1.85      jmmv     4502: <colgroup>
                   4503: <col>
                   4504: <col>
                   4505: <col>
                   4506: </colgroup>
                   4507: <thead><tr>
                   4508: <th>Where</th>
                   4509: <th>Incorrect</th>
                   4510: <th>Correct</th>
                   4511: </tr></thead>
                   4512: <tbody>
                   4513: <tr>
                   4514: <td>configure script</td>
                   4515: <td>
                   4516:                <pre class="programlisting">case ${target_os} in
1.87      wiz      4517:                netbsd*) have_kvm=yes ;;
                   4518:                *)       have_kvm=no  ;;
                   4519:                esac</pre>
1.85      jmmv     4520:              </td>
                   4521: <td>
                   4522:                <pre class="programlisting">AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)</pre>
                   4523:              </td>
                   4524: </tr>
                   4525: <tr>
                   4526: <td>C source file</td>
                   4527: <td>
                   4528:                <pre class="programlisting">#if defined(__NetBSD__)
1.87      wiz      4529:                #  include &lt;sys/event.h&gt;
                   4530:                #endif</pre>
1.85      jmmv     4531:              </td>
                   4532: <td>
                   4533:                <pre class="programlisting">#if defined(HAVE_SYS_EVENT_H)
1.87      wiz      4534:                #  include &lt;sys/event.h&gt;
                   4535:                #endif</pre>
1.85      jmmv     4536:              </td>
                   4537: </tr>
                   4538: <tr>
                   4539: <td>C source file</td>
                   4540: <td>
                   4541: <pre class="programlisting">int
1.87      wiz      4542:              monitor_file(...)
                   4543:              {
                   4544:              #if defined(__NetBSD__)
                   4545:              int fd = kqueue();
                   4546:              ...
                   4547:              #else
                   4548:              ...
                   4549:              #endif
                   4550:              }</pre>
1.85      jmmv     4551:              </td>
                   4552: <td>
                   4553:                <pre class="programlisting">int
1.87      wiz      4554:                monitor_file(...)
                   4555:                {
                   4556:                #if defined(HAVE_KQUEUE)
                   4557:                int fd = kqueue();
                   4558:                ...
                   4559:                #else
                   4560:                ...
                   4561:                #endif
                   4562:                }</pre>
1.85      jmmv     4563:              </td>
                   4564: </tr>
                   4565: </tbody>
1.91      rillig   4566: </table></div>
1.85      jmmv     4567: </div>
1.91      rillig   4568: <br class="table-break"><p>For more information, please read the <span class="emphasis"><em>Making
1.85      jmmv     4569:       packager-friendly software</em></span> article (<a href="http://www.onlamp.com/pub/a/onlamp/2005/03/31/packaging.html" target="_top">part
                   4570:       1</a>, <a href="http://www.oreillynet.com/pub/a/onlamp/2005/04/28/packaging2.html" target="_top">part
                   4571:       2</a>).  It summarizes multiple details on how to make
                   4572:       software easier to package; all the suggestions in it were
                   4573:       collected from our experience in pkgsrc work, so they are possibly
                   4574:       helpful when creating patches too.</p>
                   4575: </div>
                   4576: <div class="sect2" lang="en">
                   4577: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   4578: <a name="components.patches.feedback"></a>10.3.2. Feedback to the author</h3></div></div></div>
1.85      jmmv     4579: <p>Always, always, <span class="strong"><strong>always</strong></span>
                   4580:       feed back any <span class="emphasis"><em>portability fixes</em></span> or
                   4581:       improvements you do to a package to the mainstream developers.
                   4582:       This is the only way to get their attention on portability issues
                   4583:       and to ensure that future versions can be built out-of-the box on
                   4584:       NetBSD.  Furthermore, any user that gets newer distfiles will get
                   4585:       the fixes straight from the packaged code.</p>
                   4586: <p>This generally involves cleaning up the patches as described
                   4587:       in the following section (because sometimes the patches that are
                   4588:       added to pkgsrc are quick hacks), filling bug reports in the
                   4589:       appropriate trackers for the projects and working with the
                   4590:       mainstream authors to accept your changes.  It is
                   4591:       <span class="emphasis"><em>extremely important</em></span> that you do it so that
                   4592:       the packages in pkgsrc are kept simple and thus further changes
                   4593:       can be done without much hassle.</p>
                   4594: <p>Support the idea of free software!</p>
                   4595: </div>
1.75      rillig   4596: </div>
                   4597: <div class="sect1" lang="en">
                   4598: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   4599: <a name="other-mandatory-files"></a>10.4. Other mandatory files</h2></div></div></div>
1.75      rillig   4600: <div class="variablelist"><dl>
1.76      rillig   4601: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75      rillig   4602: <dd><p>A multi-line description of the piece of software.  This should include
1.87      wiz      4603:          any credits where they are due.  Please bear in mind that others do not
                   4604:          share your sense of humour (or spelling idiosyncrasies), and that others
                   4605:          will read everything that you write here.</p></dd>
1.76      rillig   4606: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.87      wiz      4607: <dd><p>This file governs the files that are installed on your
                   4608:          system: all the binaries, manual pages, etc. There are other
                   4609:          directives which may be entered in this file, to control the
                   4610:          creation and deletion of directories, and the location of
1.90      rillig   4611:          inserted files.  See <a href="#plist" title="Chapter 12. PLIST issues">Chapter 12, <i>PLIST issues</i></a> for more
1.87      wiz      4612:          information.</p></dd>
1.75      rillig   4613: </dl></div>
                   4614: </div>
                   4615: <div class="sect1" lang="en">
                   4616: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   4617: <a name="components.optional"></a>10.5. Optional files</h2></div></div></div>
1.78      rillig   4618: <div class="sect2" lang="en">
                   4619: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   4620: <a name="components.optional.bin"></a>10.5.1. Files affecting the binary package</h3></div></div></div>
1.75      rillig   4621: <div class="variablelist"><dl>
1.76      rillig   4622: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75      rillig   4623: <dd><p>This shell script is invoked twice by <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>.
1.87      wiz      4624:            First time after package extraction and before files are
                   4625:            moved in place, the second time after the files to install
                   4626:            are moved in place. This can be used to do any custom
                   4627:            procedures not possible with @exec commands in
                   4628:            <code class="filename">PLIST</code>. See <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> and
1.90      rillig   4629:            <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> for more information.  See also <a href="#files-and-dirs-outside-prefix" title="14.1. Files and directories outside the installation prefix">Section 14.1, &#8220;Files and directories outside the installation prefix&#8221;</a>.</p></dd>
1.76      rillig   4630: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75      rillig   4631: <dd><p>This script is executed before and after any files are removed.  It is
1.87      wiz      4632:            this script's responsibility to clean up any additional messy details
                   4633:            around the package's installation, since all pkg_delete knows is how to
                   4634:            delete the files created in the original distribution.
                   4635:            See <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a>
                   4636:            and <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> for more information.</p></dd>
1.76      rillig   4637: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75      rillig   4638: <dd>
                   4639: <p>This file is displayed after installation of the package.
1.87      wiz      4640:            Useful for things like legal notices on almost-free
                   4641:            software and hints for updating config files after
                   4642:            installing modules for apache, PHP etc.
                   4643:            Please note that you can modify variables in it easily by using
                   4644:            <code class="varname">MESSAGE_SUBST</code> in the package's
                   4645:            <code class="filename">Makefile</code>:</p>
1.75      rillig   4646: <pre class="programlisting">
1.87      wiz      4647:              MESSAGE_SUBST+=  SOMEVAR="somevalue"
                   4648:            </pre>
1.75      rillig   4649: <p>replaces "${SOMEVAR}" with &#8220;<span class="quote">somevalue</span>&#8221; in
1.87      wiz      4650:            <code class="filename">MESSAGE</code>.  By default, substitution is
                   4651:            performed for <code class="varname">PKGNAME</code>,
                   4652:            <code class="varname">PKGBASE</code>, <code class="varname">PREFIX</code>,
                   4653:            <code class="varname">LOCALBASE</code>, <code class="varname">X11PREFIX</code>,
                   4654:            <code class="varname">X11BASE</code>,
                   4655:            <code class="varname">PKG_SYSCONFDIR</code>,
                   4656:            <code class="varname">ROOT_GROUP</code>, and
                   4657:            <code class="varname">ROOT_GROUP</code>.</p>
                   4658: <p>You can display a different or additional files by
                   4659:            setting the <code class="varname">MESSAGE_SRC</code> variable.  Its
                   4660:            default is <code class="filename">MESSAGE</code>, if the file
                   4661:            exists.</p>
1.75      rillig   4662: </dd>
1.78      rillig   4663: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
                   4664: <dd><p>FIXME: There is no documentation on the
                   4665:        alternatives framework.</p></dd>
                   4666: </dl></div>
                   4667: </div>
                   4668: <div class="sect2" lang="en">
                   4669: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   4670: <a name="components.optional.build"></a>10.5.2. Files affecting the build process</h3></div></div></div>
1.78      rillig   4671: <div class="variablelist"><dl>
                   4672: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
                   4673: <dd><p>This file contains arbitrary things that could
                   4674:        also go into a <code class="filename">Makefile</code>, but its purpose is
                   4675:        to be used by more than one package. This file should only be
                   4676:        used when the packages that will use the file are known in
                   4677:        advance. For other purposes it is often better to write a
                   4678:        <code class="filename">*.mk</code> file and give it a good name that
                   4679:        describes what it does.</p></dd>
                   4680: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
                   4681: <dd><p>This file contains the dependency information
1.90      rillig   4682:        for the buildlink3 framework (see <a href="#buildlink" title="Chapter 13. Buildlink methodology">Chapter 13, <i>Buildlink methodology</i></a>).</p></dd>
1.78      rillig   4683: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
                   4684: <dd><p>This file contains workarounds for compiler bugs
                   4685:        and similar things. It is included automatically by the pkgsrc
                   4686:        infrastructure, so you don't need an extra
                   4687:        <code class="literal">.include</code> line for
                   4688:        it.</p></dd>
                   4689: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
                   4690: <dd><p>This file contains the code for the
1.90      rillig   4691:        package-specific options (see <a href="#options" title="Chapter 15. Options handling">Chapter 15, <i>Options handling</i></a>) that can be
1.78      rillig   4692:        selected by the user. If a package has only one or two options,
                   4693:        it is equally acceptable to put the code directly into the
                   4694:        <code class="filename">Makefile</code>.</p></dd>
                   4695: </dl></div>
                   4696: </div>
                   4697: <div class="sect2" lang="en">
                   4698: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   4699: <a name="components.optional.none"></a>10.5.3. Files affecting nothing at all</h3></div></div></div>
1.78      rillig   4700: <div class="variablelist"><dl>
                   4701: <dt><span class="term"><code class="filename">README*</code></span></dt>
                   4702: <dd><p>These files do not take place in the creation of
                   4703:        a package and thus are purely informative to the package
                   4704:        developer.</p></dd>
                   4705: <dt><span class="term"><code class="filename">TODO</code></span></dt>
                   4706: <dd><p>This file contains things that need to be done
                   4707:        to make the package even
                   4708:        better.</p></dd>
1.75      rillig   4709: </dl></div>
                   4710: </div>
1.78      rillig   4711: </div>
1.75      rillig   4712: <div class="sect1" lang="en">
                   4713: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   4714: <a name="work-dir"></a>10.6. <code class="filename">work*</code></h2></div></div></div>
1.75      rillig   4715: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
1.87      wiz      4716:     unpacked into the directory denoted by
                   4717:     <code class="varname">WRKDIR</code>. It can be removed by running
                   4718:     <span><strong class="command">make clean</strong></span>. Besides the sources, this
                   4719:     directory is also used to keep various timestamp files.
                   4720:     The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
                   4721:     The default is <code class="filename">${.CURDIR}/work</code>
                   4722:     or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
                   4723:     if <code class="varname">OBJMACHINE</code> is set.</p>
1.75      rillig   4724: </div>
                   4725: <div class="sect1" lang="en">
                   4726: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   4727: <a name="files-dir"></a>10.7. <code class="filename">files/*</code></h2></div></div></div>
1.75      rillig   4728: <p>If you have any files that you wish to be placed in the package prior
1.87      wiz      4729:     to configuration or building, you could place these files here and use
                   4730:     a <span><strong class="command">${CP}</strong></span> command in the
                   4731:     &#8220;<span class="quote">pre-configure</span>&#8221; target to achieve
                   4732:     this. Alternatively, you could simply diff the file against
                   4733:     <code class="filename">/dev/null</code> and use the patch mechanism to manage
                   4734:     the creation of this file.</p>
                   4735: <p>If you want to share files in this way with other
                   4736:     packages, set the <code class="varname">FILESDIR</code> variable to point
                   4737:     to the other package's <code class="filename">files</code> directory,
                   4738:     e.g.:</p>
                   4739: <pre class="programlisting">
                   4740:       FILESDIR=${.CURDIR}/../xemacs/files
                   4741:     </pre>
1.75      rillig   4742: </div>
                   4743: </div>
                   4744: <div class="chapter" lang="en">
                   4745: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   4746: <a name="makefile"></a>Chapter 11. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75      rillig   4747: <div class="toc">
                   4748: <p><b>Table of Contents</b></p>
                   4749: <dl>
1.90      rillig   4750: <dt><span class="sect1"><a href="#makefile.variables">11.1. <code class="filename">Makefile</code> variables</a></span></dt>
                   4751: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">11.1.1. Naming conventions</a></span></dt></dl></dd>
                   4752: <dt><span class="sect1"><a href="#makefile.code">11.2. Code snippets</a></span></dt>
                   4753: <dd><dl>
                   4754: <dt><span class="sect2"><a href="#adding-to-list">11.2.1. Adding things to a list</a></span></dt>
                   4755: <dt><span class="sect2"><a href="#converting-internal-to-external">11.2.2. Converting an internal list into an external list</a></span></dt>
                   4756: <dt><span class="sect2"><a href="#passing-variable-to-shell">11.2.3. Passing variables to a shell command</a></span></dt>
                   4757: <dt><span class="sect2"><a href="#quoting-guideline">11.2.4. Quoting guideline</a></span></dt>
                   4758: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">11.2.5. Workaround for a bug in BSD Make</a></span></dt>
1.75      rillig   4759: </dl></dd>
                   4760: </dl>
                   4761: </div>
1.76      rillig   4762: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75      rillig   4763:   each of which forms a well-defined part of the pkgsrc system. Using
                   4764:   the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> system as a programming language for a big system
                   4765:   like pkgsrc requires some discipline to keep the code correct and
                   4766:   understandable.</p>
1.76      rillig   4767: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75      rillig   4768:   programming are variables (which are actually macros) and shell
                   4769:   commands. Among these shell commands may even be more complex ones
                   4770:   like <a href="http://netbsd.gw.com/cgi-bin/man-cgi?awk+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">awk</span>(1)</span></a> programs. To make sure that every shell command runs
                   4771:   as intended it is necessary to quote all variables correctly when they
                   4772:   are used.</p>
                   4773: <p>This chapter describes some patterns, that appear quite often in
1.76      rillig   4774:   <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75      rillig   4775:   with them.</p>
                   4776: <div class="sect1" lang="en">
                   4777: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   4778: <a name="makefile.variables"></a>11.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76      rillig   4779: <p><code class="filename">Makefile</code> variables contain strings that
1.75      rillig   4780:     can be processed using the five operators ``='', ``+='', ``?='',
                   4781:     ``:='', and ``!='', which are described in the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> man
                   4782:     page.</p>
                   4783: <p>When a variable's value is parsed from a
1.76      rillig   4784:     <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75      rillig   4785:     backslash character ``\'' are handled specially. If a backslash is
                   4786:     followed by a newline, any whitespace immediately in front of the
                   4787:     backslash, the backslash, the newline, and any whitespace
                   4788:     immediately behind the newline are replaced with a single space. A
                   4789:     backslash character and an immediately following hash character are
                   4790:     replaced with a single hash character. Otherwise, the backslash is
                   4791:     passed as is. In a variable assignment, any hash character that is
                   4792:     not preceded by a backslash starts a comment that continues upto the
                   4793:     end of the logical line.</p>
                   4794: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
                   4795:     the only way to create a variable consisting of a single backslash
                   4796:     is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
                   4797: <p>So far for defining variables. The other thing you can do with
                   4798:     variables is evaluating them. A variable is evaluated when it is
                   4799:     part of the right side of the ``:='' or the ``!='' operator, or
                   4800:     directly before executing a shell command which the variable is part
                   4801:     of. In all other cases, <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> performs lazy evaluation, that
                   4802:     is, variables are not evaluated until there's no other way. The
                   4803:     ``modifiers'' mentioned in the man page also evaluate the
                   4804:     variable.</p>
                   4805: <p>Some of the modifiers split the string into words and then
                   4806:     operate on the words, others operate on the string as a whole. When
                   4807:     a string is split into words, it is split as you would expect
                   4808:     it from <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sh+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sh</span>(1)</span></a>.</p>
1.89      rillig   4809: <p>No rule without exception&mdash;the <span><strong class="command">.for</strong></span>
1.75      rillig   4810:     loop does not follow the shell quoting rules but splits at sequences
                   4811:     of whitespace.</p>
                   4812: <p>There are several types of variables that should be handled
                   4813:     differently. Strings and two types of lists.</p>
                   4814: <div class="itemizedlist"><ul type="disc">
                   4815: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
                   4816:       characters. Nevertheless, you should restrict yourself to only
                   4817:       using printable characters. Examples are
                   4818:       <code class="varname">PREFIX</code> and
                   4819:       <code class="varname">COMMENT</code>.</p></li>
                   4820: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
                   4821:       are never exported to any shell command. Their elements are
                   4822:       separated by whitespace. Therefore, the elements themselves cannot
                   4823:       have embedded whitespace. Any other characters are allowed.
                   4824:       Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
                   4825:       Examples are <code class="varname">DEPENDS</code> and
                   4826:       <code class="varname">BUILD_DEPENDS</code>.</p></li>
                   4827: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
                   4828:       may be exported to a shell command. Their elements can contain any
                   4829:       characters, including whitespace. That's why they cannot be used
                   4830:       in <span><strong class="command">.for</strong></span> loops. Examples are
                   4831:       <code class="varname">DISTFILES</code> and
                   4832:       <code class="varname">MASTER_SITES</code>.</p></li>
                   4833: </ul></div>
                   4834: <div class="sect2" lang="en">
                   4835: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   4836: <a name="makefile.variables.names"></a>11.1.1. Naming conventions</h3></div></div></div>
1.75      rillig   4837: <div class="itemizedlist"><ul type="disc">
                   4838: <li><p>All variable names starting with an underscore
                   4839:        are reserved for use by the pkgsrc infrastructure. They shall
                   4840:        not be used by package
1.76      rillig   4841:        <code class="filename">Makefile</code>s.</p></li>
1.75      rillig   4842: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
                   4843:        lowercase variable names for the iteration
                   4844:        variables.</p></li>
                   4845: <li><p>All list variables should have a ``plural''
                   4846:        name, e.g. <code class="varname">PKG_OPTIONS</code> or
                   4847:        <code class="varname">DISTFILES</code>.</p></li>
                   4848: </ul></div>
                   4849: </div>
                   4850: </div>
                   4851: <div class="sect1" lang="en">
                   4852: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   4853: <a name="makefile.code"></a>11.2. Code snippets</h2></div></div></div>
1.75      rillig   4854: <p>This section presents you with some code snippets you should
                   4855:     use in your own code. If you don't find anything appropriate here,
                   4856:     you should test your code and add it here.</p>
                   4857: <div class="sect2" lang="en">
                   4858: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   4859: <a name="adding-to-list"></a>11.2.1. Adding things to a list</h3></div></div></div>
1.75      rillig   4860: <pre class="programlisting">
                   4861:     STRING=                 foo * bar `date`
                   4862:     INT_LIST=               # empty
                   4863:     ANOTHER_INT_LIST=       apache-[0-9]*:../../www/apache
                   4864:     EXT_LIST=               # empty
                   4865:     ANOTHER_EXT_LIST=       a=b c=d
1.1       grant    4866: 
1.75      rillig   4867:     INT_LIST+=              ${STRING}               # 1
                   4868:     INT_LIST+=              ${ANOTHER_INT_LIST}     # 2
                   4869:     EXT_LIST+=              ${STRING:Q}             # 3
                   4870:     EXT_LIST+=              ${ANOTHER_EXT_LIST}     # 4
1.1       grant    4871: </pre>
1.75      rillig   4872: <p>When you add a string to an external list (example 3), it
                   4873:       must be quoted. In all other cases, you must not add a quoting
                   4874:       level. You must not merge internal and external lists, unless you
                   4875:       are sure that all entries are correctly interpreted in both
                   4876:       lists.</p>
                   4877: </div>
                   4878: <div class="sect2" lang="en">
                   4879: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   4880: <a name="converting-internal-to-external"></a>11.2.2. Converting an internal list into an external list</h3></div></div></div>
1.75      rillig   4881: <pre class="programlisting">
                   4882:     EXT_LIST=       # empty
                   4883:     .for i in ${INT_LIST}
                   4884:     EXT_LIST+=      ${i:Q}""
                   4885:     .endfor
1.1       grant    4886: </pre>
1.75      rillig   4887: <p>This code converts the internal list
                   4888:       <code class="varname">INT_LIST</code> into the external list
                   4889:       <code class="varname">EXT_LIST</code>. As the elements of an internal list
                   4890:       are unquoted they must be quoted here. The reason for appending
                   4891:       <code class="varname">""</code> is explained below.</p>
                   4892: </div>
                   4893: <div class="sect2" lang="en">
                   4894: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   4895: <a name="passing-variable-to-shell"></a>11.2.3. Passing variables to a shell command</h3></div></div></div>
1.79      rillig   4896: <p>Sometimes you may want to print an arbitrary string. There
                   4897:        are many ways to get it wrong and only few that can handle every
                   4898:        nastiness.</p>
1.75      rillig   4899: <pre class="programlisting">
                   4900:     STRING=         foo bar &lt;    &gt; * `date` $$HOME ' "
                   4901:     EXT_LIST=       string=${STRING:Q} x=second\ item
1.1       grant    4902: 
1.75      rillig   4903:     all:
                   4904:             echo ${STRING}                  # 1
                   4905:             echo "${STRING}"                # 2
                   4906:             echo "${STRING:Q}"              # 3
                   4907:             echo ${STRING:Q}                # 4
                   4908:             echo x${STRING:Q} | sed 1s,.,,  # 5
1.79      rillig   4909:             printf "%s\\n" ${STRING:Q}""    # 6
1.75      rillig   4910:             env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1       grant    4911: </pre>
1.75      rillig   4912: <p>Example 1 leads to a syntax error in the shell, as the
                   4913:       characters are just copied.</p>
                   4914: <p>Example 2 leads to a syntax error too, and if you leave out
                   4915:       the last " character from <code class="varname">${STRING}</code>,
                   4916:       <a href="http://netbsd.gw.com/cgi-bin/man-cgi?date+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">date</span>(1)</span></a> will be executed. The <code class="varname">$HOME</code> shell
                   4917:       variable would be evaluated, too.</p>
                   4918: <p>Example 3 outputs each space character preceded by a
                   4919:       backslash (or not), depending on the implementation of the
                   4920:       <a href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command.</p>
                   4921: <p>Example 4 handles correctly every string that does not start
                   4922:       with a dash. In that case, the result depends on the
                   4923:       implementation of the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command. As long as you can
                   4924:       guarantee that your input does not start with a dash, this form is
                   4925:       appropriate.</p>
                   4926: <p>Example 5 handles even the case of a leading dash
                   4927:       correctly.</p>
1.79      rillig   4928: <p>Example 6 also works with every string and is the
                   4929:       light-weight solution, since it does not involve a pipe, which has
                   4930:       its own problems.</p>
1.75      rillig   4931: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
                   4932:       because the quoting has already been done when adding elements to
                   4933:       the list.</p>
                   4934: <p>As internal lists shall not be passed to the shell, there is
                   4935:       no example for it.</p>
                   4936: </div>
                   4937: <div class="sect2" lang="en">
                   4938: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   4939: <a name="quoting-guideline"></a>11.2.4. Quoting guideline</h3></div></div></div>
1.75      rillig   4940: <p>There are many possible sources of wrongly quoted variables.
                   4941:       This section lists some of the commonly known ones.</p>
                   4942: <div class="itemizedlist"><ul type="disc">
                   4943: <li>
                   4944: <p>Whenever you use the value of a list, think
                   4945:        about what happens to leading or trailing whitespace. If the
                   4946:        list is a well-formed shell expression, you can apply the
                   4947:        <code class="varname">:M*</code> modifier to strip leading and trailing
                   4948:        whitespace from each word. The <code class="varname">:M</code> operator
                   4949:        first splits its argument according to the rules of the shell,
                   4950:        and then creates a new list consisting of all words that match
                   4951:        the shell glob expression <code class="varname">*</code>, that is: all.
                   4952:        One class of situations where this is needed is when adding a
                   4953:        variable like <code class="varname">CPPFLAGS</code> to
                   4954:        <code class="varname">CONFIGURE_ARGS</code>. If the configure script
                   4955:        invokes other configure scripts, it strips the leading and
                   4956:        trailing whitespace from the variable and then passes it to the
                   4957:        other configure scripts. But these configure scripts expect the
                   4958:        (child) <code class="varname">CPPFLAGS</code> variable to be the same as
                   4959:        the parent <code class="varname">CPPFLAGS</code>. That's why we better
                   4960:        pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
                   4961:        here is how we do it:</p>
                   4962: <pre class="programlisting">
                   4963:     CPPFLAGS=               # empty
                   4964:     CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX:Q}\"
                   4965:     CPPFLAGS+=              ${MY_CPPFLAGS}
1.1       grant    4966: 
1.75      rillig   4967:     CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
1.1       grant    4968: 
1.75      rillig   4969:     all:
                   4970:             echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   4971:             echo x${CONFIGURE_ARGS}x        # properly trimmed
1.1       grant    4972: </pre>
1.75      rillig   4973: </li>
                   4974: <li><p>The example above contains one bug: The
                   4975:        <code class="varname">${PREFIX}</code> is a properly quoted shell
                   4976:        expression, but there is the C compiler after it, which also
                   4977:        expects a properly quoted string (this time in C syntax). The
                   4978:        version above is therefore only correct if
                   4979:        <code class="varname">${PREFIX}</code> does not have embedded backslashes
                   4980:        or double quotes. If you want to allow these, you have to add
                   4981:        another layer of quoting to each variable that is used as a C
                   4982:        string literal. You cannot use the <code class="varname">:Q</code>
                   4983:        operator for it, as this operator only works for the
                   4984:        shell.</p></li>
                   4985: <li>
                   4986: <p>Whenever a variable can be empty, the
                   4987:        <code class="varname">:Q</code> operator can have surprising results. Here
                   4988:        are two completely different cases which can be solved with the
                   4989:        same trick.</p>
                   4990: <pre class="programlisting">
                   4991:     EMPTY=                  # empty
                   4992:     empty_test:
                   4993:             for i in a ${EMPTY:Q} c; do \
                   4994:                     echo "$$i"; \
                   4995:             done
1.1       grant    4996: 
1.75      rillig   4997:     for_test:
                   4998:     .for i in a:\ a:\test.txt
                   4999:             echo ${i:Q}
                   5000:             echo "foo"
                   5001:     .endfor
1.1       grant    5002: </pre>
1.75      rillig   5003: <p>The first example will only print two of the three lines
                   5004:        we might have expected. This is because
                   5005:        <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
                   5006:        the shell cannot see. The workaround is to write
                   5007:        <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
                   5008:        as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
                   5009:        -f ${FNAME:Q}</code> (both of these are wrong).</p>
                   5010: <p>The second example will only print three lines instead of
                   5011:        four. The first line looks like <code class="varname">a:\ echo foo</code>.
                   5012:        This is because the backslash of the value
                   5013:        <code class="varname">a:\</code> is interpreted as a line-continuation by
                   5014:        <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>, which makes the second line the arguments of the
                   5015:        <a href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command from the first line. To avoid this, write
                   5016:        <code class="varname">${i:Q}""</code>.</p>
                   5017: </li>
                   5018: </ul></div>
                   5019: </div>
                   5020: <div class="sect2" lang="en">
                   5021: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   5022: <a name="bsd-make-bug-workaround"></a>11.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75      rillig   5023: <p>The pkgsrc bmake program does not handle the following
                   5024:       assignment correctly. In case <code class="varname">_othervar_</code>
                   5025:       contains a ``-'' character, one of the closing braces is included
                   5026:       in <code class="varname">${VAR}</code> after this code executes.</p>
                   5027: <pre class="programlisting">
                   5028:     VAR:=   ${VAR:N${_othervar_:C/-//}}
1.1       grant    5029: </pre>
1.75      rillig   5030: <p>For a more complex code snippet and a workaround, see the
1.91      rillig   5031:       package <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/regress/make-quoting/README.html" target="_top"><code class="filename">regress/make-quoting</code></a>, testcase
1.75      rillig   5032:       <code class="varname">bug1</code>.</p>
                   5033: </div>
                   5034: </div>
                   5035: </div>
                   5036: <div class="chapter" lang="en">
                   5037: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   5038: <a name="plist"></a>Chapter 12. PLIST issues</h2></div></div></div>
1.75      rillig   5039: <div class="toc">
                   5040: <p><b>Table of Contents</b></p>
                   5041: <dl>
1.90      rillig   5042: <dt><span class="sect1"><a href="#rcs-id">12.1. RCS ID</a></span></dt>
                   5043: <dt><span class="sect1"><a href="#automatic-plist-generation">12.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
                   5044: <dt><span class="sect1"><a href="#print-PLIST">12.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
                   5045: <dt><span class="sect1"><a href="#plist.misc">12.4. Variable substitution in PLIST</a></span></dt>
                   5046: <dt><span class="sect1"><a href="#manpage-compression">12.5. Man page compression</a></span></dt>
                   5047: <dt><span class="sect1"><a href="#using-PLIST_SRC">12.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
                   5048: <dt><span class="sect1"><a href="#platform-specific-plist">12.7. Platform-specific and differing PLISTs</a></span></dt>
                   5049: <dt><span class="sect1"><a href="#faq.common-dirs">12.8. Sharing directories between packages</a></span></dt>
1.75      rillig   5050: </dl>
                   5051: </div>
1.87      wiz      5052: <p>The <code class="filename">PLIST</code> file contains a package's
                   5053:   &#8220;<span class="quote">packing list</span>&#8221;, i.e. a list of files that belong to
                   5054:   the package (relative to the <code class="filename">${PREFIX}</code>
                   5055:   directory it's been installed in) plus some additional statements
                   5056:   - see the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> man page for a full list.
                   5057:   This chapter addresses some issues that need attention when
                   5058:   dealing with the <code class="filename">PLIST</code> file (or files, see
                   5059:   below!).</p>
1.75      rillig   5060: <div class="sect1" lang="en">
                   5061: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5062: <a name="rcs-id"></a>12.1. RCS ID</h2></div></div></div>
1.87      wiz      5063: <p>Be sure to add a RCS ID line as the first thing in any
                   5064:     <code class="filename">PLIST</code> file you write:</p>
1.75      rillig   5065: <pre class="programlisting">
1.87      wiz      5066:       @comment $NetBSD$
                   5067:     </pre>
1.75      rillig   5068: </div>
                   5069: <div class="sect1" lang="en">
                   5070: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5071: <a name="automatic-plist-generation"></a>12.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75      rillig   5072: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
1.87      wiz      5073:     to output a PLIST that matches any new files since the package
1.90      rillig   5074:     was extracted.  See <a href="#build.helpful-targets" title="16.17. Other helpful targets">Section 16.17, &#8220;Other helpful targets&#8221;</a> for
1.87      wiz      5075:     more information on this target.</p>
1.75      rillig   5076: </div>
                   5077: <div class="sect1" lang="en">
                   5078: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5079: <a name="print-PLIST"></a>12.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></h2></div></div></div>
1.87      wiz      5080: <p>If you have used any of the *-dirs packages, as explained in
1.90      rillig   5081:     <a href="#faq.common-dirs" title="12.8. Sharing directories between packages">Section 12.8, &#8220;Sharing directories between packages&#8221;</a>, you may have noticed that
1.87      wiz      5082:     <span><strong class="command">make print-PLIST</strong></span> outputs a set of
                   5083:     <code class="varname">@comment</code>s instead of real
                   5084:     <code class="varname">@dirrm</code> lines.  You can also do this for
                   5085:     specific directories and files, so that the results of that
                   5086:     command are very close to reality. This helps <span class="emphasis"><em>a
                   5087:     lot</em></span> during the update of packages.</p>
                   5088: <p>The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
                   5089:     of AWK patterns and actions that are used to filter the output of
                   5090:     print-PLIST.  You can <span class="emphasis"><em>append</em></span> any chunk of AWK
                   5091:     scripting you like to it, but be careful with quoting.</p>
                   5092: <p>For example, to get all files inside the
                   5093:     <code class="filename">libdata/foo</code> directory removed from the
                   5094:     resulting PLIST:</p>
                   5095: <pre class="programlisting">
                   5096:       PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
                   5097:     </pre>
                   5098: <p>And to get all the <code class="varname">@dirrm</code> lines referring
                   5099:     to a specific (shared) directory converted to
                   5100:     <code class="varname">@comment</code>s:</p>
1.75      rillig   5101: <pre class="programlisting">
1.87      wiz      5102:       PRINT_PLIST_AWK+=       /^@dirrm share\/specific/ { print "@comment " $$0; next; }
                   5103:     </pre>
1.75      rillig   5104: </div>
                   5105: <div class="sect1" lang="en">
                   5106: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5107: <a name="plist.misc"></a>12.4. Variable substitution in PLIST</h2></div></div></div>
1.87      wiz      5108: <p>A number of variables are substituted automatically in
                   5109:     PLISTs when a package is installed on a system. This includes the
                   5110:     following variables:</p>
1.75      rillig   5111: <div class="variablelist"><dl>
                   5112: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
                   5113: <dd>
                   5114: <p>Some packages like emacs and perl embed information
1.87      wiz      5115:          about which architecture they were built on into the
                   5116:          pathnames where they install their files. To handle this
                   5117:          case, PLIST will be preprocessed before actually used, and
                   5118:          the symbol
                   5119:          &#8220;<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>&#8221; will be
                   5120:          replaced by what <span><strong class="command">uname -p</strong></span> gives. The
                   5121:          same is done if the string
                   5122:          <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
                   5123:          PLIST somewhere - use this on packages that have GNU
                   5124:          autoconf-created configure scripts.</p>
1.75      rillig   5125: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   5126: <h3 class="title">Legacy note</h3>
                   5127: <p>There used to be a symbol
1.87      wiz      5128:            &#8220;<span class="quote"><code class="varname">$ARCH</code></span>&#8221; that
                   5129:            was replaced by the output of <span><strong class="command">uname
                   5130:            -m</strong></span>, but that's no longer supported and has
                   5131:            been removed.</p>
1.75      rillig   5132: </div>
                   5133: </dd>
                   5134: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
                   5135: <dd>
                   5136: <p>Some packages want to embed the OS name and version
1.87      wiz      5137:          into some paths.  To do this, use these variables in the
                   5138:          <code class="filename">PLIST</code>:
                   5139:          </p>
1.75      rillig   5140: <div class="itemizedlist"><ul type="disc">
                   5141: <li><p><code class="varname">${OPSYS}</code> - output of &#8220;<span class="quote"><span><strong class="command">uname -s</strong></span></span>&#8221;</p></li>
                   5142: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. &#8220;<span class="quote">solaris</span>&#8221;)</p></li>
                   5143: <li><p><code class="varname">${OS_VERSION}</code> - &#8220;<span class="quote"><span><strong class="command">uname -r</strong></span></span>&#8221;</p></li>
                   5144: </ul></div>
                   5145: </dd>
                   5146: </dl></div>
1.87      wiz      5147: <p>For a complete list of values which are replaced by
                   5148:     default, please look in <code class="filename">bsd.pkg.mk</code> (and
                   5149:     search for <code class="varname">PLIST_SUBST</code>).</p>
                   5150: <p>If you want to change other variables not listed above, you
                   5151:     can add variables and their expansions to this variable in the
1.90      rillig   5152:     following way, similar to <code class="varname">MESSAGE_SUBST</code> (see <a href="#components.optional" title="10.5. Optional files">Section 10.5, &#8220;Optional files&#8221;</a>):</p>
1.75      rillig   5153: <pre class="programlisting">
1.87      wiz      5154:       PLIST_SUBST+=   SOMEVAR="somevalue"
                   5155:     </pre>
1.75      rillig   5156: <p>This replaces all occurrences of &#8220;<span class="quote">${SOMEVAR}</span>&#8221;
1.87      wiz      5157:     in the <code class="filename">PLIST</code> with
                   5158:     &#8220;<span class="quote">somevalue</span>&#8221;.</p>
1.75      rillig   5159: </div>
                   5160: <div class="sect1" lang="en">
                   5161: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5162: <a name="manpage-compression"></a>12.5. Man page compression</h2></div></div></div>
1.75      rillig   5163: <p>Man pages should be installed in compressed form if
1.87      wiz      5164:     <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
                   5165:     and uncompressed otherwise. To handle this in the
                   5166:     <code class="filename">PLIST</code> file, the suffix &#8220;<span class="quote">.gz</span>&#8221; is
                   5167:     appended/removed automatically for man pages according to
                   5168:     <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
                   5169:     or not, see above for details. This modification of the
                   5170:     <code class="filename">PLIST</code> file is done on a copy of it, not
                   5171:     <code class="filename">PLIST</code> itself.</p>
1.75      rillig   5172: </div>
                   5173: <div class="sect1" lang="en">
                   5174: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5175: <a name="using-PLIST_SRC"></a>12.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></h2></div></div></div>
1.76      rillig   5176: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.87      wiz      5177:     in generating the binary package, set the variable
                   5178:     <code class="varname">PLIST_SRC</code> to the names of that file(s).
                   5179:     The files are later concatenated using <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cat+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cat</span>(1)</span></a>, and the order of things is
                   5180:     important. The default for <code class="varname">PLIST_SRC</code> is
                   5181:     <code class="filename">${PKGDIR}/PLIST</code>.</p>
1.75      rillig   5182: </div>
                   5183: <div class="sect1" lang="en">
                   5184: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5185: <a name="platform-specific-plist"></a>12.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75      rillig   5186: <p>Some packages decide to install a different set of files based on
1.87      wiz      5187:     the operating system being used. These differences can be
                   5188:     automatically handled by using the following files:</p>
1.75      rillig   5189: <div class="itemizedlist"><ul type="disc">
1.76      rillig   5190: <li><p><code class="filename">PLIST.common</code></p></li>
                   5191: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
                   5192: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
                   5193: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
                   5194: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75      rillig   5195: </ul></div>
                   5196: </div>
                   5197: <div class="sect1" lang="en">
                   5198: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5199: <a name="faq.common-dirs"></a>12.8. Sharing directories between packages</h2></div></div></div>
1.87      wiz      5200: <p>A &#8220;<span class="quote">shared directory</span>&#8221; is a directory where
                   5201:     multiple (and unrelated) packages install files.  These
                   5202:     directories are problematic because you have to add special tricks
                   5203:     in the PLIST to conditionally remove them, or have some
                   5204:     centralized package handle them.</p>
                   5205: <p>Within pkgsrc, you'll find both approaches.  If a directory
                   5206:     is shared by a few unrelated packages, it's often not worth to add
                   5207:     an extra package to remove it.  Therefore, one simply does:</p>
                   5208: <pre class="programlisting">
                   5209:       @unexec ${RMDIR} %D/path/to/shared/directory 2&gt;/dev/null || ${TRUE}
                   5210:     </pre>
                   5211: <p>in the PLISTs of all affected packages, instead of the
                   5212:     regular "@dirrm" line.</p>
                   5213: <p>However, if the directory is shared across many packages, two
                   5214:     different solutions are available:</p>
1.75      rillig   5215: <div class="orderedlist"><ol type="1">
1.87      wiz      5216: <li><p>If the packages have a common dependency, the directory
                   5217:        can be removed in that.  For example, see
1.91      rillig   5218:        <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/textproc/scrollkeeper/README.html" target="_top"><code class="filename">textproc/scrollkeeper</code></a>, which
1.87      wiz      5219:        removes the shared directory
                   5220:        <code class="filename">share/omf</code>.</p></li>
                   5221: <li><p>If the packages using the directory are not related at
                   5222:        all (they have no common dependencies), a *-dirs package is
                   5223:        used.</p></li>
1.75      rillig   5224: </ol></div>
1.87      wiz      5225: <p>From now on, we'll discuss the second solution.  To get an
                   5226:     idea of the *-dirs packages available, issue:</p>
1.75      rillig   5227: <pre class="programlisting">
1.87      wiz      5228:       <code class="prompt">%</code> cd .../pkgsrc
                   5229:       <code class="prompt">%</code> ls -d */*-dirs
                   5230:     </pre>
                   5231: <p>Their use from other packages is very simple.  The
                   5232:     <code class="varname">USE_DIRS</code> variable takes a list of package names
                   5233:     (without the &#8220;<span class="quote">-dirs</span>&#8221; part) together with the required
                   5234:     version number (always pick the latest one when writing new
                   5235:     packages).</p>
                   5236: <p>For example, if a package installs files under
                   5237:     <code class="filename">share/applications</code>, it should have the
                   5238:     following line in it:</p>
                   5239: <pre class="programlisting">
                   5240:       USE_DIRS+=      xdg-1.1
                   5241:     </pre>
                   5242: <p>After regenerating the PLIST using <span><strong class="command">make
                   5243:     print-PLIST</strong></span>, you should get the right (commented out)
                   5244:     lines.</p>
                   5245: <p>Note that even if your package is using
                   5246:     <code class="filename">$X11BASE</code>, it must not depend on the
                   5247:     *-x11-dirs packages.  Just specify the name without that part and
                   5248:     pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
                   5249:     care of it.</p>
1.75      rillig   5250: </div>
                   5251: </div>
                   5252: <div class="chapter" lang="en">
                   5253: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   5254: <a name="buildlink"></a>Chapter 13. Buildlink methodology</h2></div></div></div>
1.75      rillig   5255: <div class="toc">
                   5256: <p><b>Table of Contents</b></p>
                   5257: <dl>
1.90      rillig   5258: <dt><span class="sect1"><a href="#converting-to-buildlink3">13.1. Converting packages to use buildlink3</a></span></dt>
                   5259: <dt><span class="sect1"><a href="#creating-buildlink3.mk">13.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75      rillig   5260: <dd><dl>
1.90      rillig   5261: <dt><span class="sect2"><a href="#anatomy-of-bl3">13.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
                   5262: <dt><span class="sect2"><a href="#updating-buildlink-depends">13.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75      rillig   5263: </dl></dd>
1.90      rillig   5264: <dt><span class="sect1"><a href="#writing-builtin.mk">13.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
1.75      rillig   5265: <dd><dl>
1.90      rillig   5266: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">13.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
                   5267: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">13.3.2. Global preferences for native or pkgsrc software</a></span></dt>
1.75      rillig   5268: </dl></dd>
                   5269: </dl>
                   5270: </div>
                   5271: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
1.87      wiz      5272:   are seen by a package's configure and build processes.  This is implemented
                   5273:   in a two step process:</p>
1.75      rillig   5274: <div class="orderedlist"><ol type="1">
                   5275: <li><p>Symlink headers and libraries for dependencies into
1.87      wiz      5276:       <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
                   5277:       of <code class="varname">WRKDIR</code>.</p></li>
1.75      rillig   5278: <li><p>Create wrapper scripts that are used in place of the normal compiler
1.87      wiz      5279:       tools that translate <code class="option">-I${LOCALBASE}/include</code> and
                   5280:       <code class="option">-L${LOCALBASE}/lib</code> into references to
                   5281:       <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
                   5282:       native compiler on some operating systems look like GCC, so that
                   5283:       packages that expect GCC won't require modifications to build with
                   5284:       those native compilers.</p></li>
1.75      rillig   5285: </ol></div>
                   5286: <p>This normalizes the environment in which a package is built so that the
1.87      wiz      5287:   package may be built consistently despite what other software may be
                   5288:   installed. Please note that the normal system header and library paths,
                   5289:   e.g. <code class="filename">/usr/include</code>,
                   5290:   <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
                   5291:   designed to insulate the package build from non-system-supplied
                   5292:   software.</p>
1.75      rillig   5293: <div class="sect1" lang="en">
                   5294: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5295: <a name="converting-to-buildlink3"></a>13.1. Converting packages to use buildlink3</h2></div></div></div>
1.75      rillig   5296: <p>The process of converting packages to use the buildlink3
1.87      wiz      5297:     framework (&#8220;<span class="quote">bl3ifying</span>&#8221;) is fairly straightforward.
                   5298:     The things to keep in mind are:</p>
1.75      rillig   5299: <div class="orderedlist"><ol type="1">
1.87      wiz      5300: <li><p>Ensure that the build always calls the wrapper scripts
                   5301:        instead of the actual toolchain.  Some packages are tricky,
                   5302:        and the only way to know for sure is the check
                   5303:        <code class="filename">${WRKDIR}/.work.log</code> to see if the
                   5304:        wrappers are being invoked.</p></li>
                   5305: <li><p>Don't override <code class="varname">PREFIX</code> from within
                   5306:        the package Makefile, e.g. Java VMs, standalone shells,
                   5307:        etc., because the code to symlink files into
                   5308:        <code class="filename">${BUILDLINK_DIR}</code> looks for files
                   5309:        relative to &#8220;<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>&#8221;.
                   5310:        </p></li>
                   5311: <li><p>Remember that <span class="emphasis"><em>only</em></span> the
                   5312:        <code class="filename">buildlink3.mk</code> files that you list in a
                   5313:        package's Makefile are added as dependencies for that package.
                   5314:        </p></li>
1.75      rillig   5315: </ol></div>
1.87      wiz      5316: <p>If a dependency on a particular package is required for its libraries and
                   5317:     headers, then we replace:</p>
1.75      rillig   5318: <pre class="programlisting">
1.87      wiz      5319:       DEPENDS+=   foo&gt;=1.1.0:../../category/foo
                   5320:     </pre>
1.75      rillig   5321: <p>with</p>
                   5322: <pre class="programlisting">
1.87      wiz      5323:       .include "../../category/foo/buildlink3.mk"
                   5324:     </pre>
1.75      rillig   5325: <p>The buildlink3.mk files usually define the required dependencies.
                   5326:     If you need a newer version of the dependency when using buildlink3.mk
1.87      wiz      5327:     files, then you can define it in your Makefile; for example:</p>
1.75      rillig   5328: <pre class="programlisting">
1.87      wiz      5329:       BUILDLINK_API_DEPENDS.foo+=   foo&gt;=1.1.0
                   5330:       .include "../../category/foo/buildlink3.mk"
                   5331:     </pre>
1.76      rillig   5332: <p>There are several <code class="filename">buildlink3.mk</code>
1.87      wiz      5333:     files in <code class="filename">pkgsrc/mk</code>
                   5334:     that handle special package issues:</p>
1.75      rillig   5335: <div class="itemizedlist"><ul type="disc">
1.76      rillig   5336: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.87      wiz      5337:        the native or a pkgsrc Berkeley DB implementation based on
                   5338:        the values of <code class="varname">BDB_ACCEPTED</code> and
                   5339:        <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76      rillig   5340: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.87      wiz      5341:        comes with neither Curses nor NCurses, this will take care
1.91      rillig   5342:        to install the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/ncurses/README.html" target="_top"><code class="filename">devel/ncurses</code></a> package.</p></li>
1.76      rillig   5343: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.87      wiz      5344:        of <code class="varname">KRB5_ACCEPTED</code> to choose between
                   5345:        adding a dependency on Heimdal or MIT-krb5 for packages that
                   5346:        require a Kerberos 5 implementation.</p></li>
1.88      wiz      5347: <li><p><code class="filename">motif.buildlink3.mk</code> checks for a
                   5348:        system-provided Motif installation or adds a dependency on
1.91      rillig   5349:        <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/lesstif/README.html" target="_top"><code class="filename">x11/lesstif</code></a> or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/openmotif/README.html" target="_top"><code class="filename">x11/openmotif</code></a>.  The user can set
1.88      wiz      5350:        <code class="varname">MOTIF_TYPE</code> to &#8220;<span class="quote">dt</span>&#8221;,
                   5351:        &#8220;<span class="quote">lesstif</span>&#8221;, or &#8220;<span class="quote">openmotif</span>&#8221; to choose
                   5352:        which Motif version will be used.</p></li>
1.76      rillig   5353: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.87      wiz      5354:        variables that may be used by packages that use the
                   5355:        Open Sound System (OSS) API.</p></li>
1.76      rillig   5356: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.91      rillig   5357:        either Postgres 7.4, 8.0, or 8.1, whichever is found installed. See
1.87      wiz      5358:        the file for more information.</p></li>
1.76      rillig   5359: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.87      wiz      5360:        <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
1.91      rillig   5361:        a dependency on <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/pth/README.html" target="_top"><code class="filename">devel/pth</code></a> as needed.</p></li>
1.76      rillig   5362: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.87      wiz      5363:        <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
                   5364:        library.</p></li>
1.75      rillig   5365: </ul></div>
1.76      rillig   5366: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.87      wiz      5367:     files provide a more complete
                   5368:     description of how to use them properly.</p>
1.75      rillig   5369: </div>
                   5370: <div class="sect1" lang="en">
                   5371: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5372: <a name="creating-buildlink3.mk"></a>13.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.87      wiz      5373: <p>A package's <code class="filename">buildlink3.mk</code> file is
                   5374:     included by Makefiles to indicate the need to compile and link
                   5375:     against header files and libraries provided by the package.  A
                   5376:     <code class="filename">buildlink3.mk</code> file should always provide
                   5377:     enough information to add the correct type of dependency
                   5378:     relationship and include any other
                   5379:     <code class="filename">buildlink3.mk</code> files that it needs to find
                   5380:     headers and libraries that it needs in turn.</p>
                   5381: <p>To generate an initial <code class="filename">buildlink3.mk</code>
1.91      rillig   5382:     file for further editing, Rene Hexel's <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/createbuildlink/README.html" target="_top"><code class="filename">pkgtools/createbuildlink</code></a>
1.87      wiz      5383:     package is highly recommended.  For most packages, the following
                   5384:     command will generate a good starting point for
                   5385:     <code class="filename">buildlink3.mk</code> files:</p>
                   5386: <pre class="screen">
                   5387: <code class="prompt">%</code> <strong class="userinput"><code>cd pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>pkgdir</code></em>
                   5388: <code class="prompt">%</code> createbuildlink &gt;buildlink3.mk</code></strong>
                   5389:     </pre>
1.75      rillig   5390: <div class="sect2" lang="en">
                   5391: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   5392: <a name="anatomy-of-bl3"></a>13.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75      rillig   5393: <p>The following real-life example
1.87      wiz      5394:       <code class="filename">buildlink3.mk</code> is taken
                   5395:       from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75      rillig   5396: <pre class="programlisting">
1.87      wiz      5397:        # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1       grant    5398: 
1.87      wiz      5399:        BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH}+
                   5400:        TIFF_BUILDLINK3_MK:=    ${TIFF_BUILDLINK3_MK}+
1.1       grant    5401: 
1.87      wiz      5402:        .if !empty(BUILDLINK_DEPTH:M+)
                   5403:        BUILDLINK_DEPENDS+=     tiff
                   5404:        .endif
                   5405: 
                   5406:        BUILDLINK_PACKAGES:=    ${BUILDLINK_PACKAGES:Ntiff}
                   5407:        BUILDLINK_PACKAGES+=    tiff
                   5408: 
                   5409:        .if !empty(TIFF_BUILDLINK3_MK:M+)
                   5410:        BUILDLINK_API_DEPENDS.tiff+=        tiff&gt;=3.6.1
                   5411:        BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
                   5412:        .endif  # TIFF_BUILDLINK3_MK
                   5413: 
                   5414:        .include "../../devel/zlib/buildlink3.mk"
                   5415:        .include "../../graphics/jpeg/buildlink3.mk"
                   5416: 
                   5417:        BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH:S/+$//}
                   5418:       </pre>
                   5419: <p>The header and footer manipulate
                   5420:       <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
                   5421:       <code class="filename">buildlink3.mk</code> files and is used to track
                   5422:       at what depth we are including
                   5423:       <code class="filename">buildlink3.mk</code> files.</p>
                   5424: <p>The first section controls if the dependency on
                   5425:       <em class="replaceable"><code>pkg</code></em> is added.
                   5426:       <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
                   5427:       packages for which dependencies are added by
                   5428:       buildlink3.</p>
                   5429: <p>The second section advises pkgsrc that the
                   5430:       <code class="filename">buildlink3.mk</code> file for
                   5431:       <em class="replaceable"><code>pkg</code></em> has been included at some point.
                   5432:       <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
                   5433:       packages for which <code class="filename">buildlink3.mk</code> files
                   5434:       have been included.  It must <span class="emphasis"><em>always</em></span> be
                   5435:       appended to within a <code class="filename">buildlink3.mk</code>
                   5436:       file.</p>
                   5437: <p>The third section is protected from multiple inclusion
                   5438:       and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
                   5439:       added.  Several important variables are set in the section:</p>
                   5440: <div class="itemizedlist"><ul type="disc">
                   5441: <li><p><code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5442:          is the actual dependency recorded in the installed
                   5443:          package; this should always be set using
                   5444:          <span><strong class="command">+=</strong></span> to ensure that
                   5445:          we're appending to any pre-existing list of values.  This
                   5446:          variable should be set to the first version of the
                   5447:          package that had an API change.
                   5448:          </p></li>
                   5449: <li><p><code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
                   5450:          is the location of the <em class="replaceable"><code>pkg</code></em>
                   5451:          pkgsrc directory.</p></li>
                   5452: <li><p><code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
                   5453:          (not shown above) controls whether we use
                   5454:          <code class="varname">BUILD_DEPENDS</code> or
                   5455:          <code class="varname">DEPENDS</code> to add the dependency on
                   5456:          <em class="replaceable"><code>pkg</code></em>.  The build dependency is
                   5457:          selected by setting
                   5458:          <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
                   5459:          to &#8220;<span class="quote">build</span>&#8221;.  By default, the full dependency is
                   5460:          used.</p></li>
                   5461: <li><p><code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   5462:            and
                   5463:            <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
                   5464:            (not shown above) are lists of subdirectories of
1.76      rillig   5465:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   5466:            to add to the header and library search paths.  These
                   5467:            default to &#8220;<span class="quote">include</span>&#8221; and &#8220;<span class="quote">lib</span>&#8221;
1.87      wiz      5468:          respectively.</p></li>
                   5469: <li><p><code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   5470:            (not shown above) is the list of preprocessor flags to add
                   5471:            to <code class="varname">CPPFLAGS</code>, which are passed on to the
                   5472:            configure and build phases.  The &#8220;<span class="quote">-I</span>&#8221; option
                   5473:            should be avoided and instead be handled using
                   5474:            <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
1.87      wiz      5475:          above.</p></li>
1.75      rillig   5476: </ul></div>
1.87      wiz      5477: <p>The following variables are all optionally defined within
                   5478:       this second section (protected against multiple inclusion) and
                   5479:       control which package files are symlinked into
                   5480:       <code class="filename">${BUILDLINK_DIR}</code> and how their names are
                   5481:       transformed during the symlinking:</p>
1.75      rillig   5482: <div class="itemizedlist"><ul type="disc">
1.87      wiz      5483: <li><p><code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   5484:            (not shown above) is a shell glob pattern relative to
1.76      rillig   5485:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   5486:            to be symlinked into
1.76      rillig   5487:            <code class="filename">${BUILDLINK_DIR}</code>,
1.87      wiz      5488:          e.g. <code class="filename">include/*.h</code>.</p></li>
                   5489: <li><p><code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
                   5490:            (not shown above) is a shell pipeline that
                   5491:            outputs to stdout a list of files relative to
                   5492:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
                   5493:            The resulting files are to be symlinked
                   5494:            into <code class="filename">${BUILDLINK_DIR}</code>.  By default,
                   5495:            this takes the <code class="filename">+CONTENTS</code> of a
                   5496:            <em class="replaceable"><code>pkg</code></em> and filters it through
                   5497:            <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.</p></li>
                   5498: <li><p><code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   5499:            (not shown above) is a filter command that filters
1.76      rillig   5500:            <code class="filename">+CONTENTS</code> input into a list of files
1.75      rillig   5501:            relative to
1.76      rillig   5502:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   5503:            on stdout.  By default for overwrite packages,
                   5504:            <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76      rillig   5505:            outputs the contents of the <code class="filename">include</code>
                   5506:            and <code class="filename">lib</code> directories in the package
                   5507:            <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75      rillig   5508:            it outputs any libtool archives in
1.87      wiz      5509:            <code class="filename">lib</code> directories.</p></li>
                   5510: <li><p><code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   5511:            (not shown above) is a list of sed arguments used to
                   5512:            transform the name of the source filename into a
                   5513:            destination filename, e.g. <span><strong class="command">-e
1.87      wiz      5514:            "s|/curses.h|/ncurses.h|g"</strong></span>.</p></li>
1.75      rillig   5515: </ul></div>
1.87      wiz      5516: <p>The last section includes any
                   5517:       <code class="filename">buildlink3.mk</code> needed for
                   5518:       <em class="replaceable"><code>pkg</code></em>'s library dependencies.
                   5519:       Including these <code class="filename">buildlink3.mk</code> files
                   5520:       means that the headers and libraries for these
                   5521:       dependencies are also symlinked into
                   5522:       <code class="filename">${BUILDLINK_DIR}</code>
                   5523:       whenever the <em class="replaceable"><code>pkg</code></em>
                   5524:       <code class="filename">buildlink3.mk</code>
                   5525:       file is included.</p>
1.75      rillig   5526: </div>
                   5527: <div class="sect2" lang="en">
                   5528: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   5529: <a name="updating-buildlink-depends"></a>13.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</h3></div></div></div>
1.87      wiz      5530: <p>The situation that requires increasing the dependency listed in
1.75      rillig   5531:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5532:        after a package update is when the API or interface to the
1.87      wiz      5533:       header files change.</p>
                   5534: <p>In this case,
                   5535:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5536:       should be adjusted to require at least the new package
                   5537:       version.  In some cases, the packages that depend on this new
                   5538:       version may need their <code class="varname">PKGREVISION</code>s
                   5539:       increased and, if they have <code class="filename">buildlink3.mk</code>
                   5540:       files, their
                   5541:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5542:       adjusted, too.  This is needed so pkgsrc will require the
                   5543:       correct package dependency and not settle for an older one
                   5544:       when building the source.</p>
                   5545: <p><code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   5546:        should be increased when the binary interface or sonames
                   5547:        (major number of the library version) of any installed
                   5548:        shared libraries change.  This is needed so that binary
                   5549:        packages made using it will require the correct package
                   5550:        dependency and not settle for an older one which will not
1.87      wiz      5551:       contain the necessary shared libraries.</p>
1.90      rillig   5552: <p>See <a href="#dependencies" title="18.1.6. Handling dependencies">Section 18.1.6, &#8220;Handling dependencies&#8221;</a> for
1.75      rillig   5553:        more information about dependencies on other packages,
                   5554:        including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
1.87      wiz      5555:       <code class="varname">ABI_DEPENDS</code> definitions.</p>
                   5556: <p>Please take careful consideration before adjusting
                   5557:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5558:       or
                   5559:       <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5560:       as we don't want to cause unneeded package deletions and
                   5561:       rebuilds.  In many cases, new versions of packages work just
                   5562:       fine with older dependencies.</p>
                   5563: <p>Also it is not needed to set
1.75      rillig   5564:        <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5565:        when it is identical to
1.87      wiz      5566:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.        </p>
1.75      rillig   5567: </div>
                   5568: </div>
                   5569: <div class="sect1" lang="en">
                   5570: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5571: <a name="writing-builtin.mk"></a>13.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.87      wiz      5572: <p>Some packages in pkgsrc install headers and libraries that
1.75      rillig   5573:       coincide with headers and libraries present in the base system.
1.76      rillig   5574:       Aside from a <code class="filename">buildlink3.mk</code> file, these
                   5575:       packages should also include a <code class="filename">builtin.mk</code>
1.75      rillig   5576:       file that includes the necessary checks to decide whether using
                   5577:       the built-in software or the pkgsrc software is
1.87      wiz      5578:     appropriate.</p>
                   5579: <p>The only requirements of a builtin.mk file for
                   5580:     <em class="replaceable"><code>pkg</code></em> are:</p>
1.75      rillig   5581: <div class="orderedlist"><ol type="1">
1.87      wiz      5582: <li><p>It should set
                   5583:        <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5584:        to either &#8220;<span class="quote">yes</span>&#8221; or &#8220;<span class="quote">no</span>&#8221;
                   5585:        after it is included.</p></li>
                   5586: <li><p>It should <span class="emphasis"><em>not</em></span> override any
                   5587:        <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5588:        which is already set before the
                   5589:        <code class="filename">builtin.mk</code> file is included.</p></li>
                   5590: <li><p>It should be written to allow multiple inclusion.  This
                   5591:        is <span class="emphasis"><em>very</em></span> important and takes careful
                   5592:        attention to <code class="filename">Makefile</code> coding.</p></li>
1.75      rillig   5593: </ol></div>
                   5594: <div class="sect2" lang="en">
                   5595: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   5596: <a name="anatomy-of-builtin.mk"></a>13.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</h3></div></div></div>
1.75      rillig   5597: <p>The following is the recommended template for builtin.mk
1.87      wiz      5598:       files:</p>
1.75      rillig   5599: <pre class="programlisting">
1.87      wiz      5600:        .if !defined(IS_BUILTIN.foo)
                   5601:        #
                   5602:        # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   5603:        # genuinely exists in the system or not.
                   5604:        #
                   5605:        IS_BUILTIN.foo?=        no
                   5606: 
                   5607:        # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   5608:        # version can be determined.
                   5609:        #
                   5610:        .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   5611:        BUILTIN_PKG.foo?=       foo-1.0
                   5612:        .  endif
                   5613:        .endif  # IS_BUILTIN.foo
                   5614: 
                   5615:        .if !defined(USE_BUILTIN.foo)
                   5616:        USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   5617:        .  if defined(BUILTIN_PKG.foo)
                   5618:        .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   5619:        .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   5620:        USE_BUILTIN.foo!=                                                       \
                   5621:        if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then     \
                   5622:        ${ECHO} "yes";                                            \
                   5623:        else                                                              \
                   5624:        ${ECHO} "no";                                             \
                   5625:        fi
                   5626:        .      endif
                   5627:        .    endfor
                   5628:        .  endif
                   5629:        .endif  # USE_BUILTIN.foo
                   5630: 
                   5631:        CHECK_BUILTIN.foo?=     no
                   5632:        .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   5633:        #
                   5634:        # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   5635:        # "yes" or "no".
                   5636:        #
                   5637:        .endif  # CHECK_BUILTIN.foo
                   5638:       </pre>
                   5639: <p>The first section sets
                   5640:       <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5641:       depending on if <em class="replaceable"><code>pkg</code></em> really exists
                   5642:       in the base system.  This should not be a base system software
                   5643:       with similar functionality to <em class="replaceable"><code>pkg</code></em>;
                   5644:       it should only be &#8220;<span class="quote">yes</span>&#8221; if the actual package is
                   5645:       included as part of the base system.  This variable is only
                   5646:       used internally within the <code class="filename">builtin.mk</code>
                   5647:       file.</p>
                   5648: <p>The second section sets
                   5649:       <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
                   5650:       to the version of <em class="replaceable"><code>pkg</code></em> in the base
                   5651:       system if it exists (if
                   5652:       <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5653:       is &#8220;<span class="quote">yes</span>&#8221;).  This variable is only used internally
                   5654:       within the <code class="filename">builtin.mk</code> file.</p>
                   5655: <p>The third section sets
                   5656:       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5657:       and is <span class="emphasis"><em>required</em></span> in all
                   5658:       <code class="filename">builtin.mk</code> files.  The code in this
                   5659:       section must make the determination whether the built-in
                   5660:       software is adequate to satisfy the dependencies listed in
                   5661:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
                   5662:       This is typically done by comparing
                   5663:       <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
                   5664:       against each of the dependencies in
                   5665:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
                   5666:       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5667:       <span class="emphasis"><em>must</em></span> be set to the correct value by the
                   5668:       end of the <code class="filename">builtin.mk</code> file.  Note that
                   5669:       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5670:       may be &#8220;<span class="quote">yes</span>&#8221; even if
                   5671:       <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5672:       is &#8220;<span class="quote">no</span>&#8221; because we may make the determination
                   5673:       that the built-in version of the software is similar enough to
                   5674:       be used as a replacement.</p>
                   5675: <p>The last section is guarded by
                   5676:       <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
                   5677:       and includes code that uses the value of
                   5678:       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5679:       set in the previous section.  This typically includes, e.g.,
                   5680:       adding additional dependency restrictions and listing additional
                   5681:       files to symlink into <code class="filename">${BUILDLINK_DIR}</code> (via
                   5682:       <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).</p>
1.75      rillig   5683: </div>
                   5684: <div class="sect2" lang="en">
                   5685: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   5686: <a name="native-or-pkgsrc-preference"></a>13.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.87      wiz      5687: <p>When building packages, it's possible to choose whether to set
                   5688:        a global preference for using either the built-in (native)
                   5689:        version or the pkgsrc version of software to satisfy a
                   5690:        dependency.  This is controlled by setting
                   5691:        <code class="varname">PREFER_PKGSRC</code> and
                   5692:        <code class="varname">PREFER_NATIVE</code>.  These variables take values
                   5693:        of either &#8220;<span class="quote">yes</span>&#8221;, &#8220;<span class="quote">no</span>&#8221;, or a list of
                   5694:        packages.  <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
                   5695:        use the pkgsrc versions of software, while
                   5696:        <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
                   5697:        built-in versions.  Preferences are determined by the most
                   5698:        specific instance of the package in either
                   5699:        <code class="varname">PREFER_PKGSRC</code> or
                   5700:        <code class="varname">PREFER_NATIVE</code>.  If a package is specified
                   5701:        in neither or in both variables, then
                   5702:        <code class="varname">PREFER_PKGSRC</code> has precedence over
                   5703:        <code class="varname">PREFER_NATIVE</code>.  For example, to require
                   5704:        using pkgsrc versions of software for all but the most basic
                   5705:       bits on a NetBSD system, you can set:</p>
                   5706: <pre class="programlisting">
                   5707:        PREFER_PKGSRC=  yes
                   5708:        PREFER_NATIVE=  getopt skey tcp_wrappers
                   5709:       </pre>
                   5710: <p>A package <span class="emphasis"><em>must</em></span> have a
                   5711:       <code class="filename">builtin.mk</code>
                   5712:       file to be listed in <code class="varname">PREFER_NATIVE</code>,
                   5713:       otherwise it is simply ignored in that list.</p>
1.75      rillig   5714: </div>
                   5715: </div>
                   5716: </div>
                   5717: <div class="chapter" lang="en">
                   5718: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   5719: <a name="pkginstall"></a>Chapter 14. The pkginstall framework</h2></div></div></div>
1.75      rillig   5720: <div class="toc">
                   5721: <p><b>Table of Contents</b></p>
                   5722: <dl>
1.90      rillig   5723: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">14.1. Files and directories outside the installation prefix</a></span></dt>
1.75      rillig   5724: <dd><dl>
1.90      rillig   5725: <dt><span class="sect2"><a href="#dirs-outside-prefix">14.1.1. Directory manipulation</a></span></dt>
                   5726: <dt><span class="sect2"><a href="#files-outside-prefix">14.1.2. File manipulation</a></span></dt>
1.75      rillig   5727: </dl></dd>
1.90      rillig   5728: <dt><span class="sect1"><a href="#conf-files">14.2. Configuration files</a></span></dt>
1.75      rillig   5729: <dd><dl>
1.90      rillig   5730: <dt><span class="sect2"><a href="#conf-files-sysconfdir">14.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
                   5731: <dt><span class="sect2"><a href="#conf-files-configure">14.2.2. Telling the software where configuration files are</a></span></dt>
                   5732: <dt><span class="sect2"><a href="#conf-files-patching">14.2.3. Patching installations</a></span></dt>
                   5733: <dt><span class="sect2"><a href="#conf-files-disable">14.2.4. Disabling handling of configuration files</a></span></dt>
                   5734: </dl></dd>
                   5735: <dt><span class="sect1"><a href="#rcd-scripts">14.3. System startup scripts</a></span></dt>
                   5736: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">14.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
                   5737: <dt><span class="sect1"><a href="#users-and-groups">14.4. System users and groups</a></span></dt>
                   5738: <dt><span class="sect1"><a href="#shells">14.5. System shells</a></span></dt>
                   5739: <dd><dl><dt><span class="sect2"><a href="#shells-disable">14.5.1. Disabling shell registration</a></span></dt></dl></dd>
                   5740: <dt><span class="sect1"><a href="#fonts">14.6. Fonts</a></span></dt>
                   5741: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">14.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
1.75      rillig   5742: </dl>
                   5743: </div>
                   5744: <p>This chapter describes the framework known as
                   5745: <code class="literal">pkginstall</code>, whose key features are:</p>
                   5746: <div class="itemizedlist"><ul type="disc">
                   5747: <li><p>Generic installation and manipulation of directories and files
                   5748:     outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
                   5749: <li><p>Automatic handling of configuration files during installation,
                   5750:     provided that packages are correctly designed.</p></li>
                   5751: <li><p>Generation and installation of system startup scripts.</p></li>
                   5752: <li><p>Registration of system users and groups.</p></li>
                   5753: <li><p>Registration of system shells.</p></li>
                   5754: <li><p>Automatic updating of fonts databases.</p></li>
                   5755: </ul></div>
                   5756: <p>The following sections inspect each of the above points in detail.</p>
                   5757: <p>You may be thinking that many of the things described here could be
                   5758: easily done with simple code in the package's post-installation target
                   5759: (<code class="literal">post-install</code>).  <span class="emphasis"><em>This is incorrect</em></span>,
                   5760: as the code in them is only executed when building from source.  Machines
                   5761: using binary packages could not benefit from it at all (as the code itself
                   5762: could be unavailable).  Therefore, the only way to achieve any of the items
                   5763: described above is by means of the installation scripts, which are
                   5764: automatically generated by pkginstall.</p>
                   5765: <div class="sect1" lang="en">
                   5766: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5767: <a name="files-and-dirs-outside-prefix"></a>14.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76      rillig   5768: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75      rillig   5769: of files and directories that belong to a package.  The names used in it
1.76      rillig   5770: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75      rillig   5771: which means that it cannot register files outside this directory (absolute
                   5772: path names are not allowed).  Despite this restriction, some packages need
                   5773: to install files outside this location; e.g., under
1.76      rillig   5774: <code class="filename">${VARBASE}</code> or
1.87      wiz      5775: <code class="filename">${PKG_SYSCONFDIR}</code>.  The only way to achieve this
                   5776: is to create such files during installation time by using
                   5777: installation scripts.</p>
                   5778: <p>The generic installation scripts are shell scripts that can
                   5779: contain arbitrary code.  The list of scripts to execute is taken from
                   5780: the <code class="varname">INSTALL_FILE</code> variable, which defaults to
                   5781: <code class="filename">INSTALL</code>.  A similar variable exists for package
                   5782: removal (<code class="varname">DEINSTALL_FILE</code>, whose default is
                   5783: <code class="filename">DEINSTALL</code>).  These scripts can run arbitrary
                   5784: commands, so they have the potential to create and manage files
                   5785: anywhere in the file system.</p>
                   5786: <p>Using these general installation files is not recommended, but
                   5787: may be needed in some special cases.  One reason for avoiding them is
                   5788: that the user has to trust the packager that there is no unwanted or
                   5789: simply erroneous code included in the installation script. Also,
                   5790: previously there were many similar scripts for the same functionality,
                   5791: and fixing a common error involved finding and changing all of
                   5792: them.</p>
                   5793: <p>The pkginstall framework offers another, standardized way.  It
                   5794: provides generic scripts to abstract the manipulation of such files
                   5795: and directories based on variables set in the package's
                   5796: <code class="filename">Makefile</code>.  The rest of this section describes
                   5797: these variables.</p>
1.75      rillig   5798: <div class="sect2" lang="en">
                   5799: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   5800: <a name="dirs-outside-prefix"></a>14.1.1. Directory manipulation</h3></div></div></div>
1.75      rillig   5801: <p>The following variables can be set to request the creation of
                   5802: directories anywhere in the file system:</p>
                   5803: <div class="itemizedlist"><ul type="disc">
                   5804: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
                   5805:     contain a list of directories that should be created and should attempt
                   5806:     to be destroyed by the installation scripts.  The difference between
                   5807:     the two is that the latter prompts the administrator to remove any
                   5808:     directories that may be left after deinstallation (because they were
                   5809:     not empty), while the former does not.</p></li>
                   5810: <li>
                   5811: <p><code class="varname">MAKE_DIRS_PERMS</code> and
                   5812:     <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
                   5813:     which directories should be created and should attempt to be destroyed
                   5814:     by the installation scripts.  Each tuple holds the following values,
                   5815:     separated by spaces: the directory name, its owner, its group and its
                   5816:     numerical mode.  For example:</p>
                   5817: <pre class="programlisting">
                   5818:     MAKE_DIRS_PERMS+=         ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1       grant    5819: </pre>
1.75      rillig   5820: <p>The difference between the two is exactly the same as their
                   5821:     non-<code class="varname">PERMS</code> counterparts.</p>
                   5822: </li>
                   5823: </ul></div>
                   5824: </div>
                   5825: <div class="sect2" lang="en">
                   5826: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   5827: <a name="files-outside-prefix"></a>14.1.2. File manipulation</h3></div></div></div>
1.75      rillig   5828: <p>Creating non-empty files outside the installation prefix is tricky
1.76      rillig   5829: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75      rillig   5830: To overcome this problem, the only solution is to extract the file in the
                   5831: known place (i.e., inside the installation prefix) and copy it to the
                   5832: appropriate location during installation (done by the installation scripts
                   5833: generated by pkginstall).  We will call the former the <span class="emphasis"><em>master
                   5834: file</em></span> in the following paragraphs, which describe the variables
                   5835: that can be used to automatically and consistently handle files outside the
                   5836: installation prefix:</p>
                   5837: <div class="itemizedlist"><ul type="disc">
                   5838: <li>
                   5839: <p><code class="varname">CONF_FILES</code> and
                   5840:     <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
                   5841:     During installation time, the master file is copied to the target one
                   5842:     if and only if the latter does not exist.  Upon deinstallation, the
                   5843:     target file is removed provided that it was not modified by the
                   5844:     installation.</p>
                   5845: <p>The difference between the two is that the latter prompts the
                   5846:     administrator to remove any files that may be left after
                   5847:     deinstallation (because they were not empty), while the former does
                   5848:     not.</p>
                   5849: </li>
                   5850: <li>
                   5851: <p><code class="varname">CONF_FILES_PERMS</code> and
                   5852:     <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
                   5853:     files as well as their target locations.  For each of them, it also
                   5854:     specifies their owner, their group and their numeric permissions, in
                   5855:     this order.  For example:</p>
                   5856: <pre class="programlisting">
                   5857:     SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1       grant    5858: </pre>
1.75      rillig   5859: <p>The difference between the two is exactly the same as their
                   5860:     non-<code class="varname">PERMS</code> counterparts.</p>
                   5861: </li>
                   5862: </ul></div>
                   5863: </div>
                   5864: </div>
                   5865: <div class="sect1" lang="en">
                   5866: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5867: <a name="conf-files"></a>14.2. Configuration files</h2></div></div></div>
1.75      rillig   5868: <p>Configuration files are special in the sense that they are installed
                   5869: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
                   5870: need special treatment during installation (most of which is automated by
                   5871: pkginstall).  The main concept you must bear in mind is that files marked
                   5872: as configuration files are automatically copied to the right place (somewhere
                   5873: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
                   5874: and only if</em></span> they didn't exist before.  Similarly, they will not
                   5875: be removed if they have local modifications.  This ensures that
                   5876: administrators never lose any custom changes they may have made.</p>
                   5877: <div class="sect2" lang="en">
                   5878: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   5879: <a name="conf-files-sysconfdir"></a>14.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</h3></div></div></div>
1.75      rillig   5880: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
                   5881: specifies where configuration files shall be installed.  Its contents are
                   5882: set based upon the following variables:</p>
                   5883: <div class="itemizedlist"><ul type="disc">
                   5884: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76      rillig   5885:     directory.  Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75      rillig   5886:     be overridden by the user to point to his preferred location (e.g.,
1.76      rillig   5887:     <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75      rillig   5888:     Packages must not use it directly.</p></li>
                   5889: <li>
                   5890: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
                   5891:     <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
                   5892:     for the package being built shall be installed.  The definition of this
                   5893:     variable only makes sense in the package's
1.76      rillig   5894:     <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75      rillig   5895: <p>As an example, consider the Apache package,
1.91      rillig   5896:     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/apache2/README.html" target="_top"><code class="filename">www/apache2</code></a>, which places its
1.75      rillig   5897:     configuration files under the
1.76      rillig   5898:     <code class="filename">httpd/</code> subdirectory of
1.75      rillig   5899:     <code class="varname">PKG_SYSCONFBASE</code>.  This should be set in the package
                   5900:     Makefile.</p>
                   5901: </li>
                   5902: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
                   5903:     variable that holds this package's configuration directory (if
                   5904:     different from <code class="varname">PKG_SYSCONFBASE</code>).  It defaults to
                   5905:     <code class="varname">PKGBASE</code>'s value, and is always prefixed with
                   5906:     <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
                   5907: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
                   5908:     directory where the configuration files for the package identified by
                   5909:     <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
                   5910: </ul></div>
                   5911: <p>Based on the above variables, pkginstall determines the value of
                   5912: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
                   5913: variable that can be used within a package to refer to its configuration
                   5914: directory.  The algorithm used to set its value is basically the
                   5915: following:</p>
                   5916: <div class="orderedlist"><ol type="1">
                   5917: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
                   5918:     its value is used.</p></li>
                   5919: <li><p>If the previous variable is not defined but
                   5920:     <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76      rillig   5921:     <code class="filename">Makefile</code>, the resulting value is
                   5922:     <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75      rillig   5923: <li><p>Otherwise, it is set to
1.76      rillig   5924:     <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75      rillig   5925: </ol></div>
1.76      rillig   5926: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.90      rillig   5927: automatically added to <code class="filename">OWN_DIRS</code>.  See <a href="#dirs-outside-prefix" title="14.1.1. Directory manipulation">Section 14.1.1, &#8220;Directory manipulation&#8221;</a> what this means.</p>
1.75      rillig   5928: </div>
                   5929: <div class="sect2" lang="en">
                   5930: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   5931: <a name="conf-files-configure"></a>14.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75      rillig   5932: <p>Given that pkgsrc (and users!) expect configuration files to be in a
                   5933: known place, you need to teach each package where it shall install its
                   5934: files.  In some cases you will have to patch the package Makefiles to
                   5935: achieve it.  If you are lucky, though, it may be as easy as passing an
                   5936: extra flag to the configuration script; this is the case of GNU Autoconf-
                   5937: generated files:</p>
                   5938: <pre class="programlisting">
                   5939:     CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1       grant    5940: </pre>
1.75      rillig   5941: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
                   5942: for</em></span> its configuration files, not where they will be originally
                   5943: installed (although the difference is never explicit,
                   5944: unfortunately).</p>
                   5945: </div>
                   5946: <div class="sect2" lang="en">
                   5947: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   5948: <a name="conf-files-patching"></a>14.2.3. Patching installations</h3></div></div></div>
1.75      rillig   5949: <p>As said before, pkginstall automatically handles configuration files.
                   5950: This means that <span class="strong"><strong>the packages themselves must not
1.76      rillig   5951: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75      rillig   5952: directly</strong></span>.  Bad news is that many software installation scripts
                   5953: will, out of the box, mess with the contents of that directory.  So what is
                   5954: the correct procedure to fix this issue?</p>
                   5955: <p>You must teach the package (usually by manually patching it) to
                   5956: install any configuration files under the examples hierarchy,
1.76      rillig   5957: <code class="filename">share/examples/${PKGBASE}/</code>.  This way, the
                   5958: <code class="filename">PLIST</code> registers them and the administrator always
1.75      rillig   5959: has the original copies available.</p>
                   5960: <p>Once the required configuration files are in place (i.e., under the
                   5961: examples hierarchy), the pkginstall framework can use them as master copies
                   5962: during the package installation to update what is in
1.76      rillig   5963: <code class="filename">${PKG_SYSCONFDIR}</code>.  To achieve this, the variables
1.75      rillig   5964: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.90      rillig   5965: used.  Check out <a href="#files-outside-prefix" title="14.1.2. File manipulation">Section 14.1.2, &#8220;File manipulation&#8221;</a> for information
1.75      rillig   5966: about their syntax and their purpose.  Here is an example, taken from the
1.91      rillig   5967: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/mail/mutt/README.html" target="_top"><code class="filename">mail/mutt</code></a> package:</p>
1.75      rillig   5968: <pre class="programlisting">
                   5969:     EGDIR=        ${PREFIX}/share/doc/mutt/samples
                   5970:     CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1       grant    5971: </pre>
1.75      rillig   5972: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
                   5973: package and has no meaning outside it.</p>
                   5974: </div>
                   5975: <div class="sect2" lang="en">
                   5976: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   5977: <a name="conf-files-disable"></a>14.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75      rillig   5978: <p>The automatic copying of config files can be toggled by setting the
                   5979: environment variable <code class="varname">PKG_CONFIG</code> prior to package
                   5980: installation.</p>
                   5981: </div>
                   5982: </div>
                   5983: <div class="sect1" lang="en">
                   5984: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   5985: <a name="rcd-scripts"></a>14.3. System startup scripts</h2></div></div></div>
1.75      rillig   5986: <p>System startup scripts are special files because they must be
                   5987: installed in a place known by the underlying OS, usually outside the
1.90      rillig   5988: installation prefix.  Therefore, the same rules described in <a href="#files-and-dirs-outside-prefix" title="14.1. Files and directories outside the installation prefix">Section 14.1, &#8220;Files and directories outside the installation prefix&#8221;</a> apply, and the same solutions
1.75      rillig   5989: can be used.  However, pkginstall provides a special mechanism to handle
                   5990: these files.</p>
                   5991: <p>In order to provide system startup scripts, the package has
                   5992: to:</p>
                   5993: <div class="orderedlist"><ol type="1">
1.76      rillig   5994: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75      rillig   5995:     the <code class="literal">.sh</code> suffix appended.  Considering the
1.91      rillig   5996:     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/print/cups/README.html" target="_top"><code class="filename">print/cups</code></a> package as an example, it has a
1.76      rillig   5997:     <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75      rillig   5998: <li>
                   5999: <p>Tell pkginstall to handle it, appending the name of the script,
                   6000:     without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
                   6001:     Continuing the previous example:</p>
                   6002: <pre class="programlisting">
                   6003:     RCD_SCRIPTS+=   cupsd
1.1       grant    6004: </pre>
1.75      rillig   6005: </li>
                   6006: </ol></div>
                   6007: <p>Once this is done, pkginstall will do the following steps for each
                   6008: script in an automated fashion:</p>
                   6009: <div class="orderedlist"><ol type="1">
                   6010: <li><p>Process the file found in the files directory applying all the
1.76      rillig   6011:     substitutions described in the <code class="filename">FILES_SUBST</code>
1.75      rillig   6012:     variable.</p></li>
                   6013: <li><p>Copy the script from the files directory to the examples
1.76      rillig   6014:     hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>.  Note
1.75      rillig   6015:     that this master file must be explicitly registered in the
1.76      rillig   6016:     <code class="filename">PLIST</code>.</p></li>
1.75      rillig   6017: <li><p>Add code to the installation scripts to copy the startup script
                   6018:     from the examples hierarchy into the system-wide startup scripts
                   6019:     directory.</p></li>
                   6020: </ol></div>
                   6021: <div class="sect2" lang="en">
                   6022: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   6023: <a name="rcd-scripts-disable"></a>14.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75      rillig   6024: <p>The automatic copying of config files can be toggled by setting the
                   6025: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
                   6026: installation.  Note that the scripts will be always copied inside the
1.76      rillig   6027: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75      rillig   6028: matter what the value of this variable is.</p>
                   6029: </div>
                   6030: </div>
                   6031: <div class="sect1" lang="en">
                   6032: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6033: <a name="users-and-groups"></a>14.4. System users and groups</h2></div></div></div>
1.75      rillig   6034: <p>If a package needs to create special users and/or groups during
                   6035: installation, it can do so by using the pkginstall framework.</p>
                   6036: <p>Users can be created by adding entries to the
                   6037: <code class="varname">PKG_USERS</code> variable.  Each entry has the following
                   6038: syntax:</p>
                   6039: <pre class="programlisting">
                   6040:     user:group
1.1       grant    6041: </pre>
1.87      wiz      6042: <p>Further specification of user details may be done by setting
                   6043: per-user variables.
                   6044: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the
                   6045: numeric UID for the user.
                   6046: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the
                   6047: user's description or comment.
                   6048: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the
                   6049: user's home directory, and defaults to
                   6050: <code class="filename">/nonexistent</code> if not specified.
                   6051: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the
                   6052: user's shell, and defaults to <code class="filename">/sbinno/login</code> if
                   6053: not specified.</p>
1.75      rillig   6054: <p>Similarly, groups can be created by adding entries to the
                   6055: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
                   6056: <pre class="programlisting">
                   6057:     group
1.1       grant    6058: </pre>
1.75      rillig   6059: <p>The numeric GID of the group may be set by defining 
                   6060: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
                   6061: <p>If a package needs to create the users and groups at an earlier
                   6062: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
                   6063: either <code class="literal">configure</code> or <code class="literal">build</code> to
                   6064: indicate the phase before which the users and groups are created.  In
                   6065: this case, the numeric UIDs and GIDs of the created users and groups
                   6066: are automatically hardcoded into the final installation scripts.</p>
                   6067: </div>
                   6068: <div class="sect1" lang="en">
                   6069: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6070: <a name="shells"></a>14.5. System shells</h2></div></div></div>
1.75      rillig   6071: <p>Packages that install system shells should register them in the shell
1.76      rillig   6072: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75      rillig   6073: administrator.  This must be done from the installation scripts to keep
                   6074: binary packages working on any system.  pkginstall provides an easy way to
                   6075: accomplish this task.</p>
                   6076: <p>When a package provides a shell interpreter, it has to set the
                   6077: <code class="varname">PKG_SHELL</code> variable to its absolute file name.  This will
                   6078: add some hooks to the installation scripts to handle it.  Consider the
1.91      rillig   6079: following example, taken from <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/shells/zsh/README.html" target="_top"><code class="filename">shells/zsh</code></a>:</p>
1.75      rillig   6080: <pre class="programlisting">
                   6081:     PKG_SHELL=      ${PREFIX}/bin/zsh
1.1       grant    6082: </pre>
1.75      rillig   6083: <div class="sect2" lang="en">
                   6084: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   6085: <a name="shells-disable"></a>14.5.1. Disabling shell registration</h3></div></div></div>
1.75      rillig   6086: <p>The automatic registration of shell interpreters can be disabled by
1.76      rillig   6087: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75      rillig   6088: environment variable to <code class="literal">NO</code>.</p>
                   6089: </div>
                   6090: </div>
                   6091: <div class="sect1" lang="en">
                   6092: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6093: <a name="fonts"></a>14.6. Fonts</h2></div></div></div>
1.75      rillig   6094: <p>Packages that install X11 fonts should update the database files
                   6095: that index the fonts within each fonts directory.  This can easily be
                   6096: accomplished within the pkginstall framework.</p>
                   6097: <p>When a package installs X11 fonts, it must list the directories in
                   6098: which fonts are installed in the
                   6099: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
                   6100: where <em class="replaceable"><code>type</code></em> can be one of &#8220;<span class="quote">ttf</span>&#8221;,
                   6101: &#8220;<span class="quote">type1</span>&#8221; or &#8220;<span class="quote">x11</span>&#8221;.  This will add hooks to the
                   6102: installation scripts to run the appropriate commands to update the fonts
                   6103: database files within each of those directories.  For convenience, if the
                   6104: directory path is relative, it is taken to be relative to the package's
1.91      rillig   6105: installation prefix.  Consider the following example, taken from <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/fonts/dbz-ttf/README.html" target="_top"><code class="filename">fonts/dbz-ttf</code></a>:</p>
1.75      rillig   6106: <pre class="programlisting">
                   6107:     FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1       grant    6108: </pre>
1.75      rillig   6109: <div class="sect2" lang="en">
                   6110: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   6111: <a name="fonts-disable"></a>14.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75      rillig   6112: <p>The automatic update of fonts databases can be disabled by
1.76      rillig   6113: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75      rillig   6114: environment variable to <code class="literal">NO</code>.</p>
                   6115: </div>
                   6116: </div>
                   6117: </div>
                   6118: <div class="chapter" lang="en">
                   6119: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   6120: <a name="options"></a>Chapter 15. Options handling</h2></div></div></div>
1.75      rillig   6121: <div class="toc">
                   6122: <p><b>Table of Contents</b></p>
                   6123: <dl>
1.90      rillig   6124: <dt><span class="sect1"><a href="#global-default-options">15.1. Global default options</a></span></dt>
                   6125: <dt><span class="sect1"><a href="#converting-to-options">15.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
                   6126: <dt><span class="sect1"><a href="#option-names">15.3. Option Names</a></span></dt>
1.75      rillig   6127: </dl>
                   6128: </div>
                   6129: <p>Many packages have the ability to be built to support different
1.76      rillig   6130: sets of features.  <code class="filename">bsd.options.mk</code> is a framework
1.75      rillig   6131: in pkgsrc that provides generic handling of those options that
                   6132: determine different ways in which the packages can be built.  It's
                   6133: possible for the user to specify exactly which sets of options will be
                   6134: built into a package or to allow a set of global default options
                   6135: apply.</p>
                   6136: <div class="sect1" lang="en">
                   6137: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6138: <a name="global-default-options"></a>15.1. Global default options</h2></div></div></div>
1.75      rillig   6139: <p>Global default options are listed in
                   6140: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
                   6141: that should be built into every package if that option is supported.
1.76      rillig   6142: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75      rillig   6143: </div>
                   6144: <div class="sect1" lang="en">
                   6145: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6146: <a name="converting-to-options"></a>15.2. Converting packages to use <code class="filename">bsd.options.mk</code></h2></div></div></div>
1.75      rillig   6147: <p>The following example shows how
1.76      rillig   6148: <code class="filename">bsd.options.mk</code> should be used
1.75      rillig   6149: by the hypothetical ``wibble'' package, either in the package
1.76      rillig   6150: <code class="filename">Makefile</code>, or in a file,
                   6151: e.g. <code class="filename">options.mk</code>, that is included by the
                   6152: main package <code class="filename">Makefile</code>.</p>
1.75      rillig   6153: <pre class="programlisting">
                   6154:     PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   6155:     PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   6156:     PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   6157:     PKG_OPTIONS_GROUP.database=     mysql pgsql
                   6158:     PKG_SUGGESTED_OPTIONS=          wibble-foo
                   6159:     PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   6160:     PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
1.1       grant    6161: 
1.75      rillig   6162:     .include "../../mk/bsd.prefs.mk"
1.69      rillig   6163: 
1.75      rillig   6164:     # this package was previously named wibble2
                   6165:     .if defined(PKG_OPTIONS.wibble2)
                   6166:     PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   6167:     PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78      rillig   6168:             "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75      rillig   6169:     .endif
1.69      rillig   6170: 
1.75      rillig   6171:     .include "../../mk/bsd.options.mk"
1.69      rillig   6172: 
1.75      rillig   6173:     # Package-specific option-handling
1.69      rillig   6174: 
1.75      rillig   6175:     ###
                   6176:     ### FOO support
                   6177:     ###
                   6178:     .if !empty(PKG_OPTIONS:Mwibble-foo)
                   6179:     CONFIGURE_ARGS+=    --enable-foo
                   6180:     .endif
1.69      rillig   6181: 
1.75      rillig   6182:     ###
                   6183:     ### LDAP support
                   6184:     ###
                   6185:     .if !empty(PKG_OPTIONS:Mldap)
1.77      rillig   6186:     .  include "../../databases/openldap-client/buildlink3.mk"
                   6187:     CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75      rillig   6188:     .endif
1.69      rillig   6189: 
1.75      rillig   6190:     ###
                   6191:     ### database support
                   6192:     ###
                   6193:     .if !empty(PKG_OPTIONS:Mmysql)
                   6194:     .  include "../../mk/mysql.buildlink3.mk"
                   6195:     .endif
                   6196:     .if !empty(PKG_OPTIONS:Mpgsql)
                   6197:     .  include "../../mk/pgsql.buildlink3.mk"
                   6198:     .endif
                   6199: </pre>
                   6200: <p>The first section contains the information about which build
                   6201: options are supported by the package, and any default options settings
                   6202: if needed.</p>
                   6203: <div class="orderedlist"><ol type="1">
                   6204: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
                   6205: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> variable that the user can set to override the default
                   6206: options.  It should be set to
1.78      rillig   6207: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
                   6208: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
                   6209: at the point where the options are processed.</p></li>
1.75      rillig   6210: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
                   6211: build options supported by the package.</p></li>
                   6212: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
                   6213: list of names of groups of mutually exclusive options.  The options in
                   6214: each group are listed in
                   6215: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
                   6216: The most specific setting of any option from the group takes
                   6217: precedence over all other options in the group.  Options from the
                   6218: groups will be automatically added to
                   6219: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
                   6220: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
                   6221: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
                   6222: packages will fail if no option from the group is
                   6223: selected.</p></li>
                   6224: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
                   6225: of names of sets of options.  At least one option from each set must
                   6226: be selected.  The options in each set are listed in
                   6227: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
                   6228: Options from the sets will be automatically added to
                   6229: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.  Building the package will
                   6230: fail if no option from the set is selected.</p></li>
                   6231: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
                   6232: build options which are enabled by default.</p></li>
                   6233: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
                   6234: of
                   6235: &#8220;<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>&#8221;
1.76      rillig   6236: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75      rillig   6237: their option counterparts.  Pairs should be added with
                   6238: &#8220;<span class="quote">+=</span>&#8221; to keep the listing of global legacy variables.  A
                   6239: warning will be issued if the user uses a legacy
                   6240: variable.</p></li>
                   6241: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
                   6242: of
                   6243: &#8220;<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>&#8221;
                   6244: pairs that map options that have been renamed to their new
                   6245: counterparts.  Pairs should be added with &#8220;<span class="quote">+=</span>&#8221; to keep
                   6246: the listing of global legacy options.  A warning will be issued if
                   6247: the user uses a legacy option.</p></li>
                   6248: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
                   6249: options implied by deprecated variables used.  This can be used for
                   6250: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
                   6251: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
                   6252: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
                   6253: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
                   6254: a list of warnings about deprecated variables or options used, and
                   6255: what to use instead.</p></li>
                   6256: </ol></div>
                   6257: <p>A package should never modify
                   6258: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
                   6259: <code class="varname">PKG_OPTIONS_VAR</code>.  These are strictly user-settable.
                   6260: To suggest a default set of options, use
                   6261: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
                   6262: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76      rillig   6263: including <code class="filename">bsd.options.mk</code>.  If none of
1.75      rillig   6264: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
                   6265: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
                   6266: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
                   6267: happen with platform-specific options if none of them is supported on
                   6268: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
                   6269: empty list and the package is otherwise treated as not using the
                   6270: options framework.</p>
1.76      rillig   6271: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75      rillig   6272: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
                   6273: build options, properly filtered to remove unsupported and duplicate
                   6274: options.</p>
                   6275: <p>The remaining sections contain the logic that is specific to
                   6276: each option.  The correct way to check for an option is to check
                   6277: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
                   6278: <pre class="programlisting">
                   6279:     .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
                   6280: </pre>
                   6281: </div>
                   6282: <div class="sect1" lang="en">
                   6283: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6284: <a name="option-names"></a>15.3. Option Names</h2></div></div></div>
1.75      rillig   6285: <p>Options that enable similar features in different packages (like
                   6286: optional support for a library) should use a common name in all
                   6287: packages that support it (like the name of the library).  If another
                   6288: package already has an option with the same meaning, use the same
                   6289: name.</p>
                   6290: <p>Options that enable features specific to one package, where it's
                   6291: unlikely that another (unrelated) package has the same (or a similar)
                   6292: optional feature, should use a name prefixed with
                   6293: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
                   6294: <p>If a group of related packages share an optional feature
                   6295: specific to that group, prefix it with the name of the
                   6296: &#8220;<span class="quote">main</span>&#8221; package
                   6297: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
                   6298: <p>For new options, add a line to
1.76      rillig   6299: <code class="filename">mk/defaults/options.description</code>.  Lines have two
1.75      rillig   6300: fields, separated by tab.  The first field is the option name, the
                   6301: second its description.  The description should be a whole sentence
                   6302: (starting with an uppercase letter and ending with a period) that
                   6303: describes what enabling the option does.  E. g. &#8220;<span class="quote">Enable ispell
                   6304: support.</span>&#8221; The file is sorted by option names.</p>
                   6305: </div>
                   6306: </div>
                   6307: <div class="chapter" lang="en">
                   6308: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   6309: <a name="build"></a>Chapter 16. The build process</h2></div></div></div>
1.75      rillig   6310: <div class="toc">
                   6311: <p><b>Table of Contents</b></p>
                   6312: <dl>
1.90      rillig   6313: <dt><span class="sect1"><a href="#build.intro">16.1. Introduction</a></span></dt>
                   6314: <dt><span class="sect1"><a href="#build.prefix">16.2. Program location</a></span></dt>
                   6315: <dt><span class="sect1"><a href="#build.builddirs">16.3. Directories used during the build process</a></span></dt>
                   6316: <dt><span class="sect1"><a href="#build.running">16.4. Running a phase</a></span></dt>
                   6317: <dt><span class="sect1"><a href="#build.fetch">16.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
                   6318: <dd><dl>
                   6319: <dt><span class="sect2"><a href="#build.fetch.what">16.5.1. What to fetch and where to get it from</a></span></dt>
                   6320: <dt><span class="sect2"><a href="#build.fetch.how">16.5.2. How are the files fetched?</a></span></dt>
                   6321: </dl></dd>
                   6322: <dt><span class="sect1"><a href="#build.checksum">16.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
                   6323: <dt><span class="sect1"><a href="#build.extract">16.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
                   6324: <dt><span class="sect1"><a href="#build.patch">16.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
                   6325: <dt><span class="sect1"><a href="#build.tools">16.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
                   6326: <dt><span class="sect1"><a href="#build.wrapper">16.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
                   6327: <dt><span class="sect1"><a href="#build.configure">16.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   6328: <dt><span class="sect1"><a href="#build.build">16.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   6329: <dt><span class="sect1"><a href="#build.test">16.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
                   6330: <dt><span class="sect1"><a href="#build.install">16.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   6331: <dt><span class="sect1"><a href="#build.package">16.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
                   6332: <dt><span class="sect1"><a href="#build.clean">16.16. Cleaning up</a></span></dt>
                   6333: <dt><span class="sect1"><a href="#build.helpful-targets">16.17. Other helpful targets</a></span></dt>
1.75      rillig   6334: </dl>
                   6335: </div>
                   6336: <div class="sect1" lang="en">
                   6337: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6338: <a name="build.intro"></a>16.1. Introduction</h2></div></div></div>
1.75      rillig   6339: <p>This chapter gives a detailed description on how a package is
1.87      wiz      6340:     built. Building a package is separated into different
                   6341:     <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
                   6342:     <code class="varname">build</code>, <code class="varname">install</code>), all of which are
                   6343:     described in the following sections. Each phase is splitted into
                   6344:     so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
                   6345:     containing phase, prefixed by one of <code class="varname">pre-</code>,
                   6346:     <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
                   6347:     <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
                   6348:     of the actual work is done in the <code class="varname">do-*</code> stages.</p>
1.75      rillig   6349: <p>The basic steps for building a program are always the same.  First
1.87      wiz      6350:     the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
                   6351:     the local system and then extracted. After any pkgsrc-specific patches
                   6352:     to compile properly are applied, the software can be configured, then
                   6353:     built (usually by compiling), and finally the generated binaries, etc.
                   6354:     can be put into place on the system.</p>
1.75      rillig   6355: </div>
                   6356: <div class="sect1" lang="en">
                   6357: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6358: <a name="build.prefix"></a>16.2. Program location</h2></div></div></div>
1.75      rillig   6359: <p>Before outlining the process performed by the NetBSD package system in
1.87      wiz      6360:     the next section, here's a brief discussion on where programs are
                   6361:     installed, and which variables influence this.</p>
1.75      rillig   6362: <p>The automatic variable <code class="varname">PREFIX</code> indicates
1.87      wiz      6363:     where all files of the final program shall be installed. It is
                   6364:     usually set to <code class="varname">LOCALBASE</code>
                   6365:     (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.88      wiz      6366:     for pkgs in the <code class="filename">cross</code> category.  The value of
1.87      wiz      6367:     <code class="varname">PREFIX</code> needs to be put
                   6368:     into the various places in the program's source where paths to
1.90      rillig   6369:     these files are encoded.  See <a href="#components.patches" title="10.3. patches/*">Section 10.3, &#8220;patches/*&#8221;</a> and <a href="#fixes.libtool" title="18.3.1. Shared libraries - libtool">Section 18.3.1, &#8220;Shared libraries - libtool&#8221;</a> for more details.</p>
1.75      rillig   6370: <p>When choosing which of these variables to use,
1.87      wiz      6371:     follow the following rules:</p>
1.75      rillig   6372: <div class="itemizedlist"><ul type="disc">
1.88      wiz      6373: <li><p><code class="varname">PREFIX</code> always points to the location
                   6374:        where the current pkg will be installed.  When referring to a
                   6375:        pkg's own installation path, use
                   6376:        &#8220;<span class="quote">${PREFIX}</span>&#8221;.</p></li>
                   6377: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs
                   6378:        are installed.  If you need to construct a -I or -L argument
                   6379:        to the compiler to find includes and libraries installed by
                   6380:        another non-X11 pkg, use &#8220;<span class="quote">${LOCALBASE}</span>&#8221;. The name
1.87      wiz      6381:        <code class="varname">LOCALBASE</code> stems from FreeBSD, which
                   6382:        installed all packages in <code class="filename">/usr/local</code>. As
                   6383:        pkgsrc leaves <code class="filename">/usr/local</code> for the system
                   6384:        administrator, this variable is a misnomer.</p></li>
1.88      wiz      6385: <li><p><code class="varname">X11BASE</code> is where the actual X11
                   6386:        distribution (from xsrc, etc.) is installed. When looking for
                   6387:        <span class="emphasis"><em>standard</em></span> X11 includes (not those
                   6388:        installed by a package), use &#8220;<span class="quote">${X11BASE}</span>&#8221;.</p></li>
                   6389: <li>
                   6390: <p>X11-based packages are special in that they may be
                   6391:        installed in either <code class="varname">X11BASE</code> or
                   6392:        <code class="varname">LOCALBASE</code>.</p>
1.75      rillig   6393: <p>Usually, X11 packages should be installed under
1.88      wiz      6394:        <code class="varname">LOCALBASE</code> whenever possible.  Note that you
                   6395:        will need to include
                   6396:        <code class="filename">../../mk/x11.buildlink3.mk</code> in them to
                   6397:        request the presence of X11 and to get the right compilation
                   6398:        flags.</p>
1.75      rillig   6399: <p>Even though, there are some packages that cannot be installed
1.87      wiz      6400:        under <code class="varname">LOCALBASE</code>: those that come with app-defaults
                   6401:        files. These packages are special and they must be placed under
                   6402:        <code class="varname">X11BASE</code>. To accomplish this, set either
                   6403:        <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
                   6404:        your package.</p>
1.75      rillig   6405: <p>Some notes: If you need
1.87      wiz      6406:        to find includes or libraries installed by a pkg that has
                   6407:        <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
                   6408:        its pkg <code class="filename">Makefile</code>, you need to look in
                   6409:        <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
                   6410:        <code class="filename">${LOCALBASE}</code>. To force installation of
                   6411:        all X11 packages in <code class="varname">LOCALBASE</code>, the
1.91      rillig   6412:        <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a> package
1.87      wiz      6413:        is enabled by default.</p>
1.75      rillig   6414: </li>
1.88      wiz      6415: <li><p><code class="varname">X11PREFIX</code> should be used to refer to
                   6416:        the installed location of an X11
                   6417:        package. <code class="varname">X11PREFIX</code> will be set to
                   6418:        <code class="varname">X11BASE</code> if xpkgwedge is not installed, and
                   6419:        to <code class="varname">LOCALBASE</code> if xpkgwedge is
                   6420:        installed.</p></li>
                   6421: <li>
                   6422: <p>If xpkgwedge is installed, it is possible to have some
                   6423:        packages installed in <code class="varname">X11BASE</code> and some in
                   6424:        <code class="varname">LOCALBASE</code>.  To determine the prefix of an
                   6425:        installed package, the <code class="varname">EVAL_PREFIX</code>
                   6426:        definition can be used. It takes pairs in the format
                   6427:        &#8220;<span class="quote">DIRNAME=&lt;package&gt;</span>&#8221;, and the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
                   6428:        variable <code class="varname">DIRNAME</code> will be set to the prefix
                   6429:        of the installed package &lt;package&gt;, or
                   6430:        &#8220;<span class="quote">${X11PREFIX}</span>&#8221; if the package is not
                   6431:        installed.</p>
1.75      rillig   6432: <p>This is best illustrated by example.</p>
                   6433: <p>The following lines are taken from
1.87      wiz      6434:        <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75      rillig   6435: <pre class="programlisting">
1.87      wiz      6436:          EVAL_PREFIX+=           GTKDIR=gtk+
                   6437:          CONFIGURE_ARGS+=        --with-guile-prefix=${LOCALBASE:Q}
                   6438:          CONFIGURE_ARGS+=        --with-gtk-prefix=${GTKDIR:Q}
                   6439:          CONFIGURE_ARGS+=        --enable-multibyte
                   6440:        </pre>
1.88      wiz      6441: <p>Specific defaults can be defined for the packages
                   6442:        evaluated using <code class="varname">EVAL_PREFIX</code>, by using a
                   6443:        definition of the form:</p>
1.75      rillig   6444: <pre class="programlisting">
1.87      wiz      6445:          GTKDIR_DEFAULT= ${LOCALBASE}
                   6446:        </pre>
1.75      rillig   6447: <p>where <code class="varname">GTKDIR</code> corresponds
1.87      wiz      6448:        to the first definition in
                   6449:        the <code class="varname">EVAL_PREFIX</code> pair.</p>
1.75      rillig   6450: </li>
1.76      rillig   6451: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.87      wiz      6452:        install files according to <a href="http://netbsd.gw.com/cgi-bin/man-cgi?hier+7+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">hier</span>(7)</span></a>, with the exception that
                   6453:        manual pages go into <code class="filename">${PREFIX}/man</code>, not
                   6454:        <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75      rillig   6455: </ul></div>
                   6456: </div>
                   6457: <div class="sect1" lang="en">
                   6458: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6459: <a name="build.builddirs"></a>16.3. Directories used during the build process</h2></div></div></div>
1.75      rillig   6460: <p>When building a package, a number of directories is used to store
1.87      wiz      6461:     source files, temporary files, pkgsrc-internal files, and so on. These
                   6462:     directories are explained here.</p>
1.75      rillig   6463: <p>Some of the directory variables contain relative pathnames. There
1.87      wiz      6464:     are two common base directories for these relative directories:
                   6465:     <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
                   6466:     pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
                   6467:     inside the package itself.</p>
1.75      rillig   6468: <div class="variablelist"><dl>
                   6469: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
                   6470: <dd><p>This is an absolute pathname that points to the pkgsrc
1.87      wiz      6471:       root directory. Generally, you don't need
                   6472:       it.</p></dd>
1.75      rillig   6473: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
                   6474: <dd><p>This is a pathname relative to
1.87      wiz      6475:       <code class="varname">PKGSRCDIR</code> that points to the current
                   6476:       package.</p></dd>
1.75      rillig   6477: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
                   6478: <dd><p>This is an absolute pathname pointing to the directory
1.87      wiz      6479:       where all work takes place. The distfiles are extraced to this
                   6480:       directory. It also contains temporary directories and log files used by
                   6481:       the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
                   6482:       the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
1.75      rillig   6483: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
                   6484: <dd><p>This is an absolute pathname pointing to the directory
1.87      wiz      6485:       where the distfiles are extracted. It is usually a direct subdirectory
                   6486:       of <code class="varname">WRKDIR</code>, and often it's the only directory entry
                   6487:       that isn't hidden. This variable may be changed by a package
                   6488:       <code class="filename">Makefile</code>.</p></dd>
1.75      rillig   6489: </dl></div>
                   6490: </div>
                   6491: <div class="sect1" lang="en">
                   6492: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6493: <a name="build.running"></a>16.4. Running a phase</h2></div></div></div>
1.75      rillig   6494: <p>You can run a particular phase by typing <span><strong class="command">make
1.87      wiz      6495:     phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
                   6496:     phase. This will automatically run all phases that are required for this
                   6497:     phase. The default phase is <code class="varname">build</code>, that is, when you
                   6498:     run <span><strong class="command">make</strong></span> without parameters in a package directory,
                   6499:     the package will be built, but not installed.</p>
1.75      rillig   6500: </div>
                   6501: <div class="sect1" lang="en">
                   6502: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6503: <a name="build.fetch"></a>16.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.81      rillig   6504: <p>The first step in building a package is to fetch the
1.88      wiz      6505:     distribution files (distfiles) from the sites that are providing
                   6506:     them. This is the task of the <span class="emphasis"><em>fetch</em></span>
                   6507:     phase.</p>
1.81      rillig   6508: <div class="sect2" lang="en">
                   6509: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   6510: <a name="build.fetch.what"></a>16.5.1. What to fetch and where to get it from</h3></div></div></div>
1.88      wiz      6511: <p>In simple cases, <code class="varname">MASTER_SITES</code>
                   6512:       defines all URLs from where the distfile, whose name is
                   6513:       derived from the <code class="varname">DISTNAME</code> variable, is
                   6514:       fetched. The more complicated cases are described
                   6515:       below.</p>
                   6516: <p>The variable <code class="varname">DISTFILES</code> specifies
                   6517:       the list of distfiles that have to be fetched. Its value
                   6518:       defaults to <code class="literal">${DISTNAME}${EXTRACT_SUFX}</code>,
                   6519:       so that most packages don't need to define it at all.
                   6520:       <code class="varname">EXTRACT_SUFX</code> is
                   6521:       <code class="literal">.tar.gz</code> by default, but can be changed
                   6522:       freely. Note that if your package requires additional
                   6523:       distfiles to the default one, you cannot just append the
                   6524:       additional filenames using the <code class="literal">+=</code>
                   6525:       operator, but you have write for example:</p>
1.81      rillig   6526: <pre class="programlisting">
1.88      wiz      6527:        DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   6528:       </pre>
                   6529: <p>Each distfile is fetched from a list of sites, usually
                   6530:       <code class="varname">MASTER_SITES</code>. If the package has multiple
                   6531:       <code class="varname">DISTFILES</code> or multiple
                   6532:       <code class="varname">PATCHFILES</code> from different sites, you can
                   6533:       set
                   6534:       <code class="varname">SITES.<em class="replaceable"><code>distfile</code></em></code>
                   6535:       to the list of URLs where the file
                   6536:       <code class="filename"><em class="replaceable"><code>distfile</code></em></code>
                   6537:       (including the suffix) can be found.</p>
                   6538: <pre class="programlisting">
                   6539:        DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   6540:        DISTFILES+=     foo-file.tar.gz
                   6541:        SITES.foo-file.tar.gz= \
                   6542:        http://www.somewhere.com/somehow/ \
                   6543:        http://www.somewhereelse.com/mirror/somehow/
                   6544:       </pre>
1.81      rillig   6545: <p>When actually fetching the distfiles, each item from
1.88      wiz      6546:       <code class="varname">MASTER_SITES</code> or
                   6547:       <code class="varname">SITES.*</code> gets the name of each distfile
                   6548:       appended to it, without an intermediate slash. Therefore,
                   6549:       all site values have to end with a slash or other separator
                   6550:       character. This allows for example to set
                   6551:       <code class="varname">MASTER_SITES</code> to a URL of a CGI script
                   6552:       that gets the name of the distfile as a parameter. In this
                   6553:       case, the definition would look like:</p>
1.81      rillig   6554: <pre class="programlisting">
1.88      wiz      6555:        MASTER_SITES=   http://www.example.com/download.cgi?file=
                   6556:       </pre>
1.81      rillig   6557: <p>There are some predefined values for
1.88      wiz      6558:       <code class="varname">MASTER_SITES</code>, which can be used in
                   6559:       packages.  The names of the variables should speak for
                   6560:       themselves.</p>
                   6561: <pre class="programlisting">
                   6562:        ${MASTER_SITE_APACHE}
                   6563:        ${MASTER_SITE_BACKUP}
                   6564:        ${MASTER_SITE_CYGWIN}
                   6565:        ${MASTER_SITE_DEBIAN}
                   6566:        ${MASTER_SITE_FREEBSD}
                   6567:        ${MASTER_SITE_FREEBSD_LOCAL}
                   6568:        ${MASTER_SITE_GNOME}
                   6569:        ${MASTER_SITE_GNU}
                   6570:        ${MASTER_SITE_GNUSTEP}
                   6571:        ${MASTER_SITE_IFARCHIVE}
                   6572:        ${MASTER_SITE_KDE}
                   6573:        ${MASTER_SITE_MOZILLA}
                   6574:        ${MASTER_SITE_MYSQL}
                   6575:        ${MASTER_SITE_OPENOFFICE}
                   6576:        ${MASTER_SITE_PERL_CPAN}
                   6577:        ${MASTER_SITE_PGSQL}
                   6578:        ${MASTER_SITE_R_CRAN}
                   6579:        ${MASTER_SITE_SOURCEFORGE}
                   6580:        ${MASTER_SITE_SOURCEFORGE_JP}
                   6581:        ${MASTER_SITE_SUNSITE}
                   6582:        ${MASTER_SITE_SUSE}
                   6583:        ${MASTER_SITE_TEX_CTAN}
                   6584:        ${MASTER_SITE_XCONTRIB}
                   6585:        ${MASTER_SITE_XEMACS}
                   6586:       </pre>
                   6587: <p>Some explanations for the less self-explaining ones:
                   6588:       <code class="varname">MASTER_SITE_BACKUP</code> contains backup sites
                   6589:       for packages that are maintained in <a href="ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/%24%7BDIST_SUBDIR%7D" target="_top">ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}</a>.  <code class="varname">MASTER_SITE_LOCAL</code> contains local
                   6590:       package source distributions that are maintained in <a href="ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/LOCAL_PORTS/" target="_top">ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/LOCAL_PORTS/</a>.</p>
                   6591: <p>If you choose one of these predefined sites, you may
                   6592:       want to specify a subdirectory of that site. Since these
                   6593:       macros may expand to more than one actual site, you
                   6594:       <span class="emphasis"><em>must</em></span> use the following construct to
                   6595:       specify a subdirectory:</p>
1.81      rillig   6596: <pre class="programlisting">
1.88      wiz      6597:        MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   6598:        MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
                   6599:       </pre>
1.81      rillig   6600: <p>Note the trailing slash after the subdirectory
1.88      wiz      6601:       name.</p>
1.81      rillig   6602: </div>
                   6603: <div class="sect2" lang="en">
                   6604: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   6605: <a name="build.fetch.how"></a>16.5.2. How are the files fetched?</h3></div></div></div>
1.88      wiz      6606: <p>The <span class="emphasis"><em>fetch</em></span> phase makes sure that
                   6607:       all the distfiles exist in a local directory
                   6608:       (<code class="varname">DISTDIR</code>), which can be set by the pkgsrc
                   6609:       user). If the files do not exist, they are fetched using
                   6610:       commands of the form</p>
1.75      rillig   6611: <pre class="programlisting">
1.88      wiz      6612:        ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
                   6613:       </pre>
                   6614: <p>where <code class="literal">${site}</code> varies through
                   6615:       several possibilities in turn: first,
                   6616:       <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the
                   6617:       sites specified in either <code class="varname">SITES.file</code> if
                   6618:       defined, else <code class="varname">MASTER_SITES</code> or
                   6619:       <code class="varname">PATCH_SITES</code>, as applies, then finally the
                   6620:       value of <code class="varname">MASTER_SITE_BACKUP</code>. The order of
1.91      rillig   6621:       all except the first and the last can be optionally sorted
                   6622:       by the user, via setting either
                   6623:       <code class="varname">MASTER_SORT_RANDOM</code>, and
                   6624:       <code class="varname">MASTER_SORT_AWK</code> or
1.88      wiz      6625:       <code class="varname">MASTER_SORT_REGEX</code>.</p>
1.81      rillig   6626: </div>
1.75      rillig   6627: </div>
                   6628: <div class="sect1" lang="en">
                   6629: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6630: <a name="build.checksum"></a>16.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.88      wiz      6631: <p>After the distfile(s) are fetched, their checksum is
                   6632:     generated and compared with the checksums stored in the
                   6633:     distinfo file. If the checksums don't match, the build is
                   6634:     aborted. This is to ensure the same distfile is used for
                   6635:     building, and that the distfile wasn't changed, e.g. by some
                   6636:     malign force, deliberately changed distfiles on the master
                   6637:     distribution site or network lossage.</p>
1.75      rillig   6638: </div>
                   6639: <div class="sect1" lang="en">
                   6640: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6641: <a name="build.extract"></a>16.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75      rillig   6642: <p>When the distfiles are present on the local system, they
1.88      wiz      6643:     need to be extracted, as they usually come in the form of some
                   6644:     compressed archive format.</p>
1.75      rillig   6645: <p>By default, all <code class="varname">DISTFILES</code> are
1.88      wiz      6646:     extracted. If you only need some of them, you can set the
                   6647:     <code class="varname">EXTRACT_ONLY</code> variable to the list of those
                   6648:     files.</p>
                   6649: <p>Extracting the files is usually done by a little
                   6650:     program, <code class="filename">mk/scripts/extract</code>, which
                   6651:     already knows how to extract various archive formats, so most
                   6652:     likely you will not need to change anything here. But if you
                   6653:     need, the following variables may help you:</p>
1.75      rillig   6654: <div class="variablelist"><dl>
                   6655: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
                   6656: <dd><p>Use these variables to override the default
1.88      wiz      6657:       options for an extract command, which are defined in
                   6658:       <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75      rillig   6659: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
                   6660: <dd><p>This variable can be set to
1.88      wiz      6661:       <code class="literal">pax</code>, <code class="literal">tar</code> or an
                   6662:       absolute pathname pointing to the command with which tar
                   6663:       archives should be
                   6664:       extracted.</p></dd>
1.75      rillig   6665: </dl></div>
1.88      wiz      6666: <p>If the <code class="filename">extract</code> program doesn't
                   6667:     serve your needs, you can also override the
                   6668:     <code class="varname">EXTRACT_CMD</code> variable, which holds the
                   6669:     command used for extracting the files. This command is
                   6670:     executed in the <code class="filename">${WRKSRC}</code>
                   6671:     directory. During execution of this command, the shell
                   6672:     variable <code class="varname">extract_file</code> holds the absolute
                   6673:     pathname of the file that is going to be extracted.</p>
1.75      rillig   6674: <p>And if that still does not suffice, you can override the
1.88      wiz      6675:     <code class="varname">do-extract</code> target in the package
                   6676:     Makefile.</p>
1.75      rillig   6677: </div>
                   6678: <div class="sect1" lang="en">
                   6679: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6680: <a name="build.patch"></a>16.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75      rillig   6681: <p>After extraction, all the patches named by the
1.88      wiz      6682:     <code class="varname">PATCHFILES</code>, those present in the patches
                   6683:     subdirectory of the package as well as in
                   6684:     $LOCALPATCHES/$PKGPATH (e.g.
                   6685:     <code class="filename">/usr/local/patches/graphics/png</code>) are
                   6686:     applied.  Patchfiles ending in <code class="filename">.Z</code> or
                   6687:     <code class="filename">.gz</code> are uncompressed before they are
                   6688:     applied, files ending in <code class="filename">.orig</code> or
                   6689:     <code class="filename">.rej</code> are ignored. Any special options to
                   6690:     <a href="http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span></a> can be handed in
1.90      rillig   6691:     <code class="varname">PATCH_DIST_ARGS</code>.  See <a href="#components.patches" title="10.3. patches/*">Section 10.3, &#8220;patches/*&#8221;</a> for more details.</p>
1.88      wiz      6692: <p>By default <a href="http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span></a> is given special args to make
                   6693:     it fail if the patches apply with some lines of fuzz. Please
                   6694:     fix (regen) the patches so that they apply cleanly. The
                   6695:     rationale behind this is that patches that don't apply cleanly
                   6696:     may end up being applied in the wrong place, and cause severe
                   6697:     harm there.</p>
1.75      rillig   6698: </div>
                   6699: <div class="sect1" lang="en">
                   6700: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6701: <a name="build.tools"></a>16.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
                   6702: <p>This is covered in <a href="#tools" title="Chapter 17. Tools needed for building or running">Chapter 17, <i>Tools needed for building or running</i></a>.
1.88      wiz      6703:     </p>
1.75      rillig   6704: </div>
                   6705: <div class="sect1" lang="en">
                   6706: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6707: <a name="build.wrapper"></a>16.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75      rillig   6708: <p>This phase creates wrapper programs for the compilers and
1.88      wiz      6709:     linkers. The following variables can be used to tweak the
                   6710:     wrappers.</p>
1.75      rillig   6711: <div class="variablelist"><dl>
                   6712: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
                   6713: <dd><p>The command used to print progress
1.88      wiz      6714:       messages. Does nothing by default. Set to
                   6715:       <code class="literal">${ECHO}</code> to see the progress
                   6716:       messages.</p></dd>
1.75      rillig   6717: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
                   6718: <dd><p>This variable can be set to
1.88      wiz      6719:       <code class="literal">yes</code> (default) or <code class="literal">no</code>,
                   6720:       depending on whether you want additional information in the
                   6721:       wrapper log file.</p></dd>
1.75      rillig   6722: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
                   6723: <dd><p>This variable can be set to
1.88      wiz      6724:       <code class="literal">yes</code> or <code class="literal">no</code>, depending
                   6725:       on whether the wrapper should use its cache, which will
                   6726:       improve the speed. The default value is
                   6727:       <code class="literal">yes</code>, but is forced to
                   6728:       <code class="literal">no</code> if the platform does not support
                   6729:       it.</p></dd>
1.75      rillig   6730: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
1.88      wiz      6731: <dd><p>A list of reordering commands. A reordering
                   6732:       command has the form
                   6733:       <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
                   6734:       It ensures that that
                   6735:       <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code> occurs
                   6736:       before <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
                   6737:       </p></dd>
1.75      rillig   6738: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
                   6739: <dd><p>A list of transformation commands. [TODO:
1.88      wiz      6740:       investigate further]</p></dd>
1.75      rillig   6741: </dl></div>
                   6742: </div>
                   6743: <div class="sect1" lang="en">
                   6744: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6745: <a name="build.configure"></a>16.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.88      wiz      6746: <p>Most pieces of software need information on the header
                   6747:     files, system calls, and library routines which are available
                   6748:     on the platform they run on. The process of determining this
                   6749:     information is known as configuration, and is usually
                   6750:     automated. In most cases, a script is supplied with the
                   6751:     distfiles, and its invocation results in generation of header
                   6752:     files, Makefiles, etc.</p>
                   6753: <p>If the package contains a configure script, this can be
                   6754:     invoked by setting <code class="varname">HAS_CONFIGURE</code> to
                   6755:     &#8220;<span class="quote">yes</span>&#8221;. If the configure script is a GNU autoconf
                   6756:     script, you should set <code class="varname">GNU_CONFIGURE</code> to
                   6757:     &#8220;<span class="quote">yes</span>&#8221; instead. What happens in the
                   6758:     <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
                   6759: <pre class="programlisting">
                   6760:       .for d in ${CONFIGURE_DIRS}
                   6761:       cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${CONFIGURE_ENV} \
                   6762:       ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
                   6763:       .endfor
                   6764:     </pre>
                   6765: <p><code class="varname">CONFIGURE_DIRS</code> (default:
                   6766:     &#8220;<span class="quote">.</span>&#8221;) is a list of pathnames relative to
                   6767:     <code class="varname">WRKSRC</code>. In each of these directories, the
                   6768:     configure script is run with the environment
                   6769:     <code class="varname">CONFIGURE_ENV</code> and arguments
                   6770:     <code class="varname">CONFIGURE_ARGS</code>. The variables
                   6771:     <code class="varname">CONFIGURE_ENV</code>,
                   6772:     <code class="varname">CONFIGURE_SCRIPT</code> (default:
                   6773:     &#8220;<span class="quote">./configure</span>&#8221;) and
                   6774:     <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
                   6775:     package.</p>
                   6776: <p>If the program uses an <code class="filename">Imakefile</code>
                   6777:     for configuration, the appropriate steps can be invoked by
                   6778:     setting <code class="varname">USE_IMAKE</code> to
                   6779:     &#8220;<span class="quote">yes</span>&#8221;. (If you only want the package installed in
                   6780:     <code class="varname">${X11PREFIX}</code> but xmkmf not being run, set
                   6781:     <code class="varname">USE_X11BASE</code> instead.)</p>
1.75      rillig   6782: </div>
                   6783: <div class="sect1" lang="en">
                   6784: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6785: <a name="build.build"></a>16.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.88      wiz      6786: <p>For building a package, a rough equivalent of the
                   6787:     following code is executed.</p>
1.75      rillig   6788: <pre class="programlisting">
1.88      wiz      6789:       .for d in ${BUILD_DIRS}
                   6790:       cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${MAKE_ENV} \
                   6791:       ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
                   6792:       -f ${MAKE_FILE} ${BUILD_TARGET}
                   6793:       .endfor
                   6794:     </pre>
                   6795: <p><code class="varname">BUILD_DIRS</code> (default:
                   6796:     &#8220;<span class="quote">.</span>&#8221;) is a list of pathnames relative to
                   6797:     <code class="varname">WRKSRC</code>. In each of these directories,
                   6798:     <code class="varname">MAKE_PROGRAM</code> is run with the environment
                   6799:     <code class="varname">MAKE_ENV</code> and arguments
                   6800:     <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
                   6801:     <code class="varname">MAKE_ENV</code>,
                   6802:     <code class="varname">BUILD_MAKE_FLAGS</code>,
                   6803:     <code class="varname">MAKE_FILE</code> and
                   6804:     <code class="varname">BUILD_TARGET</code> may all be changed by the
                   6805:     package.</p>
1.75      rillig   6806: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
1.88      wiz      6807:     &#8220;<span class="quote">gmake</span>&#8221; if <code class="varname">USE_TOOLS</code> contains
                   6808:     &#8220;<span class="quote">gmake</span>&#8221;, &#8220;<span class="quote">make</span>&#8221; otherwise. The
                   6809:     default value of <code class="varname">MAKE_FILE</code> is
                   6810:     &#8220;<span class="quote">Makefile</span>&#8221;, and <code class="varname">BUILD_TARGET</code>
                   6811:     defaults to &#8220;<span class="quote">all</span>&#8221;.</p>
1.75      rillig   6812: </div>
                   6813: <div class="sect1" lang="en">
                   6814: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6815: <a name="build.test"></a>16.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75      rillig   6816: <p>[TODO]</p>
                   6817: </div>
                   6818: <div class="sect1" lang="en">
                   6819: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6820: <a name="build.install"></a>16.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75      rillig   6821: <p>Once the build stage has completed, the final step is to
1.88      wiz      6822:     install the software in public directories, so users can
                   6823:     access the programs and files.</p>
1.75      rillig   6824: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
1.88      wiz      6825:     equivalent of the following code is executed. Additionally,
                   6826:     before and after this code, much magic is performed to do
                   6827:     consistency checks, registering the package, and so on.</p>
                   6828: <pre class="programlisting">
                   6829:       .for d in ${INSTALL_DIRS}
                   6830:       cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${MAKE_ENV} \
                   6831:       ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
                   6832:       -f ${MAKE_FILE} ${BUILD_TARGET}
                   6833:       .endfor
                   6834:     </pre>
1.75      rillig   6835: <p>The variable's meanings are analogous to the ones in the
1.88      wiz      6836:     <span class="emphasis"><em>build</em></span> phase.
                   6837:     <code class="varname">INSTALL_DIRS</code> defaults to
                   6838:     <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
                   6839:     is &#8220;<span class="quote">install</span>&#8221; by default, plus
                   6840:     &#8220;<span class="quote">install.man</span>&#8221; if <code class="varname">USE_IMAKE</code> is
                   6841:     defined and <code class="varname">NO_INSTALL_MANPAGES</code> is not
                   6842:     defined.</p>
1.75      rillig   6843: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
1.88      wiz      6844:     variables are useful. They are all variations of the
                   6845:     <a href="http://netbsd.gw.com/cgi-bin/man-cgi?install+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">install</span>(1)</span></a> command that have the owner, group and
                   6846:     permissions preset. <code class="varname">INSTALL</code> is the plain
                   6847:     install command. The specialized variants, together with their
                   6848:     intended use, are:</p>
1.75      rillig   6849: <div class="variablelist"><dl>
                   6850: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
1.88      wiz      6851: <dd><p>directories that contain
                   6852:       binaries</p></dd>
1.75      rillig   6853: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
1.88      wiz      6854: <dd><p>directories that contain
                   6855:       scripts</p></dd>
1.75      rillig   6856: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
1.88      wiz      6857: <dd><p>directories that contain shared and static
                   6858:       libraries</p></dd>
1.75      rillig   6859: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
1.88      wiz      6860: <dd><p>directories that contain data
                   6861:       files</p></dd>
1.75      rillig   6862: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
1.88      wiz      6863: <dd><p>directories that contain man
                   6864:       pages</p></dd>
1.75      rillig   6865: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
1.88      wiz      6866: <dd><p>binaries that can be stripped from debugging
                   6867:       symbols</p></dd>
1.75      rillig   6868: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
1.88      wiz      6869: <dd><p>binaries that cannot be
                   6870:       stripped</p></dd>
1.75      rillig   6871: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
1.88      wiz      6872: <dd><p>game
                   6873:       binaries</p></dd>
1.75      rillig   6874: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
1.88      wiz      6875: <dd><p>shared and static
                   6876:       libraries</p></dd>
1.75      rillig   6877: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
                   6878: <dd><p>data files</p></dd>
                   6879: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
1.88      wiz      6880: <dd><p>data files for
                   6881:       games</p></dd>
1.75      rillig   6882: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
                   6883: <dd><p>man pages</p></dd>
                   6884: </dl></div>
                   6885: <p>Some other variables are:</p>
                   6886: <div class="variablelist"><dl>
                   6887: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
                   6888: <dd><p>A list of directories relative to
1.88      wiz      6889:       <code class="varname">PREFIX</code> that are created by pkgsrc at the
                   6890:       beginning of the <span class="emphasis"><em>install</em></span> phase.  If
                   6891:       this variable is set,
                   6892:       <code class="varname">NO_MTREE</code>=&#8220;<span class="quote">yes</span>&#8221; is assumed,
                   6893:       which means that the package claims to create all needed
                   6894:       directories itself before installing files to it. Therefore
                   6895:       this variable should only be set in
                   6896:       <code class="filename">Makefile</code>s that are under control of the
                   6897:       package's author. The directories are created with the
                   6898:       correct ownership, depending on their
                   6899:       name.</p></dd>
1.75      rillig   6900: </dl></div>
                   6901: </div>
                   6902: <div class="sect1" lang="en">
                   6903: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6904: <a name="build.package"></a>16.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.88      wiz      6905: <p>Once the install stage has completed, a binary package of
                   6906:     the installed files can be built.  These binary packages can be
                   6907:     used for quick installation without previous compilation, e.g. by
                   6908:     the <span><strong class="command">make bin-install</strong></span> or by using
                   6909:     <span><strong class="command">pkg_add</strong></span>.</p>
                   6910: <p>By default, the binary packages are created in
                   6911:     <code class="filename">${PACKAGES}/All</code> and symlinks are created in
                   6912:     <code class="filename">${PACKAGES}/<em class="replaceable"><code>category</code></em></code>,
                   6913:     one for each category in the <code class="varname">CATEGORIES</code>
                   6914:     variable.  <code class="varname">PACKAGES</code> defaults to
                   6915:     <code class="filename">pkgsrc/packages</code>.</p>
                   6916: </div>
                   6917: <div class="sect1" lang="en">
                   6918: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6919: <a name="build.clean"></a>16.16. Cleaning up</h2></div></div></div>
1.88      wiz      6920: <p>Once you're finished with a package, you can clean the work
                   6921:     directory by running <span><strong class="command">make clean</strong></span>.  If you want
                   6922:     to clean the work directories of all dependencies too, use
                   6923:     <span><strong class="command">make clean-depends</strong></span>.</p>
1.75      rillig   6924: </div>
                   6925: <div class="sect1" lang="en">
                   6926: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   6927: <a name="build.helpful-targets"></a>16.17. Other helpful targets</h2></div></div></div>
1.75      rillig   6928: <div class="variablelist"><dl>
                   6929: <dt><span class="term">pre/post-*</span></dt>
1.88      wiz      6930: <dd><p>For any of the main targets described in the
                   6931:          previous section, two auxiliary targets exist with
1.87      wiz      6932:          &#8220;<span class="quote">pre-</span>&#8221; and &#8220;<span class="quote">post-</span>&#8221; used as a
                   6933:          prefix for the main target's name.  These targets are
1.88      wiz      6934:          invoked before and after the main target is called,
                   6935:          allowing extra configuration or installation steps be
                   6936:          performed from a package's Makefile, for example, which
                   6937:          a program's configure script or install target
                   6938:          omitted.</p></dd>
1.75      rillig   6939: <dt><span class="term">do-*</span></dt>
1.88      wiz      6940: <dd><p>Should one of the main targets do the wrong thing,
                   6941:          and should there be no variable to fix this, you can
                   6942:          redefine it with the do-* target.  (Note that redefining
                   6943:          the target itself instead of the do-* target is a bad
                   6944:          idea, as the pre-* and post-* targets won't be called
                   6945:          anymore, etc.) You will not usually need to do
                   6946:          this.</p></dd>
1.75      rillig   6947: <dt><span class="term">reinstall</span></dt>
1.88      wiz      6948: <dd>
                   6949: <p>If you did a <span><strong class="command">make install</strong></span> and
                   6950:          you noticed some file was not installed properly, you
                   6951:          can repeat the installation with this target, which will
                   6952:          ignore the &#8220;<span class="quote">already installed</span>&#8221; flag.</p>
                   6953: <p>This is the default value of
                   6954:          <code class="varname">DEPENDS_TARGET</code> except in the case of
                   6955:          <span><strong class="command">make update</strong></span> and <span><strong class="command">make
                   6956:          package</strong></span>, where the defaults are
                   6957:          &#8220;<span class="quote">package</span>&#8221; and &#8220;<span class="quote">update</span>&#8221;,
                   6958:          respectively.</p>
                   6959: </dd>
1.75      rillig   6960: <dt><span class="term">deinstall</span></dt>
                   6961: <dd>
1.88      wiz      6962: <p>This target does a <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> in the
                   6963:          current directory, effectively de-installing the
                   6964:          package. The following variables can be used to tune the
                   6965:          behaviour:</p>
1.75      rillig   6966: <div class="variablelist"><dl>
                   6967: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
                   6968: <dd><p>Add a "-v" to the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> command.</p></dd>
                   6969: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
1.88      wiz      6970: <dd><p>Remove all packages that require (depend on)
                   6971:                the given package.  This can be used to remove any
                   6972:                packages that may have been pulled in by a given
                   6973:                package, e.g. if <span><strong class="command">make deinstall
1.87      wiz      6974:                DEINSTALLDEPENDS=1</strong></span> is done in
1.88      wiz      6975:                <code class="filename">pkgsrc/x11/kde</code>, this is
                   6976:                likely to remove whole KDE. Works by adding
                   6977:                &#8220;<span class="quote">-R</span>&#8221; to the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a>
                   6978:                command line.</p></dd>
1.75      rillig   6979: </dl></div>
                   6980: </dd>
1.88      wiz      6981: <dt><span class="term">bin-install</span></dt>
                   6982: <dd><p>Install a binary package from local disk and via FTP
                   6983:          from a list of sites (see the
                   6984:          <code class="varname">BINPKG_SITES</code> variable), and do a
                   6985:          <span><strong class="command">make package</strong></span> if no binary package is
                   6986:          available anywhere.  The arguments given to
                   6987:          <span><strong class="command">pkg_add</strong></span> can be set via
                   6988:          <code class="varname">BIN_INSTALL_FLAGS</code> e.g., to do verbose
                   6989:          operation, etc.</p></dd>
1.75      rillig   6990: <dt><span class="term">update</span></dt>
                   6991: <dd>
1.88      wiz      6992: <p>This target causes the current package to be
                   6993:          updated to the latest version.  The package and all
                   6994:          depending packages first get de-installed, then current
                   6995:          versions of the corresponding packages get compiled and
                   6996:          installed.  This is similar to manually noting which
                   6997:          packages are currently installed, then performing a
                   6998:          series of <span><strong class="command">make deinstall</strong></span> and
                   6999:          <span><strong class="command">make install</strong></span> (or whatever
                   7000:          <code class="varname">UPDATE_TARGET</code> is set to) for these
                   7001:          packages.</p>
                   7002: <p>You can use the &#8220;<span class="quote">update</span>&#8221; target to
                   7003:          resume package updating in case a previous <span><strong class="command">make
                   7004:          update</strong></span> was interrupted for some reason.
                   7005:          However, in this case, make sure you don't call
                   7006:          <span><strong class="command">make clean</strong></span> or otherwise remove the
                   7007:          list of dependent packages in <code class="varname">WRKDIR</code>.
                   7008:          Otherwise, you lose the ability to automatically update
                   7009:          the current package along with the dependent packages
                   7010:          you have installed.</p>
                   7011: <p>Resuming an interrupted <span><strong class="command">make
                   7012:          update</strong></span> will only work as long as the package
                   7013:          tree remains unchanged.  If the source code for one of
                   7014:          the packages to be updated has been changed, resuming
                   7015:          <span><strong class="command">make update</strong></span> will most certainly
                   7016:          fail!</p>
                   7017: <p>The following variables can be used either on the
                   7018:          command line or in <code class="filename">/etc/mk.conf</code> to
                   7019:          alter the behaviour of <span><strong class="command">make
                   7020:          update</strong></span>:</p>
1.75      rillig   7021: <div class="variablelist"><dl>
                   7022: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
1.88      wiz      7023: <dd><p>Install target to recursively use for the
                   7024:                updated package and the dependent packages.
                   7025:                Defaults to <code class="varname">DEPENDS_TARGET</code> if
                   7026:                set, &#8220;<span class="quote">install</span>&#8221; otherwise for
                   7027:                <span><strong class="command">make update</strong></span>.  Other good
                   7028:                targets are &#8220;<span class="quote">package</span>&#8221; or
                   7029:                &#8220;<span class="quote">bin-install</span>&#8221;.  Do not set this to
                   7030:                &#8220;<span class="quote">update</span>&#8221; or you will get stuck in an
                   7031:                endless loop!</p></dd>
1.75      rillig   7032: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
1.88      wiz      7033: <dd><p>Don't clean up after updating.  Useful if
                   7034:                you want to leave the work sources of the updated
                   7035:                packages around for inspection or other purposes.
                   7036:                Be sure you eventually clean up the source tree
                   7037:                (see the &#8220;<span class="quote">clean-update</span>&#8221; target below)
                   7038:                or you may run into troubles with old source code
                   7039:                still lying around on your next
                   7040:                <span><strong class="command">make</strong></span> or <span><strong class="command">make
                   7041:                update</strong></span>.</p></dd>
1.75      rillig   7042: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
1.88      wiz      7043: <dd><p>Deinstall each package before installing
                   7044:                (making <code class="varname">DEPENDS_TARGET</code>). This
                   7045:                may be necessary if the
                   7046:                &#8220;<span class="quote">clean-update</span>&#8221; target (see below) was
                   7047:                called after interrupting a running <span><strong class="command">make
                   7048:                update</strong></span>.</p></dd>
1.75      rillig   7049: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
1.88      wiz      7050: <dd><p>Allows you to disable recursion and hardcode
                   7051:                the target for packages.  The default is
                   7052:                &#8220;<span class="quote">update</span>&#8221; for the update target,
                   7053:                facilitating a recursive update of prerequisite
                   7054:                packages.  Only set
                   7055:                <code class="varname">DEPENDS_TARGET</code> if you want to
                   7056:                disable recursive updates. Use
                   7057:                <code class="varname">UPDATE_TARGET</code> instead to just
                   7058:                set a specific target for each package to be
                   7059:                installed during <span><strong class="command">make update</strong></span>
                   7060:                (see above).</p></dd>
1.75      rillig   7061: </dl></div>
                   7062: </dd>
                   7063: <dt><span class="term">clean-update</span></dt>
                   7064: <dd>
1.88      wiz      7065: <p>Clean the source tree for all packages that would
                   7066:          get updated if <span><strong class="command">make update</strong></span> was called
                   7067:          from the current directory.  This target should not be
                   7068:          used if the current package (or any of its depending
                   7069:          packages) have already been de-installed (e.g., after
                   7070:          calling <span><strong class="command">make update</strong></span>) or you may lose
                   7071:          some packages you intended to update. As a rule of
                   7072:          thumb: only use this target <span class="emphasis"><em>before</em></span>
                   7073:          the first time you run <span><strong class="command">make update</strong></span>
                   7074:          and only if you have a dirty package tree (e.g., if you
                   7075:          used <code class="varname">NOCLEAN</code>).</p>
                   7076: <p>If you are unsure about whether your tree is
                   7077:          clean, you can either perform a <span><strong class="command">make
                   7078:          clean</strong></span> at the top of the tree, or use the
                   7079:          following sequence of commands from the directory of the
                   7080:          package you want to update (<span class="emphasis"><em>before</em></span>
                   7081:          running <span><strong class="command">make update</strong></span> for the first
                   7082:          time, otherwise you lose all the packages you wanted to
                   7083:          update!):</p>
1.87      wiz      7084: <pre class="screen">
                   7085: <code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
1.75      rillig   7086: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
1.87      wiz      7087: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong>
                   7088:          </pre>
1.88      wiz      7089: <p>The following variables can be used either on the
                   7090:          command line or in <code class="filename">/etc/mk.conf</code> to
                   7091:          alter the behaviour of <span><strong class="command">make
                   7092:          clean-update</strong></span>:</p>
1.75      rillig   7093: <div class="variablelist"><dl>
                   7094: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
1.88      wiz      7095: <dd><p>After <span><strong class="command">make clean</strong></span>, do not
                   7096:                reconstruct the list of directories to update for
                   7097:                this package.  Only use this if <span><strong class="command">make
                   7098:                update</strong></span> successfully installed all
                   7099:                packages you wanted to update.  Normally, this is
                   7100:                done automatically on <span><strong class="command">make
                   7101:                update</strong></span>, but may have been suppressed by
                   7102:                the <code class="varname">NOCLEAN</code> variable (see
                   7103:                above).</p></dd>
1.75      rillig   7104: </dl></div>
                   7105: </dd>
1.88      wiz      7106: <dt><span class="term">replace</span></dt>
                   7107: <dd>
                   7108: <p>Update the installation of the current package.  This
                   7109:          differs from update in that it does not replace dependent
1.91      rillig   7110:          packages.  You will need to install <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgsrc/pkgtools/pkg_tarup</code></a> for this
1.88      wiz      7111:          target to work.</p>
                   7112: <p><span class="emphasis"><em>Be careful when using this
                   7113:          target!</em></span> There are no guarantees that dependent
                   7114:          packages will still work, in particular they will most
                   7115:          certainly break if you <span><strong class="command">make replace</strong></span> a
                   7116:          library package whose shared library major version changed
                   7117:          between your installed version and the new one.  For this
                   7118:          reason, this target is not officially supported and only
                   7119:          recommended for advanced users.</p>
                   7120: </dd>
1.75      rillig   7121: <dt><span class="term">info</span></dt>
                   7122: <dd><p>This target invokes <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_info+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_info</span>(1)</span></a> for the current
1.88      wiz      7123:          package. You can use this to check which version of a
                   7124:          package is installed.</p></dd>
                   7125: <dt><span class="term">index</span></dt>
                   7126: <dd>
                   7127: <p>This is a top-level command, i.e. it should be used in
                   7128:          the <code class="filename">pkgsrc</code> directory.  It creates a
                   7129:          database of all packages in the local pkgsrc tree, including
                   7130:          dependencies, comment, maintainer, and some other useful
                   7131:          information.  Individual entries are created by running
                   7132:          <span><strong class="command">make describe</strong></span> in the packages'
                   7133:          directories.  This index file is saved as
                   7134:          <code class="filename">pkgsrc/INDEX</code>.  It can be displayed in
                   7135:          verbose format by running <span><strong class="command">make
                   7136:          print-index</strong></span>.  You can search in it with
                   7137:          <span><strong class="command">make search
                   7138:          key=<em class="replaceable"><code>something</code></em></strong></span>.  You can
                   7139:          extract a list of all packages that depend on a particular
                   7140:          one by running <span><strong class="command">make show-deps
                   7141:          PKG=<em class="replaceable"><code>somepackage</code></em></strong></span>.</p>
                   7142: <p>Running this command takes a very long time, some
                   7143:          hours even on fast machines!</p>
                   7144: </dd>
1.75      rillig   7145: <dt><span class="term">readme</span></dt>
1.88      wiz      7146: <dd>
                   7147: <p>This target generates a
                   7148:          <code class="filename">README.html</code> file, which can be
1.91      rillig   7149:          viewed using a browser such as <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/links/README.html" target="_top"><code class="filename">www/links</code></a>.  The generated files
1.88      wiz      7150:          contain references to any packages which are in the
                   7151:          <code class="varname">PACKAGES</code> directory on the local
                   7152:          host. The generated files can be made to refer to URLs
                   7153:          based on <code class="varname">FTP_PKG_URL_HOST</code> and
                   7154:          <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I
                   7155:          wanted to generate <code class="filename">README.html</code>
                   7156:          files which pointed to binary packages on the local
                   7157:          machine, in the directory
                   7158:          <code class="filename">/usr/packages</code>, set
                   7159:          <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
                   7160:          <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
                   7161:          <code class="varname">${PACKAGES}</code> directory and its
                   7162:          subdirectories will be searched for all the binary
                   7163:          packages.</p>
                   7164: <p>The target can be run at the toplevel or in category
                   7165:          directories, in which case it descends recursively.</p>
                   7166: </dd>
1.75      rillig   7167: <dt><span class="term">readme-all</span></dt>
1.88      wiz      7168: <dd><p>This is a top-level command, run it in
                   7169:          <code class="filename">pkgsrc</code>.  Use this target to create a
                   7170:          file <code class="filename">README-all.html</code> which contains a
                   7171:          list of all packages currently available in the NetBSD
                   7172:          Packages Collection, together with the category they belong
                   7173:          to and a short description. This file is compiled from the
                   7174:          <code class="filename">pkgsrc/*/README.html</code> files, so be sure
                   7175:          to run this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make
                   7176:          readme</strong></span>.</p></dd>
1.75      rillig   7177: <dt><span class="term">cdrom-readme</span></dt>
1.88      wiz      7178: <dd><p>This is very much the same as the
                   7179:          &#8220;<span class="quote">readme</span>&#8221; target (see above), but is to be
                   7180:          used when generating a pkgsrc tree to be written to a
                   7181:          CD-ROM.  This target also produces
                   7182:          <code class="filename">README.html</code> files, and can be made
                   7183:          to refer to URLs based on
                   7184:          <code class="varname">CDROM_PKG_URL_HOST</code> and
1.87      wiz      7185:          <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
1.75      rillig   7186: <dt><span class="term">show-distfiles</span></dt>
1.88      wiz      7187: <dd><p>This target shows which distfiles and patchfiles
                   7188:          are needed to build the package
                   7189:          (<code class="varname">ALLFILES</code>, which contains all
                   7190:          <code class="varname">DISTFILES</code> and
1.87      wiz      7191:          <code class="varname">PATCHFILES</code>, but not
                   7192:          <code class="filename">patches/*</code>).</p></dd>
1.75      rillig   7193: <dt><span class="term">show-downlevel</span></dt>
1.88      wiz      7194: <dd><p>This target shows nothing if the package is not
                   7195:          installed. If a version of this package is installed,
                   7196:          but is not the version provided in this version of
                   7197:          pkgsrc, then a warning message is displayed. This target
                   7198:          can be used to show which of your installed packages are
                   7199:          downlevel, and so the old versions can be deleted, and
                   7200:          the current ones added.</p></dd>
1.75      rillig   7201: <dt><span class="term">show-pkgsrc-dir</span></dt>
1.88      wiz      7202: <dd><p>This target shows the directory in the pkgsrc
                   7203:          hierarchy from which the package can be built and
                   7204:          installed. This may not be the same directory as the one
                   7205:          from which the package was installed. This target is
                   7206:          intended to be used by people who may wish to upgrade
                   7207:          many packages on a single host, and can be invoked from
                   7208:          the top-level pkgsrc Makefile by using the
1.87      wiz      7209:          &#8220;<span class="quote">show-host-specific-pkgs</span>&#8221; target.</p></dd>
1.75      rillig   7210: <dt><span class="term">show-installed-depends</span></dt>
1.88      wiz      7211: <dd><p>This target shows which installed packages match
                   7212:          the current package's <code class="varname">DEPENDS</code>. Useful
                   7213:          if out of date dependencies are causing build
                   7214:          problems.</p></dd>
1.75      rillig   7215: <dt><span class="term">check-shlibs</span></dt>
1.88      wiz      7216: <dd><p>After a package is installed, check all its
                   7217:          binaries and (on ELF platforms) shared libraries to see
                   7218:          if they find the shared libs they need.  Run by default
                   7219:          if <code class="varname">PKG_DEVELOPER</code> is set in
1.87      wiz      7220:          <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75      rillig   7221: <dt><span class="term">print-PLIST</span></dt>
                   7222: <dd>
                   7223: <p>After a &#8220;<span class="quote">make install</span>&#8221; from a new or
1.88      wiz      7224:          upgraded pkg, this prints out an attempt to generate a
                   7225:          new <code class="filename">PLIST</code> from a <span><strong class="command">find
                   7226:          -newer work/.extract_done</strong></span>.  An attempt is made
                   7227:          to care for shared libs etc., but it is
1.87      wiz      7228:          <span class="emphasis"><em>strongly</em></span> recommended to review the
                   7229:          result before putting it into
                   7230:          <code class="filename">PLIST</code>. On upgrades, it's useful to
                   7231:          diff the output of this command against an already
                   7232:          existing <code class="filename">PLIST</code> file.</p>
1.88      wiz      7233: <p>If the package installs files via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?tar+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span></a> or
                   7234:          other methods that don't update file access times, be
                   7235:          sure to add these files manually to your
1.87      wiz      7236:          <code class="filename">PLIST</code>, as the &#8220;<span class="quote">find
                   7237:          -newer</span>&#8221; command used by this target won't catch
                   7238:          them!</p>
1.90      rillig   7239: <p>See <a href="#print-PLIST" title="12.3. Tweaking output of make print-PLIST">Section 12.3, &#8220;Tweaking output of <span><strong class="command">make print-PLIST</strong></span>&#8221;</a> for more
1.87      wiz      7240:          information on this target.</p>
1.75      rillig   7241: </dd>
                   7242: <dt><span class="term">bulk-package</span></dt>
                   7243: <dd>
1.88      wiz      7244: <p>Used to do bulk builds. If an appropriate binary
                   7245:          package already exists, no action is taken. If not, this
                   7246:          target will compile, install and package it (and its
                   7247:          depends, if <code class="varname">PKG_DEPENDS</code> is set
                   7248:          properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, &#8220;Configuration&#8221;</a>).
                   7249:          After creating the binary package, the sources, the
                   7250:          just-installed package and its required packages are
                   7251:          removed, preserving free disk space.</p>
                   7252: <p><span class="emphasis"><em>Beware that this target may deinstall
                   7253:          all packages installed on a system!</em></span></p>
1.75      rillig   7254: </dd>
                   7255: <dt><span class="term">bulk-install</span></dt>
                   7256: <dd>
1.88      wiz      7257: <p>Used during bulk-installs to install required
                   7258:          packages. If an up-to-date binary package is available,
                   7259:          it will be installed via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>. If not,
                   7260:          <span><strong class="command">make bulk-package</strong></span> will be executed,
1.87      wiz      7261:          but the installed binary won't be removed.</p>
1.88      wiz      7262: <p>A binary package is considered
                   7263:          &#8220;<span class="quote">up-to-date</span>&#8221; to be installed via
                   7264:          <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> if:</p>
                   7265: <div class="itemizedlist"><ul type="disc">
                   7266: <li><p>None of the package's files
                   7267:              (<code class="filename">Makefile</code>, ...) were modified
                   7268:              since it was built.</p></li>
                   7269: <li><p>None of the package's required (binary)
                   7270:              packages were modified since it was built.</p></li>
1.75      rillig   7271: </ul></div>
1.88      wiz      7272: <p><span class="emphasis"><em>Beware that this target may deinstall
                   7273:          all packages installed on a system!</em></span></p>
1.75      rillig   7274: </dd>
                   7275: </dl></div>
                   7276: </div>
                   7277: </div>
                   7278: <div class="chapter" lang="en">
                   7279: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   7280: <a name="tools"></a>Chapter 17. Tools needed for building or running</h2></div></div></div>
1.75      rillig   7281: <div class="toc">
                   7282: <p><b>Table of Contents</b></p>
                   7283: <dl>
1.90      rillig   7284: <dt><span class="sect1"><a href="#pkgsrc-tools">17.1. Tools for pkgsrc builds</a></span></dt>
                   7285: <dt><span class="sect1"><a href="#package-tools">17.2. Tools needed by packages</a></span></dt>
                   7286: <dt><span class="sect1"><a href="#platform-tools">17.3. Tools provided by platforms</a></span></dt>
1.75      rillig   7287: </dl>
                   7288: </div>
1.87      wiz      7289: <p>The <code class="varname">USE_TOOLS</code> definition is used both internally
1.75      rillig   7290: by pkgsrc and also for individual packages to define what commands
                   7291: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
                   7292: or for later run-time of an installed packaged (such as
                   7293: <code class="varname">DEPENDS</code>).
                   7294: If the native system provides an adequate tool, then in many cases, a pkgsrc
1.87      wiz      7295: package will not be used.</p>
                   7296: <p>When building a package, the replacement tools are
1.75      rillig   7297: made available in a directory (as symlinks or wrapper scripts)
                   7298: that is early in the executable search path. Just like the buildlink
1.87      wiz      7299: system, this helps with consistent builds.</p>
                   7300: <p>A tool may be needed to help build a specific package. For example,
                   7301: perl, GNU make (gmake) or yacc may be needed.</p>
                   7302: <p>Also a tool may be needed, for example, because the native system's supplied
1.75      rillig   7303: tool may be inefficient for building a package with pkgsrc.
                   7304: For example, a package may need GNU awk, bison (instead of
1.87      wiz      7305: yacc) or a better sed.</p>
                   7306: <p>The tools used by a package can be listed by running
                   7307: <span><strong class="command">make show-tools</strong></span>.</p>
1.75      rillig   7308: <div class="sect1" lang="en">
                   7309: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   7310: <a name="pkgsrc-tools"></a>17.1. Tools for pkgsrc builds</h2></div></div></div>
1.87      wiz      7311: <p>The default set of tools used by pkgsrc is defined in
1.76      rillig   7312: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75      rillig   7313: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
                   7314: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
                   7315: These can be seen by running:
1.87      wiz      7316: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.</p>
                   7317: <p>If a package needs a specific program to build
1.75      rillig   7318: then the <code class="varname">USE_TOOLS</code> variable can be used
1.87      wiz      7319: to define the tools needed.</p>
1.75      rillig   7320: </div>
                   7321: <div class="sect1" lang="en">
                   7322: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   7323: <a name="package-tools"></a>17.2. Tools needed by packages</h2></div></div></div>
1.87      wiz      7324: <p>In the following examples, the :pkgsrc means to use the pkgsrc version
1.75      rillig   7325: and not the native version for a build dependency.
                   7326: And the :run means that it is used for a
                   7327: run-time dependencies also (and becomes a DEPENDS).
                   7328: The default is a build dependency which can be set with
                   7329: :build. (So in this example, it is the same as gmake:build
1.87      wiz      7330: and pkg-config:build.)</p>
1.75      rillig   7331: <pre class="programlisting">
                   7332: USE_TOOLS+=     mktemp:pkgsrc
                   7333: USE_TOOLS+=     gmake perl:run pkg-config
                   7334: </pre>
1.87      wiz      7335: <p>When using the tools framework, a
1.75      rillig   7336: <code class="varname">TOOLS_PATH.foo</code> variable is defined
                   7337: which contains the full path to the appropriate tool. For example,
                   7338: <code class="varname">TOOLS_PATH.bash</code> could be &#8220;<span class="quote">/bin/bash</span>&#8221;
1.87      wiz      7339: on Linux systems.</p>
                   7340: <p>If you always need a pkgsrc version of the
1.75      rillig   7341: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
                   7342: </p>
                   7343: </div>
                   7344: <div class="sect1" lang="en">
                   7345: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   7346: <a name="platform-tools"></a>17.3. Tools provided by platforms</h2></div></div></div>
1.87      wiz      7347: <p>When improving or porting pkgsrc to a new platform, have a look
1.75      rillig   7348: at (or create) the corresponding platform specific make file fragment under
1.76      rillig   7349: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75      rillig   7350: the name of the common tools. For example:</p>
                   7351: <pre class="programlisting">
                   7352: .if exists(/usr/bin/bzcat)
                   7353: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   7354: .elif exists(/usr/bin/bzip2)
                   7355: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   7356: .endif
1.69      rillig   7357: 
1.75      rillig   7358: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   7359: </pre>
                   7360: </div>
                   7361: </div>
                   7362: <div class="chapter" lang="en">
                   7363: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   7364: <a name="fixes"></a>Chapter 18. Making your package work</h2></div></div></div>
1.75      rillig   7365: <div class="toc">
                   7366: <p><b>Table of Contents</b></p>
                   7367: <dl>
1.90      rillig   7368: <dt><span class="sect1"><a href="#general-operation">18.1. General operation</a></span></dt>
1.75      rillig   7369: <dd><dl>
1.90      rillig   7370: <dt><span class="sect2"><a href="#portability-of-packages">18.1.1. Portability of packages</a></span></dt>
                   7371: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">18.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
                   7372: <dt><span class="sect2"><a href="#user-interaction">18.1.3. User interaction</a></span></dt>
                   7373: <dt><span class="sect2"><a href="#handling-licenses">18.1.4. Handling licenses</a></span></dt>
                   7374: <dt><span class="sect2"><a href="#restricted-packages">18.1.5. Restricted packages</a></span></dt>
                   7375: <dt><span class="sect2"><a href="#dependencies">18.1.6. Handling dependencies</a></span></dt>
                   7376: <dt><span class="sect2"><a href="#conflicts">18.1.7. Handling conflicts with other packages</a></span></dt>
                   7377: <dt><span class="sect2"><a href="#not-building-packages">18.1.8. Packages that cannot or should not be built</a></span></dt>
                   7378: <dt><span class="sect2"><a href="#undeletable-packages">18.1.9. Packages which should not be deleted, once installed</a></span></dt>
                   7379: <dt><span class="sect2"><a href="#security-handling">18.1.10. Handling packages with security problems</a></span></dt>
                   7380: <dt><span class="sect2"><a href="#bumping-pkgrevision">18.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
                   7381: <dt><span class="sect2"><a href="#fixes.subst">18.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
                   7382: </dl></dd>
                   7383: <dt><span class="sect1"><a href="#fixes.fetch">18.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
                   7384: <dd><dl>
                   7385: <dt><span class="sect2"><a href="#no-plain-download">18.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
                   7386: <dt><span class="sect2"><a href="#modified-distfiles-same-name">18.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
                   7387: </dl></dd>
                   7388: <dt><span class="sect1"><a href="#fixes.configure">18.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   7389: <dd><dl>
                   7390: <dt><span class="sect2"><a href="#fixes.libtool">18.3.1. Shared libraries - libtool</a></span></dt>
                   7391: <dt><span class="sect2"><a href="#using-libtool">18.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
                   7392: <dt><span class="sect2"><a href="#autoconf-automake">18.3.3. GNU Autoconf/Automake</a></span></dt>
                   7393: </dl></dd>
                   7394: <dt><span class="sect1"><a href="#programming-languages">18.4. Programming languages</a></span></dt>
                   7395: <dd><dl>
                   7396: <dt><span class="sect2"><a href="#basic-programming-languages">18.4.1. C, C++, and Fortran</a></span></dt>
                   7397: <dt><span class="sect2"><a href="#java-programming-language">18.4.2. Java</a></span></dt>
                   7398: <dt><span class="sect2"><a href="#perl-scripts">18.4.3. Packages containing perl scripts</a></span></dt>
                   7399: <dt><span class="sect2"><a href="#other-programming-languages">18.4.4. Other programming languages</a></span></dt>
                   7400: </dl></dd>
                   7401: <dt><span class="sect1"><a href="#fixes.build">18.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   7402: <dd><dl>
                   7403: <dt><span class="sect2"><a href="#fixes.build.cpp">18.5.1. Compiling C and C++ code conditionally</a></span></dt>
                   7404: <dt><span class="sect2"><a href="#compiler-bugs">18.5.2. How to handle compiler bugs</a></span></dt>
                   7405: <dt><span class="sect2"><a href="#undefined-reference">18.5.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
                   7406: <dt><span class="sect2"><a href="#out-of-memory">18.5.4. Running out of memory</a></span></dt>
                   7407: </dl></dd>
                   7408: <dt><span class="sect1"><a href="#fixes.install">18.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   7409: <dd><dl>
                   7410: <dt><span class="sect2"><a href="#install-scripts">18.6.1. Creating needed directories</a></span></dt>
                   7411: <dt><span class="sect2"><a href="#where-to-install-documentation">18.6.2. Where to install documentation</a></span></dt>
                   7412: <dt><span class="sect2"><a href="#installing-score-files">18.6.3. Installing score files</a></span></dt>
                   7413: <dt><span class="sect2"><a href="#hardcoded-paths">18.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
                   7414: <dt><span class="sect2"><a href="#perl-modules">18.6.5. Packages installing perl modules</a></span></dt>
                   7415: <dt><span class="sect2"><a href="#faq.info-files">18.6.6. Packages installing info files</a></span></dt>
                   7416: <dt><span class="sect2"><a href="#manpages">18.6.7. Packages installing man pages</a></span></dt>
                   7417: <dt><span class="sect2"><a href="#gconf2-data-files">18.6.8. Packages installing GConf2 data files</a></span></dt>
                   7418: <dt><span class="sect2"><a href="#scrollkeeper-data-files">18.6.9. Packages installing scrollkeeper data files</a></span></dt>
                   7419: <dt><span class="sect2"><a href="#x11-fonts">18.6.10. Packages installing X11 fonts</a></span></dt>
                   7420: <dt><span class="sect2"><a href="#gtk2-modules">18.6.11. Packages installing GTK2 modules</a></span></dt>
                   7421: <dt><span class="sect2"><a href="#sgml-xml-data">18.6.12. Packages installing SGML or XML data</a></span></dt>
                   7422: <dt><span class="sect2"><a href="#mime-database">18.6.13. Packages installing extensions to the MIME database</a></span></dt>
                   7423: <dt><span class="sect2"><a href="#intltool">18.6.14. Packages using intltool</a></span></dt>
                   7424: <dt><span class="sect2"><a href="#startup-scripts">18.6.15. Packages installing startup scripts</a></span></dt>
                   7425: <dt><span class="sect2"><a href="#tex-packages">18.6.16. Packages installing TeX modules</a></span></dt>
                   7426: <dt><span class="sect2"><a href="#emulation-packages">18.6.17. Packages supporting running binaries in
1.87      wiz      7427:     emulation</a></span></dt>
1.90      rillig   7428: <dt><span class="sect2"><a href="#hicolor-theme">18.6.18. Packages installing hicolor theme icons</a></span></dt>
                   7429: <dt><span class="sect2"><a href="#desktop-files">18.6.19. Packages installing desktop files</a></span></dt>
1.75      rillig   7430: </dl></dd>
1.90      rillig   7431: <dt><span class="sect1"><a href="#punting">18.7. Marking packages as having problems</a></span></dt>
1.75      rillig   7432: </dl>
                   7433: </div>
                   7434: <div class="sect1" lang="en">
                   7435: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   7436: <a name="general-operation"></a>18.1. General operation</h2></div></div></div>
1.75      rillig   7437: <div class="sect2" lang="en">
                   7438: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7439: <a name="portability-of-packages"></a>18.1.1. Portability of packages</h3></div></div></div>
1.78      rillig   7440: <p>One appealing feature of pkgsrc is that it runs on many
1.87      wiz      7441:     different platforms. As a result, it is important to ensure,
                   7442:     where possible, that packages in pkgsrc are portable. This
                   7443:     chapter mentions some particular details you should pay
                   7444:     attention to while working on pkgsrc.</p>
1.78      rillig   7445: </div>
                   7446: <div class="sect2" lang="en">
                   7447: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7448: <a name="pulling-vars-from-etc-mk.conf"></a>18.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></h3></div></div></div>
1.78      rillig   7449: <p>The pkgsrc user can configure pkgsrc by overriding several
1.87      wiz      7450:     variables in the file pointed to by <code class="varname">MAKECONF</code>,
                   7451:     which is <code class="filename">/etc/mk.conf</code> by default. When you
                   7452:     want to use those variables in the preprocessor directives of
                   7453:     <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> (for example <code class="literal">.if</code> or
                   7454:     <code class="literal">.for</code>), you need to include the file
                   7455:     <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
                   7456:     loads the user preferences.</p>
1.78      rillig   7457: <p>But note that some variables may not be completely defined
1.87      wiz      7458:     after <code class="filename">../../mk/bsd.prefs.mk</code> has been
                   7459:     included, as they may contain references to variables that are
                   7460:     not yet defined. In shell commands this is no problem, since
                   7461:     variables are actually macros, which are only expanded when they
                   7462:     are used. But in the preprocessor directives mentioned above and
                   7463:     in dependency lines (of the form <code class="literal">target:
                   7464:     dependencies</code>) the variables are expanded at load
                   7465:     time.</p>
1.78      rillig   7466: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   7467: <h3 class="title">Note</h3>
                   7468: <p>Currently there is no exhaustive list of all
1.87      wiz      7469:     variables that tells you whether they can be used at load time
                   7470:     or only at run time, but it is in preparation.</p>
1.78      rillig   7471: </div>
                   7472: </div>
                   7473: <div class="sect2" lang="en">
                   7474: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7475: <a name="user-interaction"></a>18.1.3. User interaction</h3></div></div></div>
1.88      wiz      7476: <p>Occasionally, packages require interaction from the user,
                   7477:     and this can be in a number of ways:</p>
1.78      rillig   7478: <div class="itemizedlist"><ul type="disc">
1.79      rillig   7479: <li><p>When fetching the distfiles, some packages require user
1.87      wiz      7480:        interaction such as entering username/password or accepting a
                   7481:        license on a web page.</p></li>
1.88      wiz      7482: <li><p>When extracting the distfiles, some packages may ask for
                   7483:        passwords.</p></li>
1.78      rillig   7484: <li><p>help to configure the package before it is built</p></li>
                   7485: <li><p>help during the build process</p></li>
                   7486: <li><p>help during the installation of a package</p></li>
                   7487: </ul></div>
1.88      wiz      7488: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is
                   7489:     provided to notify the pkgsrc mechanism of an interactive stage
                   7490:     which will be needed, and this should be set in the package's
                   7491:     <code class="filename">Makefile</code>, e.g.:</p>
1.75      rillig   7492: <pre class="programlisting">
1.87      wiz      7493:       INTERACTIVE_STAGE=      build
                   7494:     </pre>
1.78      rillig   7495: <p>Multiple interactive stages can be specified:</p>
1.75      rillig   7496: <pre class="programlisting">
1.87      wiz      7497:       INTERACTIVE_STAGE=      configure install
                   7498:     </pre>
1.88      wiz      7499: <p>The user can then decide to skip this package by setting the
                   7500:     <code class="varname">BATCH</code> variable.</p>
1.75      rillig   7501: </div>
                   7502: <div class="sect2" lang="en">
                   7503: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7504: <a name="handling-licenses"></a>18.1.4. Handling licenses</h3></div></div></div>
1.78      rillig   7505: <p>A package may be covered by a license which the user has
1.87      wiz      7506:     or has not agreed to accept.  For these cases, pkgsrc contains
                   7507:     a mechanism to note that a package is covered by a particular
                   7508:     license, and the package cannot be built unless the user has
                   7509:     accepted the license.  (Installation of binary packages are
                   7510:     not currently subject to this mechanism.)  Packages with
                   7511:     licenses that are either Open Source according to the Open
                   7512:     Source Initiative or Free according to the Free Software
                   7513:     Foundation will not be marked with a license tag.  Packages
                   7514:     with licenses that have not been determined to meet either
                   7515:     definition will be marked with a license tag referring to the
                   7516:     license.  This will prevent building unless pkgsrc is informed
                   7517:     that the license is acceptable, and enables displaying the
                   7518:     license.</p>
1.78      rillig   7519: <p>The license tag mechanism is intended to address
1.87      wiz      7520:     copyright-related issues surrounding building, installing and
                   7521:     using a package, and not to address redistribution issues (see
                   7522:     <code class="varname">RESTRICTED</code> and
                   7523:     <code class="varname">NO_SRC_ON_FTP</code>, etc.).  However, the above
                   7524:     definition of licenses for which tags are not needed implies
                   7525:     that packages with redistribution restrictions should have
                   7526:     tags.</p>
                   7527: <p>Denoting that a package is covered by a particular license
                   7528:     is done by placing the license in
                   7529:     <code class="filename">pkgsrc/licenses</code> and setting the
                   7530:     <code class="varname">LICENSE</code> variable to a string identifying the
1.91      rillig   7531:     license, e.g. in <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>:</p>
1.87      wiz      7532: <pre class="programlisting">
                   7533:       LICENSE=        xv-license
                   7534:     </pre>
                   7535: <p>When trying to build, the user will get a notice that the
                   7536:     package is covered by a license which has not been
                   7537:     accepted:</p>
                   7538: <pre class="programlisting">
                   7539:       <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
                   7540:       ===&gt; xv-3.10anb9 has an unacceptable license: xv-license.
                   7541:       ===&gt;     To view the license, enter "/usr/bin/make show-license".
                   7542:       ===&gt;     To indicate acceptance, add this line to your /etc/mk.conf:
                   7543:       ===&gt;     ACCEPTABLE_LICENSES+=xv-license
                   7544:       *** Error code 1
                   7545:     </pre>
1.78      rillig   7546: <p>The license can be viewed with <span><strong class="command">make
1.87      wiz      7547:     show-license</strong></span>, and if it is considered appropriate,
                   7548:     the line printed above can be added to
                   7549:     <code class="filename">/etc/mk.conf</code> to indicate acceptance of
                   7550:     the particular license:</p>
1.78      rillig   7551: <pre class="programlisting">
1.87      wiz      7552:       ACCEPTABLE_LICENSES+=xv-license
                   7553:     </pre>
1.78      rillig   7554: <p>When adding a package with a new license, the license
1.87      wiz      7555:     text should be added to <code class="filename">pkgsrc/licenses</code>
                   7556:     for displaying. A list of known licenses can be seen in this
1.91      rillig   7557:     directory.</p>
1.78      rillig   7558: <p>The use of <code class="varname">LICENSE=shareware</code>,
1.87      wiz      7559:     <code class="varname">LICENSE=no-commercial-use</code>, and similar
                   7560:     language is deprecated because it does not crisply refer to
                   7561:     a particular license text.  Another problem with such usage
                   7562:     is that it does not enable a user to denote acceptance of
                   7563:     the license for a single package without accepting the same
                   7564:     license text for another package.  In particular, this can
                   7565:     be inappropriate when e.g. one accepts a particular license to
                   7566:     indicate to pkgsrc that a fee has been paid.</p>
1.75      rillig   7567: </div>
                   7568: <div class="sect2" lang="en">
                   7569: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7570: <a name="restricted-packages"></a>18.1.5. Restricted packages</h3></div></div></div>
1.75      rillig   7571: <p>Some licenses restrict how software may be re-distributed.
1.87      wiz      7572:     In order to satisfy these restrictions, the package system
                   7573:     defines five make variables that can be set to note these
                   7574:     restrictions:</p>
1.75      rillig   7575: <div class="itemizedlist"><ul type="disc">
                   7576: <li>
                   7577: <p><code class="varname">RESTRICTED</code></p>
                   7578: <p>This variable should be set whenever a restriction
1.87      wiz      7579:        exists (regardless of its kind).  Set this variable to a
                   7580:        string containing the reason for the restriction.</p>
1.75      rillig   7581: </li>
                   7582: <li>
                   7583: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
                   7584: <p>Binaries may not be placed on CD-ROM.  Set this
1.87      wiz      7585:        variable to <code class="varname">${RESTRICTED}</code> whenever a
                   7586:        binary package may not be included on a CD-ROM.</p>
1.75      rillig   7587: </li>
                   7588: <li>
                   7589: <p><code class="varname">NO_BIN_ON_FTP</code></p>
                   7590: <p>Binaries may not be placed on an FTP server.  Set
1.87      wiz      7591:        this variable to <code class="varname">${RESTRICTED}</code>
                   7592:        whenever a binary package may not not be made available
                   7593:        on the Internet.</p>
1.75      rillig   7594: </li>
                   7595: <li>
                   7596: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
                   7597: <p>Distfiles may not be placed on CD-ROM.  Set this
1.87      wiz      7598:        variable to <code class="varname">${RESTRICTED}</code> if
                   7599:        re-distribution of the source code or other distfile(s) is
                   7600:        not allowed on CD-ROMs.</p>
1.75      rillig   7601: </li>
                   7602: <li>
                   7603: <p><code class="varname">NO_SRC_ON_FTP</code></p>
                   7604: <p>Distfiles may not be placed on FTP.  Set this variable
1.87      wiz      7605:        to <code class="varname">${RESTRICTED}</code> if re-distribution of
                   7606:        the source code or other distfile(s) via the Internet is not
                   7607:        allowed.  If this variable is not set, the distfile(s) will
                   7608:        be mirrored on ftp.NetBSD.org.</p>
1.75      rillig   7609: </li>
                   7610: </ul></div>
                   7611: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
1.87      wiz      7612:     <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
                   7613:     generic make variables to denote restrictions is deprecated,
                   7614:     because they unconditionally prevent users from generating
                   7615:     binary packages!</p>
1.75      rillig   7616: </div>
                   7617: <div class="sect2" lang="en">
                   7618: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7619: <a name="dependencies"></a>18.1.6. Handling dependencies</h3></div></div></div>
1.75      rillig   7620: <p>Your package may depend on some other package being present
1.88      wiz      7621:     - and there are various ways of expressing this dependency.
                   7622:     pkgsrc supports the <code class="varname">BUILD_DEPENDS</code> and
                   7623:     <code class="varname">DEPENDS</code> definitions, the
                   7624:     <code class="varname">USE_TOOLS</code> definition, as well as dependencies
                   7625:     via <code class="filename">buildlink3.mk</code>, which is the preferred way
                   7626:     to handle dependencies, and which uses the variables named above.
1.90      rillig   7627:     See <a href="#buildlink" title="Chapter 13. Buildlink methodology">Chapter 13, <i>Buildlink methodology</i></a> for more information.</p>
1.75      rillig   7628: <p>The basic difference between the two variables is as
1.87      wiz      7629:     follows: The <code class="varname">DEPENDS</code> definition registers
                   7630:     that pre-requisite in the binary package so it will be pulled in
                   7631:     when the binary package is later installed, whilst the
                   7632:     <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
                   7633:     dependency that is only needed for building the package.</p>
1.75      rillig   7634: <p>This means that if you only need a package present whilst
1.87      wiz      7635:     you are building, it should be noted as a
                   7636:     <code class="varname">BUILD_DEPENDS</code>.</p>
1.75      rillig   7637: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
1.87      wiz      7638:     <code class="varname">DEPENDS</code> definition is:</p>
1.75      rillig   7639: <pre class="programlisting">
1.87      wiz      7640:       &lt;pre-req-package-name&gt;:../../&lt;category&gt;/&lt;pre-req-package&gt;
                   7641:     </pre>
1.75      rillig   7642: <p>Please note that the &#8220;<span class="quote">pre-req-package-name</span>&#8221;
1.87      wiz      7643:     may include any of the wildcard version numbers recognized by
                   7644:     <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_info+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_info</span>(1)</span></a>.</p>
1.75      rillig   7645: <div class="orderedlist"><ol type="1">
                   7646: <li>
                   7647: <p>If your package needs another package's binaries or
1.87      wiz      7648:        libraries to build or run, and if that package has a
                   7649:        <code class="filename">buildlink3.mk</code> file available, use it:</p>
1.75      rillig   7650: <pre class="programlisting">
1.87      wiz      7651:          .include "../../graphics/jpeg/buildlink3.mk"
                   7652:        </pre>
1.75      rillig   7653: </li>
                   7654: <li>
                   7655: <p>If your package needs to use another package to build
1.87      wiz      7656:        itself and there is no <code class="filename">buildlink3.mk</code>
                   7657:        file available, use the <code class="varname">BUILD_DEPENDS</code>
                   7658:        definition:</p>
1.75      rillig   7659: <pre class="programlisting">
1.87      wiz      7660:          BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
                   7661:        </pre>
1.75      rillig   7662: </li>
                   7663: <li>
                   7664: <p>If your package needs a library with which to link and
1.76      rillig   7665:        again there is no <code class="filename">buildlink3.mk</code> file
1.87      wiz      7666:        available, this is specified using the
                   7667:        <code class="varname">DEPENDS</code> definition. For example:</p>
1.75      rillig   7668: <pre class="programlisting">
1.87      wiz      7669:          DEPENDS+=       xpm-3.4j:../../graphics/xpm
                   7670:        </pre>
1.75      rillig   7671: <p>You can also use wildcards in package dependences:</p>
                   7672: <pre class="programlisting">
1.87      wiz      7673:          DEPENDS+=       xpm-[0-9]*:../../graphics/xpm
                   7674:        </pre>
1.75      rillig   7675: <p>Note that such wildcard dependencies are retained when
1.87      wiz      7676:        creating binary packages.  The dependency is checked when
                   7677:        installing the binary package and any package which matches
                   7678:        the pattern will be used.  Wildcard dependencies should be
                   7679:        used with care.</p>
1.75      rillig   7680: <p>The &#8220;<span class="quote">-[0-9]*</span>&#8221; should be used instead of
1.87      wiz      7681:        &#8220;<span class="quote">-*</span>&#8221; to avoid potentially ambiguous matches
                   7682:        such as &#8220;<span class="quote">tk-postgresql</span>&#8221; matching a
                   7683:        &#8220;<span class="quote">tk-*</span>&#8221; <code class="varname">DEPENDS</code>.</p>
1.75      rillig   7684: <p>Wildcards can also be used to specify that a package
1.87      wiz      7685:        will only build against a certain minimum version of a
                   7686:        pre-requisite:</p>
1.75      rillig   7687: <pre class="programlisting">
1.87      wiz      7688:          DEPENDS+=       tiff&gt;=3.5.4:../../graphics/tiff
                   7689:        </pre>
1.75      rillig   7690: <p>This means that the package will build against version
1.87      wiz      7691:        3.5.4 of the tiff library or newer.  Such a dependency may
                   7692:        be warranted if, for example, the API of the library has
                   7693:        changed with version 3.5.4 and a package would not compile
                   7694:        against an earlier version of tiff.</p>
1.75      rillig   7695: <p>Please note that such dependencies should only be
1.87      wiz      7696:        updated if a package requires a newer pre-requisite, but
                   7697:        not to denote recommendations such as 
                   7698:        ABI changes that do not prevent a package from building
                   7699:        correctly.  Such recommendations can be expressed using
                   7700:        <code class="varname">ABI_DEPENDS</code>:</p>
1.75      rillig   7701: <pre class="programlisting">
1.87      wiz      7702:          ABI_DEPENDS+=   tiff&gt;=3.6.1:../../graphics/tiff
                   7703:        </pre>
1.75      rillig   7704: <p>In addition to the above <code class="varname">DEPENDS</code>
1.87      wiz      7705:        line, this denotes that while a package will build against
                   7706:        tiff&gt;=3.5.4, at least version 3.6.1 is recommended.
                   7707:        <code class="varname">ABI_DEPENDS</code> entries will be turned into
                   7708:        dependencies unless explicitly ignored (in which case a
                   7709:        warning will be printed).</p>
1.75      rillig   7710: <p>To ignore these ABI dependency recommendations and just
1.87      wiz      7711:        use the required <code class="varname">DEPENDS</code>, set
                   7712:        <code class="varname">USE_ABI_DEPENDS=NO</code>.   This may make
                   7713:        it easier and faster to update packages built using pkgsrc,
                   7714:        since older compatible dependencies can continue to be
                   7715:        used. This is useful for people who watch their rebuilds
                   7716:        very carefully; it is not very good as a general-purpose
                   7717:        hammer.  If you use it, you need to be mindful of possible
                   7718:        ABI changes, including those from the underlying OS.</p>
1.75      rillig   7719: <p>Packages that are built with recommendations ignored
1.87      wiz      7720:        may not be uploaded to ftp.NetBSD.org by developers and
                   7721:        should not be used across different systems that may have
                   7722:        different versions of binary packages installed.</p>
1.75      rillig   7723: <p>For security fixes, please update the package
1.90      rillig   7724:        vulnerabilities file. See <a href="#security-handling" title="18.1.10. Handling packages with security problems">Section 18.1.10, &#8220;Handling packages with security problems&#8221;</a> for more
1.87      wiz      7725:        information.</p>
1.75      rillig   7726: </li>
                   7727: <li>
                   7728: <p>If your package needs some executable to be able to run
1.87      wiz      7729:        correctly and if there's no
                   7730:        <code class="filename">buildlink3.mk</code> file, this is specified
                   7731:        using the <code class="varname">DEPENDS</code> variable. The
1.91      rillig   7732:        <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/print/lyx/README.html" target="_top"><code class="filename">print/lyx</code></a> package needs to
1.87      wiz      7733:        be able to execute the latex binary from the teTeX package
                   7734:        when it runs, and that is specified:</p>
1.75      rillig   7735: <pre class="programlisting">
1.87      wiz      7736:          DEPENDS+=        teTeX-[0-9]*:../../print/teTeX
                   7737:        </pre>
1.75      rillig   7738: <p>The comment about wildcard dependencies from previous
1.87      wiz      7739:        paragraph applies here, too.</p>
1.75      rillig   7740: </li>
                   7741: </ol></div>
                   7742: <p>If your package needs files from another package to build,
1.87      wiz      7743:     add the relevant distribution files to
                   7744:     <code class="varname">DISTFILES</code>, so they will be extracted
1.91      rillig   7745:     automatically. See the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/print/ghostscript/README.html" target="_top"><code class="filename">print/ghostscript</code></a> package for an example.
1.87      wiz      7746:     (It relies on the jpeg sources being present in source form
                   7747:     during the build.)</p>
1.88      wiz      7748: <p>Please also note the
                   7749:     <code class="varname">BUILD_USES_GETTEXT_M4</code> definition, which is
                   7750:     provided as convenience definition.  It adds a build dependency on
                   7751:     either an installed version of an older gettext package, or if it
1.91      rillig   7752:     isn't, installs the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/gettext-m4/README.html" target="_top"><code class="filename">devel/gettext-m4</code></a> package.</p>
1.75      rillig   7753: </div>
                   7754: <div class="sect2" lang="en">
                   7755: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7756: <a name="conflicts"></a>18.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75      rillig   7757: <p>Your package may conflict with other packages a user might
1.87      wiz      7758:     already have installed on his system, e.g. if your package
1.88      wiz      7759:     installs the same set of files as another package in the pkgsrc
                   7760:     tree.</p>
1.75      rillig   7761: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
1.87      wiz      7762:     space-separated list of packages (including version string) your
                   7763:     package conflicts with.</p>
1.91      rillig   7764: <p>For example, <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/Xaw3d/README.html" target="_top"><code class="filename">x11/Xaw3d</code></a>
                   7765:     and <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/Xaw-Xpm/README.html" target="_top"><code class="filename">x11/Xaw-Xpm</code></a>
1.87      wiz      7766:     install the same shared library, thus you set in
                   7767:     <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
                   7768: <pre class="programlisting">
                   7769:       CONFLICTS=      Xaw-Xpm-[0-9]*
                   7770:     </pre>
                   7771: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:</p>
1.75      rillig   7772: <pre class="programlisting">
1.87      wiz      7773:       CONFLICTS=      Xaw3d-[0-9]*
                   7774:     </pre>
1.75      rillig   7775: <p>Packages will automatically conflict with other packages
1.87      wiz      7776:     with the name prefix and a different version
                   7777:     string. &#8220;<span class="quote">Xaw3d-1.5</span>&#8221; e.g. will automatically
                   7778:     conflict with the older version &#8220;<span class="quote">Xaw3d-1.3</span>&#8221;.</p>
1.75      rillig   7779: </div>
                   7780: <div class="sect2" lang="en">
                   7781: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7782: <a name="not-building-packages"></a>18.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75      rillig   7783: <p>There are several reasons why a package might be
1.88      wiz      7784:     instructed to not build under certain circumstances.  If the
1.87      wiz      7785:     package builds and runs on most platforms, the exceptions
                   7786:     should be noted with <code class="varname">NOT_FOR_PLATFORM</code>.  If
                   7787:     the package builds and runs on a small handful of platforms,
                   7788:     set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
                   7789:     Both <code class="varname">ONLY_FOR_PLATFORM</code> and
                   7790:     <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
                   7791:     (OS-version-platform) that can use glob-style
                   7792:     wildcards.</p>
1.88      wiz      7793: <p>Some packages are tightly bound to a specific version of an
1.91      rillig   7794:     operating system, e.g. LKMs or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/sysutils/lsof/README.html" target="_top"><code class="filename">sysutils/lsof</code></a>.  Such binary packages are not
1.88      wiz      7795:     backwards compatible with other versions of the OS, and should be
                   7796:     uploaded to a version specific directory on the FTP server.  Mark
                   7797:     these packages by setting <code class="varname">OSVERSION_SPECIFIC</code> to
                   7798:     &#8220;<span class="quote">yes</span>&#8221;.  This variable is not currently used by any of
                   7799:     the package system internals, but may be used in the
                   7800:     future.</p>
1.75      rillig   7801: <p>If the package should be skipped (for example, because it
1.87      wiz      7802:     provides functionality already provided by the system), set
1.88      wiz      7803:     <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.  If
                   7804:     the package should fail because some preconditions are not met,
                   7805:     set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
1.87      wiz      7806:     message.</p>
1.75      rillig   7807: </div>
                   7808: <div class="sect2" lang="en">
                   7809: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7810: <a name="undeletable-packages"></a>18.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75      rillig   7811: <p>To ensure that a package may not be deleted, once it has been
1.87      wiz      7812:     installed, the <code class="varname">PKG_PRESERVE</code> definition should
                   7813:     be set in the package Makefile. This will be carried into any
                   7814:     binary package that is made from this pkgsrc entry. A
                   7815:     &#8220;<span class="quote">preserved</span>&#8221; package will
                   7816:     not be deleted using <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> unless the
                   7817:     &#8220;<span class="quote">-f</span>&#8221; option is used.</p>
1.75      rillig   7818: </div>
                   7819: <div class="sect2" lang="en">
                   7820: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7821: <a name="security-handling"></a>18.1.10. Handling packages with security problems</h3></div></div></div>
1.75      rillig   7822: <p>When a vulnerability is found, this should be noted in
1.87      wiz      7823:     <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
                   7824:     and after committing that file, use <span><strong class="command">make upload</strong></span>
                   7825:     in the same directory to update the file on ftp.NetBSD.org.</p>
1.75      rillig   7826: <p>After fixing the vulnerability by a patch, its
1.87      wiz      7827:     <code class="varname">PKGREVISION</code> should be increased (this
                   7828:     is of course not necessary if the problem is fixed by using
                   7829:     a newer release of the software).</p>
1.75      rillig   7830: <p>Also, if the fix should be applied to the stable pkgsrc
1.87      wiz      7831:     branch, be sure to submit a pullup request!</p>
1.75      rillig   7832: <p>Binary packages already on ftp.NetBSD.org will be handled
1.87      wiz      7833:     semi-automatically by a weekly cron job.</p>
1.75      rillig   7834: </div>
                   7835: <div class="sect2" lang="en">
                   7836: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7837: <a name="bumping-pkgrevision"></a>18.1.11. How to handle incrementing versions when fixing an existing package</h3></div></div></div>
1.75      rillig   7838: <p>When making fixes to an existing package it can be useful
1.87      wiz      7839:     to change the version number in <code class="varname">PKGNAME</code>. To
                   7840:     avoid conflicting with future versions by the original author, a
                   7841:     &#8220;<span class="quote">nb1</span>&#8221;, &#8220;<span class="quote">nb2</span>&#8221;, ... suffix can be used
                   7842:     on package versions by setting <code class="varname">PKGREVISION=1</code>
                   7843:     (2, ...). The &#8220;<span class="quote">nb</span>&#8221; is treated like a
                   7844:     &#8220;<span class="quote">.</span>&#8221; by the package tools. e.g.</p>
                   7845: <pre class="programlisting">
                   7846:       DISTNAME=       foo-17.42
                   7847:       PKGREVISION=    9
                   7848:     </pre>
1.75      rillig   7849: <p>will result in a <code class="varname">PKGNAME</code> of
1.87      wiz      7850:     &#8220;<span class="quote">foo-17.42nb9</span>&#8221;. If you want to use the original
                   7851:     value of <code class="varname">PKGNAME</code> without the &#8220;<span class="quote">nbX</span>&#8221;
                   7852:     suffix, e.g. for setting <code class="varname">DIST_SUBDIR</code>, use
                   7853:     <code class="varname">PKGNAME_NOREV</code>.</p>
1.75      rillig   7854: <p>When a new release of the package is released, the
1.87      wiz      7855:     <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
                   7856:     minor release of the above package, things should be like:</p>
1.75      rillig   7857: <pre class="programlisting">
1.87      wiz      7858:       DISTNAME=       foo-17.43
                   7859:     </pre>
                   7860: <p><code class="varname">PKGREVISION</code> should be incremented for any
                   7861:     non-trivial change in the resulting binary package.  Without a
                   7862:     <code class="varname">PKGREVISION</code> bump, someone with the previous
                   7863:     version installed has no way of knowing that their package is out
                   7864:     of date.  Thus, changes without increasing
                   7865:     <code class="varname">PKGREVISION</code> are essentially labeled "this is so
                   7866:     trivial that no reasonable person would want to upgrade", and this
                   7867:     is the rough test for when increasing
                   7868:     <code class="varname">PKGREVISION</code> is appropriate.  Examples of
                   7869:     changes that do not merit increasing
                   7870:     <code class="varname">PKGREVISION</code> are:</p>
                   7871: <pre class="programlisting">
                   7872:       Changing <code class="varname">HOMEPAGE</code>, <code class="varname">MAINTAINER</code>,
                   7873:       or comments in Makefile.
                   7874:       Changing build variables if the resulting binary package is the same.
                   7875:       Changing <code class="filename">DESCR</code>.
                   7876:       Adding <code class="varname">PKG_OPTIONS</code> if the default options don't change.
                   7877:     </pre>
                   7878: <p>Examples of changes that do merit an increase to
                   7879:     <code class="varname">PKGREVISION</code> include:</p>
                   7880: <pre class="programlisting">
                   7881:       Security fixes
                   7882:       Changes or additions to a patch file
                   7883:       Changes to the <code class="filename">PLIST</code>
                   7884:     </pre>
1.78      rillig   7885: <p>PKGREVISION must also be incremented when dependencies have ABI
                   7886:     changes.</p>
1.75      rillig   7887: </div>
1.79      rillig   7888: <div class="sect2" lang="en">
                   7889: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7890: <a name="fixes.subst"></a>18.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
1.79      rillig   7891: <p>When you want to replace the same text in multiple files
1.87      wiz      7892:     or when the replacement text varies, patches alone cannot help.
                   7893:     This is where the SUBST framework comes in. It provides an
                   7894:     easy-to-use interface for replacing text in files.
                   7895:     Example:</p>
                   7896: <pre class="programlisting">
                   7897:       SUBST_CLASSES+=                 fix-paths
                   7898:       SUBST_STAGE.fix-paths=          pre-configure
                   7899:       SUBST_MESSAGE.fix-paths=        Fixing absolute paths.
                   7900:       SUBST_FILES.fix-paths=          src/*.c
                   7901:       SUBST_FILES.fix-paths+=         scripts/*.sh
                   7902:       SUBST_SED.fix-paths=            -e 's,"/usr/local,"${PREFIX},g'
                   7903:       SUBST_SED.fix-paths+=           -e 's,"/var/log,"${VARBASE}/log,g'
                   7904:     </pre>
1.79      rillig   7905: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
1.87      wiz      7906:     that are used to identify the different SUBST blocks that are
                   7907:     defined. The SUBST framework is heavily used by pkgsrc, so it is
                   7908:     important to always use the <code class="literal">+=</code> operator with
                   7909:     this variable. Otherwise some substitutions may be
                   7910:     skipped.</p>
1.79      rillig   7911: <p>The remaining variables of each SUBST block are
1.87      wiz      7912:     parameterized with the identifier from the first line
                   7913:     (<code class="literal">fix-paths</code> in this case.) They can be seen as
                   7914:     parameters to a function call.</p>
1.79      rillig   7915: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
1.87      wiz      7916:     which the replacement will take place. All combinations of
                   7917:     <code class="literal">pre-</code>, <code class="literal">do-</code> and
                   7918:     <code class="literal">post-</code> together with a phase name are
                   7919:     possible, though only few are actually used. Most commonly used
                   7920:     are <code class="literal">post-patch</code> and
                   7921:     <code class="literal">pre-configure</code>. Of these two,
                   7922:     <code class="literal">pre-configure</code> should be preferred because
                   7923:     then it is possible to run <span><strong class="command">bmake patch</strong></span> and
                   7924:     have the state after applying the patches but before making any
                   7925:     other changes. This is especially useful when you are debugging
                   7926:     a package in order to create new patches for it. Similarly,
                   7927:     <code class="literal">post-build</code> is preferred over
                   7928:     <code class="literal">pre-install</code>, because the install phase should
                   7929:     generally be kept as simple as possible. When you use
                   7930:     <code class="literal">post-build</code>, you have the same files in the
                   7931:     working directory that will be installed later, so you can check
                   7932:     if the substitution has succeeded.</p>
1.79      rillig   7933: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
1.87      wiz      7934:     that is printed just before the substitution is done.</p>
1.79      rillig   7935: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
1.87      wiz      7936:     globbing patterns that specifies the files in which the
                   7937:     substitution will take place. The patterns are interpreted
                   7938:     relatively to the <code class="varname">WRKSRC</code> directory.</p>
1.79      rillig   7939: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
1.87      wiz      7940:     <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sed+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sed</span>(1)</span></a> that specify the actual substitution. Every sed
                   7941:     command should be prefixed with <code class="literal">-e</code>, so that
                   7942:     all SUBST blocks look uniform.</p>
1.79      rillig   7943: <p>There are some more variables, but they are so seldomly
1.87      wiz      7944:     used that they are only documented in the
                   7945:     <code class="filename">mk/subst.mk</code> file.</p>
1.79      rillig   7946: </div>
1.75      rillig   7947: </div>
                   7948: <div class="sect1" lang="en">
                   7949: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   7950: <a name="fixes.fetch"></a>18.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.75      rillig   7951: <div class="sect2" lang="en">
                   7952: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7953: <a name="no-plain-download"></a>18.2.1. Packages whose distfiles aren't available for plain downloading</h3></div></div></div>
1.75      rillig   7954: <p>If you need to download from a dynamic URL you can set
1.87      wiz      7955:     <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
                   7956:     fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
                   7957:     with the name of each file to download as an argument, expecting
                   7958:     it to output the URL of the directory from which to download
1.91      rillig   7959:     it. <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/graphics/ns-cult3d/README.html" target="_top"><code class="filename">graphics/ns-cult3d</code></a> is an
1.87      wiz      7960:     example of this usage.</p>
1.75      rillig   7961: <p>If the download can't be automated, because the user must
1.87      wiz      7962:     submit personal information to apply for a password, or must pay
                   7963:     for the source, or whatever, you can set
                   7964:     <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
                   7965:     displayed to the user before aborting the build. Example:</p>
                   7966: <pre class="programlisting">
                   7967:       FETCH_MESSAGE=  "Please download the files"
                   7968:       FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   7969:       FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   7970:     </pre>
1.75      rillig   7971: </div>
                   7972: <div class="sect2" lang="en">
                   7973: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   7974: <a name="modified-distfiles-same-name"></a>18.2.2. How to handle modified distfiles with the 'old' name</h3></div></div></div>
1.75      rillig   7975: <p>Sometimes authors of a software package make some
1.87      wiz      7976:     modifications after the software was released, and they put up a
                   7977:     new distfile without changing the package's version number. If a
                   7978:     package is already in pkgsrc at that time, the checksum will
                   7979:     no longer match. The contents of the new distfile should be
                   7980:     compared against the old one before changing anything, to make
                   7981:     sure the distfile was really updated on purpose, and that
                   7982:     no trojan horse or so crept in.
                   7983:     Then, the correct way to work around this is to
                   7984:     set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
                   7985:     usually based on <code class="varname">PKGNAME_NOREV</code>. All
                   7986:     <code class="varname">DISTFILES</code> and
                   7987:     <code class="varname">PATCHFILES</code> for this package will be put in that 
                   7988:     subdirectory of the local distfiles directory.  In case this
                   7989:     happens more often, <code class="varname">PKGNAME</code> can be used (thus
                   7990:     including the <code class="filename">nbX</code> suffix) or a date stamp
                   7991:     can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
                   7992:     Do not forget regenerating the <code class="filename">distinfo</code> file
                   7993:     after that, since it contains the <code class="varname">DIST_SUBDIR</code>
                   7994:     path in the filenames.
                   7995:     Furthermore, a mail to the package's authors seems appropriate
                   7996:     telling them that changing distfiles after releases without
                   7997:     changing the file names is not good practice.</p>
1.75      rillig   7998: </div>
                   7999: </div>
                   8000: <div class="sect1" lang="en">
                   8001: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   8002: <a name="fixes.configure"></a>18.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75      rillig   8003: <div class="sect2" lang="en">
                   8004: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8005: <a name="fixes.libtool"></a>18.3.1. Shared libraries - libtool</h3></div></div></div>
1.75      rillig   8006: <p>pkgsrc supports many different machines, with different
1.87      wiz      8007:     object formats like a.out and ELF, and varying abilities to do
                   8008:     shared library and dynamic loading at all. To accompany this,
                   8009:     varying commands and options have to be passed to the
                   8010:     compiler, linker, etc. to get the Right Thing, which can be
                   8011:     pretty annoying especially if you don't have all the machines
                   8012:     at your hand to test things.  The
1.91      rillig   8013:     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/libtool/README.html" target="_top"><code class="filename">devel/libtool</code></a> pkg
1.87      wiz      8014:     can help here, as it just &#8220;<span class="quote">knows</span>&#8221; how to build
                   8015:     both static and dynamic libraries from a set of source files,
                   8016:     thus being platform-independent.</p>
                   8017: <p>Here's how to use libtool in a package in seven simple
                   8018:     steps:</p>
1.75      rillig   8019: <div class="orderedlist"><ol type="1">
                   8020: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
1.87      wiz      8021:        Makefile.</p></li>
1.75      rillig   8022: <li><p>For library objects, use &#8220;<span class="quote">${LIBTOOL} --mode=compile
1.87      wiz      8023:        ${CC}</span>&#8221; in place of &#8220;<span class="quote">${CC}</span>&#8221;. You could even
                   8024:        add it to the definition of <code class="varname">CC</code>, if only
                   8025:        libraries are being built in a given Makefile. This one command
                   8026:        will build both PIC and non-PIC library objects, so you need not
                   8027:        have separate shared and non-shared library rules.</p></li>
1.75      rillig   8028: <li>
                   8029: <p>For the linking of the library, remove any
1.87      wiz      8030:        &#8220;<span class="quote">ar</span>&#8221;, &#8220;<span class="quote">ranlib</span>&#8221;, and &#8220;<span class="quote">ld
                   8031:        -Bshareable</span>&#8221; commands, and instead use:</p>
1.75      rillig   8032: <pre class="programlisting">
1.87      wiz      8033:          ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
                   8034:          -rpath ${PREFIX}/lib -version-info major:minor
                   8035:        </pre>
1.75      rillig   8036: <p>Note that the library is changed to have a
1.87      wiz      8037:        <code class="filename">.la</code> extension, and the objects are
                   8038:        changed to have a <code class="filename">.lo</code>
                   8039:        extension. Change <code class="varname">OBJS</code> as
                   8040:        necessary. This automatically creates all of the
                   8041:        <code class="filename">.a</code>,
                   8042:        <code class="filename">.so.major.minor</code>, and ELF symlinks (if
                   8043:        necessary) in the build directory. Be sure to include
                   8044:        &#8220;<span class="quote">-version-info</span>&#8221;, especially when major and
                   8045:        minor are zero, as libtool will otherwise strip off the
                   8046:        shared library version.</p>
1.75      rillig   8047: <p>From the libtool manual:</p>
                   8048: <pre class="programlisting">
1.87      wiz      8049:          So, libtool library versions are described by three integers:
1.69      rillig   8050: 
1.87      wiz      8051:          CURRENT
                   8052:          The most recent interface number that this library implements.
1.69      rillig   8053: 
1.87      wiz      8054:          REVISION
                   8055:          The implementation number of the CURRENT interface.
1.69      rillig   8056: 
1.87      wiz      8057:          AGE
                   8058:          The difference between the newest and oldest interfaces that
                   8059:          this library implements.  In other words, the library implements
                   8060:          all the interface numbers in the range from number `CURRENT -
                   8061:          AGE' to `CURRENT'.
1.1       grant    8062: 
1.87      wiz      8063:          If two libraries have identical CURRENT and AGE numbers, then the
                   8064:          dynamic linker chooses the library with the greater REVISION number.
                   8065:        </pre>
1.75      rillig   8066: <p>The &#8220;<span class="quote">-release</span>&#8221; option will produce
1.87      wiz      8067:        different results for a.out and ELF (excluding symlinks)
                   8068:        in only one case. An ELF library of the form
                   8069:        &#8220;<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;
                   8070:        will have a symlink of
                   8071:        &#8220;<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;
                   8072:        on an a.out platform. This is handled
                   8073:        automatically.</p>
1.75      rillig   8074: <p>The &#8220;<span class="quote">-rpath argument</span>&#8221; is the install
1.87      wiz      8075:        directory of the library being built.</p>
1.76      rillig   8076: <p>In the <code class="filename">PLIST</code>, include only the
1.87      wiz      8077:        <code class="filename">.la</code> file, the other files will be
                   8078:        added automatically.</p>
1.75      rillig   8079: </li>
                   8080: <li>
1.76      rillig   8081: <p>When linking shared object (<code class="filename">.so</code>)
1.87      wiz      8082:        files, i.e. files that are loaded via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?dlopen+3+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">dlopen</span>(3)</span></a>, NOT
                   8083:        shared libraries, use &#8220;<span class="quote">-module
                   8084:        -avoid-version</span>&#8221; to prevent them getting version
                   8085:        tacked on.</p>
1.76      rillig   8086: <p>The <code class="filename">PLIST</code> file gets the
1.87      wiz      8087:        <code class="filename">foo.so</code> entry.</p>
1.75      rillig   8088: </li>
                   8089: <li>
                   8090: <p>When linking programs that depend on these libraries
1.87      wiz      8091:        <span class="emphasis"><em>before</em></span> they are installed, preface
                   8092:        the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cc+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cc</span>(1)</span></a> or <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ld+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ld</span>(1)</span></a> line with &#8220;<span class="quote">${LIBTOOL}
                   8093:        --mode=link</span>&#8221;, and it will find the correct
                   8094:        libraries (static or shared), but please be aware that
                   8095:        libtool will not allow you to specify a relative path in
                   8096:        -L (such as &#8220;<span class="quote">-L../somelib</span>&#8221;), because it
                   8097:        expects you to change that argument to be the
                   8098:        <code class="filename">.la</code> file. e.g.</p>
1.75      rillig   8099: <pre class="programlisting">
1.87      wiz      8100:          ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   8101:        </pre>
1.75      rillig   8102: <p>should be changed to:</p>
                   8103: <pre class="programlisting">
1.87      wiz      8104:          ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
                   8105:        </pre>
1.75      rillig   8106: <p>and it will do the right thing with the libraries.</p>
                   8107: </li>
                   8108: <li>
                   8109: <p>When installing libraries, preface the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?install+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">install</span>(1)</span></a>
1.87      wiz      8110:        or <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cp+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cp</span>(1)</span></a> command with &#8220;<span class="quote">${LIBTOOL}
                   8111:        --mode=install</span>&#8221;, and change the library name to
                   8112:        <code class="filename">.la</code>. e.g.</p>
1.75      rillig   8113: <pre class="programlisting">
1.87      wiz      8114:          ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
                   8115:        </pre>
1.76      rillig   8116: <p>This will install the static <code class="filename">.a</code>,
1.87      wiz      8117:        shared library, any needed symlinks, and run
                   8118:        <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ldconfig+8+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ldconfig</span>(8)</span></a>.</p>
1.75      rillig   8119: </li>
1.76      rillig   8120: <li><p>In your <code class="filename">PLIST</code>, include only
1.87      wiz      8121:        the <code class="filename">.la</code>
                   8122:        file (this is a change from previous behaviour).</p></li>
1.75      rillig   8123: </ol></div>
                   8124: </div>
                   8125: <div class="sect2" lang="en">
                   8126: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8127: <a name="using-libtool"></a>18.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75      rillig   8128: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
1.87      wiz      8129:     package Makefile. This will override the package's own libtool
                   8130:     in most cases.  For older libtool using packages,  libtool is
                   8131:     made by ltconfig script during the do-configure step; you can
                   8132:     check the libtool script location by doing <span><strong class="command">make
                   8133:     configure; find work*/ -name libtool</strong></span>.</p>
1.75      rillig   8134: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
1.87      wiz      8135:     scripts, relative to <code class="varname">WRKSRC</code>, to override.  By
                   8136:     default, it is set to &#8220;<span class="quote">libtool */libtool
                   8137:     */*/libtool</span>&#8221;.  If this does not match the location of the
                   8138:     package's libtool script(s), set it as appropriate.</p>
1.76      rillig   8139: <p>If you do not need <code class="filename">*.a</code> static
1.87      wiz      8140:     libraries built and installed, then use
                   8141:     <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
1.75      rillig   8142: <p>If your package makes use of the platform-independent library
1.87      wiz      8143:     for loading dynamic shared objects, that comes with libtool
                   8144:     (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
                   8145: <p>Some packages use libtool incorrectly so that the package
                   8146:     may not work or build in some circumstances. Some of the more
                   8147:     common errors are:</p>
1.75      rillig   8148: <div class="itemizedlist"><ul type="disc">
                   8149: <li>
                   8150: <p>The inclusion of a shared object (-module) as a dependent library in an
1.87      wiz      8151:        executable or library. This in itself isn't a problem if one of two things
                   8152:        has been done:</p>
1.75      rillig   8153: <div class="orderedlist"><ol type="1">
                   8154: <li><p>The shared object is named correctly, i.e.
1.87      wiz      8155:            <code class="filename">libfoo.la</code>, not
                   8156:            <code class="filename">foo.la</code></p></li>
1.75      rillig   8157: <li><p>The -dlopen option is used when linking an executable.</p></li>
                   8158: </ol></div>
                   8159: </li>
                   8160: <li><p>The use of libltdl without the correct calls to initialisation routines.
1.87      wiz      8161:        The function lt_dlinit() should be called and the macro
                   8162:        <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
                   8163:        executables.</p></li>
1.75      rillig   8164: </ul></div>
                   8165: </div>
                   8166: <div class="sect2" lang="en">
                   8167: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8168: <a name="autoconf-automake"></a>18.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75      rillig   8169: <p>If a package needs GNU autoconf or automake to be executed
1.87      wiz      8170:     to regenerate the configure script and Makefile.in makefile
                   8171:     templates, then they should be executed in a pre-configure
                   8172:     target.</p>
1.75      rillig   8173: <p>For packages that need only autoconf:</p>
                   8174: <pre class="programlisting">
1.87      wiz      8175:       AUTOCONF_REQD=  2.50            # if default version is not good enough
                   8176:       USE_TOOLS+=     autoconf        # use "autoconf213" for autoconf-2.13
                   8177:       ...
1.1       grant    8178: 
1.87      wiz      8179:       pre-configure:
                   8180:       cd ${WRKSRC}; autoconf
1.1       grant    8181: 
1.87      wiz      8182:       ...
                   8183:     </pre>
1.75      rillig   8184: <p>and for packages that need automake and autoconf:</p>
                   8185: <pre class="programlisting">
1.87      wiz      8186:       AUTOMAKE_REQD=  1.7.1           # if default version is not good enough
                   8187:       USE_TOOLS+=     automake        # use "automake14" for automake-1.4
                   8188:       ...
                   8189: 
                   8190:       pre-configure:
                   8191:       cd ${WRKSRC};                          \
                   8192:       aclocal; autoheader;                   \
                   8193:       automake -a --foreign -i; autoconf
1.1       grant    8194: 
1.87      wiz      8195:       ...
                   8196:     </pre>
1.75      rillig   8197: <p>Packages which use GNU Automake will almost certainly
1.87      wiz      8198:     require GNU Make.</p>
1.75      rillig   8199: <p>There are times when the configure process makes
1.87      wiz      8200:     additional changes to the generated files, which then causes
                   8201:     the build process to try to re-execute the automake sequence.
                   8202:     This is prevented by touching various files in the configure
                   8203:     stage. If this causes problems with your package you can set
                   8204:     <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
                   8205:     Makefile.</p>
1.75      rillig   8206: </div>
                   8207: </div>
                   8208: <div class="sect1" lang="en">
                   8209: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   8210: <a name="programming-languages"></a>18.4. Programming languages</h2></div></div></div>
1.87      wiz      8211: <div class="sect2" lang="en">
                   8212: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8213: <a name="basic-programming-languages"></a>18.4.1. C, C++, and Fortran</h3></div></div></div>
1.87      wiz      8214: <p>Compilers for the C, C++, and Fortran languages comes with
                   8215:     the NetBSD base system.  By default, pkgsrc assumes that a package
                   8216:     is written in C and will hide all other compilers (via the wrapper
1.90      rillig   8217:     framework, see <a href="#buildlink" title="Chapter 13. Buildlink methodology">Chapter 13, <i>Buildlink methodology</i></a>).</p>
1.87      wiz      8218: <p>To declare which language's compiler a package needs, set
                   8219:     the <code class="varname">USE_LANGUAGES</code> variable. Allowed values
                   8220:     currently are &#8220;<span class="quote">c</span>&#8221;, &#8220;<span class="quote">c++</span>&#8221;, and
                   8221:     &#8220;<span class="quote">fortran</span>&#8221; (and any combination).  The default is
                   8222:     &#8220;<span class="quote">c</span>&#8221;.  Packages using GNU configure scripts, even if
                   8223:     written in C++, usually need a C compiler for the configure
                   8224:     phase.</p>
                   8225: </div>
                   8226: <div class="sect2" lang="en">
                   8227: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8228: <a name="java-programming-language"></a>18.4.2. Java</h3></div></div></div>
1.87      wiz      8229: <p>If a program is written in Java, use the Java framework in
                   8230:     pkgsrc.  The package must include
                   8231:     <code class="filename">../../mk/java-vm.mk</code>.  This Makefile fragment
                   8232:     provides the following variables:</p>
                   8233: <div class="itemizedlist"><ul type="disc">
                   8234: <li><p><code class="varname">USE_JAVA</code> defines if a build
                   8235:       dependency on the JDK is added.  If
                   8236:       <code class="varname">USE_JAVA</code> is set to &#8220;<span class="quote">run</span>&#8221;, then
                   8237:       there is only a runtime dependency on the JDK.  The default is
                   8238:       &#8220;<span class="quote">yes</span>&#8221;, which also adds a build dependency on the
                   8239:       JDK.</p></li>
                   8240: <li><p>Set <code class="varname">USE_JAVA2</code> to declare that
                   8241:       a package needs a Java2 implementation.  The supported values
                   8242:       are &#8220;<span class="quote">yes</span>&#8221;, &#8220;<span class="quote">1.4</span>&#8221;, and
                   8243:       &#8220;<span class="quote">1.5</span>&#8221;.  &#8220;<span class="quote">yes</span>&#8221; accepts any Java2
                   8244:       implementation, &#8220;<span class="quote">1.4</span>&#8221; insists on versions 1.4 or
                   8245:       above, and &#8220;<span class="quote">1.5</span>&#8221; only accepts versions 1.5 or
                   8246:       above. This variable is not set by default.</p></li>
                   8247: </ul></div>
                   8248: </div>
                   8249: <div class="sect2" lang="en">
                   8250: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8251: <a name="perl-scripts"></a>18.4.3. Packages containing perl scripts</h3></div></div></div>
1.87      wiz      8252: <p>If your package contains interpreted perl scripts, add
                   8253:     &#8220;<span class="quote">perl</span>&#8221; to the <code class="varname">USE_TOOLS</code> variable
                   8254:     and set <code class="varname">REPLACE_PERL</code> to ensure that the proper
                   8255:     interpreter path is set. <code class="varname">REPLACE_PERL</code> should
                   8256:     contain a list of scripts, relative to <code class="varname">WRKSRC</code>,
                   8257:     that you want adjusted.  Every occurrence of
                   8258:     <code class="filename">*/bin/perl</code> will be replaced with the full
                   8259:     path to the perl executable.</p>
                   8260: <p>If a particular version of perl is needed, set the
                   8261:     <code class="varname">PERL5_REQD</code> variable to the version number.  The
                   8262:     default is &#8220;<span class="quote">5.0</span>&#8221;.</p>
1.90      rillig   8263: <p>See <a href="#perl-modules" title="18.6.5. Packages installing perl modules">Section 18.6.5, &#8220;Packages installing perl modules&#8221;</a> for information
1.87      wiz      8264:     about handling perl modules.</p>
                   8265: </div>
                   8266: <div class="sect2" lang="en">
                   8267: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8268: <a name="other-programming-languages"></a>18.4.4. Other programming languages</h3></div></div></div>
1.87      wiz      8269: <p>Currently, there is no special handling for other languages
                   8270:     in pkgsrc.  If a compiler package provides a
                   8271:     <code class="filename">buildlink3.mk</code> file, include that, otherwise
                   8272:     just add a (build) dependency on the appropriate compiler
                   8273:     package.</p>
                   8274: </div>
                   8275: </div>
                   8276: <div class="sect1" lang="en">
                   8277: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   8278: <a name="fixes.build"></a>18.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.77      rillig   8279: <p>The most common failures when building a package are that
                   8280:        some platforms do not provide certain header files, functions or
                   8281:        libraries, or they provide the functions in a library that the
                   8282:        original package author didn't know. To work around this, you
                   8283:        can rewrite the source code in most cases so that it does not
                   8284:        use the missing functions or provides a replacement function.</p>
                   8285: <div class="sect2" lang="en">
                   8286: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8287: <a name="fixes.build.cpp"></a>18.5.1. Compiling C and C++ code conditionally</h3></div></div></div>
1.77      rillig   8288: <p>If a package already comes with a GNU configure script, the
                   8289:        preferred way to fix the build failure is to change the
                   8290:        configure script, not the code. In the other cases, you can
                   8291:        utilize the C preprocessor, which defines certain macros
                   8292:        depending on the operating system and hardware architecture it
                   8293:        compiles for. These macros can be queried using for example
                   8294:        <code class="varname">#if defined(__i386)</code>. Almost every operating
                   8295:        system, hardware architecture and compiler has its own macro.
                   8296:        For example, if the macros <code class="varname">__GNUC__</code>,
                   8297:        <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
                   8298:        are all defined, you know that you are using NetBSD on an i386
                   8299:        compatible CPU, and your compiler is GCC.</p>
                   8300: <p>The list of the following macros for hardware and
                   8301:        operating system depends on the compiler that is used. For
                   8302:        example, if you want to conditionally compile code on Solaris,
                   8303:        don't use <code class="varname">__sun__</code>, as the SunPro compiler
                   8304:        does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75      rillig   8305: <div class="sect3" lang="en">
                   8306: <div class="titlepage"><div><div><h4 class="title">
1.90      rillig   8307: <a name="fixes.build.cpp.os"></a>18.5.1.1. C preprocessor macros to identify the operating system</h4></div></div></div>
1.75      rillig   8308: <p>To distinguish between 4.4 BSD-derived systems and the
                   8309:         rest of the world, you should use the following code.</p>
                   8310: <pre class="programlisting">
                   8311:     #include &lt;sys/param.h&gt;
                   8312:     #if (defined(BSD) &amp;&amp; BSD &gt;= 199306)
                   8313:       /* BSD-specific code goes here */
                   8314:     #else
                   8315:       /* non-BSD-specific code goes here */
                   8316:     #endif
                   8317: </pre>
1.77      rillig   8318: <p>If this distinction is not fine enough, you can also test
                   8319:        for the following macros.</p>
1.75      rillig   8320: <pre class="programlisting">
                   8321:     FreeBSD     __FreeBSD__
                   8322:     DragonFly   __DragonFly__
                   8323:     Interix     __INTERIX
                   8324:     Linux       linux, __linux, __linux__
                   8325:     NetBSD      __NetBSD__
                   8326:     OpenBSD     __OpenBSD__
                   8327:     Solaris     sun, __sun
                   8328: </pre>
                   8329: </div>
                   8330: <div class="sect3" lang="en">
                   8331: <div class="titlepage"><div><div><h4 class="title">
1.90      rillig   8332: <a name="fixes.build.cpp.arch"></a>18.5.1.2. C preprocessor macros to identify the hardware architecture</h4></div></div></div>
1.75      rillig   8333: <pre class="programlisting">
                   8334:     i386        i386, __i386, __i386__
                   8335:     MIPS        __mips
                   8336:     SPARC       sparc, __sparc
                   8337: </pre>
                   8338: </div>
                   8339: <div class="sect3" lang="en">
                   8340: <div class="titlepage"><div><div><h4 class="title">
1.90      rillig   8341: <a name="fixes.build.cpp.compiler"></a>18.5.1.3. C preprocessor macros to identify the compiler</h4></div></div></div>
1.75      rillig   8342: <pre class="programlisting">
                   8343:     GCC         __GNUC__ (major version), __GNUC_MINOR__
                   8344:     SunPro      __SUNPRO_C (0x570 for version 5.7)
1.81      rillig   8345:     SunPro C++  __SUNPRO_CC (0x580 for version 5.8)
1.75      rillig   8346: </pre>
                   8347: </div>
                   8348: </div>
1.78      rillig   8349: <div class="sect2" lang="en">
                   8350: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8351: <a name="compiler-bugs"></a>18.5.2. How to handle compiler bugs</h3></div></div></div>
1.78      rillig   8352: <p>Some source files trigger bugs in the compiler, based on
1.87      wiz      8353:         combinations of compiler version and architecture and almost
                   8354:         always relation to optimisation being enabled.  Common symptoms
                   8355:         are gcc internal errors or never finishing compiling a
1.78      rillig   8356:        file.</p>
                   8357: <p>Typically, a workaround involves testing the
                   8358:         <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
                   8359:         optimisation for that combination of file,
                   8360:        <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
1.87      wiz      8361:        in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
1.78      rillig   8362:        number of examples.</p>
                   8363: </div>
                   8364: <div class="sect2" lang="en">
                   8365: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8366: <a name="undefined-reference"></a>18.5.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</h3></div></div></div>
1.92    ! rillig   8367: <p>This error message often means that a package did not
1.78      rillig   8368:        link to a shared library it needs. The following functions are
                   8369:        known to cause this error message over and over.</p>
                   8370: <div class="informaltable">
                   8371: <a name="undefined-reference-functions"></a><table border="1">
                   8372: <colgroup>
                   8373: <col>
                   8374: <col>
                   8375: <col>
                   8376: </colgroup>
                   8377: <thead><tr>
                   8378: <th>Function</th>
                   8379: <th>Library</th>
                   8380: <th>Affected platforms</th>
                   8381: </tr></thead>
                   8382: <tbody>
                   8383: <tr>
                   8384: <td>accept, bind, connect</td>
                   8385: <td>-lsocket</td>
                   8386: <td>Solaris</td>
                   8387: </tr>
                   8388: <tr>
                   8389: <td>crypt</td>
                   8390: <td>-lcrypt</td>
                   8391: <td>DragonFly, NetBSD</td>
                   8392: </tr>
                   8393: <tr>
                   8394: <td>dlopen, dlsym</td>
                   8395: <td>-ldl</td>
                   8396: <td>Linux</td>
                   8397: </tr>
                   8398: <tr>
                   8399: <td>gethost*</td>
                   8400: <td>-lnsl</td>
                   8401: <td>Solaris</td>
                   8402: </tr>
                   8403: <tr>
                   8404: <td>inet_aton</td>
                   8405: <td>-lresolv</td>
                   8406: <td>Solaris</td>
                   8407: </tr>
                   8408: <tr>
                   8409: <td>nanosleep, sem_*, timer_*</td>
                   8410: <td>-lrt</td>
                   8411: <td>Solaris</td>
                   8412: </tr>
                   8413: <tr>
                   8414: <td>openpty</td>
                   8415: <td>-lutil</td>
                   8416: <td>Linux</td>
                   8417: </tr>
                   8418: </tbody>
                   8419: </table>
                   8420: </div>
                   8421: <p>To fix these linker errors, it is often sufficient to say
1.87      wiz      8422:     <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
                   8423:     -l<em class="replaceable"><code>foo</code></em></code> to the package
                   8424:     <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
                   8425:     bmake</strong></span>.</p>
1.92    ! rillig   8426: <div class="sect3" lang="en">
        !          8427: <div class="titlepage"><div><div><h4 class="title">
        !          8428: <a name="undefined-reference-sunpro"></a>18.5.3.1. Special issue: The SunPro compiler</h4></div></div></div>
        !          8429: <p>When you are using the SunPro compiler, there is another
        !          8430: possibility. That compiler cannot handle the following code:</p>
        !          8431: <pre class="programlisting">
        !          8432:     extern int extern_func(int);
        !          8433:     
        !          8434:     static inline int
        !          8435:     inline_func(int x)
        !          8436:     {
        !          8437:         return extern_func(x);
        !          8438:     }
        !          8439:     
        !          8440:     int main(void)
        !          8441:     {
        !          8442:         return 0;
        !          8443:     }
        !          8444: </pre>
        !          8445: <p>It generates the code for <code class="function">inline_func</code> even if
        !          8446: that function is never used. This code then refers to
        !          8447: <code class="function">extern_func</code>, which can usually not be resolved. To
        !          8448: solve this problem you can try to tell the package to disable inlining
        !          8449: of functions.</p>
        !          8450: </div>
1.87      wiz      8451: </div>
                   8452: <div class="sect2" lang="en">
                   8453: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8454: <a name="out-of-memory"></a>18.5.4. Running out of memory</h3></div></div></div>
1.87      wiz      8455: <p>Sometimes packages fail to build because the compiler runs
                   8456:     into an operating system specific soft limit.  With the
                   8457:     <code class="varname">UNLIMIT_RESOURCES</code> variable pkgsrc can be told
                   8458:     to unlimit the resources.  Currently, the allowed values are
                   8459:     &#8220;<span class="quote">datasize</span>&#8221; and &#8220;<span class="quote">stacksize</span>&#8221; (or both).
                   8460:     Setting this variable is similar to running the shell builtin
                   8461:     <span><strong class="command">ulimit</strong></span> command to raise the maximum data
                   8462:     segment size or maximum stack size of a process, respectively, to
                   8463:     their hard limits.</p>
1.78      rillig   8464: </div>
1.75      rillig   8465: </div>
                   8466: <div class="sect1" lang="en">
                   8467: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   8468: <a name="fixes.install"></a>18.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75      rillig   8469: <div class="sect2" lang="en">
                   8470: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8471: <a name="install-scripts"></a>18.6.1. Creating needed directories</h3></div></div></div>
1.78      rillig   8472: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
1.87      wiz      8473:     with some operating systems cannot create more than one
                   8474:     directory at a time. As such, you should call
                   8475:     <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
                   8476: <pre class="programlisting">
                   8477:       ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   8478:       ${INSTALL_DATA_DIR} ${PREFIX}/dir2
                   8479:     </pre>
1.78      rillig   8480: <p>You can also just append &#8220;<span class="quote"><code class="literal">dir1
1.87      wiz      8481:     dir2</code></span>&#8221; to the
                   8482:     <code class="varname">INSTALLATION_DIRS</code> variable, which will
                   8483:     automatically do the right thing.</p>
1.75      rillig   8484: </div>
                   8485: <div class="sect2" lang="en">
                   8486: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8487: <a name="where-to-install-documentation"></a>18.6.2. Where to install documentation</h3></div></div></div>
1.83      wiz      8488: <p>In general, documentation should be installed into
1.87      wiz      8489:     <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
                   8490:     <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
                   8491:     includes the version number of the package).</p>
1.84      wiz      8492: <p>Many modern packages using GNU autoconf allow to set the
1.87      wiz      8493:     directory where HTML documentation is installed with the
                   8494:     &#8220;<span class="quote">--with-html-dir</span>&#8221; option. Sometimes using this flag
                   8495:     is needed because otherwise the documentation ends up in
                   8496:     <code class="filename">${PREFIX}/share/doc/html</code> or other
                   8497:     places.</p>
                   8498: <p>An exception to the above is that library API documentation
1.91      rillig   8499:     generated with the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/textproc/gtk-doc/README.html" target="_top"><code class="filename">textproc/gtk-doc</code></a> tools, for use by special
1.87      wiz      8500:     browsers (devhelp) should be left at their default location, which
                   8501:     is <code class="filename">${PREFIX}/share/gtk-doc</code>.  Such
                   8502:     documentation can be recognized from files ending in
                   8503:     <code class="filename">.devhelp</code> or <code class="filename">.devhelp2</code>.
                   8504:     (It is also acceptable to install such files in
                   8505:     <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
                   8506:     <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code>; the
                   8507:     <code class="filename">.devhelp*</code> file must be directly in that
                   8508:     directory then, no additional subdirectory level is allowed in
                   8509:     this case. This is usually achieved by using
                   8510:     &#8220;<span class="quote">--with-html-dir=${PREFIX}/share/doc</span>&#8221;.
                   8511:     <code class="filename">${PREFIX}/share/gtk-doc</code> is preferred
                   8512:     though.)</p>
1.75      rillig   8513: </div>
                   8514: <div class="sect2" lang="en">
                   8515: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8516: <a name="installing-score-files"></a>18.6.3. Installing score files</h3></div></div></div>
1.75      rillig   8517: <p>Certain packages, most of them in the games category, install
1.87      wiz      8518:     a score file that allows all users on the system to record their
                   8519:     highscores.  In order for this to work, the binaries need to be
                   8520:     installed setgid and the score files owned by the appropriate
                   8521:     group and/or owner (traditionally the "games" user/group).  The
                   8522:     following variables, documented in more detail in
                   8523:     <code class="filename">mk/defaults/mk.conf</code>, control this
                   8524:     behaviour: <code class="varname">SETGIDGAME</code>,
                   8525:     <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
                   8526:     <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
1.75      rillig   8527: <p>Note that per default, setgid installation of games is
1.87      wiz      8528:     disabled;  setting <code class="varname">SETGIDGAME=YES</code> will set all
                   8529:     the other variables accordingly.</p>
1.75      rillig   8530: <p>A package should therefor never hard code file ownership or
1.87      wiz      8531:     access permissions but rely on <code class="varname">INSTALL_GAME</code> and
                   8532:     <code class="varname">INSTALL_GAME_DATA</code> to set these
                   8533:     correctly.</p>
1.75      rillig   8534: </div>
                   8535: <div class="sect2" lang="en">
                   8536: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8537: <a name="hardcoded-paths"></a>18.6.4. Packages with hardcoded paths to other interpreters</h3></div></div></div>
1.87      wiz      8538: <p>Your package may also contain scripts with hardcoded paths to
                   8539:       other interpreters besides (or as well as) perl.  To correct the
                   8540:       full pathname to the script interpreter, you need to set the
                   8541:       following definitions in your <code class="filename">Makefile</code> (we
                   8542:     shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
                   8543: <pre class="programlisting">
                   8544:       REPLACE_INTERPRETER+=   tcl
                   8545:       REPLACE.tcl.old=        .*/bin/tclsh
                   8546:       REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   8547:       REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   8548:       # relative to ${WRKSRC}, just as in REPLACE_PERL
                   8549:     </pre>
1.75      rillig   8550: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   8551: <h3 class="title">Note</h3>
                   8552: <p>Before March 2006, these variables were called
1.87      wiz      8553:     <code class="varname">_REPLACE.*</code> and
                   8554:     <code class="varname">_REPLACE_FILES.*</code>.</p>
1.75      rillig   8555: </div>
                   8556: </div>
                   8557: <div class="sect2" lang="en">
                   8558: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8559: <a name="perl-modules"></a>18.6.5. Packages installing perl modules</h3></div></div></div>
1.75      rillig   8560: <p>Makefiles of packages providing perl5 modules should include
1.87      wiz      8561:     the Makefile fragment
                   8562:     <code class="filename">../../lang/perl5/module.mk</code>.  It provides a
                   8563:     <span><strong class="command">do-configure</strong></span> target for the standard perl
                   8564:     configuration for such modules as well as various hooks to tune
                   8565:     this configuration.  See comments in this file for
                   8566:     details.</p>
1.75      rillig   8567: <p>Perl5 modules will install into different places depending
1.87      wiz      8568:     on the version of perl used during the build process.  To
                   8569:     address this, pkgsrc will append lines to the
                   8570:     <code class="filename">PLIST</code> corresponding to the files listed in
                   8571:     the installed <code class="filename">.packlist</code> file generated by
                   8572:     most perl5 modules.  This is invoked by defining
                   8573:     <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
                   8574:     paths to packlist files, e.g.:</p>
1.75      rillig   8575: <pre class="programlisting">
1.87      wiz      8576:       PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
                   8577:     </pre>
1.75      rillig   8578: <p>The variables <code class="varname">PERL5_SITELIB</code>,
1.87      wiz      8579:     <code class="varname">PERL5_SITEARCH</code>, and
                   8580:     <code class="varname">PERL5_ARCHLIB</code> represent the three locations
                   8581:     in which perl5 modules may be installed, and may be used by
                   8582:     perl5 packages that don't have a packlist.  These three
                   8583:     variables are also substituted for in the
                   8584:     <code class="filename">PLIST</code>.</p>
1.75      rillig   8585: </div>
                   8586: <div class="sect2" lang="en">
                   8587: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8588: <a name="faq.info-files"></a>18.6.6. Packages installing info files</h3></div></div></div>
1.75      rillig   8589: <p>Some packages install info files or use the
1.87      wiz      8590:     &#8220;<span class="quote">makeinfo</span>&#8221;  or &#8220;<span class="quote">install-info</span>&#8221;
                   8591:     commands.  <code class="varname">INFO_FILES</code> should be defined in
                   8592:     the package Makefile so that <code class="filename">INSTALL</code> and
                   8593:     <code class="filename">DEINSTALL</code> scripts will be generated to
                   8594:     handle registration of the info files in the Info directory
                   8595:     file. The &#8220;<span class="quote">install-info</span>&#8221; command used for the info
                   8596:     files registration is either provided by the system, or by a
                   8597:     special purpose package automatically added as dependency if
                   8598:     needed.</p>
1.75      rillig   8599: <p><code class="varname">PKGINFODIR</code> is the directory under
1.87      wiz      8600:     <code class="filename">${PREFIX}</code> where info files are primarily
                   8601:     located. <code class="varname">PKGINFODIR</code> defaults to
                   8602:     &#8220;<span class="quote">info</span>&#8221; and can be overridden by the user.</p>
1.75      rillig   8603: <p>The info files for the package should be listed in the
1.87      wiz      8604:     package <code class="filename">PLIST</code>; however any split info files
                   8605:     need not be listed.</p>
1.75      rillig   8606: <p>A package which needs the &#8220;<span class="quote">makeinfo</span>&#8221; command
1.87      wiz      8607:     at build time must add &#8220;<span class="quote">makeinfo</span>&#8221; to
                   8608:     <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
                   8609:     version of the &#8220;<span class="quote">makeinfo</span>&#8221; command is needed it
                   8610:     should be noted with the <code class="varname">TEXINFO_REQD</code>
                   8611:     variable in the package <code class="filename">Makefile</code>. By
                   8612:     default, a minimum version of 3.12 is required. If the system
                   8613:     does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
                   8614:     does not match the required minimum, a build dependency on the
1.91      rillig   8615:     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/gtexinfo/README.html" target="_top"><code class="filename">devel/gtexinfo</code></a> package will
1.87      wiz      8616:     be added automatically.</p>
1.75      rillig   8617: <p>The build and installation process of the software provided
1.87      wiz      8618:     by the package should not use the
                   8619:     <span><strong class="command">install-info</strong></span> command as the registration of
                   8620:     info files is the task of the package
                   8621:     <code class="filename">INSTALL</code> script, and it must use the
                   8622:     appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
1.75      rillig   8623: <p>To achieve this goal, the pkgsrc infrastructure creates
1.87      wiz      8624:     overriding scripts for the <span><strong class="command">install-info</strong></span> and
                   8625:     <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
                   8626:     in <code class="varname">PATH</code>.</p>
1.75      rillig   8627: <p>The script overriding <span><strong class="command">install-info</strong></span> has
1.87      wiz      8628:     no effect except the logging of a message. The script overriding
                   8629:     <span><strong class="command">makeinfo</strong></span> logs a message and according to the
                   8630:     value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
                   8631:     <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
1.75      rillig   8632: </div>
                   8633: <div class="sect2" lang="en">
                   8634: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8635: <a name="manpages"></a>18.6.7. Packages installing man pages</h3></div></div></div>
1.81      rillig   8636: <p>All packages that install manual pages should install them
1.87      wiz      8637:     into the same directory, so that there is one common place to look
                   8638:     for them. In pkgsrc, this place is
                   8639:     <code class="literal">${PREFIX}/${PKGMANDIR}</code>, and this expression
                   8640:     should be used in packages. The default for
                   8641:     <code class="varname">PKGMANDIR</code> is
                   8642:     &#8220;<span class="quote"><code class="filename">man</code></span>&#8221;. Another often-used value
                   8643:     is &#8220;<span class="quote"><code class="filename">share/man</code></span>&#8221;.</p>
1.75      rillig   8644: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   8645: <h3 class="title">Note</h3>
1.87      wiz      8646: <p>The support for a custom <code class="varname">PKGMANDIR</code>
                   8647:     is far from complete.</p>
1.75      rillig   8648: </div>
1.81      rillig   8649: <p>The <code class="filename">PLIST</code> files can just use
1.87      wiz      8650:     <code class="filename">man/</code> as the top level directory for the man
                   8651:     page file entries, and the pkgsrc framework will convert as
                   8652:     needed. In all other places, the correct
                   8653:     <code class="varname">PKGMANDIR</code> must be used.</p>
                   8654: <p>Packages that are
                   8655:     configured with <code class="varname">GNU_CONFIGURE</code> set as
                   8656:     &#8220;<span class="quote">yes</span>&#8221;, by default will use the
                   8657:     <code class="filename">./configure</code>
                   8658:     --mandir switch to set where the man pages should be installed.
                   8659:     The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
                   8660:     to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.</p>
                   8661: <p>Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
                   8662:     use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
                   8663:     to &#8220;<span class="quote">no</span>&#8221;.
                   8664:     Or if the <code class="filename">./configure</code> script uses
                   8665:     a non-standard use of --mandir, you can set
                   8666:     <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.</p>
1.90      rillig   8667: <p>See <a href="#manpage-compression" title="12.5. Man page compression">Section 12.5, &#8220;Man page compression&#8221;</a> for
1.87      wiz      8668:     information on installation of compressed manual pages.</p>
1.75      rillig   8669: </div>
                   8670: <div class="sect2" lang="en">
                   8671: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8672: <a name="gconf2-data-files"></a>18.6.8. Packages installing GConf2 data files</h3></div></div></div>
1.87      wiz      8673: <p>If a package installs <code class="filename">.schemas</code> or
                   8674:     <code class="filename">.entries</code> files, used by GConf2,
                   8675:     you need to take some extra steps to make sure they get registered
                   8676:     in the database:</p>
1.75      rillig   8677: <div class="orderedlist"><ol type="1">
1.76      rillig   8678: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
1.87      wiz      8679:        instead of its <code class="filename">buildlink3.mk</code> file.  This
                   8680:        takes care of rebuilding the GConf2 database at installation and
                   8681:        deinstallation time, and tells the package where to install
                   8682:        GConf2 data files using some standard configure arguments.  It
                   8683:        also disallows any access to the database directly from the
                   8684:        package.</p></li>
1.75      rillig   8685: <li><p>Ensure that the package installs its
1.87      wiz      8686:        <code class="filename">.schemas</code> files under
                   8687:        <code class="filename">${PREFIX}/share/gconf/schemas</code>.  If they get
                   8688:        installed under <code class="filename">${PREFIX}/etc</code>, you will
                   8689:        need to manually patch the package.</p></li>
1.75      rillig   8690: <li><p>Check the PLIST and remove any entries under the etc/gconf
1.87      wiz      8691:        directory, as they will be handled automatically.  See
1.90      rillig   8692:        <a href="#faq.conf" title="8.14. How do I change the location of configuration files?">Section 8.14, &#8220;How do I change the location of configuration files?&#8221;</a> for more information.</p></li>
1.75      rillig   8693: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.87      wiz      8694:        your <code class="filename">Makefile</code> with a list of all
                   8695:        <code class="filename">.schemas</code> files installed by the package, if
                   8696:        any.  Names must not contain any directories in them.</p></li>
1.75      rillig   8697: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.87      wiz      8698:        your <code class="filename">Makefile</code> with a
                   8699:        list of all <code class="filename">.entries</code> files installed by the
                   8700:        package, if any. Names must not contain any directories in
                   8701:        them.</p></li>
1.75      rillig   8702: </ol></div>
                   8703: </div>
                   8704: <div class="sect2" lang="en">
                   8705: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8706: <a name="scrollkeeper-data-files"></a>18.6.9. Packages installing scrollkeeper data files</h3></div></div></div>
1.87      wiz      8707: <p>If a package installs <code class="filename">.omf</code> files, used by
                   8708:     scrollkeeper, you need to take some extra steps to make sure they
                   8709:     get registered in the database:</p>
1.75      rillig   8710: <div class="orderedlist"><ol type="1">
                   8711: <li><p>Include
1.87      wiz      8712:        <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
                   8713:        instead of its <code class="filename">buildlink3.mk</code> file.  This
                   8714:        takes care of rebuilding the scrollkeeper database at
                   8715:        installation and deinstallation time, and disallows any access
                   8716:        to it directly from the package.</p></li>
1.75      rillig   8717: <li><p>Check the PLIST and remove any entries under the
1.87      wiz      8718:        <code class="filename">libdata/scrollkeeper</code> directory, as they
                   8719:        will be handled automatically.</p></li>
1.76      rillig   8720: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.87      wiz      8721:        the PLIST.  It will be handled by scrollkeeper.</p></li>
1.75      rillig   8722: </ol></div>
                   8723: </div>
                   8724: <div class="sect2" lang="en">
                   8725: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8726: <a name="x11-fonts"></a>18.6.10. Packages installing X11 fonts</h3></div></div></div>
1.75      rillig   8727: <p>If a package installs font files, you will need to rebuild
1.87      wiz      8728:     the fonts database in the directory where they get installed at
                   8729:     installation and deinstallation time.  This can be automatically
                   8730:     done by using the pkginstall framework.</p>
1.75      rillig   8731: <p>You can list the directories where fonts are installed in the
1.87      wiz      8732:     <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
                   8733:     variables, where <em class="replaceable"><code>type</code></em> can be one of
                   8734:     &#8220;<span class="quote">ttf</span>&#8221;, &#8220;<span class="quote">type1</span>&#8221; or &#8220;<span class="quote">x11</span>&#8221;.
                   8735:     Also make sure that the database file
                   8736:     <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75      rillig   8737: <p>Note that you should not create new directories for fonts;
1.87      wiz      8738:     instead use the standard ones to avoid that the user needs to
                   8739:     manually configure his X server to find them.</p>
1.75      rillig   8740: </div>
                   8741: <div class="sect2" lang="en">
                   8742: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8743: <a name="gtk2-modules"></a>18.6.11. Packages installing GTK2 modules</h3></div></div></div>
1.75      rillig   8744: <p>If a package installs GTK2 immodules or loaders, you need to
1.87      wiz      8745:     take some extra steps to get them registered in the GTK2 database
                   8746:     properly:</p>
1.75      rillig   8747: <div class="orderedlist"><ol type="1">
                   8748: <li><p>Include
1.87      wiz      8749:       <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
                   8750:       <code class="filename">buildlink3.mk</code> file.  This takes care of
                   8751:       rebuilding the database at installation and deinstallation time.</p></li>
                   8752: <li><p>Set <code class="varname">GTK2_IMMODULES=YES</code> if
                   8753:       your package installs GTK2 immodules.</p></li>
                   8754: <li><p>Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
                   8755:       GTK2 loaders.</p></li>
1.75      rillig   8756: <li>
1.87      wiz      8757: <p>Patch the package to not touch any of the GTK2
                   8758:       databases directly.  These are:</p>
1.75      rillig   8759: <div class="itemizedlist"><ul type="disc">
1.76      rillig   8760: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
                   8761: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75      rillig   8762: </ul></div>
                   8763: </li>
1.87      wiz      8764: <li><p>Check the <code class="filename">PLIST</code> and remove
                   8765:       any entries under the <code class="filename">libdata/gtk-2.0</code>
                   8766:       directory, as they will be handled automatically.</p></li>
1.75      rillig   8767: </ol></div>
                   8768: </div>
                   8769: <div class="sect2" lang="en">
                   8770: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8771: <a name="sgml-xml-data"></a>18.6.12. Packages installing SGML or XML data</h3></div></div></div>
1.75      rillig   8772: <p>If a package installs SGML or XML data files that need to be
1.87      wiz      8773:     registered in system-wide catalogs (like DTDs, sub-catalogs,
                   8774:     etc.), you need to take some extra steps:</p>
1.75      rillig   8775: <div class="orderedlist"><ol type="1">
                   8776: <li><p>Include
1.87      wiz      8777:        <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
                   8778:        your <code class="filename">Makefile</code>, which takes care of
                   8779:        registering those files in system-wide catalogs at
                   8780:        installation and deinstallation time.</p></li>
1.75      rillig   8781: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
1.87      wiz      8782:        any SGML catalogs installed by the package.</p></li>
1.75      rillig   8783: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
1.87      wiz      8784:        any XML catalogs installed by the package.</p></li>
1.75      rillig   8785: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
1.87      wiz      8786:        to be added to the SGML catalog.  These come in groups of
                   8787:        three strings; see xmlcatmgr(1) for more information
                   8788:        (specifically, arguments recognized by the 'add' action).
                   8789:        Note that you will normally not use this variable.</p></li>
1.75      rillig   8790: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
1.87      wiz      8791:        to be added to the XML catalog.  These come in groups of three
                   8792:        strings; see xmlcatmgr(1) for more information (specifically,
                   8793:        arguments recognized by the 'add' action).  Note that you will
                   8794:        normally not use this variable.</p></li>
1.75      rillig   8795: </ol></div>
                   8796: </div>
                   8797: <div class="sect2" lang="en">
                   8798: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8799: <a name="mime-database"></a>18.6.13. Packages installing extensions to the MIME database</h3></div></div></div>
1.75      rillig   8800: <p>If a package provides extensions to the MIME database by
1.87      wiz      8801:     installing <code class="filename">.xml</code> files inside
                   8802:     <code class="filename">${PREFIX}/share/mime/packages</code>, you
                   8803:     need to take some extra steps to ensure that the database is kept
                   8804:     consistent with respect to these new files:</p>
1.75      rillig   8805: <div class="orderedlist"><ol type="1">
                   8806: <li><p>Include
1.87      wiz      8807:        <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
                   8808:        (avoid using the <code class="filename">buildlink3.mk</code> file from
                   8809:        this same directory, which is reserved for inclusion from
                   8810:        other <code class="filename">buildlink3.mk</code> files).  It takes
                   8811:        care of rebuilding the MIME database at installation and
                   8812:        deinstallation time, and disallows any access to it directly
                   8813:        from the package.</p></li>
1.75      rillig   8814: <li><p>Check the PLIST and remove any entries under the
1.87      wiz      8815:        <code class="filename">share/mime</code> directory,
                   8816:        <span class="emphasis"><em>except</em></span> for files saved under
                   8817:        <code class="filename">share/mime/packages</code>.  The former are
                   8818:        handled automatically by
                   8819:        the update-mime-database program, but the latter are
                   8820:        package-dependent and must be removed by the package that
                   8821:        installed them in the first place.</p></li>
1.76      rillig   8822: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.87      wiz      8823:        from the PLIST.  They will be handled by the shared-mime-info
                   8824:        package.</p></li>
1.75      rillig   8825: </ol></div>
                   8826: </div>
                   8827: <div class="sect2" lang="en">
                   8828: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8829: <a name="intltool"></a>18.6.14. Packages using intltool</h3></div></div></div>
1.75      rillig   8830: <p>If a package uses intltool during its build, include the
1.87      wiz      8831:     <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
                   8832:     which forces it to use the intltool package provided by pkgsrc,
                   8833:     instead of the one bundled with the distribution file.</p>
1.75      rillig   8834: <p>This tracks intltool's build-time dependencies and uses the
1.87      wiz      8835:     latest available version; this way, the package benefits of any
                   8836:     bug fixes that may have appeared since it was released.</p>
1.75      rillig   8837: </div>
                   8838: <div class="sect2" lang="en">
                   8839: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8840: <a name="startup-scripts"></a>18.6.15. Packages installing startup scripts</h3></div></div></div>
1.75      rillig   8841: <p>If a package contains a rc.d script, it won't be copied into
1.87      wiz      8842:     the startup directory by default, but you can enable it, by adding
                   8843:     the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
                   8844:     <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
                   8845:     into <code class="filename">/etc/rc.d</code> when a package is installed, and
                   8846:     it will automatically remove the scripts when the package is
                   8847:     deinstalled.</p>
1.75      rillig   8848: </div>
                   8849: <div class="sect2" lang="en">
                   8850: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8851: <a name="tex-packages"></a>18.6.16. Packages installing TeX modules</h3></div></div></div>
1.75      rillig   8852: <p>If a package installs TeX packages into the texmf tree,
1.87      wiz      8853:     the <code class="filename">ls-R</code> database of the tree needs to be
                   8854:     updated.</p>
1.75      rillig   8855: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   8856: <h3 class="title">Note</h3>
                   8857: <p>Except the main TeX packages such as teTeX-texmf,
1.87      wiz      8858:     packages should install files
                   8859:     into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
                   8860:     not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
1.75      rillig   8861: </div>
                   8862: <div class="orderedlist"><ol type="1">
                   8863: <li><p>Include
1.87      wiz      8864:       <code class="filename">../../print/teTeX/module.mk</code> instead
                   8865:       of <code class="filename">../../mk/tex.buildlink3.mk</code>.  This
                   8866:       takes care of rebuilding the <code class="filename">ls-R</code>
                   8867:       database at installation and deinstallation time.</p></li>
1.75      rillig   8868: <li>
                   8869: <p>If your package installs files into a texmf
1.87      wiz      8870:       tree other than the one
                   8871:       at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
                   8872:       set <code class="varname">TEXMFDIRS</code> to the list of all texmf
                   8873:       trees that need database update.</p>
1.75      rillig   8874: <p>If your package also installs font map files that need
1.87      wiz      8875:       to be registered using <span><strong class="command">updmap</strong></span>,
                   8876:       set <code class="varname">TEX_FONTMAPS</code> to the list of all
                   8877:       such font map files.  Then <span><strong class="command">updmap</strong></span> will
                   8878:       be run automatically at installation/deinstallation to
                   8879:       enable/disable font map files for TeX output
                   8880:       drivers.</p>
1.75      rillig   8881: </li>
1.76      rillig   8882: <li><p>Make sure that none of <code class="filename">ls-R</code>
1.87      wiz      8883:       databases are included in <code class="filename">PLIST</code>, as
                   8884:       they will be removed only by the teTeX-bin package.</p></li>
1.75      rillig   8885: </ol></div>
                   8886: </div>
1.85      jmmv     8887: <div class="sect2" lang="en">
                   8888: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8889: <a name="emulation-packages"></a>18.6.17. Packages supporting running binaries in
1.87      wiz      8890:     emulation</h3></div></div></div>
                   8891: <p>There are some packages that provide libraries and
                   8892:     executables for running binaries from a one operating system
                   8893:     on a different one (if the latter supports it).  One example
                   8894:     is running Linux binaries on NetBSD.</p>
1.91      rillig   8895: <p>The <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>
1.87      wiz      8896:     helps in extracting and packaging Linux rpm packages.</p>
                   8897: <p>The <code class="varname">CHECK_SHLIBS</code> can be set to no to
                   8898:     avoid the <span><strong class="command">check-shlibs</strong></span> target, which tests
                   8899:     if all libraries for each installed executable can be found by
                   8900:     the dynamic linker.  Since the standard dynamic linker is run,
                   8901:     this fails for emulation packages, because the libraries used
                   8902:     by the emulation are not in the standard directories.</p>
                   8903: </div>
                   8904: <div class="sect2" lang="en">
                   8905: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8906: <a name="hicolor-theme"></a>18.6.18. Packages installing hicolor theme icons</h3></div></div></div>
1.85      jmmv     8907: <p>If a package installs images under the
1.87      wiz      8908:     <code class="filename">share/icons/hicolor</code> and/or updates the
                   8909:     <code class="filename">share/icons/hicolor/icon-theme.cache</code>
                   8910:     database, you need to take some extra steps to make sure that the
                   8911:     shared theme directory is handled appropriately and that the cache
                   8912:     database is rebuilt:</p>
1.85      jmmv     8913: <div class="orderedlist"><ol type="1">
                   8914: <li><p>Include
1.87      wiz      8915:        <code class="filename">../../graphics/hicolor-icon-theme/buildlink3.mk</code>.</p></li>
                   8916: <li><p>Check the <code class="filename">PLIST</code> and remove the
                   8917:        entry that refers to the theme cache.</p></li>
1.85      jmmv     8918: <li><p>Ensure that the PLIST does not remove the shared icon
                   8919:          directories from the <code class="filename">share/icons/hicolor</code>
                   8920:          hierarchy because they will be handled automatically.</p></li>
                   8921: </ol></div>
                   8922: <p>The best way to verify that the PLIST is correct with
                   8923:       respect to the last two points is to regenerate it using
                   8924:       <span><strong class="command">make print-PLIST</strong></span>.</p>
                   8925: </div>
                   8926: <div class="sect2" lang="en">
                   8927: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   8928: <a name="desktop-files"></a>18.6.19. Packages installing desktop files</h3></div></div></div>
1.85      jmmv     8929: <p>If a package installs <code class="filename">.desktop</code> files
                   8930:       under <code class="filename">share/applications</code> and these include
                   8931:       MIME information, you need to take extra steps to ensure that they
                   8932:       are registered into the MIME database:</p>
                   8933: <div class="orderedlist"><ol type="1">
                   8934: <li><p>Include
                   8935:          <code class="filename">../../sysutils/desktop-file-utils/desktopdb.mk</code>.</p></li>
                   8936: <li><p>Check the PLIST and remove the entry that refers to the
                   8937:          <code class="filename">share/applications/mimeinfo.cache</code> file.
                   8938:          It will be handled automatically.</p></li>
                   8939: </ol></div>
                   8940: <p>The best way to verify that the PLIST is correct with
                   8941:       respect to the last point is to regenerate it using <span><strong class="command">make
                   8942:       print-PLIST</strong></span>.</p>
1.75      rillig   8943: </div>
                   8944: </div>
1.87      wiz      8945: <div class="sect1" lang="en">
                   8946: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   8947: <a name="punting"></a>18.7. Marking packages as having problems</h2></div></div></div>
1.87      wiz      8948: <p>In some cases one does not have the time to solve a problem
                   8949:   immediately.  There are currently two ways to declare that one knows
                   8950:   that a package has problems.</p>
                   8951: <div class="itemizedlist"><ul type="disc">
                   8952: <li><p>The first way is to plainly mark it as broken.  For
                   8953:     this, one just sets the variable <code class="varname">BROKEN</code> to the
                   8954:     reason why the package is broken (similar to the
                   8955:     <code class="varname">RESTRICTED</code> variable).  A user trying to build
                   8956:     the package will immediately be shown this message, and the build
                   8957:     will not be even tried.</p></li>
                   8958: <li><p>After each pkgsrc freeze period (a time when the
                   8959:     tree is stabilized and a new pkgsrc branch is cut), the packages
                   8960:     that were not building in the official branch build on the latest
                   8961:     NetBSD release will be marked as broken on that branch.  This is
                   8962:     done by setting the <code class="varname">BROKEN_IN</code> variable to the
                   8963:     branch name (or appending the branch name to it).  If a user tries
                   8964:     to build such a package and the build fails, the user gets a
                   8965:     message that says that the package was broken on the respective
                   8966:     branch(es).</p></li>
                   8967: </ul></div>
                   8968: <p>Both types of packages are removed from pkgsrc in irregular
                   8969:   intervals.</p>
                   8970: </div>
1.75      rillig   8971: </div>
                   8972: <div class="chapter" lang="en">
                   8973: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   8974: <a name="debug"></a>Chapter 19. Debugging</h2></div></div></div>
1.88      wiz      8975: <p>To check out all the gotchas when building a package, here are
                   8976:   the steps that I do in order to get a package working.  Please note
                   8977:   this is basically the same as what was explained in the previous
                   8978:   sections, only with some debugging aids.</p>
1.75      rillig   8979: <div class="itemizedlist"><ul type="disc">
1.88      wiz      8980: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code> in
                   8981:       <code class="filename">/etc/mk.conf</code></p></li>
1.75      rillig   8982: <li>
1.91      rillig   8983: <p>Install <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>,
1.88      wiz      8984:       create a directory for a new package, change into it, then run
                   8985:       <span><strong class="command">url2pkg</strong></span>:</p>
1.75      rillig   8986: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>mkdir /usr/pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>examplepkg</code></em></code></strong>
                   8987: <code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>examplepkg</code></em></code></strong>
                   8988: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
                   8989: </li>
1.76      rillig   8990: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
                   8991: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.87      wiz      8992: <li><p>Run <span><strong class="command">make configure</strong></span></p></li>
1.75      rillig   8993: <li><p>Add any dependencies glimpsed from documentation and the
1.88      wiz      8994:       configure step to the package's
                   8995:       <code class="filename">Makefile</code>.</p></li>
1.75      rillig   8996: <li>
                   8997: <p>Make the package compile, doing multiple rounds of</p>
                   8998: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
                   8999: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
                   9000: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
                   9001: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
                   9002: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
                   9003: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
                   9004: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
1.88      wiz      9005: <p>Doing this step as non-root user will ensure that no files
                   9006:       are modified that shouldn't be, especially during the build
                   9007:       phase.  <span><strong class="command">mkpatches</strong></span>,
                   9008:       <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
1.91      rillig   9009:       from the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>
1.88      wiz      9010:       package.</p>
1.75      rillig   9011: </li>
1.88      wiz      9012: <li><p>Look at the <code class="filename">Makefile</code>, fix if
1.90      rillig   9013:       necessary; see <a href="#components.Makefile" title="10.1. Makefile">Section 10.1, &#8220;<code class="filename">Makefile</code>&#8221;</a>.</p></li>
1.75      rillig   9014: <li>
1.76      rillig   9015: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75      rillig   9016: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
                   9017: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST &gt;PLIST</code></strong>
                   9018: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
                   9019: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
                   9020: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.88      wiz      9021: <p>You usually need to be <code class="username">root</code> to do
                   9022:       this.  Look if there are any files left:</p>
1.75      rillig   9023: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
                   9024: <p>If this reveals any files that are missing in
1.88      wiz      9025:       <code class="filename">PLIST</code>, add them.</p>
1.75      rillig   9026: </li>
                   9027: <li>
1.88      wiz      9028: <p>Now that the <code class="filename">PLIST</code> is OK, install the
                   9029:       package again and make a binary package:</p>
1.75      rillig   9030: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
                   9031: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
                   9032: </li>
                   9033: <li>
                   9034: <p>Delete the installed package:</p>
1.88      wiz      9035: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete <em class="replaceable"><code>examplepkg</code></em></code></strong></pre>
1.75      rillig   9036: </li>
                   9037: <li>
1.88      wiz      9038: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span>
                   9039:       command, which shouldn't find anything now:</p>
1.75      rillig   9040: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
                   9041: </li>
                   9042: <li>
                   9043: <p>Reinstall the binary package:</p>
1.88      wiz      9044: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../<em class="replaceable"><code>examplepkg</code></em>.tgz</code></strong></pre>
1.75      rillig   9045: </li>
1.88      wiz      9046: <li><p>Play with it.  Make sure everything works.</p></li>
1.75      rillig   9047: <li>
1.91      rillig   9048: <p>Run <span><strong class="command">pkglint</strong></span> from <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>, and fix the problems it
1.88      wiz      9049:       reports:</p>
1.75      rillig   9050: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
                   9051: </li>
1.90      rillig   9052: <li><p>Submit (or commit, if you have cvs access); see <a href="#submit" title="Chapter 20. Submitting and Committing">Chapter 20, <i>Submitting and Committing</i></a>.</p></li>
1.75      rillig   9053: </ul></div>
                   9054: </div>
                   9055: <div class="chapter" lang="en">
                   9056: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   9057: <a name="submit"></a>Chapter 20. Submitting and Committing</h2></div></div></div>
1.75      rillig   9058: <div class="toc">
                   9059: <p><b>Table of Contents</b></p>
                   9060: <dl>
1.90      rillig   9061: <dt><span class="sect1"><a href="#submitting-binary-packages">20.1. Submitting binary packages</a></span></dt>
                   9062: <dt><span class="sect1"><a href="#submitting-your-package">20.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                   9063: <dt><span class="sect1"><a href="#general-notes-for-changes">20.3. General notes when adding, updating, or removing packages</a></span></dt>
                   9064: <dt><span class="sect1"><a href="#committing-importing">20.4. Committing: Importing a package into CVS</a></span></dt>
                   9065: <dt><span class="sect1"><a href="#updating-package">20.5. Updating a package to a newer version</a></span></dt>
                   9066: <dt><span class="sect1"><a href="#moving-package">20.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig   9067: </dl>
                   9068: </div>
                   9069: <div class="sect1" lang="en">
                   9070: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9071: <a name="submitting-binary-packages"></a>20.1. Submitting binary packages</h2></div></div></div>
1.75      rillig   9072: <p>Our policy is that we accept binaries only from pkgsrc
                   9073:        developers to guarantee that the packages don't contain any
                   9074:        trojan horses etc. This is not to annoy anyone but rather to
                   9075:        protect our users! You're still free to put up your home-made
                   9076:        binary packages and tell the world where to get them. NetBSD
                   9077:        developers doing bulk builds and wanting to upload them please
                   9078:        see <a href="#bulk-upload" title="6.3.8. Uploading results of a bulk build">Section 6.3.8, &#8220;Uploading results of a bulk build&#8221;</a>.</p>
                   9079: </div>
                   9080: <div class="sect1" lang="en">
                   9081: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9082: <a name="submitting-your-package"></a>20.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75      rillig   9083: <p>First, check that your package is complete, compiles and
1.90      rillig   9084:        runs well; see <a href="#debug" title="Chapter 19. Debugging">Chapter 19, <i>Debugging</i></a> and the rest of this
1.75      rillig   9085:        document. Next, generate an uuencoded gzipped <a href="http://netbsd.gw.com/cgi-bin/man-cgi?tar+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span></a>
1.82      rillig   9086:        archive that contains all files that make up the package.
1.87      wiz      9087:        Finally, send this package to the pkgsrc bug tracking system,
                   9088:        either with the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">send-pr</span>(1)</span></a> command, or if you don't have
                   9089:        that, go to the web page
                   9090:        <a href="http://www.NetBSD.org/Misc/send-pr.html" target="_top">http://www.NetBSD.org/Misc/send-pr.html</a>,
                   9091:        which contains some instructions and a link to a form, where you
                   9092:        can submit packages.</p>
                   9093: <p>In the form of the problem report, the category should be
                   9094:        &#8220;<span class="quote">pkg</span>&#8221;, the synopsis should include the package name
                   9095:        and version number, and the description field should contain a
                   9096:        short description of your package (contents of the COMMENT
                   9097:        variable or DESCR file are OK). The uuencoded package data should
                   9098:        go into the &#8220;<span class="quote">fix</span>&#8221; field.</p>
1.75      rillig   9099: <p>If you want to submit several packages, please send a
                   9100:        separate PR for each one, it's easier for us to track things
                   9101:        that way.</p>
                   9102: <p>Alternatively, you can also import new packages into
                   9103:        pkgsrc-wip (&#8220;<span class="quote">pkgsrc work-in-progress</span>&#8221;); see the
                   9104:        homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
                   9105:        for details.</p>
                   9106: </div>
                   9107: <div class="sect1" lang="en">
                   9108: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9109: <a name="general-notes-for-changes"></a>20.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75      rillig   9110: <p>Please note all package additions, updates, moves, and
1.76      rillig   9111:        removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75      rillig   9112:        important to keep this file up to date and conforming to the
                   9113:        existing format, because it will be used by scripts to
                   9114:        automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
                   9115:        sites. Additionally, check the
1.76      rillig   9116:        <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75      rillig   9117:        for the package you updated or removed, in case it was mentioned
                   9118:        there.</p>
                   9119: <p>When the <code class="varname">PKGREVISION</code> of a package is
                   9120:        bumped, the change should appear in
1.76      rillig   9121:        <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75      rillig   9122:        related or otherwise relevant. Mass bumps that result from a
                   9123:        dependency being updated should not be mentioned. In all other
                   9124:        cases it's the developer's decision.</p>
                   9125: <p>There is a make target that helps in creating proper
1.76      rillig   9126:   <code class="filename">CHANGES</code> entries:  <span><strong class="command">make
1.75      rillig   9127:   changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
                   9128:   and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76      rillig   9129:   usage is to first make sure that your <code class="filename">CHANGES</code>
1.75      rillig   9130:   file is up-to-date (to avoid having to resolve conflicts later-on)
                   9131:   and then to <span><strong class="command">cd</strong></span> to the package directory.  For
                   9132:   package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
                   9133:   For new packages, or package moves or removals, set the
                   9134:   <code class="varname">CTYPE</code> variable on the command line to "Added",
                   9135:   "Moved", or "Removed".  You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76      rillig   9136:   in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75      rillig   9137:   not the same as your NetBSD login name. Don't forget to commit
1.76      rillig   9138:   the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75      rillig   9139: </div>
                   9140: <div class="sect1" lang="en">
                   9141: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9142: <a name="committing-importing"></a>20.4. Committing: Importing a package into CVS</h2></div></div></div>
1.87      wiz      9143: <p>This section is only of interest for pkgsrc developers with write
1.75      rillig   9144:   access to the pkgsrc repository. Please remember that cvs
                   9145:   imports files relative to the current working directory, and that
                   9146:   the pathname that you
                   9147:   give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
                   9148:   to place the files in the repository.  Newly created packages should be
                   9149:   imported with a vendor tag of &#8220;<span class="quote">TNF</span>&#8221; and a release tag of
1.87      wiz      9150:   &#8220;<span class="quote">pkgsrc-base</span>&#8221;, e.g:</p>
1.75      rillig   9151: <pre class="programlisting">
                   9152:     <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
                   9153:     <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
                   9154: </pre>
1.87      wiz      9155: <p>Remember to move the directory from which you imported out of
1.75      rillig   9156:   the way, or cvs will complain the next time you &#8220;<span class="quote">cvs
                   9157:   update</span>&#8221; your source tree.  Also don't forget to add the new
1.87      wiz      9158:   package to the category's <code class="filename">Makefile</code>.</p>
                   9159: <p>The commit message of the initial import should include part of the
1.76      rillig   9160:   <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.87      wiz      9161:   what the package is/does.</p>
                   9162: <p>For new packages, &#8220;<span class="quote">cvs import</span>&#8221; is preferred to &#8220;<span class="quote">cvs
1.75      rillig   9163:   add</span>&#8221; because the former gets everything with a single command,
1.87      wiz      9164:   and provides a consistent tag.</p>
1.75      rillig   9165: </div>
                   9166: <div class="sect1" lang="en">
                   9167: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9168: <a name="updating-package"></a>20.5. Updating a package to a newer version</h2></div></div></div>
1.87      wiz      9169: <p>Please always put a concise, appropriate and relevant summary of the
1.75      rillig   9170:   changes between old and new versions into the commit log when updating
1.87      wiz      9171:   a package. There are various reasons for this:</p>
1.75      rillig   9172: <div class="itemizedlist"><ul type="disc">
1.87      wiz      9173: <li><p>A URL is volatile, and can change over time. It may go away completely
                   9174:   or its information may be overwritten by newer information.</p></li>
                   9175: <li><p>Having the change information between old and new versions in our CVS
                   9176:   repository is very useful for people who use either cvs or anoncvs.</p></li>
                   9177: <li><p>Having the change information between old and new versions in our CVS
1.75      rillig   9178:   repository is very useful for people who read the pkgsrc-changes mailing
                   9179:   list, so that they can make tactical decisions about when to upgrade
1.87      wiz      9180:   the package.</p></li>
1.75      rillig   9181: </ul></div>
1.87      wiz      9182: <p>Please also recognize that, just because a new version of a package
1.75      rillig   9183:   has been released, it should not automatically be upgraded in the CVS
                   9184:   repository.  We prefer to be conservative in the packages that are
                   9185:   included in pkgsrc - development or beta packages are not really the
                   9186:   best thing for most places in which pkgsrc is used. Please use your
                   9187:   judgement about what should go into pkgsrc, and bear in mind that
1.87      wiz      9188:   stability is to be preferred above new and possibly untested features.</p>
1.75      rillig   9189: </div>
                   9190: <div class="sect1" lang="en">
                   9191: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9192: <a name="moving-package"></a>20.6. Moving a package in pkgsrc</h2></div></div></div>
1.75      rillig   9193: <div class="orderedlist"><ol type="1">
                   9194: <li><p>Make a copy of the directory somewhere else.</p></li>
                   9195: <li>
                   9196: <p>Remove all CVS dirs.</p>
1.87      wiz      9197: <p>Alternatively to the first two steps you can also do:</p>
1.75      rillig   9198: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package</code></strong></pre>
1.87      wiz      9199: <p>and use that for further work.</p>
1.75      rillig   9200: </li>
                   9201: <li><p>Fix <code class="varname">CATEGORIES</code> and any
                   9202: <code class="varname">DEPENDS</code> paths that just did &#8220;<span class="quote">../package</span>&#8221;
                   9203: instead of &#8220;<span class="quote">../../category/package</span>&#8221;.</p></li>
                   9204: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
                   9205: place.</p></li>
                   9206: <li>
                   9207: <p>Check if any package depends on it:
                   9208: </p>
                   9209: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   9210: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
                   9211: </li>
                   9212: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
                   9213: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76      rillig   9214: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
                   9215: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75      rillig   9216: <li>
                   9217: <p>Commit the changed and removed files:</p>
                   9218: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
1.87      wiz      9219: <p>(and any packages from step 5, of course).</p>
1.75      rillig   9220: </li>
                   9221: </ol></div>
                   9222: </div>
                   9223: </div>
                   9224: <div class="chapter" lang="en">
                   9225: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   9226: <a name="devfaq"></a>Chapter 21. Frequently Asked Questions</h2></div></div></div>
1.75      rillig   9227: <p>This section contains the answers to questions that may
                   9228:        arise when you are writing a package. If you don't find your
                   9229:        question answered here, first have a look in the other chapters,
                   9230:        and if you still don't have the answer, ask on the
                   9231:        <code class="literal">pkgsrc-users</code> mailing list.</p>
                   9232: <div class="qandaset">
                   9233: <dl>
1.92    ! rillig   9234: <dt>21.1. <a href="#id2685494">What is the difference between
1.75      rillig   9235:        MAKEFLAGS, .MAKEFLAGS and
                   9236:        MAKE_FLAGS?</a>
                   9237: </dt>
1.92    ! rillig   9238: <dt>21.2. <a href="#id2685530">What is the difference between
1.75      rillig   9239:        MAKE, GMAKE and
                   9240:        MAKE_PROGRAM?</a>
                   9241: </dt>
1.92    ! rillig   9242: <dt>21.3. <a href="#id2685637">What is the difference between
1.75      rillig   9243:        CC, PKG_CC and
                   9244:        PKGSRC_COMPILER?</a>
                   9245: </dt>
1.92    ! rillig   9246: <dt>21.4. <a href="#id2685674">What is the difference between
1.75      rillig   9247:        BUILDLINK_LDFLAGS,
                   9248:        BUILDLINK_LDADD and
                   9249:        BUILDLINK_LIBS?</a>
                   9250: </dt>
1.92    ! rillig   9251: <dt>21.5. <a href="#id2685692">Why does make show-var
1.75      rillig   9252:        VARNAME=BUILDLINK_PREFIX.foo
                   9253:        say it's empty?</a>
                   9254: </dt>
1.92    ! rillig   9255: <dt>21.6. <a href="#id2685720">What does
1.78      rillig   9256:        ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
                   9257:        don't understand the := inside
                   9258:        it.</a>
                   9259: </dt>
1.92    ! rillig   9260: <dt>21.7. <a href="#id2685795">Which mailing lists are there for package
1.78      rillig   9261:        developers?</a>
                   9262: </dt>
1.92    ! rillig   9263: <dt>21.8. <a href="#id2685831">Where is the pkgsrc
1.80      rillig   9264:        documentation?</a>
                   9265: </dt>
1.92    ! rillig   9266: <dt>21.9. <a href="#devfaq.too-much-time">I have a little time to kill.  What shall I
        !          9267: do?</a>
        !          9268: </dt>
1.75      rillig   9269: </dl>
                   9270: <table border="0" summary="Q and A Set">
                   9271: <col align="left" width="1%">
                   9272: <tbody>
                   9273: <tr class="question">
                   9274: <td align="left" valign="top">
1.92    ! rillig   9275: <a name="id2685494"></a><a name="id2685495"></a><b>21.1.</b>
1.75      rillig   9276: </td>
                   9277: <td align="left" valign="top"><p>What is the difference between
                   9278:        <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
                   9279:        <code class="varname">MAKE_FLAGS</code>?</p></td>
                   9280: </tr>
                   9281: <tr class="answer">
1.91      rillig   9282: <td align="left" valign="top"></td>
1.75      rillig   9283: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
                   9284:        to the pkgsrc-internal invocations of <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>, while
                   9285:        <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
                   9286:        the <code class="varname">MAKE_PROGRAM</code> when building the
                   9287:        package. [FIXME: What is .MAKEFLAGS for?]</p></td>
                   9288: </tr>
                   9289: <tr class="question">
                   9290: <td align="left" valign="top">
1.92    ! rillig   9291: <a name="id2685530"></a><a name="id2685531"></a><b>21.2.</b>
1.75      rillig   9292: </td>
                   9293: <td align="left" valign="top"><p>What is the difference between
                   9294:        <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
                   9295:        <code class="varname">MAKE_PROGRAM</code>?</p></td>
                   9296: </tr>
                   9297: <tr class="answer">
1.91      rillig   9298: <td align="left" valign="top"></td>
1.75      rillig   9299: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
                   9300:        <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> program that is used in the pkgsrc
                   9301:        infrastructure. <code class="varname">GMAKE</code> is the path to GNU
                   9302:        Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
                   9303:        use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
                   9304:        Make program that is used for building the
                   9305:        package.</p></td>
                   9306: </tr>
                   9307: <tr class="question">
                   9308: <td align="left" valign="top">
1.92    ! rillig   9309: <a name="id2685637"></a><a name="id2685638"></a><b>21.3.</b>
1.75      rillig   9310: </td>
                   9311: <td align="left" valign="top"><p>What is the difference between
                   9312:        <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
                   9313:        <code class="varname">PKGSRC_COMPILER</code>?</p></td>
                   9314: </tr>
                   9315: <tr class="answer">
1.91      rillig   9316: <td align="left" valign="top"></td>
1.75      rillig   9317: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
                   9318:        compiler, which can be configured by the pkgsrc user.
                   9319:        <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
                   9320:        <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
                   9321:        path to a compiler, but the type of compiler that should be
1.76      rillig   9322:        used. See <code class="filename">mk/compiler.mk</code> for more
1.75      rillig   9323:        information about the latter variable.</p></td>
                   9324: </tr>
                   9325: <tr class="question">
                   9326: <td align="left" valign="top">
1.92    ! rillig   9327: <a name="id2685674"></a><a name="id2685675"></a><b>21.4.</b>
1.75      rillig   9328: </td>
                   9329: <td align="left" valign="top"><p>What is the difference between
                   9330:        <code class="varname">BUILDLINK_LDFLAGS</code>,
                   9331:        <code class="varname">BUILDLINK_LDADD</code> and
                   9332:        <code class="varname">BUILDLINK_LIBS</code>?</p></td>
                   9333: </tr>
                   9334: <tr class="answer">
1.91      rillig   9335: <td align="left" valign="top"></td>
1.75      rillig   9336: <td align="left" valign="top"><p>[FIXME]</p></td>
                   9337: </tr>
                   9338: <tr class="question">
                   9339: <td align="left" valign="top">
1.92    ! rillig   9340: <a name="id2685692"></a><a name="id2685693"></a><b>21.5.</b>
1.75      rillig   9341: </td>
                   9342: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
                   9343:        VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
                   9344:        say it's empty?</p></td>
                   9345: </tr>
                   9346: <tr class="answer">
1.91      rillig   9347: <td align="left" valign="top"></td>
1.75      rillig   9348: <td align="left" valign="top"><p>For optimization reasons, some variables are only
                   9349:        available in the &#8220;<span class="quote">wrapper</span>&#8221; phase and later. To
                   9350:        &#8220;<span class="quote">simulate</span>&#8221; the wrapper phase, append
                   9351:        <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
                   9352:        command.</p></td>
                   9353: </tr>
1.78      rillig   9354: <tr class="question">
                   9355: <td align="left" valign="top">
1.92    ! rillig   9356: <a name="id2685720"></a><a name="id2685721"></a><b>21.6.</b>
1.78      rillig   9357: </td>
                   9358: <td align="left" valign="top"><p>What does
                   9359:        <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
                   9360:        don't understand the <code class="literal">:=</code> inside
                   9361:        it.</p></td>
                   9362: </tr>
                   9363: <tr class="answer">
1.91      rillig   9364: <td align="left" valign="top"></td>
1.78      rillig   9365: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
                   9366:        assignment operator, like you might expect at first sight.
                   9367:        Instead, it is a degenerate form of
                   9368:        <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
                   9369:        which is documented in the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> man page and which you
                   9370:        may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
                   9371:        case of <code class="varname">MASTER_SITE_*</code>,
                   9372:        <em class="replaceable"><code>old_string</code></em> is the empty string and
                   9373:        <em class="replaceable"><code>new_string</code></em> is
                   9374:        <code class="literal">package/</code>. That's where the
                   9375:        <code class="literal">:</code> and the <code class="literal">=</code> fall
                   9376:        together.</p></td>
                   9377: </tr>
                   9378: <tr class="question">
                   9379: <td align="left" valign="top">
1.92    ! rillig   9380: <a name="id2685795"></a><a name="id2685796"></a><b>21.7.</b>
1.78      rillig   9381: </td>
                   9382: <td align="left" valign="top"><p>Which mailing lists are there for package
                   9383:        developers?</p></td>
                   9384: </tr>
                   9385: <tr class="answer">
1.91      rillig   9386: <td align="left" valign="top"></td>
1.78      rillig   9387: <td align="left" valign="top"><div class="variablelist"><dl>
                   9388: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
                   9389: <dd><p>This is a list for technical discussions related
                   9390:        to pkgsrc development, e.g. soliciting feedback for changes to
                   9391:        pkgsrc infrastructure, proposed new features, questions related
                   9392:        to porting pkgsrc to a new platform, advice for maintaining a
                   9393:        package, patches that affect many packages, help requests moved
                   9394:        from pkgsrc-users when an infrastructure bug is found,
                   9395:        etc.</p></dd>
                   9396: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
                   9397: <dd><p>All bug reports in category "pkg" sent with
                   9398:        <a href="http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">send-pr</span>(1)</span></a> appear here. Please do not report your bugs here
                   9399:        directly; use one of the other mailing
                   9400:        lists.</p></dd>
                   9401: </dl></div></td>
                   9402: </tr>
1.80      rillig   9403: <tr class="question">
                   9404: <td align="left" valign="top">
1.92    ! rillig   9405: <a name="id2685831"></a><a name="id2685832"></a><b>21.8.</b>
1.80      rillig   9406: </td>
                   9407: <td align="left" valign="top"><p>Where is the pkgsrc
                   9408:        documentation?</p></td>
                   9409: </tr>
                   9410: <tr class="answer">
1.91      rillig   9411: <td align="left" valign="top"></td>
1.80      rillig   9412: <td align="left" valign="top">
                   9413: <p>There are many places where you can find
                   9414:        documentation about pkgsrc:</p>
                   9415: <div class="itemizedlist"><ul type="disc">
                   9416: <li><p>The pkgsrc guide (this document) is a collection
                   9417:        of chapters that explain large parts of pkgsrc, but some
                   9418:        chapters tend to be outdated. Which ones they are is hard to
                   9419:        say.</p></li>
                   9420: <li><p>On the mailing list archives (see <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>), you can find discussions
                   9421:        about certain features, announcements of new parts of the pkgsrc
                   9422:        infrastructure and sometimes even announcements that a certain
                   9423:        feature has been marked as obsolete. The benefit here is that
                   9424:        each message has a date appended to it.</p></li>
                   9425: <li><p>Many of the files in the
                   9426:        <code class="filename">mk/</code> directory start with a comment that
                   9427:        describes the purpose of the file and how it can be used by the
1.92    ! rillig   9428:        pkgsrc user and package authors. An easy way to find this
        !          9429:        documentation is to run <span><strong class="command">bmake
        !          9430:        help</strong></span>.</p></li>
1.80      rillig   9431: <li><p>The CVS log messages are a rich source of
                   9432:        information, but they tend to be highly abbreviated, especially
                   9433:        for actions that occur often. Some contain a detailed
                   9434:        description of what has changed, but they are geared towards the
                   9435:        other pkgsrc developers, not towards an average pkgsrc user.
                   9436:        They also only document <span class="emphasis"><em>changes</em></span>, so if you
                   9437:        don't know what has been before, these messages may not be worth
                   9438:        too much to you.</p></li>
                   9439: <li><p>Some parts of pkgsrc are only &#8220;<span class="quote">implicitly
                   9440:        documented</span>&#8221;, that is the documentation exists only in the
                   9441:        mind of the developer who wrote the code. To get this
                   9442:        information, use the the <span><strong class="command">cvs annotate</strong></span> command
                   9443:        to see who has written it and ask on the
                   9444:        <code class="literal">tech-pkg</code> mailing list, so that others can
                   9445:        find your questions later (see above). To be sure that the
                   9446:        developer in charge reads the mail, you may CC him or
                   9447:        her.</p></li>
                   9448: </ul></div>
                   9449: </td>
                   9450: </tr>
1.92    ! rillig   9451: <tr class="question">
        !          9452: <td align="left" valign="top">
        !          9453: <a name="devfaq.too-much-time"></a><a name="id2685894"></a><b>21.9.</b>
        !          9454: </td>
        !          9455: <td align="left" valign="top"><p>I have a little time to kill.  What shall I
        !          9456: do?</p></td>
        !          9457: </tr>
        !          9458: <tr class="answer">
        !          9459: <td align="left" valign="top"></td>
        !          9460: <td align="left" valign="top">
        !          9461: <p>This is not really an FAQ yet, but here's the answer  
        !          9462: anyway.</p>
        !          9463: <div class="itemizedlist"><ul type="disc">
        !          9464: <li><p>Run <span><strong class="command">pkg_chk -N</strong></span> (from the
        !          9465:     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_chk/README.html" target="_top"><code class="filename">pkgtools/pkg_chk</code></a> package).  It
        !          9466:     will tell you about newer versions of installed packages that are
        !          9467:     available, but not yet updated in pkgsrc.</p></li>
        !          9468: <li><p>Browse <code class="filename">pkgsrc/doc/TODO</code>
        !          9469:     &mdash; it contains a list of suggested new packages and a list of
        !          9470:     cleanups and enhancements for pkgsrc that would be nice to
        !          9471:     have.</p></li>
        !          9472: <li><p>Review packages for which review was requested on
        !          9473:     the <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">pkgsrc-wip</a> review
        !          9474:     mailing list.</p></li>
        !          9475: </ul></div>
        !          9476: </td>
        !          9477: </tr>
1.75      rillig   9478: </tbody>
                   9479: </table>
                   9480: </div>
                   9481: </div>
1.85      jmmv     9482: <div class="chapter" lang="en">
                   9483: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   9484: <a name="gnome"></a>Chapter 22. GNOME packaging and porting</h2></div></div></div>
1.85      jmmv     9485: <div class="toc">
                   9486: <p><b>Table of Contents</b></p>
                   9487: <dl>
1.90      rillig   9488: <dt><span class="sect1"><a href="#meta-packages">22.1. Meta packages</a></span></dt>
                   9489: <dt><span class="sect1"><a href="#new-package">22.2. Packaging a GNOME application</a></span></dt>
                   9490: <dt><span class="sect1"><a href="#full-update">22.3. Updating GNOME to a newer version</a></span></dt>
                   9491: <dt><span class="sect1"><a href="#patching">22.4. Patching guidelines</a></span></dt>
1.85      jmmv     9492: </dl>
                   9493: </div>
                   9494: <p>Quoting <a href="http://www.gnome.org/" target="_top">GNOME's web
                   9495: site</a>:</p>
                   9496: <div class="blockquote"><blockquote class="blockquote"><p>The GNOME project provides two things: The GNOME desktop
                   9497:   environment, an intuitive and attractive desktop for users, and the
                   9498:   GNOME development platform, an extensive framework for building
                   9499:   applications that integrate into the rest of the desktop.</p></blockquote></div>
                   9500: <p>pkgsrc provides a seamless way to automatically build and install
                   9501: a complete GNOME environment <span class="emphasis"><em>under many different
                   9502: platforms</em></span>.  We can say with confidence that pkgsrc is one of
                   9503: the most advanced build and packaging systems for GNOME due to its
                   9504: included technologies buildlink3, the wrappers and tools framework and
                   9505: automatic configuration file management.  Lots of efforts are put into
                   9506: achieving a completely clean deinstallation of installed software
                   9507: components.</p>
                   9508: <p>Given that pkgsrc is <a href="http://www.NetBSD.org/" target="_top">NetBSD</a>'s official packaging system,
                   9509: the above also means that great efforts are put into making GNOME work
                   9510: under this operating system.  Recently, <a href="http://www.dragonflybsd.org/" target="_top">DragonFly BSD</a> also adopted
                   9511: pkgsrc as its preferred packaging system, contributing lots of
                   9512: portability fixes to make GNOME build and install under it.</p>
                   9513: <p>This chapter is aimed at pkgsrc developers and other people
                   9514: interested in helping our GNOME porting and packaging efforts.  It
                   9515: provides instructions on how to manage the existing packages and some
                   9516: important information regarding their internals.</p>
                   9517: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   9518: <h3 class="title">We need your help!</h3>
                   9519: <p>Should you have some spare cycles to devote to NetBSD, pkgsrc
                   9520:   and GNOME and are willing to learn new exciting stuff, please jump
                   9521:   straight to the <a href="http://www.NetBSD.org/contrib/projects.html#gnome" target="_top">pending
                   9522:   work</a> list!  There is still a long way to go to get a
                   9523:   fully-functional GNOME desktop under NetBSD and we need your help to
                   9524:   achieve it!</p>
                   9525: </div>
                   9526: <div class="sect1" lang="en">
                   9527: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9528: <a name="meta-packages"></a>22.1. Meta packages</h2></div></div></div>
1.85      jmmv     9529: <p>pkgsrc includes three GNOME-related meta packages:</p>
                   9530: <div class="itemizedlist"><ul type="disc">
1.91      rillig   9531: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>: Provides
1.85      jmmv     9532:     the core GNOME desktop environment.  It only includes the necessary
                   9533:     bits to get it to boot correctly, although it may lack important
                   9534:     functionality for daily operation.  The idea behind this package is
                   9535:     to let end users build their own configurations on top of this one,
                   9536:     first installing this meta package to achieve a functional setup and
                   9537:     then adding individual applications.</p></li>
1.91      rillig   9538: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome/README.html" target="_top"><code class="filename">meta-pkgs/gnome</code></a>: Provides a
1.85      jmmv     9539:     complete installation of the GNOME platform and desktop as defined
                   9540:     by the GNOME project; this is based on the components distributed in
                   9541:     the <code class="filename">platform/x.y/x.y.z/sources</code> and
                   9542:     <code class="filename">desktop/x.y/x.y.z/sources</code> directories of the
                   9543:     official FTP server.  Developer-only tools found in those
                   9544:     directories are not installed unless required by some other
                   9545:     component to work properly.  Similarly, packages from the bindings
                   9546:     set (<code class="filename">bindings/x.y/x.y.z/sources</code>) are not pulled
                   9547:     in unless required as a dependency for an end-user component.  This
1.91      rillig   9548:     package "extends" <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>.</p></li>
                   9549: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a>:
1.85      jmmv     9550:     Installs all the tools required to build a GNOME component when
                   9551:     fetched from the CVS repository.  These are required to let the
                   9552:     <span><strong class="command">autogen.sh</strong></span> scripts work appropriately.</p></li>
                   9553: </ul></div>
                   9554: <p>In all these packages, the <code class="varname">DEPENDS</code> lines are
                   9555: sorted in a way that eases updates: a package may depend on other
                   9556: packages listed before it but not on any listed after it.  It is very
                   9557: important to keep this order to ease updates so... <span class="emphasis"><em>do not
                   9558: change it to alphabetical sorting!</em></span></p>
                   9559: </div>
                   9560: <div class="sect1" lang="en">
                   9561: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9562: <a name="new-package"></a>22.2. Packaging a GNOME application</h2></div></div></div>
1.85      jmmv     9563: <p>Almost all GNOME applications are written in C and use a common
                   9564: set of tools as their build system.  Things get different with the new
                   9565: bindings to other languages (such as Python), but the following will
                   9566: give you a general idea on the minimum required tools:</p>
                   9567: <div class="itemizedlist"><ul type="disc">
                   9568: <li>
                   9569: <p>Almost all GNOME applications use the GNU Autotools as their
                   9570:     build system.  As a general rule you will need to tell this to your
                   9571:     package:</p>
                   9572: <pre class="programlisting">GNU_CONFIGURE=yes
                   9573: USE_LIBTOOL=yes
                   9574: USE_TOOLS+=gmake</pre>
                   9575: </li>
                   9576: <li>
                   9577: <p>If the package uses pkg-config to detect dependencies, add this
                   9578:     tool to the list of required utilities:</p>
                   9579: <pre class="programlisting">USE_TOOLS+=pkg-config</pre>
1.91      rillig   9580: <p>Also use <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/verifypc/README.html" target="_top"><code class="filename">pkgtools/verifypc</code></a> at
1.85      jmmv     9581:     the end of the build process to ensure that you did not miss to
                   9582:     specify any dependency in your package and that the version
                   9583:     requirements are all correct.</p>
                   9584: </li>
                   9585: <li><p>If the package uses intltool, be sure to include the <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/textproc/intltool/buildlink3.mk?rev=HEAD&amp;content-type=text/x-cvsweb-markup" target="_top"><code class="filename">pkgsrc/textproc/intltool/buildlink3.mk</code></a> file
                   9586:     to handle dependencies and to force the package to use the latest
                   9587:     available version.</p></li>
                   9588: <li>
                   9589: <p>If the package uses gtk-doc (a documentation generation
                   9590:     utility), do <span class="emphasis"><em>not</em></span> add a dependency on it.  The
                   9591:     tool is rather big and the distfile should come with pregenerated
                   9592:     documentation anyway; if it does not, it is a bug that you ought to
                   9593:     report.  For such packages you should disable gtk-doc (unless it is
1.89      rillig   9594:     the default):</p>
                   9595: <pre class="programlisting">CONFIGURE_ARGS+=--disable-gtk-doc</pre>
                   9596: <p>The default location of installed HTML files
                   9597:     (<code class="filename">share/gtk-doc/&lt;package-name&gt;</code>) is correct
                   9598:     and should not be changed unless the package insists on installing
                   9599:     them somewhere else.  Otherwise programs as
                   9600:     <span><strong class="command">devhelp</strong></span> will not be able to open them.  You can
                   9601:     do that with an entry similar to:</p>
                   9602: <pre class="programlisting">CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...</pre>
1.85      jmmv     9603: </li>
                   9604: </ul></div>
                   9605: <p>GNOME uses multiple <span class="emphasis"><em>shared</em></span> directories and
                   9606: files under the installation prefix to maintain databases.  In this
                   9607: context, shared means that those exact same directories and files are
                   9608: used among several different packages, leading to conflicts in the
                   9609: <code class="filename">PLIST</code>.  pkgsrc currently includes functionality to
                   9610: handle the most common cases, so you have to forget about using
                   9611: <code class="literal">@unexec ${RMDIR}</code> lines in your file lists and
                   9612: omitting shared files from them.  If you find yourself doing those,
                   9613: <span class="emphasis"><em>your package is most likely incorrect</em></span>.</p>
                   9614: <p>The following table lists the common situations that result in
                   9615: using shared directories or files.  For each of them, the appropriate
                   9616: solution is given.  After applying the solution be sure to
                   9617: <span class="emphasis"><em>regenerate the package's file list</em></span> with
                   9618: <span><strong class="command">make print-PLIST</strong></span> and ensure it is correct.</p>
                   9619: <div class="table">
1.90      rillig   9620: <a name="plist-handling"></a><p class="title"><b>Table 22.1. PLIST handling for GNOME packages</b></p>
1.91      rillig   9621: <div class="table-contents"><table summary="PLIST handling for GNOME packages" border="1">
1.85      jmmv     9622: <colgroup>
                   9623: <col>
                   9624: <col>
                   9625: </colgroup>
                   9626: <thead><tr>
                   9627: <th>If the package...</th>
                   9628: <th>Then...</th>
                   9629: </tr></thead>
                   9630: <tbody>
                   9631: <tr>
                   9632: <td>Installs OMF files under <code class="filename">share/omf</code>.</td>
1.90      rillig   9633: <td>See <a href="#scrollkeeper-data-files" title="18.6.9. Packages installing scrollkeeper data files">Section 18.6.9, &#8220;Packages installing scrollkeeper data files&#8221;</a>.</td>
1.85      jmmv     9634: </tr>
                   9635: <tr>
                   9636: <td>Installs icons under the
                   9637:         <code class="filename">share/icons/hicolor</code> hierarchy or updates
                   9638:         <code class="filename">share/icons/hicolor/icon-theme.cache</code>.</td>
1.90      rillig   9639: <td>See <a href="#hicolor-theme" title="18.6.18. Packages installing hicolor theme icons">Section 18.6.18, &#8220;Packages installing hicolor theme icons&#8221;</a>.</td>
1.85      jmmv     9640: </tr>
                   9641: <tr>
                   9642: <td>Installs files under
                   9643:         <code class="filename">share/mime/packages</code>.</td>
1.90      rillig   9644: <td>See <a href="#mime-database" title="18.6.13. Packages installing extensions to the MIME database">Section 18.6.13, &#8220;Packages installing extensions to the MIME database&#8221;</a>.</td>
1.85      jmmv     9645: </tr>
                   9646: <tr>
                   9647: <td>Installs <code class="filename">.desktop</code> files under
                   9648:         <code class="filename">share/applications</code> and these include MIME
                   9649:         information.</td>
1.90      rillig   9650: <td>See <a href="#desktop-files" title="18.6.19. Packages installing desktop files">Section 18.6.19, &#8220;Packages installing desktop files&#8221;</a>.</td>
1.85      jmmv     9651: </tr>
                   9652: </tbody>
1.91      rillig   9653: </table></div>
1.85      jmmv     9654: </div>
1.91      rillig   9655: <br class="table-break">
1.85      jmmv     9656: </div>
                   9657: <div class="sect1" lang="en">
                   9658: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9659: <a name="full-update"></a>22.3. Updating GNOME to a newer version</h2></div></div></div>
1.85      jmmv     9660: <p>When seeing GNOME as a whole, there are two kinds of
                   9661: updates:</p>
                   9662: <div class="variablelist"><dl>
                   9663: <dt><span class="term">Major update</span></dt>
                   9664: <dd>
                   9665: <p>Given that there is still a very long way for GNOME 3 (if it
                   9666:       ever appears), we consider a major update one that goes from a
                   9667:       <code class="literal">2.X</code> version to a <code class="literal">2.Y</code> one,
                   9668:       where <code class="literal">Y</code> is even and greater than
                   9669:       <code class="literal">X</code>.  These are hard to achieve because they
                   9670:       introduce lots of changes in the components' code and almost all
                   9671:       GNOME distfiles are updated to newer versions.  Some of them can
                   9672:       even break API and ABI compatibility with the previous major
                   9673:       version series.  As a result, the update needs to be done all at
                   9674:       once to minimize breakage.</p>
                   9675: <p>A major update typically consists of around 80 package
                   9676:       updates and the addition of some new ones.</p>
                   9677: </dd>
                   9678: <dt><span class="term">Minor update</span></dt>
                   9679: <dd>
                   9680: <p>We consider a minor update one that goes from a
                   9681:       <code class="literal">2.A.X</code> version to a <code class="literal">2.A.Y</code>
                   9682:       one where <code class="literal">Y</code> is greater than
                   9683:       <code class="literal">X</code>.  These are easy to achieve because they do
                   9684:       not update all GNOME components, can be done in an incremental way
                   9685:       and do not break API nor ABI compatibility.</p>
                   9686: <p>A minor update typically consists of around 50 package
                   9687:       updates, although the numbers here may vary a lot.</p>
                   9688: </dd>
                   9689: </dl></div>
                   9690: <p>In order to update the GNOME components in pkgsrc to a new stable
                   9691: release (either major or minor), the following steps should be
                   9692: followed:</p>
                   9693: <div class="orderedlist"><ol type="1">
                   9694: <li>
                   9695: <p>Get a list of all the tarballs that form the new release by
                   9696:     using the following commands.  These will leave the full list of the
                   9697:     components's distfiles into the <code class="filename">list.txt</code>
                   9698:     file:</p>
1.88      wiz      9699: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
1.85      jmmv     9700:     ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   9701:     awk '{ print $9 }' &gt;list.txt</code></strong>
1.88      wiz      9702: <code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
1.85      jmmv     9703:     ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   9704:     awk '{ print $9 }' &gt;&gt;list.txt</code></strong></pre>
                   9705: </li>
                   9706: <li><p>Open each meta package's <code class="filename">Makefile</code> and
                   9707:     bump their version to the release you are updating them to.  The
                   9708:     three meta packages should be always consistent with versioning.
                   9709:     Obviously remove any <code class="varname">PKGREVISION</code>s that might be
                   9710:     in them.</p></li>
                   9711: <li>
                   9712: <p>For each meta package, update all its
                   9713:     <code class="varname">DEPENDS</code> lines to match the latest versions as
                   9714:     shown by the above commands.  Do <span class="emphasis"><em>not</em></span> list any
                   9715:     newer version (even if found in the FTP) because the meta packages
                   9716:     are supposed to list the exact versions that form a specific GNOME
                   9717:     release.  Exceptions are permitted here if a newer version solves a
                   9718:     serious issue in the overall desktop experience; these typically
                   9719:     come in the form of a revision bump in pkgsrc, not in newer versions
                   9720:     from the developers.</p>
                   9721: <p>Packages not listed in the <code class="filename">list.txt</code> file
                   9722:     should be updated to the latest version available (if found in
                   9723:     pkgsrc).  This is the case, for example, of the dependencies on the
1.91      rillig   9724:     GNU Autotools in the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a> meta package.</p>
1.85      jmmv     9725: </li>
                   9726: <li>
                   9727: <p>Generate a patch from the modified meta packages and extract the
                   9728:     list of "new" lines.  This will provide you an outline on what
                   9729:     packages need to be updated in pkgsrc and in what order:</p>
1.88      wiz      9730: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs diff gnome-devel gnome-base gnome | grep '^+D' &gt;todo.txt</code></strong></pre>
1.85      jmmv     9731: </li>
                   9732: <li><p>For major desktop updates it is recommended to zap all your
                   9733:     installed packages and start over from scratch at this point.</p></li>
                   9734: <li><p>Now comes the longest step by far: iterate over the contents
                   9735:     of <code class="filename">todo.txt</code> and update the packages listed in
                   9736:     it in order.  For major desktop updates none of these should be
                   9737:     commited until the entire set is completed because there are chances
                   9738:     of breaking not-yet-updated packages.</p></li>
                   9739: <li><p>Once the packages are up to date and working, commit them to
                   9740:     the tree one by one with appropriate log messages.  At the end,
                   9741:     commit the three meta package updates and all the corresponding
                   9742:     changes to the <code class="filename">doc/CHANGES-&lt;YEAR&gt;</code> and
                   9743:     <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/doc/TODO?rev=HEAD&amp;content-type=text/x-cvsweb-markup" target="_top"><code class="filename">pkgsrc/doc/TODO</code></a> files.</p></li>
                   9744: </ol></div>
                   9745: </div>
                   9746: <div class="sect1" lang="en">
                   9747: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9748: <a name="patching"></a>22.4. Patching guidelines</h2></div></div></div>
1.85      jmmv     9749: <p>GNOME is a very big component in pkgsrc which approaches 100
                   9750: packages.  Please, it is very important that you always, always,
                   9751: <span class="strong"><strong>always</strong></span> feed back any portability
1.90      rillig   9752: fixes you do to a GNOME package to the mainstream developers (see <a href="#components.patches.feedback" title="10.3.2. Feedback to the author">Section 10.3.2, &#8220;Feedback to the author&#8221;</a>).  This is the only way to get
1.85      jmmv     9753: their attention on portability issues and to ensure that future versions
                   9754: can be built out-of-the box on NetBSD.  The less custom patches in
                   9755: pkgsrc, the easier further updates are.  Those developers in charge of
                   9756: issuing major GNOME updates will be grateful if you do that.</p>
                   9757: <p>The most common places to report bugs are the <a href="http://bugzilla.gnome.org/" target="_top">GNOME's Bugzilla</a> and the <a href="http://bugzilla.freedesktop.org/" target="_top">freedesktop.org's
                   9758: Bugzilla</a>.  Not all components use these to track bugs, but most
                   9759: of them do.  Do not be short on your reports: always provide detailed
                   9760: explanations of the current failure, how it can be improved to achieve
                   9761: maximum portability and, if at all possible, provide a patch against CVS
                   9762: head.  The more verbose you are, the higher chances of your patch being
                   9763: accepted.</p>
                   9764: <p>Also, please avoid using preprocessor magic to fix portability
                   9765: issues.  While the FreeBSD GNOME people are doing a great job in porting
                   9766: GNOME to their operating system, the official GNOME sources are now
                   9767: plagued by conditionals that check for <code class="varname">__FreeBSD__</code>
                   9768: and similar macros.  This hurts portability.  Please see our patching
1.90      rillig   9769: guidelines (<a href="#components.patches.guidelines" title="10.3.1. Patching guidelines">Section 10.3.1, &#8220;Patching guidelines&#8221;</a>) for more
1.85      jmmv     9770: details.</p>
                   9771: </div>
                   9772: </div>
1.75      rillig   9773: </div>
                   9774: <div class="part" lang="en">
                   9775: <div class="titlepage"><div><div><h1 class="title">
                   9776: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
                   9777: <div class="partintro" lang="en">
                   9778: <div></div>
                   9779: <p>This part of the guide deals with everything
                   9780:        from the infrastructure that is behind the interfaces described
                   9781:        in the developer's guide. A casual package maintainer should not
                   9782:        need anything from this part.</p>
                   9783: <div class="toc">
                   9784: <p><b>Table of Contents</b></p>
                   9785: <dl>
1.90      rillig   9786: <dt><span class="chapter"><a href="#infr.design">23. Design of the pkgsrc infrastructure</a></span></dt>
1.75      rillig   9787: <dd><dl>
1.90      rillig   9788: <dt><span class="sect1"><a href="#infr.vardef">23.1. The meaning of variable definitions</a></span></dt>
                   9789: <dt><span class="sect1"><a href="#infr.vardef.problems">23.2. Avoiding problems before they arise</a></span></dt>
                   9790: <dt><span class="sect1"><a href="#infr.var">23.3. Variable evaluation</a></span></dt>
1.75      rillig   9791: <dd><dl>
1.90      rillig   9792: <dt><span class="sect2"><a href="#infr.var.load">23.3.1. At load time</a></span></dt>
                   9793: <dt><span class="sect2"><a href="#infr.var.run">23.3.2. At runtime</a></span></dt>
1.75      rillig   9794: </dl></dd>
1.90      rillig   9795: <dt><span class="sect1"><a href="#infr.varspec">23.4. How can variables be specified?</a></span></dt>
                   9796: <dt><span class="sect1"><a href="#infr.design.intf">23.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig   9797: <dd><dl>
1.90      rillig   9798: <dt><span class="sect2"><a href="#infr.design.intf.proc">23.5.1. Procedures with parameters</a></span></dt>
                   9799: <dt><span class="sect2"><a href="#infr.design.intf.action">23.5.2. Actions taken on behalf of parameters</a></span></dt>
1.81      rillig   9800: </dl></dd>
1.90      rillig   9801: <dt><span class="sect1"><a href="#infr.order">23.6. The order in which files are loaded</a></span></dt>
1.81      rillig   9802: <dd><dl>
1.90      rillig   9803: <dt><span class="sect2"><a href="#infr.order.prefs">23.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
                   9804: <dt><span class="sect2"><a href="#infr.order.pkg">23.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75      rillig   9805: </dl></dd>
                   9806: </dl></dd>
1.90      rillig   9807: <dt><span class="chapter"><a href="#regression">24. Regression tests</a></span></dt>
1.75      rillig   9808: <dd><dl>
1.90      rillig   9809: <dt><span class="sect1"><a href="#regression.descr">24.1. The regression tests framework</a></span></dt>
                   9810: <dt><span class="sect1"><a href="#regression.run">24.2. Running the regression tests</a></span></dt>
                   9811: <dt><span class="sect1"><a href="#regression.new">24.3. Adding a new regression test</a></span></dt>
1.75      rillig   9812: <dd><dl>
1.90      rillig   9813: <dt><span class="sect2"><a href="#regression.fun.override">24.3.1. Overridable functions</a></span></dt>
                   9814: <dt><span class="sect2"><a href="#regression.fun.helper">24.3.2. Helper functions</a></span></dt>
1.75      rillig   9815: </dl></dd>
                   9816: </dl></dd>
1.90      rillig   9817: <dt><span class="chapter"><a href="#porting">25. Porting pkgsrc</a></span></dt>
1.75      rillig   9818: <dd><dl>
1.90      rillig   9819: <dt><span class="sect1"><a href="#porting.opsys">25.1. Porting pkgsrc to a new operating system</a></span></dt>
                   9820: <dt><span class="sect1"><a href="#porting.compiler">25.2. Adding support for a new compiler</a></span></dt>
1.75      rillig   9821: </dl></dd>
                   9822: </dl>
                   9823: </div>
                   9824: </div>
                   9825: <div class="chapter" lang="en">
                   9826: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   9827: <a name="infr.design"></a>Chapter 23. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75      rillig   9828: <div class="toc">
                   9829: <p><b>Table of Contents</b></p>
                   9830: <dl>
1.90      rillig   9831: <dt><span class="sect1"><a href="#infr.vardef">23.1. The meaning of variable definitions</a></span></dt>
                   9832: <dt><span class="sect1"><a href="#infr.vardef.problems">23.2. Avoiding problems before they arise</a></span></dt>
                   9833: <dt><span class="sect1"><a href="#infr.var">23.3. Variable evaluation</a></span></dt>
1.81      rillig   9834: <dd><dl>
1.90      rillig   9835: <dt><span class="sect2"><a href="#infr.var.load">23.3.1. At load time</a></span></dt>
                   9836: <dt><span class="sect2"><a href="#infr.var.run">23.3.2. At runtime</a></span></dt>
1.81      rillig   9837: </dl></dd>
1.90      rillig   9838: <dt><span class="sect1"><a href="#infr.varspec">23.4. How can variables be specified?</a></span></dt>
                   9839: <dt><span class="sect1"><a href="#infr.design.intf">23.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig   9840: <dd><dl>
1.90      rillig   9841: <dt><span class="sect2"><a href="#infr.design.intf.proc">23.5.1. Procedures with parameters</a></span></dt>
                   9842: <dt><span class="sect2"><a href="#infr.design.intf.action">23.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75      rillig   9843: </dl></dd>
1.90      rillig   9844: <dt><span class="sect1"><a href="#infr.order">23.6. The order in which files are loaded</a></span></dt>
1.75      rillig   9845: <dd><dl>
1.90      rillig   9846: <dt><span class="sect2"><a href="#infr.order.prefs">23.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
                   9847: <dt><span class="sect2"><a href="#infr.order.pkg">23.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75      rillig   9848: </dl></dd>
                   9849: </dl>
                   9850: </div>
                   9851: <p>The pkgsrc infrastructure consists of many small Makefile
                   9852:        fragments. Each such fragment needs a properly specified
                   9853:        interface. This chapter explains how such an interface looks
                   9854:        like.</p>
                   9855: <div class="sect1" lang="en">
                   9856: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9857: <a name="infr.vardef"></a>23.1. The meaning of variable definitions</h2></div></div></div>
1.81      rillig   9858: <p>Whenever a variable is defined in the pkgsrc
                   9859:        infrastructure, the location and the way of definition provide
                   9860:        much information about the intended use of that variable.
                   9861:        Additionally, more documentation may be found in a header
                   9862:        comment or in this pkgsrc guide.</p>
                   9863: <p>A special file is
                   9864:        <code class="filename">mk/defaults/mk.conf</code>, which lists all
                   9865:        variables that are intended to be user-defined. They are either
                   9866:        defined using the <code class="literal">?=</code> operator or they are
                   9867:        left undefined because defining them to anything would
                   9868:        effectively mean &#8220;<span class="quote">yes</span>&#8221;. All these variables may be
                   9869:        overridden by the pkgsrc user in the <code class="varname">MAKECONF</code>
                   9870:        file.</p>
                   9871: <p>Outside this file, the following conventions apply:
                   9872:        Variables that are defined using the <code class="literal">?=</code>
                   9873:        operator may be overridden by a package.</p>
                   9874: <p>Variables that are defined using the <code class="literal">=</code>
                   9875:        operator may be used read-only at run-time.</p>
                   9876: <p>Variables whose name starts with an underscore must not be
                   9877:        accessed outside the pkgsrc infrastructure at all. They may
                   9878:        change without further notice.</p>
                   9879: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   9880: <h3 class="title">Note</h3>
                   9881: <p>These conventions are currently not applied
                   9882:        consistently to the complete pkgsrc
                   9883:        infrastructure.</p>
                   9884: </div>
                   9885: </div>
                   9886: <div class="sect1" lang="en">
                   9887: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9888: <a name="infr.vardef.problems"></a>23.2. Avoiding problems before they arise</h2></div></div></div>
1.81      rillig   9889: <p>All variables that contain lists of things should default
                   9890:        to being empty. Two examples that do not follow this rule are
                   9891:        <code class="varname">USE_LANGUAGES</code> and
                   9892:        <code class="varname">DISTFILES</code>. These variables cannot simply be
                   9893:        modified using the <code class="literal">+=</code> operator in package
                   9894:        <code class="filename">Makefile</code>s (or other files included by
                   9895:        them), since there is no guarantee whether the variable is
                   9896:        already set or not, and what its value is. In the case of
                   9897:        <code class="varname">DISTFILES</code>, the packages &#8220;<span class="quote">know</span>&#8221;
                   9898:        the default value and just define it as in the following
                   9899:        example.</p>
                   9900: <pre class="programlisting">
                   9901:     DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   9902: </pre>
                   9903: <p>Because of the selection of this default value, the same
                   9904:        value appears in many package Makefiles. Similarly for
                   9905:        <code class="varname">USE_LANGUAGES</code>, but in this case the default
                   9906:        value (&#8220;<span class="quote"><code class="literal">c</code></span>&#8221;) is so short that it
                   9907:        doesn't stand out. Nevertheless it is mentioned in many
                   9908:        files.</p>
                   9909: </div>
                   9910: <div class="sect1" lang="en">
                   9911: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9912: <a name="infr.var"></a>23.3. Variable evaluation</h2></div></div></div>
1.75      rillig   9913: <div class="sect2" lang="en">
                   9914: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   9915: <a name="infr.var.load"></a>23.3.1. At load time</h3></div></div></div>
1.75      rillig   9916: <p>Variable evaluation takes place either at load time or at
                   9917:        runtime, depending on the context in which they occur. The
                   9918:        contexts where variables are evaluated at load time are:</p>
                   9919: <div class="itemizedlist"><ul type="disc">
                   9920: <li><p>The right hand side of the <code class="literal">:=</code>
                   9921:        and <code class="literal">!=</code> operators,</p></li>
                   9922: <li><p>Make directives like <code class="literal">.if</code> or
                   9923:        <code class="literal">.for</code>,</p></li>
                   9924: <li><p>Dependency lines.</p></li>
                   9925: </ul></div>
                   9926: <p>A special exception are references to the iteration
                   9927:        variables of <code class="literal">.for</code> loops, which are expanded
                   9928:        inline, no matter in which context they appear.</p>
                   9929: <p>As the values of variables may change during load time,
                   9930:        care must be taken not to evaluate them by accident. Typical
                   9931:        examples for variables that should not be evaluated at load time
                   9932:        are <code class="varname">DEPENDS</code> and
                   9933:        <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
                   9934:        clear, here is an example:</p>
                   9935: <pre class="programlisting">
                   9936:     CONFIGURE_ARGS=         # none
                   9937:     CFLAGS=                 -O
                   9938:     CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
1.1       grant    9939: 
1.75      rillig   9940:     CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
1.1       grant    9941: 
1.75      rillig   9942:     CFLAGS+=                -Wall
                   9943:        </pre>
                   9944: <p>This code shows how the use of the <code class="literal">:=</code>
                   9945:        operator can quickly lead to unexpected results. The first
                   9946:        paragraph is fairly common code. The second paragraph evaluates
                   9947:        the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
                   9948:        <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
                   9949:        <code class="literal">-Wall</code> is appended to the
                   9950:        <code class="varname">CFLAGS</code>, but this addition will not appear in
                   9951:        <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
                   9952:        paragraphs from above typically occur in completely unrelated
                   9953:        files.</p>
                   9954: </div>
                   9955: <div class="sect2" lang="en">
                   9956: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   9957: <a name="infr.var.run"></a>23.3.2. At runtime</h3></div></div></div>
1.75      rillig   9958: <p>After all the files have been loaded, the values of the
                   9959:        variables cannot be changed anymore. Variables that are used in
                   9960:        the shell commands are expanded at this point.</p>
                   9961: </div>
                   9962: </div>
                   9963: <div class="sect1" lang="en">
                   9964: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9965: <a name="infr.varspec"></a>23.4. How can variables be specified?</h2></div></div></div>
1.78      rillig   9966: <p>There are many ways in which the definition and use of a
                   9967:        variable can be restricted in order to detect bugs and
                   9968:        violations of the (mostly unwritten) policies. See the
                   9969:        <code class="literal">pkglint</code> developer's documentation for further
                   9970:        details.</p>
                   9971: </div>
                   9972: <div class="sect1" lang="en">
                   9973: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   9974: <a name="infr.design.intf"></a>23.5. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76      rillig   9975: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75      rillig   9976:        of the following classes. Cases where a file falls into more
                   9977:        than one class should be avoided as it often leads to subtle
                   9978:        bugs.</p>
                   9979: <div class="sect2" lang="en">
                   9980: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   9981: <a name="infr.design.intf.proc"></a>23.5.1. Procedures with parameters</h3></div></div></div>
1.75      rillig   9982: <p>In a traditional imperative programming language some of
1.76      rillig   9983:        the <code class="filename">.mk</code> files could be described as
1.89      rillig   9984:        procedures. They take some input parameters and&mdash;after
                   9985:        inclusion&mdash;provide a result in output parameters. Since all
1.76      rillig   9986:        variables in <code class="filename">Makefile</code>s have global scope
1.75      rillig   9987:        care must be taken not to use parameter names that have already
                   9988:        another meaning. For example, <code class="varname">PKGNAME</code> is a
                   9989:        bad choice for a parameter name.</p>
                   9990: <p>Procedures are completely evaluated at preprocessing time.
                   9991:        That is, when calling a procedure all input parameters must be
                   9992:        completely resolvable. For example,
                   9993:        <code class="varname">CONFIGURE_ARGS</code> should never be an input
                   9994:        parameter since it is very likely that further text will be
                   9995:        added after calling the procedure, which would effectively apply
                   9996:        the procedure to only a part of the variable. Also, references
                   9997:        to other variables wit will be modified after calling the
                   9998:        procedure.</p>
                   9999: <p>A procedure can declare its output parameters either as
                   10000:        suitable for use in preprocessing directives or as only
                   10001:        available at runtime. The latter alternative is for variables
                   10002:        that contain references to other runtime variables.</p>
                   10003: <p>Procedures shall be written such that it is possible to
                   10004:        call the procedure more than once. That is, the file must not
                   10005:        contain multiple-inclusion guards.</p>
                   10006: <p>Examples for procedures are
1.76      rillig   10007:        <code class="filename">mk/bsd.options.mk</code> and
                   10008:        <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75      rillig   10009:        that the parameters are evaluated at load time, they should be
                   10010:        assigned using the <code class="literal">:=</code> operator, which should
                   10011:        be used only for this purpose.</p>
                   10012: </div>
                   10013: <div class="sect2" lang="en">
                   10014: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   10015: <a name="infr.design.intf.action"></a>23.5.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75      rillig   10016: <p>Action files take some input parameters and may define
                   10017:        runtime variables. They shall not define loadtime variables.
                   10018:        There are action files that are included implicitly by the
                   10019:        pkgsrc infrastructure, while other must be included
                   10020:        explicitly.</p>
                   10021: <p>An example for action files is
1.76      rillig   10022:        <code class="filename">mk/subst.mk</code>.</p>
1.75      rillig   10023: </div>
                   10024: </div>
1.81      rillig   10025: <div class="sect1" lang="en">
                   10026: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   10027: <a name="infr.order"></a>23.6. The order in which files are loaded</h2></div></div></div>
1.81      rillig   10028: <p>Package <code class="filename">Makefile</code>s usually consist of
                   10029:        a set of variable definitions, and include the file
                   10030:        <code class="filename">../../mk/bsd.pkg.mk</code> in the very last line.
                   10031:        Before that, they may also include various other
                   10032:        <code class="filename">*.mk</code> files if they need to query the
                   10033:        availability of certain features like the type of compiler or
                   10034:        the X11 implementation. Due to the heavy use of preprocessor
                   10035:        directives like <code class="literal">.if</code> and
                   10036:        <code class="literal">.for</code>, the order in which the files are loaded
                   10037:        matters.</p>
                   10038: <p>This section describes at which point the various files
                   10039:        are loaded and gives reasons for that order.</p>
                   10040: <div class="sect2" lang="en">
                   10041: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   10042: <a name="infr.order.prefs"></a>23.6.1. The order in <code class="filename">bsd.prefs.mk</code></h3></div></div></div>
1.81      rillig   10043: <p>The very first action in <code class="filename">bsd.pkg.mk</code>
                   10044:        is to define some essential variables like
                   10045:        <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code> and
                   10046:        <code class="varname">MACHINE_ARCH</code>.</p>
                   10047: <p>Then, the user settings are loaded from the file specified
                   10048:        in <code class="varname">MAKECONF</code>. If the bmake command from pkgsrc
                   10049:        is used, <code class="varname">MAKECONF</code> defaults to
                   10050:        <code class="filename"><em class="replaceable"><code>${prefix}</code></em>/etc/mk.conf</code>.
                   10051:        With the native <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> command on NetBSD, it defaults to
                   10052:        <code class="filename">/etc/mk.conf</code>. After that, those variables
                   10053:        that have not been overridden by the user are loaded from
                   10054:        <code class="filename">mk/defaults/mk.conf</code>.</p>
                   10055: <p>After the user settings, the system settings and platform
                   10056:        settings are loaded, which may override the user
                   10057:        settings.</p>
                   10058: <p>Then, the tool definitions are loaded. The tool wrappers
                   10059:        are not yet in effect. This only happens when building a
                   10060:        package, so the proper variables must be used instead of the
                   10061:        direct tool names.</p>
                   10062: <p>As the last steps, some essential variables from the
                   10063:        wrapper and the package system flavor are loaded, as well as the
                   10064:        variables that have been cached in earlier phases of a package
                   10065:        build.</p>
                   10066: </div>
                   10067: <div class="sect2" lang="en">
                   10068: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   10069: <a name="infr.order.pkg"></a>23.6.2. The order in <code class="filename">bsd.pkg.mk</code></h3></div></div></div>
1.81      rillig   10070: <p>First, <code class="filename">bsd.prefs.mk</code> is loaded.</p>
                   10071: <p>Then, the various <code class="filename">*-vars.mk</code> files are
                   10072:        loaded, which fill default values for those variables that have
                   10073:        not been defined by the the package. These variables may later
                   10074:        be used even in unrelated files.</p>
                   10075: <p>Then, the file <code class="filename">bsd.pkg.error.mk</code>
                   10076:        provides the target <code class="literal">error-check</code> that is added
                   10077:        as a special dependency to all other targets that use
                   10078:        <code class="varname">DELAYED_ERROR_MSG</code> or
                   10079:        <code class="varname">DELAYED_WARNING_MSG</code>.</p>
                   10080: <p>Then, the package-specific hacks from
                   10081:        <code class="filename">hacks.mk</code> are included.</p>
                   10082: <p>Then, various other files follow. Most of them don't have
                   10083:        any dependencies on what they need to have included before or
                   10084:        after them, though some do.</p>
                   10085: <p>The code to check <code class="varname">PKG_FAIL_REASON</code> and
                   10086:        <code class="varname">PKG_SKIP_REASON</code> is then executed, which
                   10087:        restricts the use of these variables to all the files that have
                   10088:        been included before. Appearances in later files will be
                   10089:        silently ignored.</p>
                   10090: <p>Then, the files for the main targets are included, in the
                   10091:        order of later execution, though the actual order should not
                   10092:        matter.</p>
                   10093: <p>At last, some more files are included that don't set any
                   10094:        interesting variables but rather just define make targets to be
                   10095:        executed.</p>
                   10096: </div>
                   10097: </div>
1.75      rillig   10098: </div>
                   10099: <div class="chapter" lang="en">
                   10100: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   10101: <a name="regression"></a>Chapter 24. Regression tests</h2></div></div></div>
1.75      rillig   10102: <div class="toc">
                   10103: <p><b>Table of Contents</b></p>
                   10104: <dl>
1.90      rillig   10105: <dt><span class="sect1"><a href="#regression.descr">24.1. The regression tests framework</a></span></dt>
                   10106: <dt><span class="sect1"><a href="#regression.run">24.2. Running the regression tests</a></span></dt>
                   10107: <dt><span class="sect1"><a href="#regression.new">24.3. Adding a new regression test</a></span></dt>
1.75      rillig   10108: <dd><dl>
1.90      rillig   10109: <dt><span class="sect2"><a href="#regression.fun.override">24.3.1. Overridable functions</a></span></dt>
                   10110: <dt><span class="sect2"><a href="#regression.fun.helper">24.3.2. Helper functions</a></span></dt>
1.75      rillig   10111: </dl></dd>
                   10112: </dl>
                   10113: </div>
                   10114: <p>The pkgsrc infrastructure consists of a large codebase,
                   10115:        and there are many corners where every little bit of a file is
                   10116:        well thought out, making pkgsrc likely to fail as soon as
                   10117:        anything is changed near those parts. To prevent most changes
                   10118:        from breaking anything, a suite of regression tests should go
                   10119:        along with every important part of the pkgsrc infrastructure.
                   10120:        This chapter describes how regression tests work in pkgsrc and
                   10121:        how you can add new tests.</p>
                   10122: <div class="sect1" lang="en">
                   10123: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   10124: <a name="regression.descr"></a>24.1. The regression tests framework</h2></div></div></div>
1.75      rillig   10125: <p></p>
                   10126: </div>
                   10127: <div class="sect1" lang="en">
                   10128: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   10129: <a name="regression.run"></a>24.2. Running the regression tests</h2></div></div></div>
1.91      rillig   10130: <p>You first need to install the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_regress/README.html" target="_top"><code class="filename">pkgtools/pkg_regress</code></a> package, which
1.75      rillig   10131:        provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
                   10132:        can simply run that command, which will run all tests in the
1.76      rillig   10133:        <code class="filename">regress</code> category.</p>
1.75      rillig   10134: </div>
                   10135: <div class="sect1" lang="en">
                   10136: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   10137: <a name="regression.new"></a>24.3. Adding a new regression test</h2></div></div></div>
1.76      rillig   10138: <p>Every directory in the <code class="filename">regress</code>
                   10139:        category that contains a file called <code class="filename">spec</code>
1.75      rillig   10140:        is considered a regression test. This file is a shell program
                   10141:        that is included by the <span><strong class="command">pkg_regress</strong></span> command.
                   10142:        The following functions can be overridden to suit your
                   10143:        needs.</p>
                   10144: <div class="sect2" lang="en">
                   10145: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   10146: <a name="regression.fun.override"></a>24.3.1. Overridable functions</h3></div></div></div>
1.75      rillig   10147: <p>These functions do not take any parameters. They are all
                   10148:        called in &#8220;<span class="quote">set -e</span>&#8221; mode, so you should be careful
                   10149:        to check the exitcodes of any commands you run in the
                   10150:        test.</p>
                   10151: <div class="variablelist"><dl>
                   10152: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
                   10153: <dd><p>This function prepares the environment for the
                   10154:        test. By default it does nothing.</p></dd>
                   10155: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
                   10156: <dd><p>This function runs the actual test. By default,
                   10157:        it calls <code class="varname">TEST_MAKE</code> with the arguments
                   10158:        <code class="varname">MAKEARGS_TEST</code> and writes its output including
                   10159:        error messages into the file
                   10160:        <code class="varname">TEST_OUTFILE</code>.</p></dd>
                   10161: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
                   10162: <dd><p>This function is run after the test and is
                   10163:        typically used to compare the actual output from the one that is
                   10164:        expected. It can make use of the various helper functions from
                   10165:        the next section.</p></dd>
                   10166: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
                   10167: <dd><p>This function cleans everything up after the
                   10168:        test has been run. By default it does nothing.</p></dd>
                   10169: </dl></div>
                   10170: </div>
                   10171: <div class="sect2" lang="en">
                   10172: <div class="titlepage"><div><div><h3 class="title">
1.90      rillig   10173: <a name="regression.fun.helper"></a>24.3.2. Helper functions</h3></div></div></div>
1.75      rillig   10174: <div class="variablelist"><dl>
                   10175: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
                   10176: <dd><p>This function compares the exitcode of the
                   10177:        <span><strong class="command">do_test()</strong></span> function with its first parameter.
                   10178:        If they differ, the test will fail.</p></dd>
                   10179: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
                   10180: <dd><p>This function checks for each of its parameters
                   10181:        if the output from <span><strong class="command">do_test()</strong></span> matches the
                   10182:        extended regular expression. If it does not, the test will
                   10183:        fail.</p></dd>
                   10184: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
                   10185: <dd><p>This function checks for each of its parameters
                   10186:        if the output from <span><strong class="command">do_test()</strong></span> does
                   10187:        <span class="emphasis"><em>not</em></span> match the extended regular expression.
                   10188:        If any of the regular expressions matches, the test will
                   10189:        fail.</p></dd>
                   10190: </dl></div>
                   10191: </div>
                   10192: </div>
                   10193: </div>
                   10194: <div class="chapter" lang="en">
                   10195: <div class="titlepage"><div><div><h2 class="title">
1.90      rillig   10196: <a name="porting"></a>Chapter 25. Porting pkgsrc</h2></div></div></div>
1.75      rillig   10197: <div class="toc">
                   10198: <p><b>Table of Contents</b></p>
                   10199: <dl>
1.90      rillig   10200: <dt><span class="sect1"><a href="#porting.opsys">25.1. Porting pkgsrc to a new operating system</a></span></dt>
                   10201: <dt><span class="sect1"><a href="#porting.compiler">25.2. Adding support for a new compiler</a></span></dt>
1.75      rillig   10202: </dl>
                   10203: </div>
                   10204: <p>The pkgsrc system has already been ported to many
                   10205:        operating systems, hardware architectures and compilers. This
                   10206:        chapter explains the necessary steps to make pkgsrc even more
                   10207:        portable.</p>
                   10208: <div class="sect1" lang="en">
                   10209: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   10210: <a name="porting.opsys"></a>25.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75      rillig   10211: <p>To port pkgsrc to a new operating system (called
                   10212:        <code class="literal">MyOS</code> in this example), you need to touch the
                   10213:        following files:</p>
                   10214: <div class="variablelist"><dl>
1.76      rillig   10215: <dt><span class="term"><code class="filename">bootstrap/mods/mk/<em class="replaceable"><code>MyOS</code></em>.sys.mk</code></span></dt>
1.75      rillig   10216: <dd><p>This file contains some basic definitions, for
                   10217:        example the name of the C
                   10218:        compiler.</p></dd>
1.76      rillig   10219: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75      rillig   10220: <dd><p>Insert code that defines the variables
                   10221:        <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
                   10222:        <code class="varname">LOWER_OS_VERSION</code>,
                   10223:        <code class="varname">LOWER_VENDOR</code>,
                   10224:        <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
                   10225:        <code class="varname">APPEND_ELF</code>, and the other variables that
                   10226:        appear in this file.</p></dd>
1.76      rillig   10227: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75      rillig   10228: <dd><p>This file contains the platform-specific
                   10229:        definitions that are used by pkgsrc. Start by copying one of the
                   10230:        other files and edit it to your
                   10231:        needs.</p></dd>
1.76      rillig   10232: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75      rillig   10233: <dd><p>This file contains a list of directories,
                   10234:        together with their permission bits and ownership. These
                   10235:        directories will be created automatically with every package
                   10236:        that does not explicitly set <code class="varname">NO_MTREE</code>. There
                   10237:        have been some discussions about whether this file is needed at
                   10238:        all, but with no result.</p></dd>
1.76      rillig   10239: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75      rillig   10240: <dd><p>Just copy one of the pre-existing x11.dist files
                   10241:        to your
1.76      rillig   10242:        <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
                   10243: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75      rillig   10244: <dd><p>On some operating systems, the tools that are
                   10245:        provided with the base system are not good enough for pkgsrc.
                   10246:        For example, there are many versions of <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sed+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sed</span>(1)</span></a> that have a
                   10247:        narrow limit on the line length they can process. Therefore
                   10248:        pkgsrc brings its own tools, which can be enabled
                   10249:        here.</p></dd>
1.76      rillig   10250: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75      rillig   10251: <dd><p>This file defines the paths to all the tools
                   10252:        that are needed by one or the other package in pkgsrc, as well
                   10253:        as by pkgsrc itself. Find out where these tools are on your
                   10254:        platform and add them.</p></dd>
                   10255: </dl></div>
                   10256: <p>Now, you should be able to build some basic packages, like
1.91      rillig   10257:        <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/lang/perl5/README.html" target="_top"><code class="filename">lang/perl5</code></a>, <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a>.</p>
1.75      rillig   10258: </div>
                   10259: <div class="sect1" lang="en">
                   10260: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90      rillig   10261: <a name="porting.compiler"></a>25.2. Adding support for a new compiler</h2></div></div></div>
1.75      rillig   10262: <p>TODO</p>
                   10263: </div>
                   10264: </div>
                   10265: </div>
                   10266: <div class="appendix" lang="en">
                   10267: <div class="titlepage"><div><div><h2 class="title">
                   10268: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
                   10269: <div class="toc">
                   10270: <p><b>Table of Contents</b></p>
                   10271: <dl>
                   10272: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
                   10273: <dd><dl>
                   10274: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
                   10275: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
                   10276: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
                   10277: <dt><span class="sect2"><a href="#checking-package-with-pkglint">A.1.4. Checking a package with <span><strong class="command">pkglint</strong></span></a></span></dt>
                   10278: </dl></dd>
                   10279: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
                   10280: </dl>
                   10281: </div>
                   10282: <p>We checked to find a piece of software that wasn't in the packages
                   10283:     collection, and picked GNU bison. Quite why someone would want to have
                   10284:     <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
                   10285:     present in the tree is beyond us, but it's useful for the purposes of
                   10286:     this exercise.</p>
                   10287: <div class="sect1" lang="en">
                   10288: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   10289: <a name="example-files"></a>A.1. files</h2></div></div></div>
                   10290: <div class="sect2" lang="en">
                   10291: <div class="titlepage"><div><div><h3 class="title">
                   10292: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
                   10293: <pre class="programlisting">
1.51      rillig   10294:     # $NetBSD$
                   10295:     #
1.1       grant    10296: 
1.51      rillig   10297:     DISTNAME=       bison-1.25
                   10298:     CATEGORIES=     devel
                   10299:     MASTER_SITES=   ${MASTER_SITE_GNU}
1.1       grant    10300: 
1.51      rillig   10301:     MAINTAINER=     thorpej@NetBSD.org
                   10302:     HOMEPAGE=       http://www.gnu.org/software/bison/bison.html
                   10303:     COMMENT=        GNU yacc clone
1.1       grant    10304: 
1.51      rillig   10305:     GNU_CONFIGURE=  yes
                   10306:     INFO_FILES=     bison.info
1.1       grant    10307: 
1.51      rillig   10308:     .include "../../mk/bsd.pkg.mk"
1.1       grant    10309: </pre>
1.75      rillig   10310: </div>
                   10311: <div class="sect2" lang="en">
                   10312: <div class="titlepage"><div><div><h3 class="title">
                   10313: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
                   10314: <pre class="programlisting">
1.51      rillig   10315:     GNU version of yacc.  Can make re-entrant parsers, and numerous other
1.75      rillig   10316:     improvements.  Why you would want this when Berkeley <a href="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
1.51      rillig   10317:     of the NetBSD source tree is beyond me.
1.1       grant    10318: </pre>
1.75      rillig   10319: </div>
                   10320: <div class="sect2" lang="en">
                   10321: <div class="titlepage"><div><div><h3 class="title">
                   10322: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
                   10323: <pre class="programlisting">
1.51      rillig   10324:     @comment $NetBSD$
                   10325:     bin/bison
                   10326:     man/man1/bison.1.gz
                   10327:     share/bison.simple
                   10328:     share/bison.hairy
1.1       grant    10329: </pre>
1.75      rillig   10330: </div>
                   10331: <div class="sect2" lang="en">
                   10332: <div class="titlepage"><div><div><h3 class="title">
                   10333: <a name="checking-package-with-pkglint"></a>A.1.4. Checking a package with <span><strong class="command">pkglint</strong></span></h3></div></div></div>
                   10334: <p>The NetBSD package system comes with
1.91      rillig   10335:         <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>
1.75      rillig   10336:        which helps to check the contents of these
                   10337:        files. After installation it is quite easy to use, just change to the
                   10338:        directory of the package you wish to examine and execute
                   10339:        <span><strong class="command">pkglint</strong></span>:</p>
                   10340: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
                   10341: looks fine.</pre>
                   10342: <p>Depending on the supplied command line arguments (see pkglint(1)),
                   10343:        more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
                   10344:        -Wall</strong></span> for a very thorough check.</p>
                   10345: </div>
                   10346: </div>
                   10347: <div class="sect1" lang="en">
                   10348: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   10349: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
                   10350: <p>Create the directory where the package lives,
                   10351:       plus any auxiliary directories:</p>
                   10352: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
                   10353: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
                   10354: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
                   10355: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76      rillig   10356: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.90      rillig   10357:       <code class="filename">PLIST</code> (see <a href="#components" title="Chapter 10. Package components - files, directories and contents">Chapter 10, <i>Package components - files, directories and contents</i></a>)
1.75      rillig   10358:       then continue with fetching the distfile:</p>
                   10359: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1       grant    10360: &gt;&gt; bison-1.25.tar.gz doesn't seem to exist on this system.
                   10361: &gt;&gt; Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   10362: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   10363: ftp: Error retrieving file: 500 Internal error
                   10364: 
                   10365: &gt;&gt; Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   10366: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   10367: ftp: Error retrieving file: 500 Internal error
                   10368: 
                   10369: &gt;&gt; Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   10370: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75      rillig   10371: Successfully retrieved file.</pre>
                   10372: <p>Generate the checksum of the distfile into
1.76      rillig   10373:       <code class="filename">distinfo</code>:</p>
1.88      wiz      10374: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makedistinfo</code></strong></pre>
1.75      rillig   10375: <p>Now compile:</p>
                   10376: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1       grant    10377: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   10378: ===&gt;  Extracting for bison-1.25
                   10379: ===&gt;  Patching for bison-1.25
                   10380: ===&gt;   Ignoring empty patch directory
                   10381: ===&gt;  Configuring for bison-1.25
                   10382: creating cache ./config.cache
                   10383: checking for gcc... cc
                   10384: checking whether we are using GNU C... yes
                   10385: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   10386: checking how to run the C preprocessor... cc -E
                   10387: checking for minix/config.h... no
                   10388: checking for POSIXized ISC... no
                   10389: checking whether cross-compiling... no
                   10390: checking for ANSI C header files... yes
                   10391: checking for string.h... yes
                   10392: checking for stdlib.h... yes
                   10393: checking for memory.h... yes
                   10394: checking for working const... yes
                   10395: checking for working alloca.h... no
                   10396: checking for alloca... yes
                   10397: checking for strerror... yes
                   10398: updating cache ./config.cache
                   10399: creating ./config.status
                   10400: creating Makefile
                   10401: ===&gt;  Building for bison-1.25
                   10402: 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
                   10403: 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
                   10404: 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
                   10405: 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
                   10406: 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
1.68      rillig   10407: 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
1.1       grant    10408: 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
                   10409: 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
                   10410: 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
                   10411: 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
                   10412: 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
                   10413: 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
                   10414: 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
                   10415: 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
                   10416: 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
                   10417: 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
                   10418: 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
                   10419: 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
                   10420: 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
                   10421: 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
                   10422: 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
                   10423: 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
                   10424: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   10425: rm -f bison.s1
1.75      rillig   10426: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" &lt; ./bison.simple &gt; bison.s1</pre>
                   10427: <p>Everything seems OK, so install the files:</p>
                   10428: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1       grant    10429: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   10430: ===&gt;  Installing for bison-1.25
                   10431: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   10432: rm -f /usr/pkg/bin/bison
                   10433: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   10434: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   10435: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   10436: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   10437: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   10438: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   10439: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75      rillig   10440: ===&gt;  Registering installation for bison-1.25</pre>
                   10441: <p>You can now use bison, and also - if you decide so - remove it with
                   10442:       <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
                   10443:       binary package, do this now:</p>
                   10444: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1       grant    10445: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   10446: ===&gt;  Building package for bison-1.25
                   10447: Creating package bison-1.25.tgz
                   10448: Registering depends:.
1.75      rillig   10449: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
                   10450: <p>Now that you don't need the source and object files
                   10451:       any more, clean up:</p>
                   10452: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
                   10453: ===&gt;  Cleaning for bison-1.25</pre>
                   10454: </div>
                   10455: </div>
                   10456: <div class="appendix" lang="en">
                   10457: <div class="titlepage"><div><div><h2 class="title">
                   10458: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
                   10459: <div class="toc">
                   10460: <p><b>Table of Contents</b></p>
                   10461: <dl>
                   10462: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
                   10463: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
                   10464: </dl>
                   10465: </div>
                   10466: <div class="sect1" lang="en">
                   10467: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   10468: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
                   10469: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1       grant    10470: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   10471: =&gt; figlet221.tar.gz doesn't seem to exist on this system.
                   10472: =&gt; Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   10473: =&gt; [172219 bytes]
                   10474: Connected to ftp.plig.net.
                   10475: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   10476: 331 Guest login ok, send your complete e-mail address as password.
                   10477: 230-You are user #5 of 500 simultaneous users allowed.
                   10478: 230-
1.68      rillig   10479: 230-  ___ _             _ _
                   10480: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
1.1       grant    10481: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   10482: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   10483: 230-         |_|   |_|     |___|         |___|
                   10484: 230-
                   10485: 230-** Welcome to ftp.plig.org **
                   10486: 230-
                   10487: 230-Please note that all transfers from this FTP site are logged. If you
                   10488: 230-do not like this, please disconnect now.
                   10489: 230-
                   10490: 230-This arhive is available via
                   10491: 230-
                   10492: 230-HTTP:  http://ftp.plig.org/
                   10493: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   10494: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   10495: 230-
                   10496: 230-Please email comments, bug reports and requests for packages to be
1.68      rillig   10497: 230-mirrored to ftp-admin@plig.org.
1.1       grant    10498: 230-
                   10499: 230-
                   10500: 230 Logged in anonymously.
                   10501: Remote system type is UNIX.
                   10502: Using binary mode to transfer files.
                   10503: 200 Type okay.
                   10504: 250 "/pub" is new cwd.
                   10505: 250-"/pub/figlet" is new cwd.
                   10506: 250-
                   10507: 250-Welcome to the figlet archive at ftp.figlet.org
1.68      rillig   10508: 250-
1.75      rillig   10509: 250-   ftp://ftp.figlet.org/pub/figlet/
1.1       grant    10510: 250-
                   10511: 250-The official FIGlet web page is:
1.75      rillig   10512: 250-   http://www.figlet.org/
1.1       grant    10513: 250-
                   10514: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   10515: 250-contribute a font or something else, you can email us.
1.68      rillig   10516: 250
1.1       grant    10517: 250 "/pub/figlet/program" is new cwd.
                   10518: 250 "/pub/figlet/program/unix" is new cwd.
                   10519: local: figlet221.tar.gz remote: figlet221.tar.gz
                   10520: 502 Unimplemented command.
                   10521: 227 Entering Passive Mode (195,40,6,41,246,104)
                   10522: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   10523: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   10524: 226 Transfer completed.
                   10525: 172219 bytes received in 00:02 (75.99 KB/s)
                   10526: 221 Goodbye.
                   10527: =&gt; Checksum OK for figlet221.tar.gz.
                   10528: ===&gt; Extracting for figlet-2.2.1nb2
                   10529: ===&gt; Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   10530: ===&gt; Patching for figlet-2.2.1nb2
                   10531: ===&gt; Applying pkgsrc patches for figlet-2.2.1nb2
                   10532: ===&gt; Overriding tools for figlet-2.2.1nb2
                   10533: ===&gt; Creating toolchain wrappers for figlet-2.2.1nb2
                   10534: ===&gt; Configuring for figlet-2.2.1nb2
                   10535: ===&gt; Building for figlet-2.2.1nb2
                   10536: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   10537: chmod a+x figlet
                   10538: gcc -O2 -o chkfont chkfont.c
                   10539: =&gt; Unwrapping files-to-be-installed.
1.14      xtraeme  10540: <code class="prompt">#</code>
1.75      rillig   10541: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1       grant    10542: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   10543: ===&gt; Installing for figlet-2.2.1nb2
                   10544: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   10545: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   10546: mkdir -p /usr/pkg/share/figlet
                   10547: cp figlet /usr/pkg/bin
                   10548: cp chkfont /usr/pkg/bin
                   10549: chmod 555 figlist showfigfonts
                   10550: cp figlist /usr/pkg/bin
                   10551: cp showfigfonts /usr/pkg/bin
                   10552: cp fonts/*.flf /usr/pkg/share/figlet
                   10553: cp fonts/*.flc /usr/pkg/share/figlet
                   10554: cp figlet.6 /usr/pkg/man/man6
                   10555: ===&gt; Registering installation for figlet-2.2.1nb2
1.75      rillig   10556: <code class="prompt">#</code></pre>
                   10557: </div>
                   10558: <div class="sect1" lang="en">
                   10559: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   10560: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
                   10561: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1       grant    10562: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   10563: ===&gt; Packaging figlet-2.2.1nb2
                   10564: ===&gt; Building binary package for figlet-2.2.1nb2
                   10565: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   10566: Using SrcDir value of /usr/pkg
1.68      rillig   10567: Registering depends:.
1.75      rillig   10568: <code class="prompt">#</code></pre>
                   10569: </div>
                   10570: </div>
                   10571: <div class="appendix" lang="en">
                   10572: <div class="titlepage"><div><div><h2 class="title">
1.76      rillig   10573: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
                   10574: <div class="toc">
                   10575: <p><b>Table of Contents</b></p>
                   10576: <dl>
                   10577: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
                   10578: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
                   10579: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
                   10580: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
                   10581: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
                   10582: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
                   10583: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                   10584: source packages</a></span></dt>
                   10585: </dl>
                   10586: </div>
                   10587: <p>As in other big projects, the directory layout of pkgsrc
                   10588:        is quite complex for newbies. This chapter explains where you
                   10589:        find things on the FTP server. The base directory on
1.89      rillig   10590:        <code class="filename">ftp.NetBSD.org</code> is <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top"><code class="filename">/pub/pkgsrc/</code></a>.
                   10591:        On other servers it may be different, but inside this directory,
                   10592:        everything should look the same, no matter on which server you
                   10593:        are. This directory contains some subdirectories, which are
                   10594:        explained below.</p>
1.76      rillig   10595: <div class="sect1" lang="en">
                   10596: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   10597: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
                   10598: <p>For those who only want to manage binary packages on
                   10599:        systems other than NetBSD, we provide the package management
                   10600:        tools in a separate, small tar file.</p>
                   10601: </div>
                   10602: <div class="sect1" lang="en">
                   10603: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   10604: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
                   10605: <p>The directory <code class="filename">distfiles</code> contains lots
                   10606:        of archive files from all pkgsrc packages, which are mirrored
                   10607:        here. The subdirectories are called after their package names
                   10608:        and are used when the distributed files have names that don't
                   10609:        explicitly contain a version number or are otherwise too generic
                   10610:        (for example <code class="filename">release.tar.gz</code>).</p>
                   10611: </div>
                   10612: <div class="sect1" lang="en">
                   10613: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   10614: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
                   10615: <p>This directory is currently not in use.</p>
                   10616: </div>
                   10617: <div class="sect1" lang="en">
                   10618: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   10619: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
                   10620: <p>This directory contains things that individual pkgsrc
                   10621:        developers find worth publishing.</p>
                   10622: </div>
                   10623: <div class="sect1" lang="en">
                   10624: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   10625: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
                   10626: <p>These directories contain binary packages. Those
                   10627:        directories that have a branch name
                   10628:        (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
                   10629:        contain packages from that particular branch. The directory
                   10630:        <code class="filename">packages</code> contains binary packages from
                   10631:        pkgsrc-current. (However, this does not necessarily mean that
                   10632:        the packages are still current anymore.)</p>
                   10633: <p>Below the <code class="filename">packages*</code> directories are
                   10634:        directories that distinguish the packages by operating system
                   10635:        and version, the next directory level specifies the hardware
                   10636:        architecture.</p>
                   10637: <p>In each of the platform-specific directories, there is a
                   10638:        whole binary packages collection. It has a directory called
                   10639:        <code class="filename">All</code> which contains all binary packages.
                   10640:        Besides that, there are various category directories that
                   10641:        contain symbolic links to the real binary packages.</p>
                   10642: </div>
                   10643: <div class="sect1" lang="en">
                   10644: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   10645: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
                   10646: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                   10647: source packages</h2></div></div></div>
                   10648: <p>These directories contain the &#8220;<span class="quote">real</span>&#8221; pkgsrc,
                   10649:        that is the files that define how to create binary packages from
                   10650:        source archives.</p>
                   10651: <p>The directory <code class="filename">pkgsrc</code> contains a
1.89      rillig   10652:        snapshot of the CVS repository, which is updated regularly. The
                   10653:        file <code class="filename">pkgsrc.tar.gz</code> contains the same as the
                   10654:        directory, ready to be downloaded as a whole.</p>
1.76      rillig   10655: <p>In the directories for the quarterly branches, there is an
                   10656:        additional file called
                   10657:        <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
                   10658:        which contains the state of pkgsrc when it was branched.</p>
                   10659: </div>
1.75      rillig   10660: </div>
                   10661: <div class="appendix" lang="en">
                   10662: <div class="titlepage"><div><div><h2 class="title">
                   10663: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
                   10664: <div class="toc">
                   10665: <p><b>Table of Contents</b></p>
                   10666: <dl>
1.79      rillig   10667: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75      rillig   10668: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
                   10669: </dl>
                   10670: </div>
1.79      rillig   10671: <p>This section contains information on editing the pkgsrc
                   10672:        guide itself.</p>
1.75      rillig   10673: <div class="sect1" lang="en">
                   10674: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79      rillig   10675: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
                   10676: <p>The pkgsrc guide's source code is stored in
                   10677:        <code class="filename">pkgsrc/doc/guide/files</code>, and several files
                   10678:        are created from it:</p>
                   10679: <div class="itemizedlist"><ul type="disc">
                   10680: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
                   10681: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
                   10682: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/</a></p></li>
                   10683: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</a>:
                   10684:        The PDF version of the pkgsrc guide.</p></li>
                   10685: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</a>:
                   10686:        PostScript version of the pkgsrc guide.</p></li>
1.75      rillig   10687: </ul></div>
                   10688: </div>
                   10689: <div class="sect1" lang="en">
                   10690: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   10691: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
1.79      rillig   10692: <p>The procedure to edit the pkgsrc guide is:</p>
                   10693: <div class="procedure"><ol type="1">
                   10694: <li><p>Make sure you have the packages needed to
1.83      wiz      10695:        regenerate the pkgsrc guide (and other XML-based NetBSD
1.91      rillig   10696:        documentation) installed. These are <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/netbsd-doc/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc</code></a> for creating the
                   10697:        ASCII and HTML versions, and <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/netbsd-doc-print/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc-print</code></a> for the
1.79      rillig   10698:        PostScript and PDF versions. You will need both packages
                   10699:        installed, to make sure documentation is consistent across all
                   10700:        formats.</p></li>
                   10701: <li><p>Run <span><strong class="command">cd doc/guide</strong></span> to get to the
                   10702:        right directory. All further steps will take place
                   10703:        here.</p></li>
                   10704: <li><p>Edit the XML file(s) in
                   10705:        <code class="filename">files/</code>.</p></li>
                   10706: <li><p>Run <span><strong class="command">bmake</strong></span> to check the pkgsrc
                   10707:        guide for valid XML and to build the final output files. If you
                   10708:        get any errors at this stage, you can just edit the files, as
                   10709:        there are only symbolic links in the working directory, pointing
                   10710:        to the files in <code class="filename">files/</code>.</p></li>
                   10711: <li><p><span><strong class="command">(cd files &amp;&amp; cvs
                   10712:        commit)</strong></span></p></li>
                   10713: <li><p>Run <span><strong class="command">bmake clean &amp;&amp; bmake</strong></span> to
                   10714:        regenerate the output files with the proper RCS
                   10715:        Ids.</p></li>
1.91      rillig   10716: <li>
                   10717: <p>Run <span><strong class="command">bmake regen</strong></span> to install and
                   10718:        commit the files in both <code class="filename">pkgsrc/doc</code> and
                   10719:        <code class="filename">htdocs</code>.</p>
                   10720: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   10721: <h3 class="title">Note</h3>
                   10722: <p>If you have added, removed or renamed some chapters,
1.83      wiz      10723:        you need to synchronize them using <span><strong class="command">cvs add</strong></span> or
                   10724:        <span><strong class="command">cvs delete</strong></span> in the htdocs
1.91      rillig   10725:        directory.</p>
                   10726: </div>
                   10727: </li>
1.79      rillig   10728: </ol></div>
1.75      rillig   10729: </div>
                   10730: </div>
                   10731: </div></body>
1.1       grant    10732: </html>

CVSweb <webmaster@jp.NetBSD.org>