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

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.83      wiz         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.85      jmmv       34: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.22 2006/09/01 16:35:39 jmmv 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.78      rillig     58: <dd><dl>
                     59: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
1.82      rillig     60: <dt><span class="sect2"><a href="#term.roles">1.3.2. Roles involved in pkgsrc</a></span></dt>
1.78      rillig     61: </dl></dd>
1.75      rillig     62: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
                     63: </dl></dd>
                     64: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
                     65: <dd><dl>
                     66: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
                     67: <dd><dl>
                     68: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                     69: <dd><dl>
                     70: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                     71: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                     72: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                     73: </dl></dd>
                     74: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                     75: <dd><dl>
                     76: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                     77: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                     78: </dl></dd>
                     79: </dl></dd>
                     80: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
                     81: <dd><dl>
1.82      rillig     82: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
                     83: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
                     84: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
                     85: <dd><dl>
                     86: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
                     87: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
                     88: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
                     89: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
                     90: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
                     91: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
                     92: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75      rillig     93: </dl></dd>
                     94: </dl></dd>
                     95: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
                     96: <dd><dl>
                     97: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                     98: <dd><dl>
                     99: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                    100: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82      rillig    101: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
                    102: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
                    103: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
                    104: <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>
                    105: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
                    106: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75      rillig    107: </dl></dd>
                    108: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                    109: <dd><dl>
                    110: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                    111: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                    112: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                    113: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
                    114: </dl></dd>
                    115: </dl></dd>
                    116: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
                    117: <dd><dl>
                    118: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                    119: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78      rillig    120: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
                    121: <dd><dl><dt><span class="sect2"><a href="#conf.cflags">5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt></dl></dd>
                    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>
                    143: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
                    144: <dd><dl>
                    145: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                    146: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
                    147: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
                    148: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
                    149: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
                    150: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                    151: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                    152: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
                    153: <dt><span class="sect1"><a href="#passive-ftp">7.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
                    154: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
                    155: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does &#8220;<span class="quote">Don't know how to make
                    156: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
                    157: <dt><span class="sect1"><a href="#bsd.own.mk-missing">7.12. What does &#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221; mean?</a></span></dt>
                    158: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
                    159: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
                    160: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
                    161: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80      rillig    162: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75      rillig    163: </dl></dd>
                    164: </dl></dd>
                    165: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
                    166: <dd><dl>
1.77      rillig    167: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
                    168: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75      rillig    169: <dd><dl>
1.77      rillig    170: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
                    171: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
                    172: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
1.85      jmmv      173: <dd><dl>
                    174: <dt><span class="sect2"><a href="#components.patches.guidelines">9.3.1. Patching guidelines</a></span></dt>
                    175: <dt><span class="sect2"><a href="#components.patches.feedback">9.3.2. Feedback to the author</a></span></dt>
                    176: </dl></dd>
1.77      rillig    177: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
                    178: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78      rillig    179: <dd><dl>
                    180: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
                    181: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
                    182: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
                    183: </dl></dd>
1.77      rillig    184: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
                    185: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
                    186: </dl></dd>
                    187: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
                    188: <dd><dl>
                    189: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
                    190: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
                    191: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
                    192: <dd><dl>
                    193: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
                    194: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
                    195: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
                    196: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
                    197: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
                    198: </dl></dd>
                    199: </dl></dd>
                    200: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
                    201: <dd><dl>
                    202: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
                    203: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
                    204: <dt><span class="sect1"><a href="#print-PLIST">11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
                    205: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
                    206: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
                    207: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
                    208: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
                    209: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
                    210: </dl></dd>
                    211: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
                    212: <dd><dl>
                    213: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
                    214: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
                    215: <dd><dl>
                    216: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
                    217: <dt><span class="sect2"><a href="#updating-buildlink-depends">12.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>
                    218: </dl></dd>
                    219: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
                    220: <dd><dl>
                    221: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">12.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
                    222: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
                    223: </dl></dd>
                    224: </dl></dd>
                    225: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
                    226: <dd><dl>
                    227: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
                    228: <dd><dl>
                    229: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
                    230: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
                    231: </dl></dd>
                    232: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
                    233: <dd><dl>
                    234: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
                    235: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
                    236: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
                    237: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
                    238: </dl></dd>
                    239: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
                    240: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">13.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
                    241: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
                    242: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
                    243: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
                    244: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
                    245: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">13.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
                    246: </dl></dd>
                    247: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
                    248: <dd><dl>
                    249: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
                    250: <dt><span class="sect1"><a href="#converting-to-options">14.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
                    251: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
                    252: </dl></dd>
                    253: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
                    254: <dd><dl>
                    255: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
                    256: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
                    257: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
                    258: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
                    259: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
1.81      rillig    260: <dd><dl>
                    261: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
                    262: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
                    263: </dl></dd>
1.77      rillig    264: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
                    265: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
                    266: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
                    267: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
                    268: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
                    269: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                    270: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                    271: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
                    272: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                    273: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
                    274: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
                    275: </dl></dd>
                    276: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
                    277: <dd><dl>
                    278: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
                    279: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
                    280: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
                    281: </dl></dd>
                    282: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
                    283: <dd><dl>
                    284: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
                    285: <dd><dl>
1.78      rillig    286: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
                    287: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">17.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
                    288: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
                    289: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
                    290: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
                    291: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
                    292: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
                    293: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
                    294: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
                    295: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
                    296: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
1.79      rillig    297: <dt><span class="sect2"><a href="#fixes.subst">17.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
1.77      rillig    298: </dl></dd>
                    299: <dt><span class="sect1"><a href="#fixes.fetch">17.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
                    300: <dd><dl>
                    301: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
                    302: <dt><span class="sect2"><a href="#modified-distfiles-same-name">17.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
                    303: </dl></dd>
                    304: <dt><span class="sect1"><a href="#fixes.configure">17.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                    305: <dd><dl>
                    306: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
                    307: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
                    308: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
                    309: </dl></dd>
1.87    ! wiz       310: <dt><span class="sect1"><a href="#programming-languages">17.4. Programming languages</a></span></dt>
1.77      rillig    311: <dd><dl>
1.87    ! wiz       312: <dt><span class="sect2"><a href="#basic-programming-languages">17.4.1. C, C++, and Fortran</a></span></dt>
        !           313: <dt><span class="sect2"><a href="#java-programming-language">17.4.2. Java</a></span></dt>
        !           314: <dt><span class="sect2"><a href="#perl-scripts">17.4.3. Packages containing perl scripts</a></span></dt>
        !           315: <dt><span class="sect2"><a href="#other-programming-languages">17.4.4. Other programming languages</a></span></dt>
        !           316: </dl></dd>
        !           317: <dt><span class="sect1"><a href="#fixes.build">17.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
        !           318: <dd><dl>
        !           319: <dt><span class="sect2"><a href="#fixes.build.cpp">17.5.1. Compiling C and C++ code conditionally</a></span></dt>
        !           320: <dt><span class="sect2"><a href="#compiler-bugs">17.5.2. How to handle compiler bugs</a></span></dt>
        !           321: <dt><span class="sect2"><a href="#undefined-reference">17.5.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
        !           322: <dt><span class="sect2"><a href="#out-of-memory">17.5.4. Running out of memory</a></span></dt>
        !           323: </dl></dd>
        !           324: <dt><span class="sect1"><a href="#fixes.install">17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
        !           325: <dd><dl>
        !           326: <dt><span class="sect2"><a href="#install-scripts">17.6.1. Creating needed directories</a></span></dt>
        !           327: <dt><span class="sect2"><a href="#where-to-install-documentation">17.6.2. Where to install documentation</a></span></dt>
        !           328: <dt><span class="sect2"><a href="#installing-score-files">17.6.3. Installing score files</a></span></dt>
        !           329: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
        !           330: <dt><span class="sect2"><a href="#perl-modules">17.6.5. Packages installing perl modules</a></span></dt>
        !           331: <dt><span class="sect2"><a href="#faq.info-files">17.6.6. Packages installing info files</a></span></dt>
        !           332: <dt><span class="sect2"><a href="#manpages">17.6.7. Packages installing man pages</a></span></dt>
        !           333: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.8. Packages installing GConf2 data files</a></span></dt>
        !           334: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.9. Packages installing scrollkeeper data files</a></span></dt>
        !           335: <dt><span class="sect2"><a href="#x11-fonts">17.6.10. Packages installing X11 fonts</a></span></dt>
        !           336: <dt><span class="sect2"><a href="#gtk2-modules">17.6.11. Packages installing GTK2 modules</a></span></dt>
        !           337: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.12. Packages installing SGML or XML data</a></span></dt>
        !           338: <dt><span class="sect2"><a href="#mime-database">17.6.13. Packages installing extensions to the MIME database</a></span></dt>
        !           339: <dt><span class="sect2"><a href="#intltool">17.6.14. Packages using intltool</a></span></dt>
        !           340: <dt><span class="sect2"><a href="#startup-scripts">17.6.15. Packages installing startup scripts</a></span></dt>
        !           341: <dt><span class="sect2"><a href="#tex-packages">17.6.16. Packages installing TeX modules</a></span></dt>
        !           342: <dt><span class="sect2"><a href="#emulation-packages">17.6.17. Packages supporting running binaries in
        !           343:     emulation</a></span></dt>
        !           344: <dt><span class="sect2"><a href="#hicolor-theme">17.6.18. Packages installing hicolor theme icons</a></span></dt>
        !           345: <dt><span class="sect2"><a href="#desktop-files">17.6.19. Packages installing desktop files</a></span></dt>
1.77      rillig    346: </dl></dd>
1.87    ! wiz       347: <dt><span class="sect1"><a href="#punting">17.7. Marking packages as having problems</a></span></dt>
1.77      rillig    348: </dl></dd>
                    349: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
                    350: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
                    351: <dd><dl>
                    352: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
                    353: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                    354: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
                    355: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
                    356: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
                    357: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig    358: </dl></dd>
1.77      rillig    359: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.85      jmmv      360: <dt><span class="chapter"><a href="#gnome">21. GNOME packaging and porting</a></span></dt>
                    361: <dd><dl>
                    362: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
                    363: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
                    364: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
                    365: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
                    366: </dl></dd>
1.75      rillig    367: </dl></dd>
                    368: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
                    369: <dd><dl>
1.85      jmmv      370: <dt><span class="chapter"><a href="#infr.design">22. Design of the pkgsrc infrastructure</a></span></dt>
1.75      rillig    371: <dd><dl>
1.85      jmmv      372: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
                    373: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
                    374: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.81      rillig    375: <dd><dl>
1.85      jmmv      376: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
                    377: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.81      rillig    378: </dl></dd>
1.85      jmmv      379: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
                    380: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig    381: <dd><dl>
1.85      jmmv      382: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
                    383: <dt><span class="sect2"><a href="#infr.design.intf.action">22.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75      rillig    384: </dl></dd>
1.85      jmmv      385: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.75      rillig    386: <dd><dl>
1.85      jmmv      387: <dt><span class="sect2"><a href="#infr.order.prefs">22.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
                    388: <dt><span class="sect2"><a href="#infr.order.pkg">22.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75      rillig    389: </dl></dd>
                    390: </dl></dd>
1.85      jmmv      391: <dt><span class="chapter"><a href="#regression">23. Regression tests</a></span></dt>
1.75      rillig    392: <dd><dl>
1.85      jmmv      393: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
                    394: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
                    395: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75      rillig    396: <dd><dl>
1.85      jmmv      397: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
                    398: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75      rillig    399: </dl></dd>
                    400: </dl></dd>
1.85      jmmv      401: <dt><span class="chapter"><a href="#porting">24. Porting pkgsrc</a></span></dt>
1.75      rillig    402: <dd><dl>
1.85      jmmv      403: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
                    404: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75      rillig    405: </dl></dd>
                    406: </dl></dd>
                    407: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
                    408: <dd><dl>
                    409: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
                    410: <dd><dl>
                    411: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
                    412: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
                    413: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
                    414: <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>
                    415: </dl></dd>
                    416: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
                    417: </dl></dd>
                    418: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
                    419: <dd><dl>
                    420: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
                    421: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
                    422: </dl></dd>
1.76      rillig    423: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
                    424: <dd><dl>
                    425: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
                    426: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
                    427: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
                    428: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
                    429: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
                    430: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
                    431: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                    432: source packages</a></span></dt>
                    433: </dl></dd>
1.75      rillig    434: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
                    435: <dd><dl>
1.79      rillig    436: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75      rillig    437: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
                    438: </dl></dd>
                    439: </dl>
                    440: </div>
1.82      rillig    441: <div class="list-of-tables">
                    442: <p><b>List of Tables</b></p>
                    443: <dl>
                    444: <dt>1.1. <a href="#supported-platforms">Platforms supported by pkgsrc</a>
                    445: </dt>
                    446: <dt>3.1. <a href="#binary-kits">Binary kits and available packages</a>
                    447: </dt>
1.85      jmmv      448: <dt>9.1. <a href="#patch-examples">Patching examples</a>
                    449: </dt>
                    450: <dt>21.1. <a href="#plist-handling">PLIST handling for GNOME packages</a>
                    451: </dt>
1.82      rillig    452: </dl>
                    453: </div>
1.75      rillig    454: <div class="chapter" lang="en">
                    455: <div class="titlepage"><div><div><h2 class="title">
                    456: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
                    457: <div class="toc">
                    458: <p><b>Table of Contents</b></p>
                    459: <dl>
                    460: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82      rillig    461: <dd><dl>
                    462: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
                    463: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
                    464: </dl></dd>
1.75      rillig    465: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
                    466: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.78      rillig    467: <dd><dl>
                    468: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
1.82      rillig    469: <dt><span class="sect2"><a href="#term.roles">1.3.2. Roles involved in pkgsrc</a></span></dt>
1.78      rillig    470: </dl></dd>
1.75      rillig    471: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
                    472: </dl>
                    473: </div>
                    474: <div class="sect1" lang="en">
                    475: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    476: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
1.82      rillig    477: <p>There is a lot of software freely available for Unix-based
                    478: systems, which is usually available in form of the source code. Before
                    479: such software can be used, it needs to be configured to the local
                    480: system, compiled and installed, and this is exactly what The NetBSD
                    481: Packages Collection (pkgsrc) does. pkgsrc also has some basic commands
                    482: to handle binary packages, so that not every user has to build the
                    483: packages for himself, which is a time-costly task.</p>
1.75      rillig    484: <p>pkgsrc currently contains several thousand packages,
                    485:       including:</p>
                    486: <div class="itemizedlist"><ul type="disc">
1.76      rillig    487: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/apache/README.html" target="_top"><code class="filename">www/apache</code></a> - The Apache
1.75      rillig    488:          web server</p></li>
1.83      wiz       489: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> - The Firefox
1.75      rillig    490:          web browser</p></li>
1.76      rillig    491: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome/README.html" target="_top"><code class="filename">meta-pkgs/gnome</code></a> - The GNOME
1.75      rillig    492:          Desktop Environment</p></li>
1.76      rillig    493: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a> - The K
1.75      rillig    494:          Desktop Environment</p></li>
                    495: </ul></div>
                    496: <p>...just to name a few.</p>
                    497: <p>pkgsrc has built-in support for handling varying dependencies,
                    498:       such as pthreads and X11, and extended features such as IPv6 support on
                    499:       a range of platforms.</p>
1.82      rillig    500: <div class="sect2" lang="en">
                    501: <div class="titlepage"><div><div><h3 class="title">
                    502: <a name="why-pkgsrc"></a>1.1.1. Why pkgsrc?</h3></div></div></div>
                    503: <p>
                    504: pkgsrc provides the following key features:
                    505: </p>
                    506: <div class="itemizedlist"><ul type="disc">
                    507: <li><p>Easy building of software from source as well as the creation
                    508:   and installation of binary packages. The source and latest
                    509:   patches are retrieved from a master or mirror download site, checksum
                    510:   verified, then built on your system. Support for binary-only
                    511:   distributions is available for both native platforms and NetBSD
                    512:   emulated platforms.</p></li>
                    513: <li><p>All packages are installed in a consistent directory tree,
                    514:   including binaries, libraries, man pages and other
                    515:   documentation.</p></li>
                    516: <li><p>Package dependencies, including when performing package updates,
                    517:   are handled automatically. The configuration files of various
                    518:   packages are handled automatically during updates, so local changes
                    519:   are preserved.</p></li>
                    520: <li><p>Like NetBSD, pkgsrc is designed with portability in mind and
                    521:   consists of highly portable code. This allows the greatest speed of
                    522:   development when porting to new a platform. This portability also
                    523:   ensures that pkgsrc is <span class="emphasis"><em>consistent across all
                    524:   platforms</em></span>.</p></li>
                    525: <li><p>The installation prefix, acceptable software licenses,
                    526:   international encryption requirements and build-time options for a
                    527:   large number of packages are all set in a simple, central
                    528:   configuration file.</p></li>
                    529: <li><p>The entire source (not including the distribution files) is
                    530:   freely available under a BSD license, so you may extend and adapt
                    531:   pkgsrc to your needs. Support for local packages and patches is
                    532:   available right out of the box, so you can configure it specifically
                    533:   for your environment.</p></li>
                    534: </ul></div>
                    535: </div>
                    536: <div class="sect2" lang="en">
                    537: <div class="titlepage"><div><div><h3 class="title">
                    538: <a name="intro.platforms"></a>1.1.2. Supported platforms</h3></div></div></div>
                    539: <p>pkgsrc consists of both a source distribution and a binary
                    540: distribution for these operating systems. After retrieving the required
                    541: source or binaries, you can be up and running with pkgsrc in just
                    542: minutes!</p>
1.75      rillig    543: <p>pkgsrc was derived from FreeBSD's ports system, and
                    544:       initially developed for NetBSD only. Since then, pkgsrc has
                    545:       grown a lot, and now supports the following platforms:</p>
1.82      rillig    546: <div class="table">
                    547: <a name="supported-platforms"></a><p class="title"><b>Table 1.1. Platforms supported by pkgsrc</b></p>
1.83      wiz       548: <div class="table-contents"><table summary="Platforms supported by pkgsrc" border="1">
1.82      rillig    549: <colgroup>
                    550: <col>
                    551: <col>
                    552: </colgroup>
                    553: <thead><tr>
                    554: <th>Platform</th>
                    555: <th>Date Support Added</th>
                    556: </tr></thead>
                    557: <tbody>
                    558: <tr>
                    559: <td><a href="http://www.NetBSD.org/" target="_top">NetBSD</a></td>
                    560: <td align="center">Aug 1997</td>
                    561: </tr>
                    562: <tr>
                    563: <td><a href="http://wwws.sun.com/software/solaris/" target="_top">Solaris</a></td>
                    564: <td align="center">Mar 1999</td>
                    565: </tr>
                    566: <tr>
                    567: <td><a href="http://www.kernel.org/" target="_top">Linux</a></td>
                    568: <td align="center">Jun 1999</td>
                    569: </tr>
                    570: <tr>
                    571: <td>
                    572:           <a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
                    573:           (<a href="http://developer.apple.com/macosx/" target="_top">Mac OS X</a>)
                    574:         </td>
                    575: <td align="center">Oct 2001</td>
                    576: </tr>
                    577: <tr>
                    578: <td><a href="http://www.freebsd.org/" target="_top">FreeBSD</a></td>
                    579: <td align="center">Nov 2002</td>
                    580: </tr>
                    581: <tr>
                    582: <td><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></td>
                    583: <td align="center">Nov 2002</td>
                    584: </tr>
                    585: <tr>
                    586: <td><a href="http://www.sgi.com/software/irix/" target="_top">IRIX</a></td>
                    587: <td align="center">Dec 2002</td>
                    588: </tr>
                    589: <tr>
                    590: <td>BSD/OS</td>
                    591: <td align="center">Dec 2003</td>
                    592: </tr>
                    593: <tr>
                    594: <td><a href="http://www-1.ibm.com/servers/aix/" target="_top">AIX</a></td>
                    595: <td align="center">Dec 2003</td>
                    596: </tr>
                    597: <tr>
                    598: <td>
                    599:           <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a>
                    600:           (Microsoft Windows Services for Unix)
                    601:         </td>
                    602: <td align="center">Mar 2004</td>
                    603: </tr>
                    604: <tr>
                    605: <td><a href="http://www.dragonflybsd.org/" target="_top">DragonFlyBSD</a></td>
                    606: <td align="center">Oct 2004</td>
                    607: </tr>
                    608: <tr>
                    609: <td><a href="http://www.tru64.org/" target="_top">OSF/1</a></td>
                    610: <td align="center">Nov 2004</td>
                    611: </tr>
                    612: </tbody>
1.83      wiz       613: </table></div>
1.82      rillig    614: </div>
1.83      wiz       615: <br class="table-break">
1.82      rillig    616: </div>
1.75      rillig    617: </div>
                    618: <div class="sect1" lang="en">
                    619: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    620: <a name="overview"></a>1.2. Overview</h2></div></div></div>
                    621: <p>This document is divided into three parts. The first,
                    622:        <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
                    623:        describes how one can use one of the packages in the Package
                    624:        Collection, either by installing a precompiled binary package,
                    625:        or by building one's own copy using the NetBSD package system. 
                    626:        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
                    627:        package so it can be easily built by other NetBSD users without
                    628:        knowing about the package's building details. The third part,
                    629:        <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
                    630:        is intended for those who want to understand how pkgsrc is
                    631:        implemented.</p>
                    632: <p>This document is available in various formats:
                    633:        <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>
                    634: </div>
                    635: <div class="sect1" lang="en">
                    636: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    637: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
                    638: <p>There has been a lot of talk about &#8220;<span class="quote">ports</span>&#8221;,
                    639:       &#8220;<span class="quote">packages</span>&#8221;, etc. so far. Here is a description of all the
                    640:       terminology used within this document.</p>
                    641: <div class="variablelist"><dl>
                    642: <dt><span class="term">Package</span></dt>
                    643: <dd><p>A set of files and building instructions
                    644:            that describe what's necessary
                    645:            to build a certain piece of software using
                    646:             pkgsrc. Packages are traditionally stored under
1.76      rillig    647:            <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75      rillig    648: <dt><span class="term">The NetBSD package system</span></dt>
1.87    ! wiz       649: <dd><p>This is the former name of &#8220;<span class="quote">pkgsrc</span>&#8221;.  It
        !           650:          is part of the NetBSD operating system and can be bootstrapped
        !           651:          to run on non-NetBSD operating systems as well.  It handles
        !           652:          building (compiling), installing, and removing of
        !           653:          packages.</p></dd>
1.75      rillig    654: <dt><span class="term">Distfile</span></dt>
                    655: <dd><p>This term describes the file or files that are
                    656:            provided by the author of the piece of software to
                    657:            distribute his work. All the changes necessary to build on
                    658:            NetBSD are reflected in the corresponding package. Usually
                    659:            the distfile is in the form of a compressed tar-archive,
                    660:            but other types are possible, too. Distfiles are usually
                    661:            stored below
1.76      rillig    662:            <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75      rillig    663: <dt><span class="term">Port</span></dt>
                    664: <dd><p>This is the term used by FreeBSD and OpenBSD people
                    665:            for what we call a package.
                    666:            In NetBSD terminology, &#8220;<span class="quote">port</span>&#8221; refers to a different
                    667:            architecture.</p></dd>
                    668: <dt><span class="term">Precompiled/binary package</span></dt>
                    669: <dd>
                    670: <p>A set of binaries built with pkgsrc from a distfile
1.76      rillig    671:            and stuffed together in a single <code class="filename">.tgz</code>
1.75      rillig    672:            file so it can be installed on machines of the same
                    673:            machine architecture without the need to
                    674:            recompile. Packages are usually generated in
1.76      rillig    675:            <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75      rillig    676:            an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
                    677: <p>Sometimes, this is referred to by the term &#8220;<span class="quote">package</span>&#8221; too,
                    678:            especially in the context of precompiled packages.</p>
                    679: </dd>
                    680: <dt><span class="term">Program</span></dt>
                    681: <dd><p>The piece of software to be installed which will be constructed from
                    682:            all the files in the distfile by the actions defined in the
                    683:            corresponding package.</p></dd>
                    684: </dl></div>
                    685: <div class="sect2" lang="en">
                    686: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig    687: <a name="term.abbrev"></a>1.3.1. Commonly used abbreviations</h3></div></div></div>
                    688: <div class="variablelist"><dl>
                    689: <dt><span class="term">ICE</span></dt>
                    690: <dd><p>Internal Compiler
                    691:        Error</p></dd>
                    692: </dl></div>
                    693: </div>
                    694: <div class="sect2" lang="en">
                    695: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig    696: <a name="term.roles"></a>1.3.2. Roles involved in pkgsrc</h3></div></div></div>
1.75      rillig    697: <div class="variablelist"><dl>
                    698: <dt><span class="term">pkgsrc users</span></dt>
                    699: <dd>
                    700: <p>The
                    701:        pkgsrc users are people who use the packages provided by pkgsrc.
                    702:        Typically they are system administrators. The people using the
                    703:        software that is inside the packages (maybe called &#8220;<span class="quote">end
                    704:        users</span>&#8221;) are not covered by the pkgsrc guide.</p>
                    705: <p>There are two kinds of pkgsrc users: Some only want to
                    706:        install pre-built binary packages. Others build the pkgsrc
                    707:        packages from source, either for installing them directly or for
                    708:        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
                    709:        documentation.</p>
                    710: </dd>
                    711: <dt><span class="term">package maintainers</span></dt>
                    712: <dd><p>A
                    713:        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>
                    714: <dt><span class="term">infrastructure developers</span></dt>
                    715: <dd><p>These people are involved in all those files
1.76      rillig    716:        that live in the <code class="filename">mk/</code> directory and below.
1.75      rillig    717:        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,
                    718:        too.</p></dd>
                    719: </dl></div>
                    720: </div>
                    721: </div>
                    722: <div class="sect1" lang="en">
                    723: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    724: <a name="typography"></a>1.4. Typography</h2></div></div></div>
                    725: <p>When giving examples for commands, shell prompts are used to
                    726:       show if the command should/can be issued as root, or if
                    727:       &#8220;<span class="quote">normal</span>&#8221; user privileges are sufficient. We use a
                    728:       <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
                    729:       shell prompt, assuming they use the C-shell or tcsh.</p>
                    730: </div>
                    731: </div>
                    732: <div class="part" lang="en">
                    733: <div class="titlepage"><div><div><h1 class="title">
                    734: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
                    735: <div class="toc">
                    736: <p><b>Table of Contents</b></p>
                    737: <dl>
                    738: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
                    739: <dd><dl>
                    740: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                    741: <dd><dl>
                    742: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                    743: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                    744: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                    745: </dl></dd>
                    746: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                    747: <dd><dl>
                    748: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                    749: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                    750: </dl></dd>
                    751: </dl></dd>
                    752: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
                    753: <dd><dl>
1.82      rillig    754: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
                    755: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
                    756: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
                    757: <dd><dl>
                    758: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
                    759: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
                    760: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
                    761: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
                    762: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
                    763: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
                    764: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75      rillig    765: </dl></dd>
                    766: </dl></dd>
                    767: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
                    768: <dd><dl>
                    769: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                    770: <dd><dl>
                    771: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                    772: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82      rillig    773: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
                    774: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
                    775: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
                    776: <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>
                    777: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
                    778: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75      rillig    779: </dl></dd>
                    780: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                    781: <dd><dl>
                    782: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                    783: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                    784: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                    785: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
                    786: </dl></dd>
                    787: </dl></dd>
                    788: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
                    789: <dd><dl>
                    790: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                    791: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78      rillig    792: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
                    793: <dd><dl><dt><span class="sect2"><a href="#conf.cflags">5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt></dl></dd>
                    794: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
                    795: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75      rillig    796: </dl></dd>
                    797: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
                    798: <dd><dl>
                    799: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                    800: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                    801: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                    802: <dd><dl>
                    803: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                    804: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                    805: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                    806: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                    807: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                    808: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                    809: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                    810: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                    811: </dl></dd>
                    812: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                    813: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                    814: </dl></dd>
                    815: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
                    816: <dd><dl>
                    817: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                    818: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
                    819: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
                    820: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
                    821: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
                    822: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                    823: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                    824: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
                    825: <dt><span class="sect1"><a href="#passive-ftp">7.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
                    826: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
                    827: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does &#8220;<span class="quote">Don't know how to make
                    828: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
                    829: <dt><span class="sect1"><a href="#bsd.own.mk-missing">7.12. What does &#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221; mean?</a></span></dt>
                    830: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
                    831: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
                    832: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
                    833: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80      rillig    834: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75      rillig    835: </dl></dd>
                    836: </dl>
                    837: </div>
                    838: <div class="chapter" lang="en">
                    839: <div class="titlepage"><div><div><h2 class="title">
                    840: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
                    841: <div class="toc">
                    842: <p><b>Table of Contents</b></p>
                    843: <dl>
                    844: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                    845: <dd><dl>
                    846: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                    847: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                    848: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                    849: </dl></dd>
                    850: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                    851: <dd><dl>
                    852: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                    853: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                    854: </dl></dd>
                    855: </dl>
                    856: </div>
                    857: <p>The most common location where pkgsrc is installed is
1.76      rillig    858:        <code class="filename">/usr/pkgsrc</code> for the &#8220;<span class="quote">package
                    859:        sources</span>&#8221; and <code class="filename">/usr/pkg</code> for the
1.75      rillig    860:        installed binary packages. You are though free to install the
                    861:        sources and binary packages wherever you want in your
                    862:        filesystem, provided that both paths do not contain white-space
                    863:        or other characters that are interpreted specially by the shell
                    864:        and some other programs. A safe bet is to use only letters,
                    865:        digits, underscores and dashes in the names.</p>
                    866: <div class="sect1" lang="en">
                    867: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    868: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
                    869: <p>Before you download any pkgsrc files, you should decide
                    870:        whether you want the <span class="emphasis"><em>current</em></span> branch or the
                    871:        <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
                    872:        quarterly basis from the current branch and only gets modified
                    873:        for security updates. The names of the stable branches are built
                    874:        from the year and the quarter, for example
                    875:        <code class="literal">2006Q1</code>.</p>
                    876: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
                    877:        want to download pkgsrc. You can get it as a tar file, via SUP,
                    878:        or via CVS. All three ways are described here.</p>
                    879: <div class="sect2" lang="en">
                    880: <div class="titlepage"><div><div><h3 class="title">
                    881: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
                    882: <p>The primary download location for all pkgsrc files is
                    883:        <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
                    884:        number of subdirectories for different purposes, which are
1.76      rillig    885:        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    886: <p>The tar file for the current branch is in the directory
1.76      rillig    887:        <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    888:        It is autogenerated daily.</p>
                    889: <p>The tar file for the stable branch 2006Q1 is in the
1.76      rillig    890:        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    891: <p>After downloading the tar file, change to the directory
                    892:        where you want to have pkgsrc. This is usually
1.76      rillig    893:        <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75      rillig    894:        pkgsrc.tar.gz</strong></span> to extract the files.</p>
                    895: </div>
                    896: <div class="sect2" lang="en">
                    897: <div class="titlepage"><div><div><h3 class="title">
                    898: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
                    899: <p>As an alternative to the tar file, you can get pkgsrc via
                    900:        the Software Update Protocol, SUP. To do so, make sure your
                    901:        supfile has a line
1.1       grant     902: 
1.75      rillig    903: </p>
                    904: <pre class="programlisting">
1.51      rillig    905:     release=pkgsrc
1.1       grant     906: </pre>
1.75      rillig    907: <p>
1.1       grant     908: 
1.75      rillig    909:        in it, see the examples in
1.76      rillig    910:        <code class="filename">/usr/share/examples/supfiles</code>, and that the
                    911:        <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75      rillig    912:        run <span><strong class="command">sup -v
                    913:        <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
                    914: </div>
                    915: <div class="sect2" lang="en">
                    916: <div class="titlepage"><div><div><h3 class="title">
                    917: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
                    918: <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>
                    919:        installed. To do an initial (full) checkout of pkgsrc, you first
                    920:        have to set some environment variables. For the C-Shell,
                    921:        type:</p>
                    922: <pre class="screen">
                    923:     <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
                    924:     <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
                    925: </pre>
                    926: <p>Or, the same for the bourne shell:</p>
                    927: <pre class="screen">
                    928:     <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
                    929:     <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
                    930:     <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
                    931: </pre>
                    932: <p>Then, you change to the directory where you want to have
                    933:        your copy of pkgsrc. In most cases this is
1.76      rillig    934:        <code class="filename">/usr</code>. In that directory you run the
1.75      rillig    935:        checkout command, which is <span><strong class="command">cvs -q checkout -P
                    936:        pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
                    937:        checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
                    938:        branch. This command will create a directory called
1.76      rillig    939:        <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75      rillig    940:        it.</p>
                    941: </div>
                    942: </div>
                    943: <div class="sect1" lang="en">
                    944: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    945: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
                    946: <p>The preferred way to keep pkgsrc up-to-date is via CVS
                    947:        (which also works if you have first installed it via a tar
                    948:        file). It saves bandwidth and hard disk activity, compared to
                    949:        downloading the tar file again.</p>
                    950: <div class="sect2" lang="en">
                    951: <div class="titlepage"><div><div><h3 class="title">
                    952: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
                    953: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
                    954: <h3 class="title">Warning</h3>
1.77      rillig    955: <p>When updating from a tar file, you first need to
                    956:        completely remove the old pkgsrc directory. Otherwise those
                    957:        files that have been removed from pkgsrc in the mean time will
                    958:        not be removed on your local disk, resulting in inconsistencies.
                    959:        When removing the old files, any changes that you have done to
                    960:        the pkgsrc files will be lost after updating. Therefore updating
                    961:        via CVS is strongly recommended.</p>
1.75      rillig    962: </div>
1.82      rillig    963: <p>Note that by default the distfiles and the binary packages
                    964:        are saved in the pkgsrc tree, so don't forget to rescue them
                    965:        before updating. You can also configure pkgsrc to use other than
                    966:        the default directories by setting the
                    967:        <code class="varname">DISTDIR</code> and <code class="varname">PACKAGES</code>
                    968:        variables. See <a href="#configuring" title="Chapter 5. Configuring pkgsrc">Chapter 5, <i>Configuring pkgsrc</i></a> for the details.</p>
1.75      rillig    969: <p>To update pkgsrc from a tar file, download the tar file as
                    970:        explained above. Then, make sure that you have not made any
                    971:        changes to the files in the pkgsrc directory. Remove the pkgsrc
                    972:        directory and extract the new tar file. Done.</p>
                    973: </div>
                    974: <div class="sect2" lang="en">
                    975: <div class="titlepage"><div><div><h3 class="title">
                    976: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
                    977: <p>To update pkgsrc via CVS, make sure the environment
                    978:        variable <code class="varname">CVS_RSH</code> is set as above. Then,
                    979:        change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77      rillig    980:        -dP</strong></span>.</p>
1.75      rillig    981: <div class="sect3" lang="en">
                    982: <div class="titlepage"><div><div><h4 class="title">
                    983: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
                    984: <p>When updating pkgsrc, the CVS program keeps track of the
                    985:        branch you selected. But if you, for whatever reason, want to
                    986:        switch from the stable branch to the current one, you can do it
                    987:        by adding the option &#8220;<span class="quote">-A</span>&#8221; after the
                    988:        &#8220;<span class="quote">update</span>&#8221; keyword. To switch from the current branch
                    989:        back to the stable branch, add the
                    990:        &#8220;<span class="quote">-rpkgsrc-2006Q1</span>&#8221; option.</p>
                    991: </div>
                    992: <div class="sect3" lang="en">
                    993: <div class="titlepage"><div><div><h4 class="title">
                    994: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
                    995: <p>When you update pkgsrc, the CVS program will only touch
                    996:        those files that are registered in the CVS repository. That
                    997:        means that any packages that you created on your own will stay
                    998:        unmodified. If you change files that are managed by CVS, later
                    999:        updates will try to merge your changes with those that have been
                   1000:        done by others. See the CVS manual, chapter
                   1001:        &#8220;<span class="quote">update</span>&#8221; for details.</p>
                   1002: </div>
                   1003: </div>
                   1004: </div>
                   1005: </div>
                   1006: <div class="chapter" lang="en">
                   1007: <div class="titlepage"><div><div><h2 class="title">
                   1008: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
                   1009: <div class="toc">
                   1010: <p><b>Table of Contents</b></p>
                   1011: <dl>
1.82      rillig   1012: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
                   1013: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
                   1014: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
                   1015: <dd><dl>
                   1016: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
                   1017: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
                   1018: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
                   1019: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
                   1020: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
                   1021: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
                   1022: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75      rillig   1023: </dl></dd>
                   1024: </dl>
                   1025: </div>
                   1026: <div class="sect1" lang="en">
                   1027: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82      rillig   1028: <a name="binarydist"></a>3.1. Binary distribution</h2></div></div></div>
                   1029: <p>
                   1030: We provide a bootstrap kit in both source and binary form for other
                   1031: platforms than NetBSD, consisting of the pkg administration tools and other
                   1032: tools required to use pkgsrc and build packages.
                   1033: </p>
                   1034: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1035: <h3 class="title">Note</h3>
                   1036: <p>
                   1037: Older binary snapshots are available in the
                   1038: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/archive/" target="_top">bootstrap-pkgsrc/archive</a>
                   1039: directory on ftp.NetBSD.org.</p>
                   1040: </div>
                   1041: <div class="table">
                   1042: <a name="binary-kits"></a><p class="title"><b>Table 3.1. Binary kits and available packages</b></p>
1.83      wiz      1043: <div class="table-contents"><table summary="Binary kits and available packages" border="1">
1.82      rillig   1044: <colgroup>
                   1045: <col>
                   1046: <col>
                   1047: <col>
                   1048: <col>
                   1049: </colgroup>
                   1050: <thead><tr>
                   1051: <th>Platform</th>
                   1052: <th>Latest snapshot</th>
                   1053: <th>Binary kit</th>
                   1054: <th>Binary packages</th>
                   1055: </tr></thead>
                   1056: <tbody>
                   1057: <tr>
                   1058: <td class="osname">Darwin 5.5/powerpc (Mac OS X 10.1.5)</td>
                   1059: <td class="date">20021209</td>
                   1060: <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>
                   1061: <td class="binary-pkgs-url"> </td>
                   1062: </tr>
                   1063: <tr>
                   1064: <td class="osname">Darwin 6.6/powerpc (Mac OS X 10.2.6)</td>
                   1065: <td class="date">20030623</td>
                   1066: <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>
                   1067: <td class="binary-pkgs-url"> </td>
                   1068: </tr>
                   1069: <tr>
                   1070: <td class="osname">Darwin 7.6/powerpc (Mac OS X 10.3.6)</td>
                   1071: <td class="date">20041219</td>
                   1072: <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>
                   1073: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Darwin-7.6/" target="_top">binary packages</a></td>
                   1074: </tr>
                   1075: <tr>
                   1076: <td class="osname">Darwin 7.8/powerpc (Mac OS X 10.3.8)</td>
                   1077: <td class="date">20050320</td>
                   1078: <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>
                   1079: <td class="binary-pkgs-url"> </td>
                   1080: </tr>
                   1081: <tr>
                   1082: <td class="osname">Darwin 8.1/powerpc (Mac OS X 10.4.1)</td>
                   1083: <td class="date">20050625</td>
                   1084: <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>
                   1085: <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>
                   1086: </tr>
                   1087: <tr>
                   1088: <td class="osname">Debian GNU Linux/i386</td>
                   1089: <td class="date">20031023</td>
                   1090: <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>
                   1091: <td class="binary-pkgs-url"> </td>
                   1092: </tr>
                   1093: <tr>
                   1094: <td class="osname">Fedora Core 2 Linux/i386</td>
                   1095: <td class="date">20050618</td>
                   1096: <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>
                   1097: <td class="binary-pkgs-url"> </td>
                   1098: </tr>
                   1099: <tr>
                   1100: <td class="osname">Fedora Core 4 Linux/i386</td>
                   1101: <td class="date">20060105</td>
                   1102: <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>
                   1103: <td class="binary-pkgs-url"> </td>
                   1104: </tr>
                   1105: <tr>
                   1106: <td class="osname">FreeBSD 3.5/i386</td>
                   1107: <td class="date">20030411</td>
                   1108: <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>
                   1109: <td class="binary-pkgs-url"> </td>
                   1110: </tr>
                   1111: <tr>
                   1112: <td class="osname">FreeBSD 4.7/i386</td>
                   1113: <td class="date">20021211</td>
                   1114: <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>
                   1115: <td class="binary-pkgs-url"> </td>
                   1116: </tr>
                   1117: <tr>
                   1118: <td class="osname">FreeBSD 5.0/i386</td>
                   1119: <td class="date">20030411</td>
                   1120: <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>
                   1121: <td class="binary-pkgs-url"> </td>
                   1122: </tr>
                   1123: <tr>
                   1124: <td class="osname">FreeBSD 5.1/i386</td>
                   1125: <td class="date">20030630</td>
                   1126: <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>
                   1127: <td class="binary-pkgs-url"> </td>
                   1128: </tr>
                   1129: <tr>
                   1130: <td class="osname">FreeBSD 5.2.1/i386</td>
                   1131: <td class="date">20040227</td>
                   1132: <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>
                   1133: <td class="binary-pkgs-url"> </td>
                   1134: </tr>
                   1135: <tr>
                   1136: <td class="osname">FreeBSD 5.3/i386</td>
                   1137: <td class="date">20050119</td>
                   1138: <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>
                   1139: <td class="binary-pkgs-url"> </td>
                   1140: </tr>
                   1141: <tr>
                   1142: <td class="osname">Interix 3.5</td>
                   1143: <td class="date">20051010</td>
                   1144: <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>
                   1145: <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>
                   1146: </tr>
                   1147: <tr>
                   1148: <td class="osname">IRIX 6.5 n32-bit ABI</td>
                   1149: <td class="date">20040911</td>
                   1150: <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>
                   1151: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/n32/" target="_top">binary packages</a></td>
                   1152: </tr>
                   1153: <tr>
                   1154: <td class="osname">IRIX 6.5 64-bit ABI</td>
                   1155: <td class="date">20040912</td>
                   1156: <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>
                   1157: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/64/" target="_top">binary packages</a></td>
                   1158: </tr>
                   1159: <tr>
                   1160: <td class="osname">OpenBSD 3.2/i386</td>
                   1161: <td class="date">20030420</td>
                   1162: <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>
                   1163: <td class="binary-pkgs-url"> </td>
                   1164: </tr>
                   1165: <tr>
                   1166: <td class="osname">OpenBSD 3.3/i386</td>
                   1167: <td class="date">20030503</td>
                   1168: <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>
                   1169: <td class="binary-pkgs-url"> </td>
                   1170: </tr>
                   1171: <tr>
                   1172: <td class="osname">OpenBSD 3.5/i386</td>
                   1173: <td class="date">20040507</td>
                   1174: <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>
                   1175: <td class="binary-pkgs-url"> </td>
                   1176: </tr>
                   1177: <tr>
                   1178: <td class="osname">Slackware Linux 8.1/i386</td>
                   1179: <td class="date">20030417</td>
                   1180: <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>
                   1181: <td class="binary-pkgs-url"> </td>
                   1182: </tr>
                   1183: <tr>
                   1184: <td class="osname">Slackware Linux 9/i386</td>
                   1185: <td class="date">20031023</td>
                   1186: <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>
                   1187: <td class="binary-pkgs-url"> </td>
                   1188: </tr>
                   1189: <tr>
                   1190: <td class="osname">Solaris 8/sparc</td>
                   1191: <td class="date">20050220</td>
                   1192: <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>
                   1193: <td class="binary-pkgs-url"> </td>
                   1194: </tr>
                   1195: <tr>
                   1196: <td class="osname">Solaris 8/i386</td>
                   1197: <td class="date">20050220</td>
                   1198: <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>
                   1199: <td class="binary-pkgs-url"> </td>
                   1200: </tr>
                   1201: <tr>
                   1202: <td class="osname">Solaris 9/sparc</td>
                   1203: <td class="date">20041208</td>
                   1204: <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>
                   1205: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/SunOS-5.9/sparc/" target="_top">binary packages</a></td>
                   1206: </tr>
                   1207: <tr>
                   1208: <td class="osname">Solaris 9/i386</td>
                   1209: <td class="date">20030411</td>
                   1210: <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>
                   1211: <td class="binary-pkgs-url"> </td>
                   1212: </tr>
                   1213: </tbody>
1.83      wiz      1214: </table></div>
1.82      rillig   1215: </div>
1.83      wiz      1216: <br class="table-break"><p>
1.82      rillig   1217: Simply download the binary kit for your platform, and extract it into
                   1218: <code class="filename">/</code> e.g.
                   1219: </p>
                   1220: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
                   1221: <code class="prompt">#</code> <strong class="userinput"><code>gzip -c -d /tmp/bootstrap-pkgsrc-SunOS-5.9-sparc-20031023.tar.gz \
                   1222:   | tar -xpf -</code></strong></pre>
                   1223: <p>
                   1224: Of course, as with any binary distributions, you should verify the
                   1225: checksum against the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/SUM" target="_top">SUM</a>
                   1226: or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/CKSUM" target="_top">CKSUM</a>
                   1227: file and inspect the contents before extracting it.
                   1228: </p>
                   1229: </div>
                   1230: <div class="sect1" lang="en">
                   1231: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1232: <a name="bootstrapping-pkgsrc"></a>3.2. Bootstrapping pkgsrc</h2></div></div></div>
                   1233: <p>Installing the bootstrap kit from source should be as simple as:</p>
1.75      rillig   1234: <pre class="screen">
                   1235: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
                   1236: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1.87    ! wiz      1237: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong>
        !          1238:     </pre>
1.75      rillig   1239: <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      1240:     pkgsrc before bootstrapping. The given
        !          1241:     <span><strong class="command">bootstrap</strong></span> command will use the defaults of
        !          1242:     <code class="filename">/usr/pkg</code> for the
        !          1243:     <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
        !          1244:     and <code class="filename">/var/db/pkg</code> for the package database
        !          1245:     directory where pkgsrc will do its internal bookkeeping.
        !          1246:     However, these can also be set using command-line
        !          1247:     arguments.</p>
1.75      rillig   1248: <p>Binary packages for the pkgsrc tools and an initial set of packages is
1.87    ! wiz      1249:     available for supported platforms. An up-to-date list of these can be
        !          1250:     found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
        !          1251:     Note that this only works for privileged builds that install
        !          1252:     into <code class="filename">/usr/pkg</code>.</p>
1.75      rillig   1253: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1254: <h3 class="title">Note</h3>
                   1255: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
1.87    ! wiz      1256:       Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
        !          1257:       For examples in this guide, use <span><strong class="command">bmake</strong></span>
        !          1258:       instead of &#8220;<span class="quote">make</span>&#8221;.</p>
1.75      rillig   1259: </div>
                   1260: </div>
                   1261: <div class="sect1" lang="en">
                   1262: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82      rillig   1263: <a name="platform-specific-notes"></a>3.3. Platform-specific notes</h2></div></div></div>
1.75      rillig   1264: <p>Here are some platform-specific notes you should be aware of.</p>
                   1265: <div class="sect2" lang="en">
                   1266: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1267: <a name="darwin"></a>3.3.1. Darwin (Mac OS X)</h3></div></div></div>
1.85      jmmv     1268: <p>Darwin 5.x and up are supported. There are two methods of using
1.82      rillig   1269:        pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.3.1.1. Using a disk image">disk
                   1270:          image</a>, or a <a href="#platform.osx-ufs" title="3.3.1.2. Using a UFS partition">UFS
1.75      rillig   1271:          partition</a>.</p>
                   1272: <p>Before you start, you will need to download and install the Mac OS X Developer
1.87    ! wiz      1273:       Tools from Apple's Developer Connection.  See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
        !          1274:       for details.  Also, make sure you install X11 for Mac OS X and the X11 SDK
        !          1275:       from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
        !          1276:       if you intend to build packages that use the X11 Window System.</p>
1.75      rillig   1277: <p>If you already have a UFS partition, or have a spare partition
1.87    ! wiz      1278:       that you can format as UFS, it is recommended to use that instead of
        !          1279:       the disk image. It'll be somewhat faster and will mount automatically
        !          1280:       at boot time, where you must manually mount a disk image.</p>
1.75      rillig   1281: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1282: <h3 class="title">Note</h3>
1.85      jmmv     1283: <p>You cannot use an ordinary HFS+ file system for pkgsrc, because pkgsrc currently
                   1284:          requires the file system to be case-sensitive. You can, however, use a case-sensitive HFS+ file system as found in Darwin 7.0 and newer.</p>
1.75      rillig   1285: </div>
                   1286: <div class="sect3" lang="en">
                   1287: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1288: <a name="platform.osx-image"></a>3.3.1.1. Using a disk image</h4></div></div></div>
1.75      rillig   1289: <p>Create the disk image:</p>
                   1290: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1.85      jmmv     1291: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
                   1292: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage mount ~/Documents/NetBSD</code></strong>
1.75      rillig   1293: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
1.85      jmmv     1294: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1295: <h3 class="title">Note</h3>
                   1296: <p>darwindiskimage will mount the filesystem nosuid, which will cause problems for packages that depend on setgid.  It will also mount the filesystem asynchronous, which is somewhat dangerous according to the mount(8) man page.</p>
                   1297: </div>
                   1298: <p>Allow suid and synchronous writes:</p>
                   1299: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sudo mount -u -o suid,sync /Volumes/NetBSD</code></strong></pre>
1.75      rillig   1300: </div>
                   1301: <div class="sect3" lang="en">
                   1302: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1303: <a name="platform.osx-ufs"></a>3.3.1.2. Using a UFS partition</h4></div></div></div>
1.76      rillig   1304: <p>By default, <code class="filename">/usr</code> will be on your root file
1.87    ! wiz      1305:        system, normally HFS+. It is possible to use the default
        !          1306:        <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
        !          1307:        by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
        !          1308:        file system. Obviously, another symlink is required if you want to
        !          1309:        place the package database directory outside the
        !          1310:        <span class="emphasis"><em>prefix</em></span>. e.g.</p>
1.75      rillig   1311: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
                   1312: <p>If you created your partitions at the time of installing Mac OS X
1.87    ! wiz      1313:        and formatted the target partition as UFS, it should automatically
        !          1314:        mount on <code class="filename">/Volumes/&lt;volume name&gt;</code> when the
        !          1315:        machine boots. If you are (re)formatting a partition as UFS, you need
        !          1316:        to ensure that the partition map correctly reflects
        !          1317:        &#8220;<span class="quote">Apple_UFS</span>&#8221; and not &#8220;<span class="quote">Apple_HFS</span>&#8221;.</p>
1.75      rillig   1318: <p>The problem is that none of the disk tools will let you touch a
1.87    ! wiz      1319:        disk that is booted from. You can unmount the partition, but even if
        !          1320:        you newfs it, the partition type will be incorrect and the
        !          1321:        automounter won't mount it. It can be mounted manually, but it won't
        !          1322:        appear in Finder.</p>
1.75      rillig   1323: <p>You'll need to boot off of the OS X Installation (User) CD.  When
1.87    ! wiz      1324:        the Installation program starts, go up to the menu and select Disk
        !          1325:        Utility.  Now, you will be able to select the partition you want
        !          1326:        to be UFS, and Format it Apple UFS. Quit the Disk Utility, quit the
        !          1327:        installer which will reboot your machine. The new UFS file system
        !          1328:        will appear in Finder.</p>
1.75      rillig   1329: <p>Be aware that the permissions on the new file system will be writable
1.87    ! wiz      1330:        by root only.</p>
1.75      rillig   1331: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
1.87    ! wiz      1332:        Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
1.75      rillig   1333: </div>
                   1334: </div>
                   1335: <div class="sect2" lang="en">
                   1336: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1337: <a name="freebsd"></a>3.3.2. FreeBSD</h3></div></div></div>
1.87    ! wiz      1338: <p>FreeBSD 4.7 and 5.0 have been tested and are supported,
        !          1339:       other versions may work.</p>
1.75      rillig   1340: <p>Care should be taken so that the tools that this kit installs do not conflict
1.87    ! wiz      1341:       with the FreeBSD userland tools. There are several steps:</p>
1.75      rillig   1342: <div class="orderedlist"><ol type="1">
                   1343: <li><p>FreeBSD stores its ports pkg database in
1.87    ! wiz      1344:          <code class="filename">/var/db/pkg</code>. It is therefore
        !          1345:          recommended that you choose a different location (e.g.
        !          1346:          <code class="filename">/usr/pkgdb</code>) by
        !          1347:          using the --pkgdbdir option to the bootstrap script.</p></li>
1.75      rillig   1348: <li>
                   1349: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
1.87    ! wiz      1350:          good idea to move them out of the way to avoid confusion, e.g.</p>
        !          1351: <pre class="screen">
        !          1352: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1.75      rillig   1353: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
                   1354: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
                   1355: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1.87    ! wiz      1356: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
        !          1357:          </pre>
1.75      rillig   1358: </li>
1.76      rillig   1359: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1.87    ! wiz      1360:          <code class="filename">/etc/mk.conf.example</code> file
        !          1361:          when you use the bootstrap script.</p></li>
1.75      rillig   1362: </ol></div>
                   1363: </div>
                   1364: <div class="sect2" lang="en">
                   1365: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1366: <a name="interix"></a>3.3.3. Interix</h3></div></div></div>
1.75      rillig   1367: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
1.87    ! wiz      1368:       providing a Unix-like environment with a tighter kernel integration than
        !          1369:       available with Cygwin.  It is part of the Windows Services for Unix
        !          1370:       package, available for free for any licensed copy of Windows 2000, XP
        !          1371:       (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   1372: <p>Services for Unix 3.5, current as of this writing, has been tested.  3.0
1.87    ! wiz      1373:       or 3.1 may work, but are not officially supported.  (The main difference
        !          1374:       in 3.0/3.1 is lack of pthreads.)</p>
1.75      rillig   1375: <div class="sect3" lang="en">
                   1376: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1377: <a name="platform.interix-sfu-install"></a>3.3.3.1. When installing Interix/SFU</h4></div></div></div>
1.75      rillig   1378: <p>At an absolute minimum, the following packages must be installed from
1.87    ! wiz      1379:        the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
1.75      rillig   1380: <div class="itemizedlist"><ul type="disc">
                   1381: <li><p>Utilities -&gt; Base Utilities</p></li>
                   1382: <li><p>Interix GNU Components -&gt; (all)</p></li>
                   1383: <li><p>Remote Connectivity</p></li>
                   1384: <li><p>Interix SDK</p></li>
                   1385: </ul></div>
                   1386: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1.87    ! wiz      1387:        "UNIX Perl".  That is Perl 5.6 without shared module support, installed to
        !          1388:        /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
        !          1389:        pkgsrc (or from a binary package).</p>
1.75      rillig   1390: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1.87    ! wiz      1391:        not need to be installed, but Remote Connectivity itself should be
        !          1392:        installed in order to have a working inetd.</p>
1.75      rillig   1393: <p>During installation you may be asked whether to enable setuid
1.87    ! wiz      1394:        behavior for Interix programs, and whether to make pathnames default to
        !          1395:        case-sensitive.  Setuid should be enabled, and case-sensitivity MUST be
        !          1396:        enabled.  (Without case-sensitivity, a large number of packages including
        !          1397:        perl will not build.)</p>
1.75      rillig   1398: <p>NOTE:  Newer Windows service packs change the way binary execution
1.87    ! wiz      1399:        works (via the Data Execution Prevention feature).  In order to use
        !          1400:        pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
        !          1401:        POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
        !          1402:        must be installed.  Hotfixes are available from Microsoft through a
        !          1403:        support contract; however, a NetBSD developer has made most Interix
        !          1404:        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   1405: </div>
                   1406: <div class="sect3" lang="en">
                   1407: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1408: <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   1409: <p>If SFU is already installed and you wish to alter these settings to work
1.87    ! wiz      1410:        with pkgsrc, note the following things.</p>
1.75      rillig   1411: <div class="itemizedlist"><ul type="disc">
                   1412: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1.87    ! wiz      1413:            Windows Services for UNIX, then click Change.  In the installer, choose
        !          1414:            Add or Remove, then uncheck Utilities-&gt;UNIX Perl.</p></li>
1.75      rillig   1415: <li>
                   1416: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1.87    ! wiz      1417:            change the following registry key:</p>
1.75      rillig   1418: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
                   1419: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
                   1420: </li>
                   1421: <li>
                   1422: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1.87    ! wiz      1423:            following registry key:</p>
1.75      rillig   1424: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
                   1425: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
                   1426: </li>
                   1427: </ul></div>
                   1428: </div>
                   1429: <div class="sect3" lang="en">
                   1430: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1431: <a name="platform.interix-notes"></a>3.3.3.3. Important notes for using pkgsrc</h4></div></div></div>
1.75      rillig   1432: <p>The package manager (either the pkgsrc "su" user, or the user
1.87    ! wiz      1433:        running "pkg_add") must be a member of the local Administrators
        !          1434:        group.  Such a user must also be used to run the bootstrap.  This is
        !          1435:        slightly relaxed from the normal pkgsrc requirement of "root".</p>
1.75      rillig   1436: <p>The package manager should use a umask of 002.  "make install" will
1.87    ! wiz      1437:        automatically complain if this is not the case.  This ensures that
        !          1438:        directories written in /var/db/pkg are Administrators-group writeable.</p>
1.75      rillig   1439: <p>The popular Interix binary packages from http://www.interopsystems.com/
1.87    ! wiz      1440:        use an older version of pkgsrc's pkg_* tools.  Ideally, these should
        !          1441:        NOT be used in conjunction with pkgsrc.  If you choose to use them at
        !          1442:        the same time as the pkgsrc packages, ensure that you use the proper
        !          1443:        pkg_* tools for each type of binary package.</p>
1.75      rillig   1444: <p>The TERM setting used for DOS-type console windows (including those
1.87    ! wiz      1445:        invoked by the csh and ksh startup shortcuts) is "interix".  Most systems
        !          1446:        don't have a termcap/terminfo entry for it, but the following .termcap
        !          1447:        entry provides adequate emulation in most cases:</p>
1.75      rillig   1448: <pre class="programlisting">
1.87    ! wiz      1449:          interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
        !          1450:        </pre>
1.75      rillig   1451: </div>
                   1452: <div class="sect3" lang="en">
                   1453: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1454: <a name="platform.interix-limits"></a>3.3.3.4. Limitations of the Interix platform</h4></div></div></div>
1.75      rillig   1455: <p>Though Interix suffices as a familiar and flexible substitute
1.87    ! wiz      1456:        for a full Unix-like platform, it has some drawbacks that should
        !          1457:        be noted for those desiring to make the most of Interix.</p>
1.75      rillig   1458: <div class="itemizedlist"><ul type="disc">
                   1459: <li>
                   1460: <p><span class="strong"><strong>X11:</strong></span></p>
                   1461: <p>Interix comes with the standard set of X11R6 client libraries,
1.87    ! wiz      1462:          and can run X11 based applications, but it does
        !          1463:          <span class="emphasis"><em>not</em></span> come with an X server.  Some options are
        !          1464:          <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
        !          1465:          <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
        !          1466:          (available in a trimmed version for Interix from Interop Systems as the
        !          1467:          <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
        !          1468:          and the free X11 server included with
        !          1469:          <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1.75      rillig   1470: <p>Also, StarNet Communications has graciously provided a free
1.87    ! wiz      1471:          version of their X-Win32 product that accepts connections only
        !          1472:          from localhost:
        !          1473:          <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
        !          1474:          recommended by the maintainer of Interix pkgsrc support.</p>
1.75      rillig   1475: </li>
                   1476: <li>
                   1477: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
                   1478: <p>Because Interix runs in a completely different NT subsystem from
1.87    ! wiz      1479:          Win32 applications, it does not currently support various X11
        !          1480:          protocol extensions for acceleration (such as MIT-SHM or DGA).
        !          1481:          Most interactive applications to a local X server will run
        !          1482:          reasonably fast, but full motion video and other graphics
        !          1483:          intensive applications may require a faster-than-expected CPU.</p>
1.75      rillig   1484: </li>
                   1485: <li>
                   1486: <p><span class="strong"><strong>Audio:</strong></span></p>
                   1487: <p>Interix has no native support for audio output.  For audio
1.87    ! wiz      1488:          support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
        !          1489:          audio system on Interix.  Unlike on most platforms, the
        !          1490:          <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/audio/esound/README.html" target="_top"><code class="filename">audio/esound</code></a> package does
        !          1491:          <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
        !          1492:          server component.  To output audio via an Interix host, the
        !          1493:          <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/emulators/cygwin_esound/README.html" target="_top"><code class="filename">emulators/cygwin_esound</code></a> package
        !          1494:          must also be installed.</p>
1.75      rillig   1495: </li>
                   1496: <li>
                   1497: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
                   1498: <p>Direct device access is not currently supported in Interix, so it
1.87    ! wiz      1499:          is not currently possible to access CD/DVD drives, USB devices,
        !          1500:          or SCSI devices through non-filesystem means.  Among other things,
        !          1501:          this makes it impossible to use Interix directly for CD/DVD
        !          1502:          burning.</p>
1.75      rillig   1503: </li>
                   1504: <li>
                   1505: <p><span class="strong"><strong>Tape drives:</strong></span></p>
                   1506: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1.87    ! wiz      1507:          drives are also not directly accessible in Interix.  However,
        !          1508:          support is in work to make tape drive access possible by using
        !          1509:          Cygwin as a bridge (similarly to audio bridged via Cygwin's
        !          1510:          esound server).</p>
1.75      rillig   1511: </li>
                   1512: </ul></div>
                   1513: </div>
                   1514: <div class="sect3" lang="en">
                   1515: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1516: <a name="platform.interix-knownissues"></a>3.3.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1.75      rillig   1517: <p>It is not necessary, in general, to have a "root" user on the
1.87    ! wiz      1518:        Windows system; any member of the local Administrators group will
        !          1519:        suffice.  However, some packages currently assume that the user
        !          1520:        named "root" is the privileged user.  To accommodate these, you
        !          1521:        may create such a user; make sure it is in the local group
        !          1522:        Administrators (or your language equivalent).</p>
        !          1523: <p><span><strong class="command">pkg_add</strong></span> creates directories of mode
        !          1524:        0755, not 0775, in <code class="filename">$PKG_DBDIR</code>.  For the
        !          1525:        time being, install packages as the local Administrator (or
        !          1526:        your language equivalent), or run the following command after
        !          1527:        installing a package to work around the issue:</p>
1.75      rillig   1528: <pre class="screen">
1.87    ! wiz      1529: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong>
        !          1530:        </pre>
1.75      rillig   1531: </div>
                   1532: </div>
                   1533: <div class="sect2" lang="en">
                   1534: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1535: <a name="irix"></a>3.3.4. IRIX</h3></div></div></div>
1.75      rillig   1536: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1.87    ! wiz      1537:       compiler (cc/c89).  Please set the <code class="varname">CC</code> environment variable
        !          1538:       according to your preference.  If you do not have a license for the MIPSpro
        !          1539:       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   1540: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1.87    ! wiz      1541:       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>,
        !          1542:       etc.</p>
1.86      schwarz  1543: <p>At this point in time, pkgsrc only supports one ABI at a time.  That is, you cannot
1.75      rillig   1544:        switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI.  If
                   1545:        you start out using "abi=n32", that's what all your packages will be built
                   1546:        with.</p>
                   1547: <p>Therefore, please make sure that you have no conflicting
1.87    ! wiz      1548:       <code class="varname">CFLAGS</code> in your environment or the
        !          1549:       <code class="filename">/etc/mk.conf</code>.  Particularly, make sure that you do not
        !          1550:       try to link n32 object files with lib64 or vice versa.  Check your
        !          1551:       <code class="filename">/etc/compiler.defaults</code>!</p>
1.75      rillig   1552: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1.87    ! wiz      1553:       please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
        !          1554:       as it appears that IRIX linker occasionally runs into issues when trying to
        !          1555:       link over a network-mounted file system.</p>
1.75      rillig   1556: <p>The bootstrapping process should set all the right options for programs such
1.87    ! wiz      1557:       as imake(1), but you may want to set some options depending on your local
        !          1558:       setup.  Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
        !          1559:       course, your compiler's man pages for details.</p>
1.75      rillig   1560: <p>If you are using SGI's MIPSPro compiler, please set
1.1       grant    1561: 
1.87    ! wiz      1562:       </p>
1.75      rillig   1563: <pre class="programlisting">
1.87    ! wiz      1564:        PKGSRC_COMPILER=        mipspro
        !          1565:       </pre>
1.75      rillig   1566: <p>
1.1       grant    1567: 
1.87    ! wiz      1568:       in <code class="filename">/etc/mk.conf</code>.  Otherwise, pkgsrc will assume you
        !          1569:       are using gcc and may end up passing invalid flags to the compiler.  Note that
        !          1570:       bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
        !          1571:       default.</p>
1.75      rillig   1572: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1.87    ! wiz      1573:       but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
        !          1574:       to <span class="emphasis"><em>not</em></span> include the location of gcc (often
        !          1575:       <code class="filename">/usr/freeware/bin</code>), and (important) pass the
        !          1576:       '--preserve-path' flag.</p>
1.75      rillig   1577: </div>
                   1578: <div class="sect2" lang="en">
                   1579: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1580: <a name="linux"></a>3.3.5. Linux</h3></div></div></div>
1.87    ! wiz      1581: <p>Some versions of Linux (for example Debian GNU/Linux) need
        !          1582:       either libtermcap or libcurses (libncurses).  Installing the
        !          1583:       distributions libncurses-dev package (or equivalent) should fix
        !          1584:       the problem.</p>
        !          1585: <p>pkgsrc supports both gcc (GNU Compiler Collection) and icc
        !          1586:       (Intel C++ Compiler). gcc is the default. icc 8.0 and 8.1 on
        !          1587:       i386 have been tested.</p>
1.75      rillig   1588: <p>To bootstrap using icc, assuming the default icc installation
1.87    ! wiz      1589:       directory:</p>
1.75      rillig   1590: <pre class="programlisting">
1.87    ! wiz      1591:        env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
        !          1592:        ac_cv___attribute__=yes ./bootstrap
        !          1593:       </pre>
1.75      rillig   1594: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1595: <h3 class="title">Note</h3>
                   1596: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
                   1597: </div>
                   1598: <p>icc supports __attribute__, but the GNU configure test uses a nested
1.87    ! wiz      1599:       function, which icc does not support. #undef'ing __attribute__ has the
        !          1600:       unfortunate side-effect of breaking many of the Linux header files, which
        !          1601:       cannot be compiled properly without __attribute__. The test must be
        !          1602:       overridden so that __attribute__ is assumed supported by the
        !          1603:       compiler.</p>
1.75      rillig   1604: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.87    ! wiz      1605:       in <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   1606: <pre class="programlisting">
1.87    ! wiz      1607:        PKGSRC_COMPILER=        icc
        !          1608:       </pre>
1.75      rillig   1609: <p>The default installation directory for icc is
1.87    ! wiz      1610:       <code class="filename">/opt/intel_cc_80</code>, which
        !          1611:       is also the pkgsrc default. If you have installed it into a different
        !          1612:       directory, set <code class="varname">ICCBASE</code> in
        !          1613:       <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   1614: <pre class="programlisting">
1.87    ! wiz      1615:        ICCBASE=                /opt/icc
        !          1616:       </pre>
1.75      rillig   1617: <p>pkgsrc uses the static linking method of the runtime libraries
1.87    ! wiz      1618:       provided by icc, so binaries can be run on other systems which do not
        !          1619:       have the shared libraries installed.</p>
        !          1620: <p>Libtool, however, extracts a list of libraries from the
        !          1621:       <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
        !          1622:       records it, throwing away the -Bstatic and -Bdynamic options
        !          1623:       interspersed between the libraries.  This means that
        !          1624:       libtool-linked C++ shared libraries will have a runtime
        !          1625:       dependency on the icc libraries until this is fixed in
        !          1626:       libtool.</p>
1.75      rillig   1627: </div>
                   1628: <div class="sect2" lang="en">
                   1629: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1630: <a name="openbsd"></a>3.3.6. OpenBSD</h3></div></div></div>
1.75      rillig   1631: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
                   1632: <p>Care should be taken so that the tools that this kit installs do not conflict
1.87    ! wiz      1633:       with the OpenBSD userland tools. There are several steps:</p>
1.75      rillig   1634: <div class="orderedlist"><ol type="1">
                   1635: <li><p>OpenBSD stores its ports pkg database in
1.87    ! wiz      1636:          <code class="filename">/var/db/pkg</code>. It is therefore
        !          1637:          recommended that you choose a different location (e.g.
        !          1638:          <code class="filename">/usr/pkgdb</code>) by
        !          1639:          using the --pkgdbdir option to the bootstrap script.</p></li>
1.75      rillig   1640: <li>
                   1641: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1.87    ! wiz      1642:          good idea to move them out of the way to avoid confusion, e.g.</p>
        !          1643: <pre class="screen">
        !          1644: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1.75      rillig   1645: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
                   1646: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
                   1647: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1.87    ! wiz      1648: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
        !          1649:          </pre>
1.75      rillig   1650: </li>
                   1651: <li>
1.76      rillig   1652: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1.87    ! wiz      1653:          <code class="filename">/etc/mk.conf.example</code> file
        !          1654:          when you use the bootstrap script. OpenBSD's make program uses
        !          1655:          <code class="filename">/etc/mk.conf</code>
        !          1656:          as well. You can work around this by enclosing all the pkgsrc-specific parts
        !          1657:          of the file with:</p>
        !          1658: <pre class="programlisting">
        !          1659:            .ifdef BSD_PKG_MK
        !          1660:            # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
        !          1661:            .else
        !          1662:            # OpenBSD stuff
        !          1663:            .endif
        !          1664:          </pre>
1.75      rillig   1665: </li>
                   1666: </ol></div>
                   1667: </div>
                   1668: <div class="sect2" lang="en">
                   1669: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1670: <a name="solaris"></a>3.3.7. Solaris</h3></div></div></div>
1.75      rillig   1671: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
1.87    ! wiz      1672:       You will need a working C compiler. Both gcc 2.95.3 and
        !          1673:       Sun WorkShop 5 have been tested.</p>
1.75      rillig   1674: <p>The following packages are required on Solaris 8 for the bootstrap
1.87    ! wiz      1675:       process and to build packages.</p>
1.75      rillig   1676: <div class="itemizedlist"><ul type="disc">
                   1677: <li><p>SUNWsprot</p></li>
                   1678: <li><p>SUNWarc</p></li>
                   1679: <li><p>SUNWbtool</p></li>
                   1680: <li><p>SUNWtoo</p></li>
                   1681: <li><p>SUNWlibm</p></li>
                   1682: </ul></div>
1.78      rillig   1683: <p>Please note that the use of GNU binutils on Solaris is
1.87    ! wiz      1684:       <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1.75      rillig   1685: <p>Whichever compiler you use, please ensure the compiler tools and
1.87    ! wiz      1686:       your $prefix are in your <code class="varname">PATH</code>. This includes
        !          1687:       <code class="filename">/usr/ccs/{bin,lib}</code>
        !          1688:       and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75      rillig   1689: <div class="sect3" lang="en">
                   1690: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1691: <a name="solaris-gcc-note"></a>3.3.7.1. If you are using gcc</h4></div></div></div>
1.75      rillig   1692: <p>It makes life much simpler if you only use the same gcc consistently
1.87    ! wiz      1693:        for building all packages.</p>
1.75      rillig   1694: <p>It is recommended that an external gcc be used only for bootstrapping,
1.87    ! wiz      1695:        then either build gcc from
        !          1696:        <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/lang/gcc/README.html" target="_top"><code class="filename">lang/gcc</code></a> or install a binary gcc
        !          1697:        package, then remove gcc used during bootstrapping.</p>
1.75      rillig   1698: <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>
                   1699: </div>
                   1700: <div class="sect3" lang="en">
                   1701: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1702: <a name="solaris-sun-workshop-note"></a>3.3.7.2. If you are using Sun WorkShop</h4></div></div></div>
1.75      rillig   1703: <p>You will need at least the following packages installed (from WorkShop
1.87    ! wiz      1704:        5.0)</p>
1.75      rillig   1705: <div class="itemizedlist"><ul type="disc">
                   1706: <li><p>SPROcc
1.87    ! wiz      1707:          - Sun WorkShop Compiler C 5.0</p></li>
1.75      rillig   1708: <li><p>SPROcpl
1.87    ! wiz      1709:          - Sun WorkShop Compiler C++ 5.0</p></li>
1.75      rillig   1710: <li><p>SPROild
1.87    ! wiz      1711:          - Sun WorkShop Incremental Linker</p></li>
1.75      rillig   1712: <li><p>SPROlang
1.87    ! wiz      1713:          - Sun WorkShop Compilers common components</p></li>
1.75      rillig   1714: </ul></div>
                   1715: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.87    ! wiz      1716:        optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
        !          1717:        e.g.:</p>
1.75      rillig   1718: <pre class="programlisting">
1.87    ! wiz      1719:          CC=     cc
        !          1720:          CXX=    CC
        !          1721:          CPP=    /usr/ccs/lib/cpp
        !          1722:        </pre>
1.75      rillig   1723: </div>
                   1724: <div class="sect3" lang="en">
                   1725: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1726: <a name="solaris-sunpro-64"></a>3.3.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1.75      rillig   1727: <p>Building 64-bit binaries is a little trickier. First, you
                   1728:        need to bootstrap pkgsrc in 64-bit mode. One problem here is
                   1729:        that while building one of the programs in the bootstrap kit
1.76      rillig   1730:        (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75      rillig   1731:        variable is not honored, even if it is set in the environment.
                   1732:        To work around this bug, you can create a simple shell script
1.76      rillig   1733:        called <code class="filename">cc64</code> and put it somewhere in the
1.75      rillig   1734:        <code class="varname">PATH</code>:</p>
                   1735: <pre class="programlisting">
1.87    ! wiz      1736:          #! /bin/sh
        !          1737:          exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
        !          1738:        </pre>
1.75      rillig   1739: <p>Then, pass the definition for <code class="varname">CC</code> in the
                   1740:        environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
                   1741: <pre class="programlisting">
1.87    ! wiz      1742:          <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
        !          1743:          <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
        !          1744:        </pre>
1.75      rillig   1745: <p>After bootstrapping, there are two alternative ways,
                   1746:        depending on whether you want to find bugs in packages or get
                   1747:        your system ready quickly. If you just want a running system,
1.76      rillig   1748:        add the following lines to your <code class="filename">mk.conf</code>
1.75      rillig   1749:        file:</p>
                   1750: <pre class="programlisting">
1.87    ! wiz      1751:          CC=                     cc64
        !          1752:          CXX=                    CC64
        !          1753:          PKGSRC_COMPILER=        sunpro
        !          1754:        </pre>
1.75      rillig   1755: <p>This way, all calls to the compiler will be intercepted by
                   1756:        the above wrapper and therefore get the necessary ABI options
                   1757:        automatically. (Don't forget to create the shell script
1.76      rillig   1758:        <code class="filename">CC64</code>, too.)</p>
1.75      rillig   1759: <p>To find packages that ignore the user-specified
                   1760:        <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76      rillig   1761:        the following lines to your <code class="filename">mk.conf</code>
1.75      rillig   1762:        file:</p>
                   1763: <pre class="programlisting">
1.87    ! wiz      1764:          CC=                     cc
        !          1765:          CXX=                    CC
        !          1766:          PKGSRC_COMPILER=        sunpro
        !          1767:          CFLAGS=                 -xtarget=ultra -xarch=v9
        !          1768:          CXXFLAGS=               -xtarget=ultra -xarch=v9
        !          1769:          LDFLAGS=                -xtarget=ultra -xarch=v9
        !          1770:        </pre>
1.75      rillig   1771: <p>Packages that don't use the flags provided in the
                   1772:        configuration file will try to build 32-bit binaries and fail
                   1773:        during linking. Detecting this is useful to prevent bugs on
                   1774:        other platforms where the error would not show up but pass
                   1775:        silently.</p>
                   1776: </div>
                   1777: <div class="sect3" lang="en">
                   1778: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1779: <a name="plat.sunos.problems"></a>3.3.7.4. Common problems</h4></div></div></div>
1.75      rillig   1780: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.87    ! wiz      1781:       <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
        !          1782:       The workaround is to use another shell for the configure
        !          1783:       scripts, for example by installing <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a> and adding the following lines
        !          1784:       to your <code class="filename">mk.conf</code>:</p>
        !          1785: <pre class="programlisting">
        !          1786:        CONFIG_SHELL=   ${LOCALBASE}/bin/bash
        !          1787:        WRAPPER_SHELL=  ${LOCALBASE}/bin/bash
        !          1788:       </pre>
1.76      rillig   1789: <p>Then, rebuild the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/libtool-base/README.html" target="_top"><code class="filename">devel/libtool-base</code></a> package.</p>
1.75      rillig   1790: </div>
                   1791: </div>
                   1792: </div>
                   1793: </div>
                   1794: <div class="chapter" lang="en">
                   1795: <div class="titlepage"><div><div><h2 class="title">
                   1796: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
                   1797: <div class="toc">
                   1798: <p><b>Table of Contents</b></p>
                   1799: <dl>
                   1800: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                   1801: <dd><dl>
                   1802: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                   1803: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82      rillig   1804: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
                   1805: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
                   1806: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
                   1807: <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>
                   1808: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
                   1809: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75      rillig   1810: </dl></dd>
                   1811: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                   1812: <dd><dl>
                   1813: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                   1814: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                   1815: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                   1816: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
                   1817: </dl></dd>
                   1818: </dl>
                   1819: </div>
                   1820: <p>Basically, there are two ways of using pkgsrc. The first
                   1821:        is to only install the package tools and to use binary packages
                   1822:        that someone else has prepared. This is the &#8220;<span class="quote">pkg</span>&#8221;
                   1823:        in pkgsrc. The second way is to install the &#8220;<span class="quote">src</span>&#8221;
                   1824:        of pkgsrc, too. Then you are able to build your own packages,
                   1825:        and you can still use binary packages from someone else.</p>
                   1826: <div class="sect1" lang="en">
                   1827: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1828: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
                   1829: <p>To use binary packages, you need some tools to manage
                   1830:        them. On NetBSD, these tools are already installed. On all other
                   1831:        operating systems, you need to install them first. For the
                   1832:        following platforms, prebuilt versions of the package tools
                   1833:        are available and can simply be downloaded and unpacked in the
1.76      rillig   1834:        <code class="filename">/</code> directory:</p>
1.75      rillig   1835: <div class="informaltable">
                   1836: <a name="binary-bootstrap-kits"></a><table border="1">
                   1837: <colgroup>
                   1838: <col>
                   1839: <col>
                   1840: </colgroup>
                   1841: <thead><tr>
                   1842: <th>Platform</th>
                   1843: <th>URL</th>
                   1844: </tr></thead>
                   1845: <tbody>
                   1846: <tr>
                   1847: <td>Solaris 9</td>
1.76      rillig   1848: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75      rillig   1849: </tr>
                   1850: <tr>
                   1851: <td>Solaris 10</td>
1.76      rillig   1852: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75      rillig   1853: </tr>
                   1854: </tbody>
                   1855: </table>
                   1856: </div>
1.82      rillig   1857: <p>These pre-built package tools use
1.76      rillig   1858:        <code class="filename">/usr/pkg</code> for the base directory, and
                   1859:        <code class="filename">/var/db/pkg</code> for the database of installed
1.75      rillig   1860:        packages. If you cannot use these directories for whatever
                   1861:        reasons (maybe because you're not root), you have to build the
1.82      rillig   1862:        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   1863: <div class="sect2" lang="en">
                   1864: <div class="titlepage"><div><div><h3 class="title">
                   1865: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
                   1866: <p>To install binary packages, you first need to know from
                   1867:        where to get them. You can get them on CD-ROMs, DVDs, or via FTP
                   1868:        or HTTP.</p>
1.81      rillig   1869: <p>The binary packages can be found at the following
                   1870:        locations.</p>
1.75      rillig   1871: <div class="informaltable">
                   1872: <a name="binary-packages"></a><table border="1">
                   1873: <colgroup>
                   1874: <col>
                   1875: <col>
                   1876: </colgroup>
                   1877: <thead><tr>
                   1878: <th>Platform</th>
                   1879: <th>URL</th>
                   1880: </tr></thead>
                   1881: <tbody>
                   1882: <tr>
1.81      rillig   1883: <td>NetBSD</td>
                   1884: <td><code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/</code></td>
                   1885: </tr>
                   1886: <tr>
1.75      rillig   1887: <td>Solaris 9</td>
1.76      rillig   1888: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75      rillig   1889: </tr>
                   1890: <tr>
                   1891: <td>Solaris 10</td>
1.76      rillig   1892: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75      rillig   1893: </tr>
                   1894: </tbody>
                   1895: </table>
                   1896: </div>
1.81      rillig   1897: <p>Most of these directories contain binary packages for
                   1898:        multiple platforms. Select the appropriate subdirectories,
1.75      rillig   1899:        according to your machine architecture and operating system,
1.76      rillig   1900:        until you find a directory called <code class="filename">All</code>. This
1.75      rillig   1901:        directory contains all the binary packages. Further, there are
                   1902:        subdirectories for categories that contain symbolic links that
                   1903:        point to the actual binary package in
1.76      rillig   1904:        <code class="filename">../All</code>. This directory layout is used for
1.75      rillig   1905:        all package repositories, no matter if they are accessed via
                   1906:        HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
                   1907: </div>
                   1908: <div class="sect2" lang="en">
                   1909: <div class="titlepage"><div><div><h3 class="title">
                   1910: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1.87    ! wiz      1911: <p>If you have the files on a CD-ROM or downloaded them to
1.75      rillig   1912:         your hard disk, you can install them with the following command
                   1913:         (be sure to <span><strong class="command">su</strong></span> to root first):</p>
                   1914: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
1.87    ! wiz      1915: <p>If you have FTP access and you don't want to download the
1.75      rillig   1916:         packages via FTP prior to installation, you can do this
1.87    ! wiz      1917:         automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:</p>
1.82      rillig   1918: <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   1919: <p>Note that any prerequisite packages needed to run the
                   1920:         package in question will be installed, too, assuming they are
1.87    ! wiz      1921:         present where you install from.</p>
1.75      rillig   1922: <p>To save some typing, you can set the
                   1923:         <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
                   1924:        list of paths (including remote URLs); trailing slashes are not allowed.
                   1925:        </p>
1.76      rillig   1926: <p>Additionally to the <code class="filename">All</code> directory
                   1927:         there exists a <code class="filename">vulnerable</code> directory to
1.75      rillig   1928:         which binary packages with known vulnerabilities are
                   1929:         moved, since removing them could cause missing dependencies. To
1.76      rillig   1930:         use these packages, add the <code class="filename">vulnerable</code>
1.75      rillig   1931:         directory to your <code class="varname">PKG_PATH</code>. However, you should run
1.76      rillig   1932:         <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> regularly,
1.75      rillig   1933:        especially after installing new packages, and verify that the
                   1934:        vulnerabilities are acceptable for your configuration. An example
                   1935:         <code class="varname">PKG_PATH</code> would be:
1.76      rillig   1936:       <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>
1.75      rillig   1937:         Please note that semicolon (';') is a shell meta-character, so
                   1938:         you'll probably have to quote it.</p>
                   1939: <p>After you've installed packages, be sure to have
1.76      rillig   1940:         <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1.75      rillig   1941:         <code class="varname">PATH</code> so you can actually start the just
1.87    ! wiz      1942:         installed program.</p>
1.75      rillig   1943: </div>
                   1944: <div class="sect2" lang="en">
                   1945: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1946: <a name="using.pkg_delete"></a>4.1.3. Deinstalling packages</h3></div></div></div>
                   1947: <p>To deinstall a package, it does not matter whether it was
                   1948:        installed from source code or from a binary package. The
                   1949:        <span><strong class="command">pkg_delete</strong></span> command does not know it anyway.
                   1950:        To delete a package, you can just run <span><strong class="command">pkg_delete
                   1951:        <em class="replaceable"><code>package-name</code></em></strong></span>. The package
                   1952:        name can be given with or without version number. Wildcards can
                   1953:        also be used to deinstall a set of packages, for example
                   1954:        <code class="literal">*emacs*</code>. Be sure to include them in quotes,
                   1955:        so that the shell does not expand them before
                   1956:        <code class="literal">pkg_delete</code> sees them.</p>
                   1957: <p>The <code class="option">-r</code> option is very powerful: it
                   1958:        removes all the packages that require the package in question
                   1959:        and then removes the package itself. For example:
                   1960: 
                   1961: </p>
                   1962: <pre class="screen">
                   1963:     <code class="prompt">#</code> <strong class="userinput"><code>pkg_delete -r jpeg</code></strong>
                   1964: </pre>
                   1965: <p>
                   1966: 
                   1967:        will remove jpeg and all the packages that used it; this allows
                   1968:        upgrading the jpeg package.</p>
                   1969: </div>
                   1970: <div class="sect2" lang="en">
                   1971: <div class="titlepage"><div><div><h3 class="title">
                   1972: <a name="using.pkg_info"></a>4.1.4. Getting information about installed packages</h3></div></div></div>
                   1973: <p>The <span><strong class="command">pkg_info</strong></span> shows information about
                   1974:        installed packages or binary package files.</p>
                   1975: </div>
                   1976: <div class="sect2" lang="en">
                   1977: <div class="titlepage"><div><div><h3 class="title">
                   1978: <a name="vulnerabilities"></a>4.1.5. Checking for security vulnerabilities in installed packages</h3></div></div></div>
                   1979: <p>
                   1980: The NetBSD Security-Officer and Packages Groups maintain a list of
                   1981: known security vulnerabilities to packages which are (or have been)
                   1982: included in pkgsrc.  The list is available from the NetBSD
                   1983: FTP site at <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities</a>.
                   1984: </p>
                   1985: <p>
                   1986: Through <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>, 
                   1987: this list can be downloaded
                   1988: automatically, and a security audit of all packages installed on a system
                   1989: can take place.
                   1990: </p>
                   1991: <p>
                   1992: There are two components to 
                   1993: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>.  The first
                   1994: component, &#8220;<span class="quote">download-vulnerability-list</span>&#8221;, is for downloading
                   1995: the list of vulnerabilities from the NetBSD FTP site.  The second
                   1996: component, &#8220;<span class="quote">audit-packages</span>&#8221;, checks to see if any of your
                   1997: installed packages are vulnerable.  If a package is vulnerable, you
                   1998: will see output similar to the following:
                   1999: </p>
                   2000: <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
                   2001: http://www.samba.org/samba/whatsnew/macroexploit.html</pre>
                   2002: <p>
                   2003: One can set up <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> to download the
                   2004: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
                   2005: file daily, and include a package audit in the daily security script.
                   2006: 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>
                   2007: file for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>.
                   2008: </p>
                   2009: </div>
                   2010: <div class="sect2" lang="en">
                   2011: <div class="titlepage"><div><div><h3 class="title">
                   2012: <a name="pkg_versions"></a>4.1.6. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
                   2013: <p>
                   2014: Install <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a> and run 
                   2015: <span><strong class="command">lintpkgsrc</strong></span> with the &#8220;<span class="quote">-i</span>&#8221;
                   2016: argument to check if your packages are up-to-date, e.g.
                   2017: </p>
                   2018: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
                   2019: ...
                   2020: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00</pre>
                   2021: <p>You can then use <span><strong class="command">make update</strong></span> to update the
                   2022: package on your system and rebuild any dependencies.
                   2023: </p>
                   2024: </div>
                   2025: <div class="sect2" lang="en">
                   2026: <div class="titlepage"><div><div><h3 class="title">
                   2027: <a name="using.pkg_admin"></a>4.1.7. Other administrative functions</h3></div></div></div>
                   2028: <p>The <span><strong class="command">pkg_admin</strong></span> executes various
                   2029:        administrative functions on the package system.</p>
                   2030: </div>
                   2031: <div class="sect2" lang="en">
                   2032: <div class="titlepage"><div><div><h3 class="title">
                   2033: <a name="a-word-of-warning"></a>4.1.8. A word of warning</h3></div></div></div>
1.75      rillig   2034: <p>Please pay very careful attention to the warnings
                   2035:         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
                   2036:         inherent dangers of installing binary packages which you did
                   2037:         not create yourself, and the security holes that can be
                   2038:         introduced onto your system by indiscriminate adding of such
                   2039:         files.</p>
                   2040: <p>The same warning of course applies to every package you
                   2041:       install from source when you haven't completely read and
                   2042:       understood the source code of the package, the compiler that
                   2043:       is used to build the package and all the other tools that are
                   2044:       involved.</p>
                   2045: </div>
                   2046: </div>
                   2047: <div class="sect1" lang="en">
                   2048: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2049: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1.87    ! wiz      2050: <p>After obtaining pkgsrc, the <code class="filename">pkgsrc</code> directory
1.82      rillig   2051: now contains a set of packages, organized into categories. You can browse
                   2052: the online index of packages, or run <span><strong class="command">make readme</strong></span>
                   2053: from the <code class="filename">pkgsrc</code> directory to build local
                   2054: <code class="filename">README.html</code> files for all packages, viewable with any web browser such as
                   2055: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/lynx/README.html" target="_top"><code class="filename">www/lynx</code></a> or 
1.83      wiz      2056: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a>.</p>
1.82      rillig   2057: <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages is
                   2058: <code class="filename">/usr/pkg</code>. If you wish to change this, you should do
                   2059: so by setting <code class="varname">LOCALBASE</code> in
                   2060: <code class="filename">mk.conf</code>. You should not try to use multiple
                   2061: different <code class="varname">LOCALBASE</code> definitions on the same system
                   2062: (inside a chroot is an exception). </p>
                   2063: <p>The rest of this chapter assumes that the package is already in pkgsrc. If it
1.75      rillig   2064:       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 instructions
                   2065:       how to create your own packages.</p>
                   2066: <div class="sect2" lang="en">
                   2067: <div class="titlepage"><div><div><h3 class="title">
                   2068: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1.82      rillig   2069: <p>To build packages from source, you need a working C
                   2070:       compiler. On NetBSD, you need to install the
                   2071:       &#8220;<span class="quote">comp</span>&#8221; and the &#8220;<span class="quote">text</span>&#8221; distribution
                   2072:       sets. If you want to build X11-related packages, the
                   2073:       &#8220;<span class="quote">xbase</span>&#8221; and &#8220;<span class="quote">xcomp</span>&#8221; distribution
                   2074:       sets are required, too.</p>
1.75      rillig   2075: </div>
                   2076: <div class="sect2" lang="en">
                   2077: <div class="titlepage"><div><div><h3 class="title">
                   2078: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
                   2079: <p>The first step for building a package is downloading the
                   2080:       distfiles (i.e. the unmodified source). If they have not yet been
                   2081:       downloaded, pkgsrc will fetch them automatically.</p>
1.82      rillig   2082: <p>
                   2083: If you have all files that you need in the
                   2084: <code class="filename">distfiles</code> directory,
                   2085: you don't need to connect. If the distfiles are on CD-ROM, you can
                   2086: mount the CD-ROM on <code class="filename">/cdrom</code> and add:
                   2087: </p>
                   2088: <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
                   2089: <p>
                   2090: to your <code class="filename">mk.conf</code>.
                   2091: </p>
1.75      rillig   2092: <p>You can overwrite some of the major distribution sites to fit to sites
                   2093:         that are close to your own.  Have a look at
1.76      rillig   2094:         <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find some examples
1.87    ! wiz      2095:         &#8212; in particular, look for the <code class="varname">MASTER_SORT</code>,
1.75      rillig   2096:         <code class="varname">MASTER_SORT_REGEX</code> and
                   2097:         <code class="varname">INET_COUNTRY</code> definitions.  This may save some of your
                   2098:         bandwidth and time.</p>
                   2099: <p>You can change these settings either in your shell's environment, or,
                   2100:         if you want to keep the settings, by editing the
1.76      rillig   2101:         <code class="filename">/etc/mk.conf</code> file,
1.75      rillig   2102:         and adding the definitions there.</p>
1.82      rillig   2103: <p>
                   2104: If a package depends on many other packages (such as
                   2105: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a>), the build process may 
                   2106: alternate between periods of
                   2107: downloading source, and compiling. To ensure you have all the source
                   2108: downloaded initially you can run the command:
                   2109: </p>
                   2110: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
                   2111: <p>
                   2112: which will output and run a set of shell commands to fetch the
                   2113: necessary files into the <code class="filename">distfiles</code> directory.  You can
                   2114: also choose to download the files manually.
                   2115: </p>
1.75      rillig   2116: </div>
                   2117: <div class="sect2" lang="en">
                   2118: <div class="titlepage"><div><div><h3 class="title">
                   2119: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1.82      rillig   2120: <p>
                   2121: Once the software has downloaded, any patches will be applied, then it
                   2122: will be compiled for you. This may take some time depending on your
                   2123: computer, and how many other packages the software depends on and their
                   2124: compile time.
                   2125: </p>
1.75      rillig   2126: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   2127: <h3 class="title">Note</h3>
                   2128: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
                   2129:         use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
                   2130:         &#8220;<span class="quote">make</span>&#8221; in the examples in this guide.</p>
                   2131: </div>
1.87    ! wiz      2132: <p>For example, type</p>
1.75      rillig   2133: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
                   2134: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong></pre>
                   2135: <p>at the shell prompt to build the various components of the
1.82      rillig   2136:         package.</p>
                   2137: <p>The next stage is to actually install the newly compiled
                   2138:        program onto your system. Do this by entering:
                   2139: 
                   2140: </p>
                   2141: <pre class="screen">
                   2142:     <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
                   2143: </pre>
                   2144: <p>
                   2145: 
                   2146:        while you are still in the directory for whatever package you
                   2147:        are installing.</p>
                   2148: <p>Installing the package on your system may require you to
                   2149:        be root.  However, pkgsrc has a
1.75      rillig   2150:         <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
1.82      rillig   2151:         to only become root for the actual installation step.</p>
                   2152: <p>That's it, the software should now be installed and setup for use.
                   2153: You can now enter:
                   2154: 
                   2155: </p>
                   2156: <pre class="screen">
                   2157:     <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
                   2158: </pre>
                   2159: <p>
                   2160: 
                   2161:        to remove the compiled files in the work directory, as you shouldn't need
                   2162:        them any more. If other packages were also added to your system
                   2163:        (dependencies) to allow your program to compile, you can tidy these up
                   2164:        also with the command:</p>
                   2165: <pre class="screen">
                   2166:     <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
                   2167: </pre>
1.75      rillig   2168: <p>Taking the figlet utility as an example, we can install it on our
                   2169:         system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
                   2170: <p>The program is installed under the default root of the packages tree -
1.76      rillig   2171:         <code class="filename">/usr/pkg</code>. Should this not conform to your tastes,
1.75      rillig   2172:         set the <code class="varname">LOCALBASE</code>
                   2173:         variable in your environment, and it will use that value as the root of
1.76      rillig   2174:         your packages tree. So, to use <code class="filename">/usr/local</code>, set
1.75      rillig   2175:         <code class="varname">LOCALBASE=/usr/local</code> in your environment.  Please note
                   2176:         that you should use a directory which is
                   2177:         dedicated to packages and not shared with other programs (i.e., do not try
                   2178:         and use <code class="varname">LOCALBASE=/usr</code>).  Also, you should not try to
1.76      rillig   2179:         add any of your own files or directories (such as <code class="filename">src/</code>,
                   2180:         <code class="filename">obj/</code>, or <code class="filename">pkgsrc/</code>) below the
1.75      rillig   2181:         <code class="varname">LOCALBASE</code> tree.  This is to prevent possible conflicts
                   2182:         between programs and other files installed by the package system and
                   2183:         whatever else may have been installed there.</p>
1.76      rillig   2184: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to alter some
1.75      rillig   2185:         configuration options at build time.  Have a look at
1.76      rillig   2186:         <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to
1.75      rillig   2187:         get an overview of what will be set there by default.  Environment
                   2188:         variables such as <code class="varname">LOCALBASE</code>
1.76      rillig   2189:         can be set in <code class="filename">/etc/mk.conf</code> to
1.75      rillig   2190:         save having to remember to set them each time you want to use pkgsrc.</p>
                   2191: <p>Occasionally, people want to &#8220;<span class="quote">look under the covers</span>&#8221; to see
                   2192:         what is going on when a package is building or being installed. This may be
                   2193:         for debugging purposes, or out of simple curiosity. A number of utility
                   2194:         values have been added to help with this.</p>
                   2195: <div class="orderedlist"><ol type="1">
                   2196: <li>
                   2197: <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 <code class="varname">PKG_DEBUG_LEVEL=2</code>,
                   2198:             then a huge amount of information will be displayed. For example,</p>
                   2199: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
                   2200: <p>will show all the commands that are invoked, up to and including the
                   2201:             &#8220;<span class="quote">patch</span>&#8221; stage.</p>
                   2202: </li>
                   2203: <li>
                   2204: <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> definition, then
                   2205:             the <code class="varname">VARNAME</code> definition should be used, in conjunction
                   2206:             with the show-var 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> variable
                   2207:             <code class="varname">LOCALBASE</code>:</p>
                   2208: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
                   2209: /usr/pkg
                   2210: <code class="prompt">%</code>
                   2211:           </pre>
                   2212: </li>
                   2213: </ol></div>
                   2214: <p>If you want to install a binary package that you've either
                   2215:         created yourself (see next section), that you put into pkgsrc/packages manually or
                   2216:         that is located on a remote FTP server, you can use the "bin-install"
                   2217:         target. This target will install a binary package - if available - via
                   2218:         <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>, else do a <span><strong class="command">make package</strong></span>.
                   2219:         The list of remote
                   2220:         FTP sites searched is kept in the variable
                   2221:         <code class="varname">BINPKG_SITES</code>, which defaults to
                   2222:         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> can be put
                   2223:         into <code class="varname">BIN_INSTALL_FLAGS</code>.
1.76      rillig   2224:         See <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more details.</p>
1.75      rillig   2225: <p>A final word of warning: If you set up a system that has a non-standard
                   2226:         setting for <code class="varname">LOCALBASE</code>, be sure to set that
1.86      schwarz  2227:         before any packages are installed, as you cannot use several directories
1.75      rillig   2228:         for the same purpose. Doing so will result in pkgsrc not being able to
                   2229:         properly detect your installed packages, and fail miserably. Note also that
                   2230:         precompiled binary packages are usually built with the default
                   2231:         <code class="varname">LOCALBASE</code> of
1.76      rillig   2232:         <code class="filename">/usr/pkg</code>, and that you should <span class="emphasis"><em>not</em></span>
1.75      rillig   2233:         install any if you use a non-standard <code class="varname">LOCALBASE</code>.</p>
                   2234: </div>
                   2235: <div class="sect2" lang="en">
                   2236: <div class="titlepage"><div><div><h3 class="title">
                   2237: <a name="selecting-the-compiler"></a>4.2.4. Selecting the compiler</h3></div></div></div>
                   2238: <p>By default, pkgsrc will use GCC to build packages.  This may be
1.87    ! wiz      2239:         overridden by setting the following variables in /etc/mk.conf:</p>
1.75      rillig   2240: <div class="variablelist"><dl>
                   2241: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
                   2242: <dd>
1.87    ! wiz      2243: <p>This is a list of values specifying the chain of
1.75      rillig   2244:               compilers to invoke when building packages.  Valid values
1.87    ! wiz      2245:               are:</p>
1.75      rillig   2246: <div class="itemizedlist"><ul type="disc">
                   2247: <li><p><code class="varname">distcc</code>:
                   2248:                 distributed C/C++ (chainable)</p></li>
                   2249: <li><p><code class="varname">ccache</code>:
                   2250:                 compiler cache (chainable)</p></li>
                   2251: <li><p><code class="varname">gcc</code>:
                   2252:                 GNU C/C++ Compiler</p></li>
                   2253: <li><p><code class="varname">mipspro</code>:
                   2254:                 Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
                   2255: <li><p><code class="varname">mipspro</code>:
                   2256:                 Silicon Graphics, Inc. MIPSpro (o32)</p></li>
                   2257: <li><p><code class="varname">sunpro</code>:
                   2258:                 Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
                   2259: </ul></div>
1.87    ! wiz      2260: <p>The default is
1.75      rillig   2261:               &#8220;<span class="quote"><code class="varname">gcc</code></span>&#8221;.  You can use
                   2262:               <code class="varname">ccache</code> and/or
                   2263:               <code class="varname">distcc</code> with an appropriate
                   2264:               <code class="varname">PKGSRC_COMPILER</code> setting,
                   2265:               e.g. &#8220;<span class="quote"><code class="varname">ccache gcc</code></span>&#8221;.  This
                   2266:               variable should always be
1.87    ! wiz      2267:               terminated with a value for a real compiler.</p>
1.75      rillig   2268: </dd>
                   2269: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
1.87    ! wiz      2270: <dd><p>This specifies the minimum version of GCC to use
1.75      rillig   2271:               when building packages.  If the system GCC doesn't
                   2272:               satisfy this requirement, then pkgsrc will build and
1.87    ! wiz      2273:               install one of the GCC packages to use instead.</p></dd>
1.75      rillig   2274: </dl></div>
                   2275: </div>
                   2276: </div>
                   2277: </div>
                   2278: <div class="chapter" lang="en">
                   2279: <div class="titlepage"><div><div><h2 class="title">
                   2280: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
                   2281: <div class="toc">
                   2282: <p><b>Table of Contents</b></p>
                   2283: <dl>
                   2284: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                   2285: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78      rillig   2286: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
                   2287: <dd><dl><dt><span class="sect2"><a href="#conf.cflags">5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt></dl></dd>
                   2288: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
                   2289: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75      rillig   2290: </dl>
                   2291: </div>
                   2292: <div class="sect1" lang="en">
                   2293: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2294: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
                   2295: <p>In this section, you can find some variables that apply to all
1.82      rillig   2296:     pkgsrc packages.  The preferred method of setting these variables is
                   2297:     by setting them in <code class="filename">/etc/mk.conf</code>. A complete
                   2298:     list of the variables that can be configured by the user is
                   2299:     available in <code class="filename">mk/defaults/mk.conf</code>, together with
                   2300:     some comments that describe the variable's intent.</p>
1.75      rillig   2301: <div class="itemizedlist"><ul type="disc">
                   2302: <li><p><code class="varname">LOCALBASE</code>: Where
                   2303:            packages will be installed. The default is
1.76      rillig   2304:            <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75      rillig   2305:            with different <code class="varname">LOCALBASE</code>s!</p></li>
                   2306: <li><p><code class="varname">CROSSBASE</code>: Where
                   2307:            &#8220;<span class="quote">cross</span>&#8221; category packages will be
                   2308:            installed. The default is
1.76      rillig   2309:            <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75      rillig   2310: <li><p><code class="varname">X11BASE</code>: Where
                   2311:            X11 is installed on the system. The default is
1.76      rillig   2312:            <code class="filename">/usr/X11R6</code>.</p></li>
1.75      rillig   2313: <li><p><code class="varname">DISTDIR</code>: Where to store the
                   2314:            downloaded copies of the original source distributions used
                   2315:            for building pkgsrc packages. The default is
1.76      rillig   2316:            <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75      rillig   2317: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
                   2318:            If set, override the packages'
                   2319:            <code class="varname">MASTER_SITES</code> with this value.</p></li>
                   2320: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
                   2321:            Backup location(s) for distribution files and patch files
                   2322:            if not found locally or in
1.76      rillig   2323:            <code class="filename">${MASTER_SITES}</code> or
                   2324:            <code class="filename">${PATCH_SITES}</code> respectively.
1.75      rillig   2325:            The defaults are
1.76      rillig   2326:            <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75      rillig   2327:            and
1.76      rillig   2328:            <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75      rillig   2329: <li><p><code class="varname">BINPKG_SITES</code>:
                   2330:            List of sites carrying binary pkgs.</p></li>
1.82      rillig   2331: <li><p><code class="varname">ACCEPTABLE_LICENSES</code>:
                   2332:            List of acceptable licenses. Whenever you try to build a package
                   2333:            whose license is not in this list, you will get an error message
                   2334:            that includes instructions on how to change this variable.</p></li>
1.75      rillig   2335: </ul></div>
                   2336: </div>
                   2337: <div class="sect1" lang="en">
                   2338: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2339: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
                   2340: <p>XXX
                   2341:       </p>
                   2342: <div class="itemizedlist"><ul type="disc">
                   2343: <li><p><code class="varname">PACKAGES</code>: The top level
                   2344:            directory for the binary packages. The default is
1.76      rillig   2345:            <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75      rillig   2346: <li><p><code class="varname">WRKOBJDIR</code>:
                   2347:            The top level directory where, if defined, the separate
                   2348:            working directories will get created, and symbolically
1.76      rillig   2349:            linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75      rillig   2350:            This is useful for building packages on several
1.76      rillig   2351:            architectures, then <code class="filename">${PKGSRCDIR}</code>
                   2352:            can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75      rillig   2353:            is local to every architecture. (It should be noted that
                   2354:            <code class="varname">PKGSRCDIR</code> should not be set by the user
1.87    ! wiz      2355:            &#8212; it is an internal definition which refers to the
1.75      rillig   2356:            root of the pkgsrc tree. It is possible to have many
                   2357:            pkgsrc tree instances.)</p></li>
                   2358: <li><p><code class="varname">LOCALPATCHES</code>:
                   2359:            Directory for local patches that aren't part of pkgsrc.
1.77      rillig   2360:            See <a href="#components.patches" title="9.3. patches/*">Section 9.3, &#8220;patches/*&#8221;</a> for more
1.75      rillig   2361:            information. <em class="replaceable"><code>rel</code></em> and
                   2362:            <em class="replaceable"><code>arch</code></em> are replaced with OS
                   2363:            release (&#8220;<span class="quote">2.0</span>&#8221;, etc.) and architecture
                   2364:            (&#8220;<span class="quote">mipsel</span>&#8221;, etc.).</p></li>
                   2365: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76      rillig   2366:            the <code class="filename">mk.conf</code> file used by a package's
1.75      rillig   2367:            BSD-style Makefile. If this is not set,
                   2368:            <code class="varname">MAKECONF</code> is set to
1.76      rillig   2369:            <code class="filename">/dev/null</code> to avoid picking up
                   2370:            settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.82      rillig   2371: <li><p><code class="varname">DEPENDS_TARGET</code>:
                   2372:            By default, dependencies are only installed, and no binary
                   2373:            package is created for them. You can set this variable to
                   2374:            <code class="literal">package</code> to automatically create binary
                   2375:            packages after installing dependencies.</p></li>
1.75      rillig   2376: </ul></div>
                   2377: </div>
                   2378: <div class="sect1" lang="en">
                   2379: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78      rillig   2380: <a name="conf.compiler"></a>5.3. Selecting and configuring the compiler</h2></div></div></div>
                   2381: <div class="sect2" lang="en">
                   2382: <div class="titlepage"><div><div><h3 class="title">
                   2383: <a name="conf.cflags"></a>5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
                   2384: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
                   2385:        please make sure to use the <code class="literal">+=</code> operator
                   2386:        instead of the <code class="literal">=</code> operator:</p>
                   2387: <pre class="programlisting">
                   2388:     CFLAGS+=        -your -flags
                   2389: </pre>
                   2390: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
                   2391:        &#8220;<span class="quote">+</span>&#8221;) may lead to problems with packages that need
                   2392:        to add their own flags.  Also, you may want to take a look at
                   2393:        the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a> package if
                   2394:        you're interested in optimization for the current CPU.</p>
                   2395: </div>
                   2396: </div>
                   2397: <div class="sect1" lang="en">
                   2398: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2399: <a name="developer-advanced-settings"></a>5.4. Developer/advanced settings</h2></div></div></div>
1.75      rillig   2400: <p>XXX
                   2401:       </p>
                   2402: <div class="itemizedlist"><ul type="disc">
                   2403: <li>
                   2404: <p><code class="varname">PKG_DEVELOPER</code>:
                   2405:            Run some sanity checks that package developers want:
                   2406:            </p>
                   2407: <div class="itemizedlist"><ul type="circle">
                   2408: <li><p>make sure patches apply with zero fuzz</p></li>
                   2409: <li><p>run check-shlibs to see that all binaries will
                   2410:                find their shared libs.</p></li>
                   2411: </ul></div>
                   2412: <p>
1.87    ! wiz      2413:        </p>
1.75      rillig   2414: </li>
                   2415: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>:
                   2416:            The level of debugging output which is displayed whilst
                   2417:            making and installing the package.
                   2418:            The default value for this is 0, which will not display
                   2419:            the commands as they are executed (normal, default, quiet
                   2420:            operation); the value 1 will display all shell commands
                   2421:            before their invocation, and the value 2 will display both
                   2422:            the shell commands before their invocation, and their
                   2423:            actual execution progress with <span><strong class="command">set -x</strong></span>
                   2424:            will be displayed.</p></li>
                   2425: </ul></div>
                   2426: <p>
                   2427:     </p>
                   2428: </div>
                   2429: <div class="sect1" lang="en">
                   2430: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78      rillig   2431: <a name="selecting-build-options"></a>5.5. Selecting Build Options</h2></div></div></div>
1.75      rillig   2432: <p>Some packages have build time options, usually to select between
                   2433:       different dependencies, enable optional support for big dependencies
                   2434:       or enable experimental features.</p>
                   2435: <p>To see which options, if any, a package supports, and which
                   2436:       options are mutually exclusive, run <span><strong class="command">make show-options</strong></span>,
                   2437:       for example:</p>
                   2438: <pre class="programlisting">
                   2439:     The following options are supported by this package:
                   2440:         ssl      Enable SSL support.
                   2441:     Exactly one of the following gecko options is required:
                   2442:         firefox  Use firefox as gecko rendering engine.
                   2443:         mozilla  Use mozilla as gecko rendering engine.
                   2444:     At most one of the following database options may be selected:
                   2445:         mysql    Enable support for MySQL database.
                   2446:         pgsql    Enable support for PostgreSQL database.
1.1       grant    2447: 
1.75      rillig   2448:     These options are enabled by default: firefox
                   2449:     These options are currently enabled: mozilla ssl
1.1       grant    2450: </pre>
1.75      rillig   2451: <p>The following variables can be defined in
1.76      rillig   2452:       <code class="filename">/etc/mk.conf</code> to select which options to enable
1.75      rillig   2453:       for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which can be
                   2454:       used to select or disable options for all packages that support them,
                   2455:       and <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
                   2456:       which can be used to select or disable options specifically for
                   2457:       package <em class="replaceable"><code>pkgbase</code></em>.  Options listed in these
                   2458:       variables are selected, options preceded by &#8220;<span class="quote">-</span>&#8221; are
                   2459:       disabled. A few examples:</p>
                   2460: <pre class="screen">
                   2461: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
                   2462: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   2463: PKG_OPTIONS.kdebase=    debug -sasl
                   2464: PKG_OPTIONS.apache=     suexec </pre>
                   2465: <p>The following settings are consulted in the order given, and the
                   2466:       last setting that selects or disables an option is used:</p>
                   2467: <div class="orderedlist"><ol type="1">
                   2468: <li><p>the default options as suggested by the package
                   2469:          maintainer</p></li>
                   2470: <li><p>the options implied by the settings of legacy
                   2471:          variables (see below)</p></li>
                   2472: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
                   2473: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
                   2474: </ol></div>
                   2475: <p>For groups of mutually exclusive options, the last option
                   2476:       selected is used, all others are automatically disabled.  If an option
                   2477:       of the group is explicitly disabled, the previously selected option,
                   2478:       if any, is used.  It is an error if no option from a required group of
                   2479:       options is selected, and building the package will fail.</p>
                   2480: <p>Before the options framework was introduced, build options were
                   2481:       selected by setting a variable (often named
                   2482:       <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
1.76      rillig   2483:       <code class="filename">/etc/mk.conf</code> for each option.  To ease transition
1.75      rillig   2484:       to the options framework for the user, these legacy variables are
                   2485:       converted to the appropriate options setting
                   2486:       (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
                   2487:       automatically.  A warning is issued to prompt the user to
1.76      rillig   2488:       update <code class="filename">/etc/mk.conf</code> to use the options framework
1.75      rillig   2489:       directly.  Support for the legacy variables will be removed
                   2490:       eventually.</p>
                   2491: </div>
                   2492: </div>
                   2493: <div class="chapter" lang="en">
                   2494: <div class="titlepage"><div><div><h2 class="title">
                   2495: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
                   2496: <div class="toc">
                   2497: <p><b>Table of Contents</b></p>
                   2498: <dl>
                   2499: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                   2500: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                   2501: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                   2502: <dd><dl>
                   2503: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                   2504: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                   2505: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                   2506: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                   2507: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                   2508: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                   2509: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                   2510: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                   2511: </dl></dd>
                   2512: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                   2513: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                   2514: </dl>
                   2515: </div>
                   2516: <div class="sect1" lang="en">
                   2517: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2518: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
1.87    ! wiz      2519: <p>Once you have built and installed a package, you can create
        !          2520:     a <span class="emphasis"><em>binary package</em></span> which can be installed on
        !          2521:     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
        !          2522:     the same package on a group of hosts and wasting CPU time. It also
        !          2523:     provides a simple means for others to install your package, should
        !          2524:     you distribute it.</p>
        !          2525: <p>To create a binary package, change into the appropriate
        !          2526:     directory in pkgsrc, and run <span><strong class="command">make
        !          2527:     package</strong></span>:</p>
        !          2528: <pre class="screen">
        !          2529: <code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
        !          2530: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
        !          2531:     </pre>
        !          2532: <p>This will build and install your package (if not already done),
        !          2533:     and then build a binary package from what was installed. You can
        !          2534:     then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
        !          2535:     it. Binary packages are created by default in
        !          2536:     <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
        !          2537:     gzipped tar file. See <a href="#logs.package" title="B.2. Packaging figlet">Section B.2, &#8220;Packaging figlet&#8221;</a> for a
        !          2538:     continuation of the above <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/misc/figlet/README.html" target="_top"><code class="filename">misc/figlet</code></a> example.</p>
        !          2539: <p>See <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a> for information on how to submit
        !          2540:     such a binary package.</p>
1.75      rillig   2541: </div>
                   2542: <div class="sect1" lang="en">
                   2543: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2544: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.77      rillig   2545: <p>See <a href="#build.helpful-targets" title="15.16. Other helpful targets">Section 15.16, &#8220;Other helpful targets&#8221;</a>.</p>
1.75      rillig   2546: </div>
                   2547: <div class="sect1" lang="en">
                   2548: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2549: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
                   2550: <p>If you want to get a full set of precompiled binary
1.87    ! wiz      2551:     packages, this section describes how to get them. Beware that
        !          2552:     the bulk build will remove all currently installed packages from
        !          2553:     your system!</p>
1.75      rillig   2554: <p>Having an FTP server configured either on the
1.87    ! wiz      2555:     machine doing the bulk builds or on a nearby NFS server can help
        !          2556:     to make the packages available to other machines that can then
        !          2557:     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
        !          2558:     more information. If you use a remote NFS server's storage, be
        !          2559:     sure to not actually compile on NFS storage, as this slows
        !          2560:     things down a lot.</p>
1.75      rillig   2561: <div class="sect2" lang="en">
                   2562: <div class="titlepage"><div><div><h3 class="title">
                   2563: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
                   2564: <div class="sect3" lang="en">
                   2565: <div class="titlepage"><div><div><h4 class="title">
1.76      rillig   2566: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
                   2567: <p>The <code class="filename">build.conf</code> file is the main
1.87    ! wiz      2568:        configuration file for bulk builds. You can configure how your
        !          2569:        copy of pkgsrc is kept up to date, how the distfiles are
        !          2570:        downloaded, how the packages are built and how the report is
        !          2571:        generated. You can find an annotated example file in
        !          2572:        <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
        !          2573:        it, copy <code class="filename">build.conf-example</code> to
        !          2574:        <code class="filename">build.conf</code> and edit it, following the
        !          2575:        comments in that file.</p>
1.75      rillig   2576: </div>
                   2577: <div class="sect3" lang="en">
                   2578: <div class="titlepage"><div><div><h4 class="title">
                   2579: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
                   2580: <p>You may want to set variables in
1.87    ! wiz      2581:        <code class="filename">/etc/mk.conf</code>.
        !          2582:        Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
        !          2583:        details of the default settings. You will want to ensure that
        !          2584:        <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
        !          2585:        As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
        !          2586:        accepts <span class="emphasis"><em>all</em></span> licenses.</p>
        !          2587: <pre class="programlisting">
        !          2588:          PACKAGES?=      ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
        !          2589:          WRKOBJDIR?=     /usr/tmp/pkgsrc   # build here instead of in pkgsrc
        !          2590:          BSDSRCDIR=      /usr/src
        !          2591:          BSDXSRCDIR=     /usr/xsrc         # for x11/xservers
        !          2592:          OBJHOSTNAME?=   yes               # use work.`hostname`
        !          2593:          FAILOVER_FETCH= yes               # insist on the correct checksum
        !          2594:          PKG_DEVELOPER?= yes
        !          2595:          _ACCEPTABLE=    yes
        !          2596:        </pre>
1.75      rillig   2597: <p>Some options that are especially useful for bulk builds
                   2598:        can be found at the top lines of the file
1.76      rillig   2599:        <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75      rillig   2600:        options of these are briefly described here.</p>
                   2601: <div class="itemizedlist"><ul type="disc">
                   2602: <li><p>If you are on a slow machine, you may want to
1.87    ! wiz      2603:          set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
        !          2604:          &#8220;<span class="quote">no</span>&#8221;.</p></li>
1.75      rillig   2605: <li><p>If you are doing bulk builds from a read-only
1.87    ! wiz      2606:          copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
        !          2607:          to the directory where all log files are created. Otherwise the
        !          2608:          log files are created in the pkgsrc directory.</p></li>
1.75      rillig   2609: <li><p>Another important variable is
1.87    ! wiz      2610:          <code class="varname">BULK_PREREQ</code>, which is a list of packages that
        !          2611:          should be always available while building other
        !          2612:          packages.</p></li>
1.75      rillig   2613: </ul></div>
                   2614: <p>Some other options are scattered in the pkgsrc
                   2615:        infrastructure:</p>
                   2616: <div class="itemizedlist"><ul type="disc">
                   2617: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
1.87    ! wiz      2618:          should be set to <code class="literal">yes</code>. The purpose of the bulk
        !          2619:          builds is creating binary packages, no matter if they are
        !          2620:          vulnerable or not. When uploading the packages to a public
        !          2621:          server, the vulnerable packages will be put into a directory of
        !          2622:          their own. Leaving this variable unset would prevent the bulk
        !          2623:          build system from even trying to build them, so possible
        !          2624:          building errors would not show up.</p></li>
1.75      rillig   2625: <li><p><code class="varname">CHECK_FILES</code>
1.87    ! wiz      2626:          (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
        !          2627:          &#8220;<span class="quote">yes</span>&#8221; to check that the installed set of files
        !          2628:          matches the <code class="filename">PLIST</code>.</p></li>
1.75      rillig   2629: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.87    ! wiz      2630:          (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
        !          2631:          &#8220;<span class="quote">yes</span>&#8221; to check that the installed
        !          2632:          &#8220;<span class="quote">#!</span>&#8221;-scripts will find their
        !          2633:          interpreter.</p></li>
1.75      rillig   2634: </ul></div>
                   2635: </div>
                   2636: <div class="sect3" lang="en">
                   2637: <div class="titlepage"><div><div><h4 class="title">
1.76      rillig   2638: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75      rillig   2639: <p>It is possible to configure the bulk build to perform
1.87    ! wiz      2640:        certain site-specific tasks at the end of the pre-build
        !          2641:        stage.  If the file
        !          2642:        <code class="filename">pre-build.local</code> exists in
        !          2643:        <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
        !          2644:        (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
        !          2645:        stage.  An example use of
        !          2646:        <code class="filename">pre-build.local</code> is to have the line:</p>
1.75      rillig   2647: <pre class="screen">echo "I do not have enough disk space to build this pig." \
1.87    ! wiz      2648:        &gt; misc/openoffice/$BROKENF</pre>
1.75      rillig   2649: <p>to prevent the system from trying to build a particular package
1.87    ! wiz      2650:        which requires nearly 3 GB of disk space.</p>
1.75      rillig   2651: </div>
                   2652: </div>
                   2653: <div class="sect2" lang="en">
                   2654: <div class="titlepage"><div><div><h3 class="title">
                   2655: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76      rillig   2656: <p>As <code class="filename">/usr/pkg</code> will be completely
1.87    ! wiz      2657:       deleted at the start of bulk builds, make sure your login
        !          2658:       shell is placed somewhere else. Either drop it into
        !          2659:       <code class="filename">/usr/local/bin</code> (and adjust your login
        !          2660:       shell in the passwd file), or (re-)install it via
        !          2661:       <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
        !          2662:       you can login after a reboot (remember that your current
        !          2663:       process won't die if the package is removed, you just can't
        !          2664:       start any new instances of the shell any more).  Also, if you
        !          2665:       use NetBSD earlier than 1.5, or you still want to use the pkgsrc
        !          2666:       version of ssh for some reason, be sure to install ssh before
        !          2667:       starting it from <code class="filename">rc.local</code>:</p>
        !          2668: <pre class="programlisting">
        !          2669:        ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
        !          2670:        if [ -f /usr/pkg/etc/rc.d/sshd ]; then
        !          2671:        /usr/pkg/etc/rc.d/sshd
        !          2672:        fi
        !          2673:       </pre>
1.75      rillig   2674: <p>Not doing so will result in you being not able to log in
1.87    ! wiz      2675:       via ssh after the bulk build is finished or if the machine
        !          2676:       gets rebooted or crashes. You have been warned! :)</p>
1.75      rillig   2677: </div>
                   2678: <div class="sect2" lang="en">
                   2679: <div class="titlepage"><div><div><h3 class="title">
                   2680: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
                   2681: <p>Make sure you don't need any of the packages still
1.87    ! wiz      2682:       installed.</p>
1.75      rillig   2683: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
                   2684: <h3 class="title">Warning</h3>
                   2685: <p>During the bulk build, <span class="emphasis"><em>all packages will be
1.87    ! wiz      2686:        removed!</em></span></p>
1.75      rillig   2687: </div>
                   2688: <p>Be sure to remove all other things that might
1.87    ! wiz      2689:       interfere with builds, like some libs installed in
        !          2690:       <code class="filename">/usr/local</code>, etc. then become root and type:</p>
        !          2691: <pre class="screen">
        !          2692: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
        !          2693: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong>
        !          2694:       </pre>
1.75      rillig   2695: <p>If for some reason your last build didn't complete (power
1.87    ! wiz      2696:       failure, system panic, ...), you can continue it by
        !          2697:       running:</p>
1.75      rillig   2698: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
1.87    ! wiz      2699: <p>At the end of the bulk build, you will get a summary via mail,
        !          2700:       and find build logs in the directory specified by
        !          2701:       <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
        !          2702:       file.</p>
1.75      rillig   2703: </div>
                   2704: <div class="sect2" lang="en">
                   2705: <div class="titlepage"><div><div><h3 class="title">
                   2706: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
                   2707: <p>The bulk builds consist of three steps:</p>
                   2708: <div class="variablelist"><dl>
                   2709: <dt><span class="term">1. pre-build</span></dt>
1.87    ! wiz      2710: <dd><p>The script updates your pkgsrc tree via (anon)cvs, then
        !          2711:            cleans out any broken distfiles, and removes all
        !          2712:            packages installed.</p></dd>
1.75      rillig   2713: <dt><span class="term">2. the bulk build</span></dt>
1.87    ! wiz      2714: <dd><p>This is basically &#8220;<span class="quote">make bulk-package</span>&#8221; with
        !          2715:            an optimised order in which packages will be
        !          2716:            built. Packages that don't require other packages will
        !          2717:            be built first, and packages with many dependencies will
        !          2718:            be built later.</p></dd>
1.75      rillig   2719: <dt><span class="term">3. post-build</span></dt>
1.87    ! wiz      2720: <dd><p>Generates a report that's placed in the directory
        !          2721:            specified in the <code class="filename">build.conf</code> file
        !          2722:            named <code class="filename">broken.html</code>, a short version
        !          2723:            of that report will also be mailed to the build's
        !          2724:            admin.</p></dd>
1.75      rillig   2725: </dl></div>
1.87    ! wiz      2726: <p>During the build, a list of broken packages will be compiled
        !          2727:       in <code class="filename">/usr/pkgsrc/.broken</code> (or
        !          2728:       <code class="filename">.../.broken.${MACHINE}</code> if
        !          2729:       <code class="varname">OBJMACHINE</code> is set), individual build logs
        !          2730:       of broken builds can be found in the package's
        !          2731:       directory. These files are used by the bulk-targets to mark
        !          2732:       broken builds to not waste time trying to rebuild them, and
        !          2733:       they can be used to debug these broken package builds
        !          2734:       later.</p>
1.75      rillig   2735: </div>
                   2736: <div class="sect2" lang="en">
                   2737: <div class="titlepage"><div><div><h3 class="title">
                   2738: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
                   2739: <p>Currently, roughly the following requirements are valid for
1.87    ! wiz      2740:       NetBSD 2.0/i386:</p>
1.75      rillig   2741: <div class="itemizedlist"><ul type="disc">
1.87    ! wiz      2742: <li><p>10 GB - distfiles (NFS ok)</p></li>
        !          2743: <li><p>8 GB - full set of all binaries (NFS ok)</p></li>
        !          2744: <li><p>5 GB - temp space for compiling (local disk recommended)</p></li>
        !          2745: </ul></div>
        !          2746: <p>Note that all pkgs will be de-installed as soon as they are
        !          2747:       turned into a binary package, and that sources are removed,
        !          2748:       so there is no excessively huge demand to disk
        !          2749:       space. Afterwards, if the package is needed again, it will
        !          2750:       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
        !          2751:       there are no cycles wasted by recompiling.</p>
1.75      rillig   2752: </div>
                   2753: <div class="sect2" lang="en">
                   2754: <div class="titlepage"><div><div><h3 class="title">
                   2755: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
1.87    ! wiz      2756: <p>If you don't want all the packages nuked from a machine
        !          2757:       (rendering it useless for anything but pkg compiling), there
        !          2758:       is the possibility of doing the package bulk build inside a
        !          2759:       chroot environment.</p>
        !          2760: <p>The first step is to set up a chroot sandbox,
        !          2761:       e.g. <code class="filename">/usr/sandbox</code>.  This can be done by
        !          2762:       using null mounts, or manually.</p>
        !          2763: <p>There is a shell script called
        !          2764:       <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
        !          2765:       up the sandbox environment using null mounts. It will also
        !          2766:       create a script called <code class="filename">sandbox</code> in the
        !          2767:       root of the sandbox environment, which will allow the null
        !          2768:       mounts to be activated using the <span><strong class="command">sandbox
        !          2769:       mount</strong></span> command and deactivated using the
        !          2770:       <span><strong class="command">sandbox umount</strong></span> command.</p>
        !          2771: <p>To set up a sandbox environment by hand, after extracting all
        !          2772:       the sets from a NetBSD installation or doing a <span><strong class="command">make
        !          2773:       distribution DESTDIR=/usr/sandbox</strong></span> in
        !          2774:       <code class="filename">/usr/src/etc</code>, be sure the following items
        !          2775:       are present and properly configured:</p>
1.75      rillig   2776: <div class="procedure"><ol type="1">
                   2777: <li>
                   2778: <p>Kernel</p>
                   2779: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
                   2780: </li>
                   2781: <li>
1.76      rillig   2782: <p><code class="filename">/dev/*</code></p>
1.75      rillig   2783: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
                   2784: </li>
                   2785: <li>
1.76      rillig   2786: <p><code class="filename">/etc/resolv.conf</code> (for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a> and mail):</p>
1.75      rillig   2787: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
                   2788: </li>
                   2789: <li>
                   2790: <p>Working(!) mail config (hostname, sendmail.cf):</p>
                   2791: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
                   2792: </li>
                   2793: <li>
1.76      rillig   2794: <p><code class="filename">/etc/localtime</code> (for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a>):</p>
1.75      rillig   2795: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
                   2796: </li>
                   2797: <li>
1.76      rillig   2798: <p><code class="filename">/usr/src</code> (system sources,
1.87    ! wiz      2799:          e. g. for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/sysutils/aperture/README.html" target="_top"><code class="filename">sysutils/aperture</code></a>):</p>
1.75      rillig   2800: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
1.87    ! wiz      2801:          <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
1.75      rillig   2802: </li>
                   2803: <li>
1.76      rillig   2804: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75      rillig   2805: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
                   2806: </li>
                   2807: <li>
1.76      rillig   2808: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75      rillig   2809: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
                   2810: </li>
                   2811: <li>
                   2812: <p>Checkout pkgsrc via cvs into
1.87    ! wiz      2813:          <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
        !          2814: <pre class="screen">
        !          2815: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
        !          2816: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong>
        !          2817:          </pre>
1.75      rillig   2818: <p>Do not mount/link this to the copy of your pkgsrc tree
1.87    ! wiz      2819:          you do development in, as this will likely cause problems!</p>
1.75      rillig   2820: </li>
                   2821: <li><p>Make
1.87    ! wiz      2822:          <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
        !          2823:          <code class="filename">.../distfiles</code> point somewhere
        !          2824:          appropriate. NFS- and/or nullfs-mounts may come in handy!</p></li>
1.76      rillig   2825: <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>
                   2826: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75      rillig   2827: </ol></div>
                   2828: <p>When the chroot sandbox is set up, you can start
1.87    ! wiz      2829:       the build with the following steps:</p>
        !          2830: <pre class="screen">
        !          2831: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
        !          2832: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong>
        !          2833:       </pre>
        !          2834: <p>This will just jump inside the sandbox and start building.  At
        !          2835:        the end of the build, mail will be sent with the results of
        !          2836:        the build. Created binary pkgs will be in
        !          2837:        <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
        !          2838:       (wherever that points/mounts to/from).</p>
1.75      rillig   2839: </div>
                   2840: <div class="sect2" lang="en">
                   2841: <div class="titlepage"><div><div><h3 class="title">
                   2842: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
1.87    ! wiz      2843: <p>In addition to building a complete set of all packages in
        !          2844:       pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
        !          2845:       may be used to build a subset of the packages contained in
        !          2846:       pkgsrc.  By setting <code class="varname">SPECIFIC_PKGS</code>
        !          2847:       in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75      rillig   2848: <div class="itemizedlist"><ul type="disc">
                   2849: <li><p>SITE_SPECIFIC_PKGS</p></li>
                   2850: <li><p>HOST_SPECIFIC_PKGS</p></li>
                   2851: <li><p>GROUP_SPECIFIC_PKGS</p></li>
                   2852: <li><p>USER_SPECIFIC_PKGS</p></li>
                   2853: </ul></div>
1.87    ! wiz      2854: <p>will define the set of packages which should be built.
        !          2855:       The bulk build code will also include any packages which are
        !          2856:       needed as dependencies for the explicitly listed packages.</p>
        !          2857: <p>One use of this is to do a bulk build with
        !          2858:       <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
        !          2859:       periodically to have a complete set of the binary packages
        !          2860:       needed for your site available without the overhead of
        !          2861:       building extra packages that are not needed.</p>
1.75      rillig   2862: </div>
                   2863: <div class="sect2" lang="en">
                   2864: <div class="titlepage"><div><div><h3 class="title">
                   2865: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
1.87    ! wiz      2866: <p>This section describes how pkgsrc developers can upload binary
        !          2867:       pkgs built by bulk builds to ftp.NetBSD.org.</p>
        !          2868: <p>If you would like to automatically create checksum files for the
        !          2869:       binary packages you intend to upload, remember to set
        !          2870:       <code class="varname">MKSUMS=yes</code> in your
        !          2871:       <code class="filename">mk/bulk/build.conf</code>.</p>
        !          2872: <p>If you would like to PGP sign the checksum files (highly
        !          2873:       recommended!), remember to set
        !          2874:       <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
        !          2875:       <code class="filename">mk/bulk/build.conf</code>.  This will prompt you for
        !          2876:       your GPG password to sign the files before uploading everything.</p>
        !          2877: <p>Then, make sure that you have <code class="varname">RSYNC_DST</code>
        !          2878:       set properly in your <code class="filename">mk/bulk/build.conf</code>
        !          2879:       file, i.e. adjust it to something like one of the following:</p>
1.75      rillig   2880: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
                   2881: <p>Please use appropriate values for "pkgsrc-200xQy",
1.87    ! wiz      2882:       "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
        !          2883:       is different from your local login, write your login directly
        !          2884:       into the variable, e.g. my local account is "feyrer", but for my
        !          2885:       login "hubertf", I use:</p>
        !          2886: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload</pre>
        !          2887: <p>A separate <code class="filename">upload</code> directory is used
        !          2888:       here to allow "closing" the directory during upload. To do
        !          2889:       so, run the following command on ftp.NetBSD.org next:</p>
1.75      rillig   2890: <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      2891: <p>Please note that <code class="filename">/pub/NetBSD/packages</code> is
        !          2892:       only appropriate for packages for the NetBSD operating
        !          2893:       system. Binary packages for other operating systems should go
        !          2894:       into <code class="filename">/pub/pkgsrc</code>.</p>
        !          2895: <p>Before uploading the binary pkgs, ssh authentication needs
        !          2896:       to be set up. This example shows how to set up temporary keys
        !          2897:       for the root account <span class="emphasis"><em>inside the sandbox</em></span>
        !          2898:       (assuming that no keys should be present there usually):</p>
        !          2899: <pre class="screen">
        !          2900: <code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
1.75      rillig   2901: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
                   2902: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
1.87    ! wiz      2903: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong>
        !          2904:       </pre>
        !          2905: <p>Now take the output of <code class="filename">id-dsa.pub</code> and
        !          2906:       append it to your <code class="filename">~/.ssh/authorized_keys</code>
        !          2907:       file on ftp.NetBSD.org. You can remove the key after the
        !          2908:       upload is done!</p>
        !          2909: <p>Next, test if your ssh connection really works:</p>
1.75      rillig   2910: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
1.87    ! wiz      2911: <p>Use "-l yourNetBSDlogin" here as appropriate!</p>
        !          2912: <p>Now after all this works, you can exit the sandbox and start
        !          2913:       the upload:</p>
        !          2914: <pre class="screen">
        !          2915: chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
1.75      rillig   2916: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
1.87    ! wiz      2917: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong>
        !          2918:       </pre>
        !          2919: <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
        !          2920:       <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
        !          2921:       upload. The upload script will take care of not uploading
        !          2922:       restricted packages and putting vulnerable packages into the
        !          2923:       <code class="filename">vulnerable</code> subdirectory.</p>
        !          2924: <p>After the upload has ended, first thing is to revoke ssh access:</p>
1.75      rillig   2925: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
1.87    ! wiz      2926:       Gdd:x! </pre>
        !          2927: <p>Use whatever is needed to remove the key you've entered
        !          2928:       before! Last, move the uploaded packages out of the
        !          2929:       <code class="filename">upload</code> directory to have them accessible
        !          2930:       to everyone:</p>
        !          2931: <pre class="screen">
        !          2932: nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
1.75      rillig   2933: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
                   2934: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
1.87    ! wiz      2935: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong>
        !          2936:       </pre>
1.75      rillig   2937: </div>
                   2938: </div>
                   2939: <div class="sect1" lang="en">
                   2940: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2941: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
1.87    ! wiz      2942: <p>After your pkgsrc bulk-build has completed, you may wish to
        !          2943:     create a CD-ROM set of the resulting binary packages to assist
        !          2944:     in installing packages on other machines.  The
        !          2945:     <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/cdpack/README.html" target="_top"><code class="filename">pkgtools/cdpack</code></a> package provides
        !          2946:     a simple tool for creating the ISO 9660 images.
        !          2947:     <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
        !          2948:     way that keeps all the dependencies for a given package on the same
        !          2949:     CD as that package.</p>
1.75      rillig   2950: <div class="sect2" lang="en">
                   2951: <div class="titlepage"><div><div><h3 class="title">
                   2952: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
1.87    ! wiz      2953: <p>Complete documentation for cdpack is found in the cdpack(1)
        !          2954:       man page. The following short example assumes that the binary
        !          2955:       packages are left in
        !          2956:       <code class="filename">/usr/pkgsrc/packages/All</code> and that
        !          2957:       sufficient disk space exists in <code class="filename">/u2</code> to
        !          2958:       hold the ISO 9660 images.</p>
        !          2959: <pre class="screen">
        !          2960: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
1.75      rillig   2961: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
1.87    ! wiz      2962: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong>
        !          2963:       </pre>
        !          2964: <p>If you wish to include a common set of files
        !          2965:       (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
        !          2966:       etc.) on each CD in the collection, then you need to create a
        !          2967:       directory which contains these files. e.g.</p>
        !          2968: <pre class="screen">
        !          2969: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
1.75      rillig   2970: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" &gt; /tmp/common/README</code></strong>
                   2971: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" &gt; /tmp/common/COPYING</code></strong>
                   2972: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
                   2973: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" &gt; /tmp/common/bin/myscript</code></strong>
                   2974: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" &gt;&gt; /tmp/common/bin/myscript</code></strong>
1.87    ! wiz      2975: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong>
        !          2976:       </pre>
1.75      rillig   2977: <p>Now create the images:</p>
                   2978: <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   2979: <p>Each image will contain <code class="filename">README</code>,
1.87    ! wiz      2980:       <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
        !          2981:       in their root directories.</p>
1.75      rillig   2982: </div>
                   2983: </div>
                   2984: </div>
                   2985: <div class="chapter" lang="en">
                   2986: <div class="titlepage"><div><div><h2 class="title">
                   2987: <a name="faq"></a>Chapter 7. Frequently Asked Questions</h2></div></div></div>
                   2988: <div class="toc">
                   2989: <p><b>Table of Contents</b></p>
                   2990: <dl>
                   2991: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                   2992: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
                   2993: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
                   2994: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
                   2995: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
                   2996: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                   2997: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                   2998: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
                   2999: <dt><span class="sect1"><a href="#passive-ftp">7.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
                   3000: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
                   3001: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does &#8220;<span class="quote">Don't know how to make
                   3002: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
                   3003: <dt><span class="sect1"><a href="#bsd.own.mk-missing">7.12. What does &#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221; mean?</a></span></dt>
                   3004: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
                   3005: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
                   3006: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
                   3007: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
1.80      rillig   3008: <dt><span class="sect1"><a href="#ufaq-fail">7.17. A package does not build. What shall I do?</a></span></dt>
1.75      rillig   3009: </dl>
                   3010: </div>
                   3011: <p>This section contains hints, tips &amp; tricks on special things in
                   3012: pkgsrc that we didn't find a better place for in the previous chapters, and
                   3013: it contains items for both pkgsrc users and developers.</p>
                   3014: <div class="sect1" lang="en">
                   3015: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3016: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
                   3017: <p>The following mailing lists may be of interest to pkgsrc users:</p>
                   3018: <div class="itemizedlist"><ul type="disc">
1.78      rillig   3019: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
                   3020:          This is a general purpose list for most issues regarding
                   3021:          pkgsrc, regardless of platform, e.g. soliciting user help
                   3022:          for pkgsrc configuration, unexpected build failures, using
                   3023:          particular packages, upgrading pkgsrc installations,
                   3024:          questions regarding the pkgsrc release branches, etc.  General announcements or
                   3025:          proposals for changes that impact the pkgsrc user community,
                   3026:          e.g. major infrastructure changes, new features, package
                   3027:          removals, etc., may also be posted.</p></li>
1.75      rillig   3028: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
                   3029:          A list where the results of pkgsrc bulk builds are sent and
                   3030:          discussed.</p></li>
                   3031: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
                   3032:          This list is for those who are interested in getting a
                   3033:          commit message for every change committed to pkgsrc. It is
                   3034:          also available in digest form, meaning one daily message
                   3035:          containing all commit messages for changes to the package
                   3036:          source tree in that 24 hour period.</p></li>
                   3037: </ul></div>
                   3038: <p>To subscribe, do:</p>
                   3039: <pre class="programlisting">
                   3040:     <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
                   3041: </pre>
                   3042: <p>Archives for all these mailing lists are available from
                   3043: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
                   3044: </div>
                   3045: <div class="sect1" lang="en">
                   3046: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3047: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
                   3048: <p>Pkgviews is tightly integrated with buildlink.  You can find a
                   3049: pkgviews User's guide in
1.76      rillig   3050: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75      rillig   3051: </div>
                   3052: <div class="sect1" lang="en">
                   3053: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3054: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.80      rillig   3055: <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
1.75      rillig   3056: a number of useful utilities for both users and developers of pkgsrc.  This
                   3057: section attempts only to make the reader aware of the utilities and when
                   3058: they might be useful, and not to duplicate the documentation that comes
                   3059: with each package.</p>
                   3060: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76      rillig   3061: <div class="itemizedlist"><ul type="disc"><li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/x11-links/README.html" target="_top"><code class="filename">pkgtools/x11-links</code></a>:
1.75      rillig   3062:       Symlinks for use by buildlink.</p></li></ul></div>
                   3063: <p>OS tool augmentation (automatically installed when needed):</p>
                   3064: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3065: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/digest/README.html" target="_top"><code class="filename">pkgtools/digest</code></a>:
1.75      rillig   3066:       Calculates various kinds of checksums (including SHA1).</p></li>
1.76      rillig   3067: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/libnbcompat/README.html" target="_top"><code class="filename">pkgtools/libnbcompat</code></a>:
1.75      rillig   3068:       Compatibility library for pkgsrc tools.</p></li>
1.76      rillig   3069: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/mtree/README.html" target="_top"><code class="filename">pkgtools/mtree</code></a>: Installed on
1.87    ! wiz      3070:       non-BSD systems due to lack of native mtree.</p></li>
1.76      rillig   3071: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>:
1.75      rillig   3072:       Up-to-date replacement for
1.76      rillig   3073:       <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75      rillig   3074:       systems where pkg_install is not present.</p></li>
                   3075: </ul></div>
                   3076: <p>Utilities used by pkgsrc (not automatically installed):</p>
                   3077: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3078: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgtools/pkg_tarup</code></a>:
1.75      rillig   3079:       Create a binary package from an
                   3080:       already-installed package.  Used by <span><strong class="command">make replace</strong></span> to
                   3081:       save the old package.</p></li>
1.76      rillig   3082: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/dfdisk/README.html" target="_top"><code class="filename">pkgtools/dfdisk</code></a>:
1.75      rillig   3083:       Adds extra functionality to pkgsrc, allowing it to fetch distfiles
                   3084:       from multiple locations. It currently supports the following
                   3085:       methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76      rillig   3086: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a>: Put X11
1.75      rillig   3087:       packages someplace else (enabled by default).</p></li>
1.76      rillig   3088: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a>: Determine the
1.75      rillig   3089:       best compiler flags to optimise code for your current CPU and
                   3090:       compiler.</p></li>
                   3091: </ul></div>
                   3092: <p>Utilities for keeping track of installed packages, being up to date,
                   3093: etc:</p>
                   3094: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3095: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_chk/README.html" target="_top"><code class="filename">pkgtools/pkg_chk</code></a>: Reports on
1.75      rillig   3096:       packages whose installed versions do not match the latest pkgsrc
                   3097:       entries.</p></li>
1.76      rillig   3098: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a>: Makes
1.75      rillig   3099:       dependency graphs of packages, to aid in choosing a strategy for
                   3100:       updating.</p></li>
1.76      rillig   3101: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdepgraph/README.html" target="_top"><code class="filename">pkgtools/pkgdepgraph</code></a>: Makes
                   3102:       graphs from the output of <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a> (uses graphviz).</p></li>
                   3103: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>: The
1.75      rillig   3104:       pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
                   3105:       does various checks on the complete pkgsrc system.</p></li>
1.76      rillig   3106: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgsurvey/README.html" target="_top"><code class="filename">pkgtools/pkgsurvey</code></a>: Report what
1.75      rillig   3107:       packages you have installed.</p></li>
                   3108: </ul></div>
                   3109: <p>Utilities for people maintaining or creating individual packages:</p>
                   3110: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3111: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>: Automate
1.75      rillig   3112:       making and maintaining patches for a package (includes pkgdiff,
                   3113:       pkgvi, mkpatches, etc.).</p></li>
1.76      rillig   3114: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>,
                   3115:       <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>: Aids in
1.75      rillig   3116:       converting to pkgsrc.</p></li>
1.76      rillig   3117: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>: Convert
1.75      rillig   3118:       pkgsrc to a Solaris package.</p></li>
                   3119: </ul></div>
                   3120: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
                   3121: utilities)</p>
                   3122: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3123: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_comp/README.html" target="_top"><code class="filename">pkgtools/pkg_comp</code></a>: Build
1.75      rillig   3124:       packages in a chrooted area.</p></li>
1.76      rillig   3125: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/libkver/README.html" target="_top"><code class="filename">pkgtools/libkver</code></a>: Spoof
1.75      rillig   3126:       kernel version for chrooted cross builds.</p></li>
                   3127: </ul></div>
                   3128: </div>
                   3129: <div class="sect1" lang="en">
                   3130: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3131: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
                   3132: <p>If you want to use pkgsrc as non-root user, you can set some
                   3133: variables to make pkgsrc work under these conditions.  At the very least,
                   3134: you need to set <code class="varname">UNPRIVILEGED</code> to &#8220;<span class="quote">yes</span>&#8221;; this
                   3135: will turn on unprivileged mode and set multiple related variables to allow
                   3136: installation of packages as non-root.</p>
                   3137: <p>In case the defaults are not enough, you may want to tune some other
                   3138: variables used.  For example, if the automatic user/group detection leads
                   3139: to incorrect values (or not the ones you would like to use), you can change
                   3140: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
                   3141: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
                   3142: <p>As regards bootstrapping, please note that the
                   3143: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
                   3144: given the &#8220;<span class="quote">--ignore-user-check</span>&#8221; flag, as it will choose and
1.76      rillig   3145: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75      rillig   3146: installation targets.  These directories can be overriden by the
                   3147: &#8220;<span class="quote">--prefix</span>&#8221; flag provided by the script, as well as some others
                   3148: that allow finer tuning of the tree layout.</p>
                   3149: </div>
                   3150: <div class="sect1" lang="en">
                   3151: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3152: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
                   3153: <p>By default, resuming transfers in pkgsrc is disabled, but you can
                   3154: enable this feature by adding the option
                   3155: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76      rillig   3156: <code class="filename">/etc/mk.conf</code>.  If, during a fetch step, an incomplete
1.75      rillig   3157: distfile is found, pkgsrc will try to resume it.</p>
                   3158: <p>You can also
                   3159: 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
                   3160: <code class="varname">FETCH_CMD</code> variable.  Don't forget to set
                   3161: <code class="varname">FETCH_RESUME_ARGS</code> and
                   3162: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
                   3163: values.</p>
                   3164: <p>For example, if you want to use
1.76      rillig   3165: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75      rillig   3166: like:</p>
                   3167: <pre class="programlisting">
                   3168:     FETCH_CMD=             wget
                   3169:     FETCH_BEFORE_ARGS=     --passive-ftp
                   3170:     FETCH_RESUME_ARGS=     -c
                   3171:     FETCH_OUTPUT_ARGS=     -O
1.1       grant    3172: </pre>
1.75      rillig   3173: </div>
                   3174: <div class="sect1" lang="en">
                   3175: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3176: <a name="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
                   3177: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76      rillig   3178: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75      rillig   3179: ...), you will have to add the following line into
1.76      rillig   3180: <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3181: <pre class="programlisting">
                   3182:     X11_TYPE=XFree86
1.1       grant    3183: </pre>
1.75      rillig   3184: </div>
                   3185: <div class="sect1" lang="en">
                   3186: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3187: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
                   3188: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76      rillig   3189: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75      rillig   3190: you will have to add the following line into
1.76      rillig   3191: <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3192: <pre class="programlisting">
                   3193:     X11_TYPE=xorg
1.1       grant    3194: </pre>
1.75      rillig   3195: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   3196: <h3 class="title">Note</h3>
                   3197: <p>The DragonFly operating system defaults to using
1.87    ! wiz      3198: this X.org X11 implementation from pkgsrc.</p>
1.75      rillig   3199: </div>
                   3200: </div>
                   3201: <div class="sect1" lang="en">
                   3202: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3203: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
                   3204: <p>If you are sitting behind a firewall which does not allow direct
                   3205: connections to Internet hosts (i.e. non-NAT), you may specify the
                   3206: relevant proxy hosts.  This is done using an environment variable in the
                   3207: form of a URL, e.g. in Amdahl, the machine
                   3208: &#8220;<span class="quote">orpheus.amdahl.com</span>&#8221; is one of the firewalls, and it uses
                   3209: port 80 as the proxy port number.  So the proxy environment variables
                   3210: are:</p>
                   3211: <pre class="programlisting">
                   3212:     ftp_proxy=ftp://orpheus.amdahl.com:80/
                   3213:     http_proxy=http://orpheus.amdahl.com:80/
1.1       grant    3214: </pre>
1.75      rillig   3215: </div>
                   3216: <div class="sect1" lang="en">
                   3217: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3218: <a name="passive-ftp"></a>7.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</h2></div></div></div>
                   3219: <p>This depends on which utility is used to retrieve distfiles.  From
1.76      rillig   3220: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75      rillig   3221: the first available command from the following list:</p>
                   3222: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3223: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
                   3224: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75      rillig   3225: </ul></div>
                   3226: <p>On a default NetBSD installation, this will be
1.76      rillig   3227: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75      rillig   3228: connections first, and falls back to active connections if the server
                   3229: refuses to do passive.  For the other tools, add the following to your
1.76      rillig   3230: <code class="filename">/etc/mk.conf</code> file:
1.75      rillig   3231: <code class="varname">PASSIVE_FETCH=1</code>.</p>
                   3232: <p>Having that option present will prevent
1.76      rillig   3233: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75      rillig   3234: transfers.</p>
                   3235: </div>
                   3236: <div class="sect1" lang="en">
                   3237: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3238: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
                   3239: <p>You would like to download all the distfiles in a single batch from
                   3240: work or university, where you can't run a <span><strong class="command">make fetch</strong></span>.
                   3241: There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
                   3242: but downloading the entire directory may not be appropriate.</p>
                   3243: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76      rillig   3244: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75      rillig   3245: resulting list to your machine at work/school and use it there.  If you
                   3246: 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
                   3247: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
                   3248: URL:</p>
                   3249: <p>At home:</p>
                   3250: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   3251: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles &gt;/tmp/fetch.sh</code></strong>
                   3252: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
                   3253: <p>At work:</p>
                   3254: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76      rillig   3255: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75      rillig   3256: home.</p>
                   3257: <p>If you have a machine running NetBSD, and you want to get
                   3258: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your machine
                   3259: architecture), you can do so by using the above-mentioned <span><strong class="command">make
                   3260: fetch-list</strong></span> approach, or fetch the distfiles directly by
                   3261: running:</p>
                   3262: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
                   3263: <p>If you even decide to ignore
                   3264: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
                   3265: by running:</p>
                   3266: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
                   3267: </div>
                   3268: <div class="sect1" lang="en">
                   3269: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3270: <a name="tmac.andoc-missing"></a>7.11. What does &#8220;<span class="quote">Don't know how to make
                   3271: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</h2></div></div></div>
1.76      rillig   3272: <p>When compiling the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>
1.75      rillig   3273: package, you get the error from make that it doesn't know how to make
1.76      rillig   3274: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75      rillig   3275: you don't have installed the &#8220;<span class="quote">text</span>&#8221; set (nroff, ...) from
                   3276: the NetBSD base distribution on your machine.  It is recommended to do
                   3277: that to format man pages.</p>
1.76      rillig   3278: <p>In the case of the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a> package, you
1.75      rillig   3279: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76      rillig   3280: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75      rillig   3281: </div>
                   3282: <div class="sect1" lang="en">
                   3283: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3284: <a name="bsd.own.mk-missing"></a>7.12. What does &#8220;<span class="quote">Could not find bsd.own.mk</span>&#8221; mean?</h2></div></div></div>
1.87    ! wiz      3285: <p>You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75      rillig   3286: when you installed your NetBSD machine.  Please get and install it, by
1.76      rillig   3287: extracting it in <code class="filename">/</code>:</p>
1.75      rillig   3288: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
                   3289: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76      rillig   3290: <p><code class="filename">comp.tgz</code> is part of every NetBSD release.  Get
1.75      rillig   3291: the one that corresponds to your release (determine via <span><strong class="command">uname
                   3292: -r</strong></span>).</p>
                   3293: </div>
                   3294: <div class="sect1" lang="en">
                   3295: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3296: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
                   3297: <p>When installing packages as non-root user and using the just-in-time
                   3298: <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
                   3299: password for each required package installed.  To avoid this, the sudo
                   3300: package can be used, which does password caching over a limited time.  To
                   3301: use it, install sudo (either as binary package or from
1.76      rillig   3302: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/sudo/README.html" target="_top"><code class="filename">security/sudo</code></a>) and then put the following
                   3303: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3304: <pre class="programlisting">
                   3305:     .if exists(${LOCALBASE}/bin/sudo)
                   3306:     SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   3307:     .endif
1.1       grant    3308: </pre>
1.75      rillig   3309: </div>
                   3310: <div class="sect1" lang="en">
                   3311: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3312: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
                   3313: <p>As the system administrator, you can choose where configuration files
                   3314: are installed.  The default settings make all these files go into
1.76      rillig   3315: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75      rillig   3316: be suboptimal depending on your expectations (e.g., a read-only,
                   3317: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
                   3318: configuration of the provided packages).</p>
                   3319: <p>In order to change the defaults, you can modify the
                   3320: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76      rillig   3321: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
                   3322: directory; some common examples include <code class="filename">/etc</code> or
                   3323: <code class="filename">/etc/pkg</code>.</p>
1.75      rillig   3324: <p>Furthermore, you can change this value on a per-package basis by
                   3325: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
                   3326: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
                   3327: package you would like to modify, that is, the contents of
                   3328: <code class="varname">PKGBASE</code>.</p>
                   3329: <p>Note that after changing these settings, you must rebuild and
                   3330: reinstall any affected packages.</p>
                   3331: </div>
                   3332: <div class="sect1" lang="en">
                   3333: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3334: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
                   3335: <p>Please be aware that there can often be bugs in third-party software,
                   3336: and some of these bugs can leave a machine vulnerable to exploitation by
                   3337: attackers.  In an effort to lessen the exposure, the NetBSD packages team
                   3338: maintains a database of known-exploits to packages which have at one time
                   3339: been included in pkgsrc.  The database can be downloaded automatically, and
                   3340: a security audit of all packages installed on a system can take place.  To
1.76      rillig   3341: do this, install the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> package.  It has two
1.75      rillig   3342: components:</p>
                   3343: <div class="orderedlist"><ol type="1">
                   3344: <li>
                   3345: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
                   3346:     download a list of the security vulnerabilities information.  This list
                   3347:     is kept up to date by the NetBSD security officer and the NetBSD
                   3348:     packages team, and is distributed from the NetBSD ftp server:</p>
                   3349: <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>
                   3350: </li>
                   3351: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
                   3352:     current machine, checking each vulnerability which is known.  If a
                   3353:     vulnerable package is installed, it will be shown by output to stdout,
                   3354:     including a description of the type of vulnerability, and a URL
                   3355:     containing more information.</p></li>
                   3356: </ol></div>
1.76      rillig   3357: <p>Use of the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>
1.75      rillig   3358: package is strongly recommended!  After
                   3359: &#8220;<span class="quote">audit-packages</span>&#8221; is installed, please read
                   3360: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
                   3361: audit-packages</code></strong>.</p>
1.87    ! wiz      3362: <p>If this package is installed, pkgsrc builds will use it to
        !          3363: 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
        !          3364: check.</p>
1.75      rillig   3365: </div>
                   3366: <div class="sect1" lang="en">
                   3367: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3368: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
                   3369: <p>When you add your own preferences to the
                   3370:        <code class="varname">CFLAGS</code> variable in your
1.76      rillig   3371:        <code class="filename">mk.conf</code>, these flags are passed in
                   3372:        environment variables to the <code class="filename">./configure</code>
1.75      rillig   3373:        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
                   3374:        <code class="varname">CFLAGS</code> from the environment variable by
1.76      rillig   3375:        overriding them in the <code class="filename">Makefile</code>s of their
1.75      rillig   3376:        package.</p>
                   3377: <p>Currently there is no solution to this problem. If you
                   3378:        really need the package to use your <code class="varname">CFLAGS</code>
                   3379:        you should run <span><strong class="command">make patch</strong></span> in the package
1.76      rillig   3380:        directory and then inspect any <code class="filename">Makefile</code> and
                   3381:        <code class="filename">Makefile.in</code> for whether they define
1.75      rillig   3382:        <code class="varname">CFLAGS</code> explicitly. Usually you can remove
                   3383:        these lines. But be aware that some &#8220;<span class="quote">smart</span>&#8221;
                   3384:        programmers write so bad code that it only works for the
                   3385:        specific combination of <code class="varname">CFLAGS</code> they have
                   3386:        chosen.</p>
                   3387: </div>
1.80      rillig   3388: <div class="sect1" lang="en">
                   3389: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3390: <a name="ufaq-fail"></a>7.17. A package does not build. What shall I do?</h2></div></div></div>
                   3391: <div class="procedure"><ol type="1">
                   3392: <li><p>Make sure that your copy of pkgsrc is consistent. A
                   3393:        case that occurs often is that people only update pkgsrc in
                   3394:        parts, because of performance reasons. Since pkgsrc is one large
                   3395:        system, not a collection of many small systems, there are
                   3396:        sometimes changes that only work when the whole pkgsrc tree is
                   3397:        updated.</p></li>
                   3398: <li><p>Make sure that you don't have any CVS conflicts.
                   3399:        Search for &#8220;<span class="quote">&lt;&lt;&lt;&lt;&lt;&lt;</span>&#8221; or
                   3400:        &#8220;<span class="quote">&gt;&gt;&gt;&gt;&gt;&gt;</span>&#8221; in all your pkgsrc
                   3401:        files.</p></li>
                   3402: <li><p>Make sure that you don't have old copies of the packages
                   3403:        extracted. Run <span><strong class="command">make clean clean-depends</strong></span> to
                   3404:        verify this.</p></li>
                   3405: <li><p>If the problem still exists, write a mail to the
                   3406:        <code class="literal">pkgsrc-users</code> mailing list.</p></li>
                   3407: </ol></div>
                   3408: </div>
1.75      rillig   3409: </div>
                   3410: </div>
                   3411: <div class="part" lang="en">
                   3412: <div class="titlepage"><div><div><h1 class="title">
                   3413: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77      rillig   3414: <div class="partintro" lang="en">
                   3415: <div></div>
                   3416: <p>This part of the book deals with creating and
                   3417:        modifying packages. It starts with a &#8220;<span class="quote">HOWTO</span>&#8221;-like
                   3418:        guide on creating a new package. The remaining chapters are more
                   3419:        like a reference manual for pkgsrc.</p>
1.75      rillig   3420: <div class="toc">
                   3421: <p><b>Table of Contents</b></p>
                   3422: <dl>
1.77      rillig   3423: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
                   3424: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75      rillig   3425: <dd><dl>
1.77      rillig   3426: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
                   3427: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
                   3428: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
1.85      jmmv     3429: <dd><dl>
                   3430: <dt><span class="sect2"><a href="#components.patches.guidelines">9.3.1. Patching guidelines</a></span></dt>
                   3431: <dt><span class="sect2"><a href="#components.patches.feedback">9.3.2. Feedback to the author</a></span></dt>
                   3432: </dl></dd>
1.77      rillig   3433: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
                   3434: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78      rillig   3435: <dd><dl>
                   3436: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
                   3437: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
                   3438: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
                   3439: </dl></dd>
1.77      rillig   3440: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
                   3441: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
                   3442: </dl></dd>
                   3443: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
                   3444: <dd><dl>
                   3445: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
                   3446: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
                   3447: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
                   3448: <dd><dl>
                   3449: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
                   3450: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
                   3451: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
                   3452: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
                   3453: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
                   3454: </dl></dd>
                   3455: </dl></dd>
                   3456: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
                   3457: <dd><dl>
                   3458: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
                   3459: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
                   3460: <dt><span class="sect1"><a href="#print-PLIST">11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
                   3461: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
                   3462: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
                   3463: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
                   3464: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
                   3465: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
                   3466: </dl></dd>
                   3467: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
                   3468: <dd><dl>
                   3469: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
                   3470: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
                   3471: <dd><dl>
                   3472: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
                   3473: <dt><span class="sect2"><a href="#updating-buildlink-depends">12.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>
                   3474: </dl></dd>
                   3475: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
                   3476: <dd><dl>
                   3477: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">12.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
                   3478: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
                   3479: </dl></dd>
                   3480: </dl></dd>
                   3481: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
                   3482: <dd><dl>
                   3483: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
                   3484: <dd><dl>
                   3485: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
                   3486: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
                   3487: </dl></dd>
                   3488: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
                   3489: <dd><dl>
                   3490: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
                   3491: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
                   3492: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
                   3493: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
                   3494: </dl></dd>
                   3495: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
                   3496: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">13.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
                   3497: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
                   3498: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
                   3499: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
                   3500: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
                   3501: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">13.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
                   3502: </dl></dd>
                   3503: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
                   3504: <dd><dl>
                   3505: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
                   3506: <dt><span class="sect1"><a href="#converting-to-options">14.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
                   3507: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
                   3508: </dl></dd>
                   3509: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
                   3510: <dd><dl>
                   3511: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
                   3512: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
                   3513: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
                   3514: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
                   3515: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
1.81      rillig   3516: <dd><dl>
                   3517: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
                   3518: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
                   3519: </dl></dd>
1.77      rillig   3520: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
                   3521: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
                   3522: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
                   3523: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
                   3524: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
                   3525: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   3526: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   3527: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
                   3528: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   3529: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
                   3530: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
                   3531: </dl></dd>
                   3532: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
                   3533: <dd><dl>
                   3534: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
                   3535: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
                   3536: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
                   3537: </dl></dd>
                   3538: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
                   3539: <dd><dl>
                   3540: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
                   3541: <dd><dl>
1.78      rillig   3542: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
                   3543: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">17.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
                   3544: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
                   3545: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
                   3546: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
                   3547: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
                   3548: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
                   3549: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
                   3550: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
                   3551: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
                   3552: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
1.79      rillig   3553: <dt><span class="sect2"><a href="#fixes.subst">17.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
1.77      rillig   3554: </dl></dd>
                   3555: <dt><span class="sect1"><a href="#fixes.fetch">17.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
                   3556: <dd><dl>
                   3557: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
                   3558: <dt><span class="sect2"><a href="#modified-distfiles-same-name">17.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
                   3559: </dl></dd>
                   3560: <dt><span class="sect1"><a href="#fixes.configure">17.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   3561: <dd><dl>
                   3562: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
                   3563: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
                   3564: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
                   3565: </dl></dd>
1.87    ! wiz      3566: <dt><span class="sect1"><a href="#programming-languages">17.4. Programming languages</a></span></dt>
1.77      rillig   3567: <dd><dl>
1.87    ! wiz      3568: <dt><span class="sect2"><a href="#basic-programming-languages">17.4.1. C, C++, and Fortran</a></span></dt>
        !          3569: <dt><span class="sect2"><a href="#java-programming-language">17.4.2. Java</a></span></dt>
        !          3570: <dt><span class="sect2"><a href="#perl-scripts">17.4.3. Packages containing perl scripts</a></span></dt>
        !          3571: <dt><span class="sect2"><a href="#other-programming-languages">17.4.4. Other programming languages</a></span></dt>
        !          3572: </dl></dd>
        !          3573: <dt><span class="sect1"><a href="#fixes.build">17.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
        !          3574: <dd><dl>
        !          3575: <dt><span class="sect2"><a href="#fixes.build.cpp">17.5.1. Compiling C and C++ code conditionally</a></span></dt>
        !          3576: <dt><span class="sect2"><a href="#compiler-bugs">17.5.2. How to handle compiler bugs</a></span></dt>
        !          3577: <dt><span class="sect2"><a href="#undefined-reference">17.5.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
        !          3578: <dt><span class="sect2"><a href="#out-of-memory">17.5.4. Running out of memory</a></span></dt>
        !          3579: </dl></dd>
        !          3580: <dt><span class="sect1"><a href="#fixes.install">17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
        !          3581: <dd><dl>
        !          3582: <dt><span class="sect2"><a href="#install-scripts">17.6.1. Creating needed directories</a></span></dt>
        !          3583: <dt><span class="sect2"><a href="#where-to-install-documentation">17.6.2. Where to install documentation</a></span></dt>
        !          3584: <dt><span class="sect2"><a href="#installing-score-files">17.6.3. Installing score files</a></span></dt>
        !          3585: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
        !          3586: <dt><span class="sect2"><a href="#perl-modules">17.6.5. Packages installing perl modules</a></span></dt>
        !          3587: <dt><span class="sect2"><a href="#faq.info-files">17.6.6. Packages installing info files</a></span></dt>
        !          3588: <dt><span class="sect2"><a href="#manpages">17.6.7. Packages installing man pages</a></span></dt>
        !          3589: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.8. Packages installing GConf2 data files</a></span></dt>
        !          3590: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.9. Packages installing scrollkeeper data files</a></span></dt>
        !          3591: <dt><span class="sect2"><a href="#x11-fonts">17.6.10. Packages installing X11 fonts</a></span></dt>
        !          3592: <dt><span class="sect2"><a href="#gtk2-modules">17.6.11. Packages installing GTK2 modules</a></span></dt>
        !          3593: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.12. Packages installing SGML or XML data</a></span></dt>
        !          3594: <dt><span class="sect2"><a href="#mime-database">17.6.13. Packages installing extensions to the MIME database</a></span></dt>
        !          3595: <dt><span class="sect2"><a href="#intltool">17.6.14. Packages using intltool</a></span></dt>
        !          3596: <dt><span class="sect2"><a href="#startup-scripts">17.6.15. Packages installing startup scripts</a></span></dt>
        !          3597: <dt><span class="sect2"><a href="#tex-packages">17.6.16. Packages installing TeX modules</a></span></dt>
        !          3598: <dt><span class="sect2"><a href="#emulation-packages">17.6.17. Packages supporting running binaries in
        !          3599:     emulation</a></span></dt>
        !          3600: <dt><span class="sect2"><a href="#hicolor-theme">17.6.18. Packages installing hicolor theme icons</a></span></dt>
        !          3601: <dt><span class="sect2"><a href="#desktop-files">17.6.19. Packages installing desktop files</a></span></dt>
1.77      rillig   3602: </dl></dd>
1.87    ! wiz      3603: <dt><span class="sect1"><a href="#punting">17.7. Marking packages as having problems</a></span></dt>
1.77      rillig   3604: </dl></dd>
                   3605: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
                   3606: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
                   3607: <dd><dl>
                   3608: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
                   3609: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                   3610: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
                   3611: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
                   3612: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
                   3613: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig   3614: </dl></dd>
1.77      rillig   3615: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.85      jmmv     3616: <dt><span class="chapter"><a href="#gnome">21. GNOME packaging and porting</a></span></dt>
                   3617: <dd><dl>
                   3618: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
                   3619: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
                   3620: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
                   3621: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
                   3622: </dl></dd>
1.75      rillig   3623: </dl>
                   3624: </div>
1.77      rillig   3625: </div>
                   3626: <div class="chapter" lang="en">
                   3627: <div class="titlepage"><div><div><h2 class="title">
                   3628: <a name="creating"></a>Chapter 8. Creating a new pkgsrc package from scratch</h2></div></div></div>
                   3629: <p>When you find a package that is not yet in pkgsrc, you
                   3630:        most likely have a URL from where you can download the source
                   3631:        code. Starting with this URL, creating a package involves only a
                   3632:        few steps.</p>
                   3633: <div class="procedure"><ol type="1">
                   3634: <li><p>First, install the packages <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a> and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>.</p></li>
                   3635: <li><p>Then, choose one of the top-level directories as the
                   3636:        category in which you want to place your package. You can also
                   3637:        create a directory of your own (maybe called
                   3638:        <code class="filename">local</code>). In that category directory, create
                   3639:        another directory for your package and change into
                   3640:        it.</p></li>
                   3641: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
                   3642:        will ask you for a URL. Enter the URL of the distribution file
                   3643:        (in most cases a <code class="filename">.tar.gz</code> file) and watch
                   3644:        how the basic ingredients of your package are created
                   3645:        automatically. The distribution file is extracted automatically
                   3646:        to fill in some details in the <code class="filename">Makefile</code>
                   3647:        that would otherwise have to be done manually.</p></li>
                   3648: <li>
                   3649: <p>Examine the extracted files to determine the
                   3650:        dependencies of your package. Ideally, this is mentioned in some
                   3651:        <code class="filename">README</code> file, but things may differ. For
                   3652:        each of these dependencies, look where it exists in pkgsrc, and
                   3653:        if there is a file called <code class="filename">buildlink3.mk</code> in
                   3654:        that directory, add a line to your package
                   3655:        <code class="filename">Makefile</code> which includes that file just
                   3656:        before the last line. If the <code class="filename">buildlink3.mk</code>
                   3657:        file does not exist, add a <code class="varname">DEPENDS</code> line to
                   3658:        the Makefile, which specifies the version of the dependency and
                   3659:        where it can be found in pkgsrc. This line should be placed in
                   3660:        the third paragraph. If the dependency is only needed for
                   3661:        building the package, but not when using it, use
                   3662:        <code class="varname">BUILD_DEPENDS</code> instead of
                   3663:        <code class="varname">DEPENDS</code>. Your package may then look like
                   3664:        this:</p>
                   3665: <pre class="programlisting">
                   3666:     [...]
                   3667: 
                   3668:     BUILD_DEPENDS+= lua&gt;=5.0:../../lang/lua
                   3669:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   3670:     DEPENDS+=       screen&gt;=4.0:../../misc/screen
                   3671: 
                   3672:     [...]
                   3673: 
                   3674:     .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
                   3675:     .include "../../devel/glib2/buildlink3.mk"
                   3676:     .include "../../mk/bsd.pkg.mk"
                   3677: </pre>
                   3678: </li>
                   3679: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
                   3680:        still need to be done to make your package a &#8220;<span class="quote">good</span>&#8221;
                   3681:        one. If you don't know what pkglint's warnings want to tell you,
                   3682:        try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
                   3683:        -e</strong></span>, which outputs additional
                   3684:        explanations.</p></li>
                   3685: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
                   3686:        package. For the various things that can go wrong in this phase,
                   3687:        consult <a href="#fixes" title="Chapter 17. Making your package work">Chapter 17, <i>Making your package work</i></a>.</p></li>
                   3688: <li><p>When the package builds fine, the next step is to
                   3689:        install the package. Run <span><strong class="command">bmake install</strong></span> and
                   3690:        hope that everything works.</p></li>
                   3691: <li><p>Up to now, the file <code class="filename">PLIST</code>,
                   3692:        which contains a list of the files that are installed by the
                   3693:        package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
                   3694:        &gt;PLIST</strong></span> to generate a probably correct list. Check
                   3695:        the file using your preferred text editor to see if the list of
                   3696:        files looks plausible.</p></li>
                   3697: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
                   3698:        generated <code class="filename">PLIST</code> contains garbage or
                   3699:        not.</p></li>
                   3700: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
                   3701:        package has been registered in the database of installed files,
                   3702:        but with an empty list of files. To fix this, run <span><strong class="command">bmake
                   3703:        deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
                   3704:        Now the package is registered with the list of files from
                   3705:        <code class="filename">PLIST</code>.</p></li>
                   3706: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
                   3707:        binary package from the set of installed files.</p></li>
                   3708: </ol></div>
                   3709: </div>
1.75      rillig   3710: <div class="chapter" lang="en">
                   3711: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   3712: <a name="components"></a>Chapter 9. Package components - files, directories and contents</h2></div></div></div>
1.75      rillig   3713: <div class="toc">
                   3714: <p><b>Table of Contents</b></p>
                   3715: <dl>
1.77      rillig   3716: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
                   3717: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
                   3718: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
1.85      jmmv     3719: <dd><dl>
                   3720: <dt><span class="sect2"><a href="#components.patches.guidelines">9.3.1. Patching guidelines</a></span></dt>
                   3721: <dt><span class="sect2"><a href="#components.patches.feedback">9.3.2. Feedback to the author</a></span></dt>
                   3722: </dl></dd>
1.77      rillig   3723: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
                   3724: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78      rillig   3725: <dd><dl>
                   3726: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
                   3727: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
                   3728: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
                   3729: </dl></dd>
1.77      rillig   3730: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
                   3731: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
1.75      rillig   3732: </dl>
                   3733: </div>
1.87    ! wiz      3734: <p>Whenever you're preparing a package, there are a number of
        !          3735: files involved which are described in the following
        !          3736: sections.</p>
1.75      rillig   3737: <div class="sect1" lang="en">
                   3738: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   3739: <a name="components.Makefile"></a>9.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75      rillig   3740: <p>Building, installation and creation of a binary package are all
1.87    ! wiz      3741:   controlled by the package's <code class="filename">Makefile</code>.
        !          3742:   The <code class="filename">Makefile</code> describes various things about
        !          3743:   a package, for example from where to get it, how to configure,
        !          3744:   build, and install it.</p>
1.76      rillig   3745: <p>A package <code class="filename">Makefile</code> contains several
1.87    ! wiz      3746:   sections that describe the package.</p>
1.75      rillig   3747: <p>In the first section there are the following variables, which
1.87    ! wiz      3748:   should appear exactly in the order given here.  The order and
        !          3749:   grouping of the variables is mostly historical and has no further
        !          3750:   meaning.</p>
1.75      rillig   3751: <div class="itemizedlist"><ul type="disc">
                   3752: <li><p><code class="varname">DISTNAME</code> is the basename of the
1.87    ! wiz      3753:     distribution file to be downloaded from the package's
        !          3754:     website.</p></li>
1.75      rillig   3755: <li><p><code class="varname">PKGNAME</code> is the name of the
1.87    ! wiz      3756:     package, as used by pkgsrc. You only need to provide it if
        !          3757:     <code class="varname">DISTNAME</code> (which is the default) is not a good
        !          3758:     name for the package in pkgsrc.  Usually it is the pkgsrc
        !          3759:     directory name together with the version number. It must match the
        !          3760:     regular expression
        !          3761:     <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
        !          3762:     starts with a letter or digit, and contains only letters, digits,
        !          3763:     dashes, underscores, dots and plus signs.</p></li>
        !          3764: <li><p><code class="varname">SVR4_PKGNAME</code> is the name of
        !          3765:     the package file to create if the <code class="varname">PKGNAME</code>
        !          3766:     isn't unique on a SVR4 system. The default is
        !          3767:     <code class="varname">PKGNAME</code>, which may be shortened when you use
        !          3768:     <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>. Only add
        !          3769:     <code class="varname">SVR4_PKGNAME</code> if <code class="varname">PKGNAME</code>
        !          3770:     does not produce an unique package name on a SVR4 system.
        !          3771:     The length of <code class="varname">SVR4_PKGNAME</code> is limited to 5
        !          3772:     characters.</p></li>
1.75      rillig   3773: <li>
                   3774: <p><code class="varname">CATEGORIES</code> is a list of categories
1.87    ! wiz      3775:     which the package fits in. You can choose any of the top-level
        !          3776:     directories of pkgsrc for it.</p>
1.75      rillig   3777: <p>Currently the following values are available for
1.87    ! wiz      3778:     <code class="varname">CATEGORIES</code>. If more than
        !          3779:     one is used, they need to be separated by spaces:</p>
1.75      rillig   3780: <pre class="programlisting">
1.87    ! wiz      3781:       archivers     cross         geography     meta-pkgs     security
        !          3782:       audio         databases     graphics      misc          shells
        !          3783:       benchmarks    devel         ham           multimedia    sysutils
        !          3784:       biology       editors       inputmethod   net           textproc
        !          3785:       cad           emulators     lang          news          time
        !          3786:       chat          finance       mail          parallel      wm
        !          3787:       comms         fonts         math          pkgtools      www
        !          3788:       converters    games         mbone         print         x11
        !          3789:     </pre>
1.75      rillig   3790: </li>
1.81      rillig   3791: <li><p><code class="varname">MASTER_SITES</code>,
1.87    ! wiz      3792:     <code class="varname">DYNAMIC_MASTER_SITES</code>,
        !          3793:     <code class="varname">DIST_SUBDIR</code>, <code class="varname">EXTRACT_SUFX</code>
        !          3794:     and <code class="varname">DISTFILES</code> are discussed in detail in
        !          3795:     <a href="#build.fetch" title="15.5. The fetch phase">Section 15.5, &#8220;The <span class="emphasis"><em>fetch</em></span> phase&#8221;</a>.</p></li>
1.75      rillig   3796: </ul></div>
                   3797: <p>The second section contains information about separately
1.87    ! wiz      3798:   downloaded patches, if any.
        !          3799:   </p>
1.75      rillig   3800: <div class="itemizedlist"><ul type="disc">
                   3801: <li><p><code class="varname">PATCHFILES:</code>
1.87    ! wiz      3802:     Name(s) of additional files that contain distribution patches.
        !          3803:     There is no default. pkgsrc will look for them at
        !          3804:     <code class="varname">PATCH_SITES</code>.
        !          3805:     They will automatically be uncompressed before patching if
        !          3806:     the names end with <code class="filename">.gz</code> or
        !          3807:     <code class="filename">.Z</code>.</p></li>
1.75      rillig   3808: <li><p><code class="varname">PATCH_SITES</code>:
1.87    ! wiz      3809:     Primary location(s) for distribution patch files (see
        !          3810:     <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
1.75      rillig   3811: </ul></div>
                   3812: <p>The third section contains the following variables.
1.87    ! wiz      3813:   </p>
1.75      rillig   3814: <div class="itemizedlist"><ul type="disc">
                   3815: <li><p><code class="varname">MAINTAINER</code> is the email address
1.87    ! wiz      3816:     of the person who feels responsible for this package, and who is
        !          3817:     most likely to look at problems or questions regarding this
        !          3818:     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
        !          3819:     developers should contact the <code class="varname">MAINTAINER</code> before
        !          3820:     making major changes to the package. When packaging a new program,
        !          3821:     set <code class="varname">MAINTAINER</code> to yourself. If you really can't
        !          3822:     maintain the package for future updates, set it to
        !          3823:     <code class="email">&lt;<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>&gt;</code>.</p></li>
1.75      rillig   3824: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
1.87    ! wiz      3825:     find more information about the package.</p></li>
1.75      rillig   3826: <li><p><code class="varname">COMMENT</code> is a one-line
1.87    ! wiz      3827:     description of the package (should not include the package
        !          3828:     name).</p></li>
1.75      rillig   3829: </ul></div>
                   3830: <p>Other variables that affect the build:
1.87    ! wiz      3831:   </p>
1.75      rillig   3832: <div class="itemizedlist"><ul type="disc"><li>
                   3833: <p><code class="varname">WRKSRC</code>: The directory where the
1.87    ! wiz      3834:       interesting distribution files of the package are found. The
        !          3835:       default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
        !          3836:       works for most packages.</p>
1.75      rillig   3837: <p>If a package doesn't create a subdirectory for itself
1.87    ! wiz      3838:       (most GNU software does, for instance), but extracts itself in
        !          3839:       the current directory, you should set
        !          3840:       <code class="varname">WRKSRC=${WRKDIR}</code>.</p>
        !          3841: <p>If a package doesn't create a subdirectory with the
        !          3842:       name of <code class="varname">DISTNAME</code> but some different name,
        !          3843:       set <code class="varname">WRKSRC</code> to point to the proper name in
        !          3844:       <code class="filename">${WRKDIR}</code>, for example
        !          3845:       <code class="varname">WRKSRC=${WRKDIR}/${DISTNAME}/unix</code>. See
        !          3846:       <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/lang/tcl/README.html" target="_top"><code class="filename">lang/tcl</code></a> and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/tk/README.html" target="_top"><code class="filename">x11/tk</code></a> for other examples.</p>
1.75      rillig   3847: <p>The name of the working directory created by pkgsrc is
1.87    ! wiz      3848:       taken from the <code class="varname">WRKDIR_BASENAME</code>
        !          3849:       variable. By default, its value is
        !          3850:       <code class="filename">work</code>. If you want to use the same
        !          3851:       pkgsrc tree for building different kinds of binary packages,
        !          3852:       you can change the variable according to your needs. Two
        !          3853:       other variables handle common cases of setting
        !          3854:       <code class="varname">WRKDIR_BASENAME</code> individually. If
        !          3855:       <code class="varname">OBJHOSTNAME</code> is defined in
        !          3856:       <code class="filename">/etc/mk.conf</code>, the first component of
        !          3857:       the host's name is attached to the directory name. If
        !          3858:       <code class="varname">OBJMACHINE</code> is defined, the platform name
        !          3859:       is attached, which might look like
        !          3860:       <code class="filename">work.i386</code> or
        !          3861:       <code class="filename">work.sparc</code>.</p>
1.75      rillig   3862: </li></ul></div>
                   3863: <p>Please pay attention to the following gotchas:</p>
                   3864: <div class="itemizedlist"><ul type="disc">
1.87    ! wiz      3865: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are
        !          3866:       installed in compressed form by the package; see comment in
        !          3867:       <code class="filename">bsd.pkg.mk</code>.</p></li>
1.76      rillig   3868: <li><p>Replace <code class="filename">/usr/local</code> with
1.87    ! wiz      3869:       &#8220;<span class="quote">${PREFIX}</span>&#8221; in all files (see patches, below).</p></li>
1.75      rillig   3870: <li><p>If the package installs any info files, see
1.87    ! wiz      3871:       <a href="#faq.info-files" title="17.6.6. Packages installing info files">Section 17.6.6, &#8220;Packages installing info files&#8221;</a>.</p></li>
1.75      rillig   3872: </ul></div>
                   3873: </div>
                   3874: <div class="sect1" lang="en">
                   3875: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   3876: <a name="components.distinfo"></a>9.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76      rillig   3877: <p>The <code class="filename">distinfo</code> file contains the message
1.87    ! wiz      3878:   digest, or checksum, of each distfile needed for the package. This
        !          3879:   ensures that the distfiles retrieved from the Internet have not been
        !          3880:   corrupted during transfer or altered by a malign force to introduce
        !          3881:   a security hole. Due to recent rumor about weaknesses of digest
        !          3882:   algorithms, all distfiles are protected using both SHA1 and RMD160
        !          3883:   message digests, as well as the file size.</p>
1.76      rillig   3884: <p>The <code class="filename">distinfo</code> file also contains the
1.87    ! wiz      3885:   checksums for all the patches found in the
        !          3886:   <code class="filename">patches</code> directory (see <a href="#components.patches" title="9.3. patches/*">Section 9.3, &#8220;patches/*&#8221;</a>).</p>
1.76      rillig   3887: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.87    ! wiz      3888:   <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
        !          3889:   command.</p>
1.75      rillig   3890: <p>Some packages have different sets of distfiles depending on
1.87    ! wiz      3891:   the platform, for example <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/navigator/README.html" target="_top"><code class="filename">www/navigator</code></a>). These are kept in the same
        !          3892:   <code class="filename">distinfo</code> file and care should be taken when
        !          3893:   upgrading such a package to ensure distfile information is not
        !          3894:   lost.</p>
1.75      rillig   3895: </div>
                   3896: <div class="sect1" lang="en">
                   3897: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   3898: <a name="components.patches"></a>9.3. patches/*</h2></div></div></div>
1.75      rillig   3899: <p>This directory contains files that are used by the
1.87    ! wiz      3900:   <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
        !          3901:   modify the sources as distributed in the distribution file into a form
        !          3902:   that will compile and run perfectly on NetBSD. The files are applied
        !          3903:   successively in alphabetic order (as returned by a shell
        !          3904:   &#8220;<span class="quote">patches/patch-*</span>&#8221; glob expansion), so
        !          3905:   <code class="filename">patch-aa</code> is applied before
        !          3906:   <code class="filename">patch-ab</code>, etc.</p>
1.76      rillig   3907: <p>The <code class="filename">patch-*</code> files should be in
1.87    ! wiz      3908:   <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
        !          3909:   problems. (To force patches to apply
        !          3910:   with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
        !          3911:   Furthermore, do not put changes for more than one file into a single
        !          3912:   patch file, as this will make future modifications more difficult.</p>
1.75      rillig   3913: <p>Similar, a file should be patched at most once, not several times by
1.87    ! wiz      3914:   several different patches. If a file needs several patches, they should
        !          3915:   be combined into one file.</p>
1.75      rillig   3916: <p>One important thing to mention is to pay attention that no RCS IDs
1.87    ! wiz      3917:   get stored in the patch files, as these will cause problems when
        !          3918:   later checked into the NetBSD CVS tree. Use the
        !          3919:   <span><strong class="command">pkgdiff</strong></span> from the
        !          3920:   <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a> package to avoid
        !          3921:   these problems.</p>
        !          3922: <p>For even more automation, we recommend using
        !          3923:   <span><strong class="command">mkpatches</strong></span> from the same package to make a
        !          3924:   whole set of patches. You just have to backup files before you
        !          3925:   edit them to <code class="filename">filename.orig</code>, e.g. with
        !          3926:   <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by
        !          3927:   using <span><strong class="command">pkgvi</strong></span> again from the same package. If
        !          3928:   you upgrade a package this way, you can easily compare the new
        !          3929:   set of patches with the previously existing one with
        !          3930:   <span><strong class="command">patchdiff</strong></span>. Copy the patches you want to use
        !          3931:   or update from the <code class="filename">work/.newpatches</code>
        !          3932:   directory to <code class="filename">patches/</code>.</p>
        !          3933: <p>When you have finished a package, remember to generate
        !          3934:   the checksums for the patch files by using the <span><strong class="command">make
        !          3935:   makepatchsum</strong></span> command, see <a href="#components.distinfo" title="9.2. distinfo">Section 9.2, &#8220;<code class="filename">distinfo</code>&#8221;</a>.</p>
        !          3936: <p>When adding a patch that corrects a problem in the
        !          3937:   distfile (rather than e.g. enforcing pkgsrc's view of where
        !          3938:   man pages should go), send the patch as a bug report to the
        !          3939:   maintainer.  This benefits non-pkgsrc users of the package,
        !          3940:   and usually makes it possible to remove the patch in future
        !          3941:   version.</p>
        !          3942: <p>If you want to share patches between multiple packages
        !          3943:   in pkgsrc, e.g. because they use the same distfiles, set
        !          3944:   <code class="varname">PATCHDIR</code> to the path where the patch files
        !          3945:   can be found, e.g.:</p>
        !          3946: <pre class="programlisting">
        !          3947:     PATCHDIR= ${.CURDIR}/../xemacs/patches
        !          3948:   </pre>
1.75      rillig   3949: <p>Patch files that are distributed by the author or other
1.87    ! wiz      3950:     maintainers can be listed in
        !          3951:     <code class="varname">PATCHFILES</code>.</p>
        !          3952: <p>If it is desired to store any patches that should not be
        !          3953:     committed into pkgsrc, they can be kept outside the pkgsrc
        !          3954:     tree in the <code class="filename">$LOCALPATCHES</code> directory. The
        !          3955:     directory tree there is expected to have the same
        !          3956:     &#8220;<span class="quote">category/package</span>&#8221; structure as pkgsrc, and
        !          3957:     patches are expected to be stored inside these dirs (also
        !          3958:     known as <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
        !          3959:     example, if you want to keep a private patch for
        !          3960:     <code class="filename">pkgsrc/graphics/png</code>, keep it in
        !          3961:     <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
        !          3962:     files in the named directory are expected to be patch files,
        !          3963:     and <span class="emphasis"><em>they are applied after pkgsrc patches are
        !          3964:     applied</em></span>.</p>
1.85      jmmv     3965: <div class="sect2" lang="en">
                   3966: <div class="titlepage"><div><div><h3 class="title">
                   3967: <a name="components.patches.guidelines"></a>9.3.1. Patching guidelines</h3></div></div></div>
                   3968: <p>When fixing a portability issue in the code do not use
                   3969:       preprocessor magic to check for the current operating system nor
                   3970:       platform.  Doing so hurts portability to other platforms because
                   3971:       the OS-specific details are not abstracted appropriately.</p>
                   3972: <p>The general rule to follow is: instead of checking for the
                   3973:       operating system the application is being built on, check for the
                   3974:       specific <span class="emphasis"><em>features</em></span> you need.  For example,
                   3975:       instead of assuming that kqueue is available under NetBSD and
                   3976:       using the <code class="varname">__NetBSD__</code> macro to conditionalize
1.87    ! wiz      3977:       kqueue support, add a check that detects kqueue itself &#8212;
1.85      jmmv     3978:       yes, this generally involves patching the
                   3979:       <span><strong class="command">configure</strong></span> script.  There is absolutely nothing
                   3980:       that prevents some OSes from adopting interfaces from other OSes
                   3981:       (e.g. Linux implementing kqueue), something that the above checks
                   3982:       cannot take into account.</p>
                   3983: <p>Of course, checking for features generally involves more
                   3984:       work on the developer's side, but the resulting changes are
1.87    ! wiz      3985:       cleaner and there are chances they will work on many other
1.85      jmmv     3986:       platforms.  Not to mention that there are higher chances of being
                   3987:       later integrated into the mainstream sources.  Remember:
                   3988:       <span class="emphasis"><em>It doesn't work unless it is right!</em></span></p>
                   3989: <p>Some typical examples:</p>
                   3990: <div class="table">
                   3991: <a name="patch-examples"></a><p class="title"><b>Table 9.1. Patching examples</b></p>
                   3992: <div class="table-contents"><table summary="Patching examples" border="1">
                   3993: <colgroup>
                   3994: <col>
                   3995: <col>
                   3996: <col>
                   3997: </colgroup>
                   3998: <thead><tr>
                   3999: <th>Where</th>
                   4000: <th>Incorrect</th>
                   4001: <th>Correct</th>
                   4002: </tr></thead>
                   4003: <tbody>
                   4004: <tr>
                   4005: <td>configure script</td>
                   4006: <td>
                   4007:                <pre class="programlisting">case ${target_os} in
1.87    ! wiz      4008:                netbsd*) have_kvm=yes ;;
        !          4009:                *)       have_kvm=no  ;;
        !          4010:                esac</pre>
1.85      jmmv     4011:              </td>
                   4012: <td>
                   4013:                <pre class="programlisting">AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)</pre>
                   4014:              </td>
                   4015: </tr>
                   4016: <tr>
                   4017: <td>C source file</td>
                   4018: <td>
                   4019:                <pre class="programlisting">#if defined(__NetBSD__)
1.87    ! wiz      4020:                #  include &lt;sys/event.h&gt;
        !          4021:                #endif</pre>
1.85      jmmv     4022:              </td>
                   4023: <td>
                   4024:                <pre class="programlisting">#if defined(HAVE_SYS_EVENT_H)
1.87    ! wiz      4025:                #  include &lt;sys/event.h&gt;
        !          4026:                #endif</pre>
1.85      jmmv     4027:              </td>
                   4028: </tr>
                   4029: <tr>
                   4030: <td>C source file</td>
                   4031: <td>
                   4032: <pre class="programlisting">int
1.87    ! wiz      4033:              monitor_file(...)
        !          4034:              {
        !          4035:              #if defined(__NetBSD__)
        !          4036:              int fd = kqueue();
        !          4037:              ...
        !          4038:              #else
        !          4039:              ...
        !          4040:              #endif
        !          4041:              }</pre>
1.85      jmmv     4042:              </td>
                   4043: <td>
                   4044:                <pre class="programlisting">int
1.87    ! wiz      4045:                monitor_file(...)
        !          4046:                {
        !          4047:                #if defined(HAVE_KQUEUE)
        !          4048:                int fd = kqueue();
        !          4049:                ...
        !          4050:                #else
        !          4051:                ...
        !          4052:                #endif
        !          4053:                }</pre>
1.85      jmmv     4054:              </td>
                   4055: </tr>
                   4056: </tbody>
                   4057: </table></div>
                   4058: </div>
                   4059: <br class="table-break"><p>For more information, please read the <span class="emphasis"><em>Making
                   4060:       packager-friendly software</em></span> article (<a href="http://www.onlamp.com/pub/a/onlamp/2005/03/31/packaging.html" target="_top">part
                   4061:       1</a>, <a href="http://www.oreillynet.com/pub/a/onlamp/2005/04/28/packaging2.html" target="_top">part
                   4062:       2</a>).  It summarizes multiple details on how to make
                   4063:       software easier to package; all the suggestions in it were
                   4064:       collected from our experience in pkgsrc work, so they are possibly
                   4065:       helpful when creating patches too.</p>
                   4066: </div>
                   4067: <div class="sect2" lang="en">
                   4068: <div class="titlepage"><div><div><h3 class="title">
                   4069: <a name="components.patches.feedback"></a>9.3.2. Feedback to the author</h3></div></div></div>
                   4070: <p>Always, always, <span class="strong"><strong>always</strong></span>
                   4071:       feed back any <span class="emphasis"><em>portability fixes</em></span> or
                   4072:       improvements you do to a package to the mainstream developers.
                   4073:       This is the only way to get their attention on portability issues
                   4074:       and to ensure that future versions can be built out-of-the box on
                   4075:       NetBSD.  Furthermore, any user that gets newer distfiles will get
                   4076:       the fixes straight from the packaged code.</p>
                   4077: <p>This generally involves cleaning up the patches as described
                   4078:       in the following section (because sometimes the patches that are
                   4079:       added to pkgsrc are quick hacks), filling bug reports in the
                   4080:       appropriate trackers for the projects and working with the
                   4081:       mainstream authors to accept your changes.  It is
                   4082:       <span class="emphasis"><em>extremely important</em></span> that you do it so that
                   4083:       the packages in pkgsrc are kept simple and thus further changes
                   4084:       can be done without much hassle.</p>
                   4085: <p>Support the idea of free software!</p>
                   4086: </div>
1.75      rillig   4087: </div>
                   4088: <div class="sect1" lang="en">
                   4089: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4090: <a name="other-mandatory-files"></a>9.4. Other mandatory files</h2></div></div></div>
1.75      rillig   4091: <div class="variablelist"><dl>
1.76      rillig   4092: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75      rillig   4093: <dd><p>A multi-line description of the piece of software.  This should include
1.87    ! wiz      4094:          any credits where they are due.  Please bear in mind that others do not
        !          4095:          share your sense of humour (or spelling idiosyncrasies), and that others
        !          4096:          will read everything that you write here.</p></dd>
1.76      rillig   4097: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.87    ! wiz      4098: <dd><p>This file governs the files that are installed on your
        !          4099:          system: all the binaries, manual pages, etc. There are other
        !          4100:          directives which may be entered in this file, to control the
        !          4101:          creation and deletion of directories, and the location of
        !          4102:          inserted files.  See <a href="#plist" title="Chapter 11. PLIST issues">Chapter 11, <i>PLIST issues</i></a> for more
        !          4103:          information.</p></dd>
1.75      rillig   4104: </dl></div>
                   4105: </div>
                   4106: <div class="sect1" lang="en">
                   4107: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4108: <a name="components.optional"></a>9.5. Optional files</h2></div></div></div>
1.78      rillig   4109: <div class="sect2" lang="en">
                   4110: <div class="titlepage"><div><div><h3 class="title">
                   4111: <a name="components.optional.bin"></a>9.5.1. Files affecting the binary package</h3></div></div></div>
1.75      rillig   4112: <div class="variablelist"><dl>
1.76      rillig   4113: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75      rillig   4114: <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      4115:            First time after package extraction and before files are
        !          4116:            moved in place, the second time after the files to install
        !          4117:            are moved in place. This can be used to do any custom
        !          4118:            procedures not possible with @exec commands in
        !          4119:            <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
        !          4120:            <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="13.1. Files and directories outside the installation prefix">Section 13.1, &#8220;Files and directories outside the installation prefix&#8221;</a>.</p></dd>
1.76      rillig   4121: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75      rillig   4122: <dd><p>This script is executed before and after any files are removed.  It is
1.87    ! wiz      4123:            this script's responsibility to clean up any additional messy details
        !          4124:            around the package's installation, since all pkg_delete knows is how to
        !          4125:            delete the files created in the original distribution.
        !          4126:            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>
        !          4127:            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   4128: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75      rillig   4129: <dd>
                   4130: <p>This file is displayed after installation of the package.
1.87    ! wiz      4131:            Useful for things like legal notices on almost-free
        !          4132:            software and hints for updating config files after
        !          4133:            installing modules for apache, PHP etc.
        !          4134:            Please note that you can modify variables in it easily by using
        !          4135:            <code class="varname">MESSAGE_SUBST</code> in the package's
        !          4136:            <code class="filename">Makefile</code>:</p>
1.75      rillig   4137: <pre class="programlisting">
1.87    ! wiz      4138:              MESSAGE_SUBST+=  SOMEVAR="somevalue"
        !          4139:            </pre>
1.75      rillig   4140: <p>replaces "${SOMEVAR}" with &#8220;<span class="quote">somevalue</span>&#8221; in
1.87    ! wiz      4141:            <code class="filename">MESSAGE</code>.  By default, substitution is
        !          4142:            performed for <code class="varname">PKGNAME</code>,
        !          4143:            <code class="varname">PKGBASE</code>, <code class="varname">PREFIX</code>,
        !          4144:            <code class="varname">LOCALBASE</code>, <code class="varname">X11PREFIX</code>,
        !          4145:            <code class="varname">X11BASE</code>,
        !          4146:            <code class="varname">PKG_SYSCONFDIR</code>,
        !          4147:            <code class="varname">ROOT_GROUP</code>, and
        !          4148:            <code class="varname">ROOT_GROUP</code>.</p>
        !          4149: <p>You can display a different or additional files by
        !          4150:            setting the <code class="varname">MESSAGE_SRC</code> variable.  Its
        !          4151:            default is <code class="filename">MESSAGE</code>, if the file
        !          4152:            exists.</p>
1.75      rillig   4153: </dd>
1.78      rillig   4154: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
                   4155: <dd><p>FIXME: There is no documentation on the
                   4156:        alternatives framework.</p></dd>
                   4157: </dl></div>
                   4158: </div>
                   4159: <div class="sect2" lang="en">
                   4160: <div class="titlepage"><div><div><h3 class="title">
                   4161: <a name="components.optional.build"></a>9.5.2. Files affecting the build process</h3></div></div></div>
                   4162: <div class="variablelist"><dl>
                   4163: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
                   4164: <dd><p>This file contains arbitrary things that could
                   4165:        also go into a <code class="filename">Makefile</code>, but its purpose is
                   4166:        to be used by more than one package. This file should only be
                   4167:        used when the packages that will use the file are known in
                   4168:        advance. For other purposes it is often better to write a
                   4169:        <code class="filename">*.mk</code> file and give it a good name that
                   4170:        describes what it does.</p></dd>
                   4171: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
                   4172: <dd><p>This file contains the dependency information
                   4173:        for the buildlink3 framework (see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p></dd>
                   4174: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
                   4175: <dd><p>This file contains workarounds for compiler bugs
                   4176:        and similar things. It is included automatically by the pkgsrc
                   4177:        infrastructure, so you don't need an extra
                   4178:        <code class="literal">.include</code> line for
                   4179:        it.</p></dd>
                   4180: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
                   4181: <dd><p>This file contains the code for the
                   4182:        package-specific options (see <a href="#options" title="Chapter 14. Options handling">Chapter 14, <i>Options handling</i></a>) that can be
                   4183:        selected by the user. If a package has only one or two options,
                   4184:        it is equally acceptable to put the code directly into the
                   4185:        <code class="filename">Makefile</code>.</p></dd>
                   4186: </dl></div>
                   4187: </div>
                   4188: <div class="sect2" lang="en">
                   4189: <div class="titlepage"><div><div><h3 class="title">
                   4190: <a name="components.optional.none"></a>9.5.3. Files affecting nothing at all</h3></div></div></div>
                   4191: <div class="variablelist"><dl>
                   4192: <dt><span class="term"><code class="filename">README*</code></span></dt>
                   4193: <dd><p>These files do not take place in the creation of
                   4194:        a package and thus are purely informative to the package
                   4195:        developer.</p></dd>
                   4196: <dt><span class="term"><code class="filename">TODO</code></span></dt>
                   4197: <dd><p>This file contains things that need to be done
                   4198:        to make the package even
                   4199:        better.</p></dd>
1.75      rillig   4200: </dl></div>
                   4201: </div>
1.78      rillig   4202: </div>
1.75      rillig   4203: <div class="sect1" lang="en">
                   4204: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4205: <a name="work-dir"></a>9.6. <code class="filename">work*</code></h2></div></div></div>
1.75      rillig   4206: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
1.87    ! wiz      4207:     unpacked into the directory denoted by
        !          4208:     <code class="varname">WRKDIR</code>. It can be removed by running
        !          4209:     <span><strong class="command">make clean</strong></span>. Besides the sources, this
        !          4210:     directory is also used to keep various timestamp files.
        !          4211:     The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
        !          4212:     The default is <code class="filename">${.CURDIR}/work</code>
        !          4213:     or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
        !          4214:     if <code class="varname">OBJMACHINE</code> is set.</p>
1.75      rillig   4215: </div>
                   4216: <div class="sect1" lang="en">
                   4217: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4218: <a name="files-dir"></a>9.7. <code class="filename">files/*</code></h2></div></div></div>
1.75      rillig   4219: <p>If you have any files that you wish to be placed in the package prior
1.87    ! wiz      4220:     to configuration or building, you could place these files here and use
        !          4221:     a <span><strong class="command">${CP}</strong></span> command in the
        !          4222:     &#8220;<span class="quote">pre-configure</span>&#8221; target to achieve
        !          4223:     this. Alternatively, you could simply diff the file against
        !          4224:     <code class="filename">/dev/null</code> and use the patch mechanism to manage
        !          4225:     the creation of this file.</p>
        !          4226: <p>If you want to share files in this way with other
        !          4227:     packages, set the <code class="varname">FILESDIR</code> variable to point
        !          4228:     to the other package's <code class="filename">files</code> directory,
        !          4229:     e.g.:</p>
        !          4230: <pre class="programlisting">
        !          4231:       FILESDIR=${.CURDIR}/../xemacs/files
        !          4232:     </pre>
1.75      rillig   4233: </div>
                   4234: </div>
                   4235: <div class="chapter" lang="en">
                   4236: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   4237: <a name="makefile"></a>Chapter 10. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75      rillig   4238: <div class="toc">
                   4239: <p><b>Table of Contents</b></p>
                   4240: <dl>
1.77      rillig   4241: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
                   4242: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
                   4243: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
                   4244: <dd><dl>
                   4245: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
                   4246: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
                   4247: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
                   4248: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
                   4249: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
1.75      rillig   4250: </dl></dd>
                   4251: </dl>
                   4252: </div>
1.76      rillig   4253: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75      rillig   4254:   each of which forms a well-defined part of the pkgsrc system. Using
                   4255:   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
                   4256:   like pkgsrc requires some discipline to keep the code correct and
                   4257:   understandable.</p>
1.76      rillig   4258: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75      rillig   4259:   programming are variables (which are actually macros) and shell
                   4260:   commands. Among these shell commands may even be more complex ones
                   4261:   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
                   4262:   as intended it is necessary to quote all variables correctly when they
                   4263:   are used.</p>
                   4264: <p>This chapter describes some patterns, that appear quite often in
1.76      rillig   4265:   <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75      rillig   4266:   with them.</p>
                   4267: <div class="sect1" lang="en">
                   4268: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4269: <a name="makefile.variables"></a>10.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76      rillig   4270: <p><code class="filename">Makefile</code> variables contain strings that
1.75      rillig   4271:     can be processed using the five operators ``='', ``+='', ``?='',
                   4272:     ``:='', 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
                   4273:     page.</p>
                   4274: <p>When a variable's value is parsed from a
1.76      rillig   4275:     <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75      rillig   4276:     backslash character ``\'' are handled specially. If a backslash is
                   4277:     followed by a newline, any whitespace immediately in front of the
                   4278:     backslash, the backslash, the newline, and any whitespace
                   4279:     immediately behind the newline are replaced with a single space. A
                   4280:     backslash character and an immediately following hash character are
                   4281:     replaced with a single hash character. Otherwise, the backslash is
                   4282:     passed as is. In a variable assignment, any hash character that is
                   4283:     not preceded by a backslash starts a comment that continues upto the
                   4284:     end of the logical line.</p>
                   4285: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
                   4286:     the only way to create a variable consisting of a single backslash
                   4287:     is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
                   4288: <p>So far for defining variables. The other thing you can do with
                   4289:     variables is evaluating them. A variable is evaluated when it is
                   4290:     part of the right side of the ``:='' or the ``!='' operator, or
                   4291:     directly before executing a shell command which the variable is part
                   4292:     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
                   4293:     is, variables are not evaluated until there's no other way. The
                   4294:     ``modifiers'' mentioned in the man page also evaluate the
                   4295:     variable.</p>
                   4296: <p>Some of the modifiers split the string into words and then
                   4297:     operate on the words, others operate on the string as a whole. When
                   4298:     a string is split into words, it is split as you would expect
                   4299:     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.87    ! wiz      4300: <p>No rule without exception&#8212;the <span><strong class="command">.for</strong></span>
1.75      rillig   4301:     loop does not follow the shell quoting rules but splits at sequences
                   4302:     of whitespace.</p>
                   4303: <p>There are several types of variables that should be handled
                   4304:     differently. Strings and two types of lists.</p>
                   4305: <div class="itemizedlist"><ul type="disc">
                   4306: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
                   4307:       characters. Nevertheless, you should restrict yourself to only
                   4308:       using printable characters. Examples are
                   4309:       <code class="varname">PREFIX</code> and
                   4310:       <code class="varname">COMMENT</code>.</p></li>
                   4311: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
                   4312:       are never exported to any shell command. Their elements are
                   4313:       separated by whitespace. Therefore, the elements themselves cannot
                   4314:       have embedded whitespace. Any other characters are allowed.
                   4315:       Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
                   4316:       Examples are <code class="varname">DEPENDS</code> and
                   4317:       <code class="varname">BUILD_DEPENDS</code>.</p></li>
                   4318: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
                   4319:       may be exported to a shell command. Their elements can contain any
                   4320:       characters, including whitespace. That's why they cannot be used
                   4321:       in <span><strong class="command">.for</strong></span> loops. Examples are
                   4322:       <code class="varname">DISTFILES</code> and
                   4323:       <code class="varname">MASTER_SITES</code>.</p></li>
                   4324: </ul></div>
                   4325: <div class="sect2" lang="en">
                   4326: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4327: <a name="makefile.variables.names"></a>10.1.1. Naming conventions</h3></div></div></div>
1.75      rillig   4328: <div class="itemizedlist"><ul type="disc">
                   4329: <li><p>All variable names starting with an underscore
                   4330:        are reserved for use by the pkgsrc infrastructure. They shall
                   4331:        not be used by package
1.76      rillig   4332:        <code class="filename">Makefile</code>s.</p></li>
1.75      rillig   4333: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
                   4334:        lowercase variable names for the iteration
                   4335:        variables.</p></li>
                   4336: <li><p>All list variables should have a ``plural''
                   4337:        name, e.g. <code class="varname">PKG_OPTIONS</code> or
                   4338:        <code class="varname">DISTFILES</code>.</p></li>
                   4339: </ul></div>
                   4340: </div>
                   4341: </div>
                   4342: <div class="sect1" lang="en">
                   4343: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4344: <a name="makefile.code"></a>10.2. Code snippets</h2></div></div></div>
1.75      rillig   4345: <p>This section presents you with some code snippets you should
                   4346:     use in your own code. If you don't find anything appropriate here,
                   4347:     you should test your code and add it here.</p>
                   4348: <div class="sect2" lang="en">
                   4349: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4350: <a name="adding-to-list"></a>10.2.1. Adding things to a list</h3></div></div></div>
1.75      rillig   4351: <pre class="programlisting">
                   4352:     STRING=                 foo * bar `date`
                   4353:     INT_LIST=               # empty
                   4354:     ANOTHER_INT_LIST=       apache-[0-9]*:../../www/apache
                   4355:     EXT_LIST=               # empty
                   4356:     ANOTHER_EXT_LIST=       a=b c=d
1.1       grant    4357: 
1.75      rillig   4358:     INT_LIST+=              ${STRING}               # 1
                   4359:     INT_LIST+=              ${ANOTHER_INT_LIST}     # 2
                   4360:     EXT_LIST+=              ${STRING:Q}             # 3
                   4361:     EXT_LIST+=              ${ANOTHER_EXT_LIST}     # 4
1.1       grant    4362: </pre>
1.75      rillig   4363: <p>When you add a string to an external list (example 3), it
                   4364:       must be quoted. In all other cases, you must not add a quoting
                   4365:       level. You must not merge internal and external lists, unless you
                   4366:       are sure that all entries are correctly interpreted in both
                   4367:       lists.</p>
                   4368: </div>
                   4369: <div class="sect2" lang="en">
                   4370: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4371: <a name="converting-internal-to-external"></a>10.2.2. Converting an internal list into an external list</h3></div></div></div>
1.75      rillig   4372: <pre class="programlisting">
                   4373:     EXT_LIST=       # empty
                   4374:     .for i in ${INT_LIST}
                   4375:     EXT_LIST+=      ${i:Q}""
                   4376:     .endfor
1.1       grant    4377: </pre>
1.75      rillig   4378: <p>This code converts the internal list
                   4379:       <code class="varname">INT_LIST</code> into the external list
                   4380:       <code class="varname">EXT_LIST</code>. As the elements of an internal list
                   4381:       are unquoted they must be quoted here. The reason for appending
                   4382:       <code class="varname">""</code> is explained below.</p>
                   4383: </div>
                   4384: <div class="sect2" lang="en">
                   4385: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4386: <a name="passing-variable-to-shell"></a>10.2.3. Passing variables to a shell command</h3></div></div></div>
1.79      rillig   4387: <p>Sometimes you may want to print an arbitrary string. There
                   4388:        are many ways to get it wrong and only few that can handle every
                   4389:        nastiness.</p>
1.75      rillig   4390: <pre class="programlisting">
                   4391:     STRING=         foo bar &lt;    &gt; * `date` $$HOME ' "
                   4392:     EXT_LIST=       string=${STRING:Q} x=second\ item
1.1       grant    4393: 
1.75      rillig   4394:     all:
                   4395:             echo ${STRING}                  # 1
                   4396:             echo "${STRING}"                # 2
                   4397:             echo "${STRING:Q}"              # 3
                   4398:             echo ${STRING:Q}                # 4
                   4399:             echo x${STRING:Q} | sed 1s,.,,  # 5
1.79      rillig   4400:             printf "%s\\n" ${STRING:Q}""    # 6
1.75      rillig   4401:             env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1       grant    4402: </pre>
1.75      rillig   4403: <p>Example 1 leads to a syntax error in the shell, as the
                   4404:       characters are just copied.</p>
                   4405: <p>Example 2 leads to a syntax error too, and if you leave out
                   4406:       the last " character from <code class="varname">${STRING}</code>,
                   4407:       <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
                   4408:       variable would be evaluated, too.</p>
                   4409: <p>Example 3 outputs each space character preceded by a
                   4410:       backslash (or not), depending on the implementation of the
                   4411:       <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>
                   4412: <p>Example 4 handles correctly every string that does not start
                   4413:       with a dash. In that case, the result depends on the
                   4414:       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
                   4415:       guarantee that your input does not start with a dash, this form is
                   4416:       appropriate.</p>
                   4417: <p>Example 5 handles even the case of a leading dash
                   4418:       correctly.</p>
1.79      rillig   4419: <p>Example 6 also works with every string and is the
                   4420:       light-weight solution, since it does not involve a pipe, which has
                   4421:       its own problems.</p>
1.75      rillig   4422: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
                   4423:       because the quoting has already been done when adding elements to
                   4424:       the list.</p>
                   4425: <p>As internal lists shall not be passed to the shell, there is
                   4426:       no example for it.</p>
                   4427: </div>
                   4428: <div class="sect2" lang="en">
                   4429: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4430: <a name="quoting-guideline"></a>10.2.4. Quoting guideline</h3></div></div></div>
1.75      rillig   4431: <p>There are many possible sources of wrongly quoted variables.
                   4432:       This section lists some of the commonly known ones.</p>
                   4433: <div class="itemizedlist"><ul type="disc">
                   4434: <li>
                   4435: <p>Whenever you use the value of a list, think
                   4436:        about what happens to leading or trailing whitespace. If the
                   4437:        list is a well-formed shell expression, you can apply the
                   4438:        <code class="varname">:M*</code> modifier to strip leading and trailing
                   4439:        whitespace from each word. The <code class="varname">:M</code> operator
                   4440:        first splits its argument according to the rules of the shell,
                   4441:        and then creates a new list consisting of all words that match
                   4442:        the shell glob expression <code class="varname">*</code>, that is: all.
                   4443:        One class of situations where this is needed is when adding a
                   4444:        variable like <code class="varname">CPPFLAGS</code> to
                   4445:        <code class="varname">CONFIGURE_ARGS</code>. If the configure script
                   4446:        invokes other configure scripts, it strips the leading and
                   4447:        trailing whitespace from the variable and then passes it to the
                   4448:        other configure scripts. But these configure scripts expect the
                   4449:        (child) <code class="varname">CPPFLAGS</code> variable to be the same as
                   4450:        the parent <code class="varname">CPPFLAGS</code>. That's why we better
                   4451:        pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
                   4452:        here is how we do it:</p>
                   4453: <pre class="programlisting">
                   4454:     CPPFLAGS=               # empty
                   4455:     CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX:Q}\"
                   4456:     CPPFLAGS+=              ${MY_CPPFLAGS}
1.1       grant    4457: 
1.75      rillig   4458:     CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
1.1       grant    4459: 
1.75      rillig   4460:     all:
                   4461:             echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   4462:             echo x${CONFIGURE_ARGS}x        # properly trimmed
1.1       grant    4463: </pre>
1.75      rillig   4464: </li>
                   4465: <li><p>The example above contains one bug: The
                   4466:        <code class="varname">${PREFIX}</code> is a properly quoted shell
                   4467:        expression, but there is the C compiler after it, which also
                   4468:        expects a properly quoted string (this time in C syntax). The
                   4469:        version above is therefore only correct if
                   4470:        <code class="varname">${PREFIX}</code> does not have embedded backslashes
                   4471:        or double quotes. If you want to allow these, you have to add
                   4472:        another layer of quoting to each variable that is used as a C
                   4473:        string literal. You cannot use the <code class="varname">:Q</code>
                   4474:        operator for it, as this operator only works for the
                   4475:        shell.</p></li>
                   4476: <li>
                   4477: <p>Whenever a variable can be empty, the
                   4478:        <code class="varname">:Q</code> operator can have surprising results. Here
                   4479:        are two completely different cases which can be solved with the
                   4480:        same trick.</p>
                   4481: <pre class="programlisting">
                   4482:     EMPTY=                  # empty
                   4483:     empty_test:
                   4484:             for i in a ${EMPTY:Q} c; do \
                   4485:                     echo "$$i"; \
                   4486:             done
1.1       grant    4487: 
1.75      rillig   4488:     for_test:
                   4489:     .for i in a:\ a:\test.txt
                   4490:             echo ${i:Q}
                   4491:             echo "foo"
                   4492:     .endfor
1.1       grant    4493: </pre>
1.75      rillig   4494: <p>The first example will only print two of the three lines
                   4495:        we might have expected. This is because
                   4496:        <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
                   4497:        the shell cannot see. The workaround is to write
                   4498:        <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
                   4499:        as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
                   4500:        -f ${FNAME:Q}</code> (both of these are wrong).</p>
                   4501: <p>The second example will only print three lines instead of
                   4502:        four. The first line looks like <code class="varname">a:\ echo foo</code>.
                   4503:        This is because the backslash of the value
                   4504:        <code class="varname">a:\</code> is interpreted as a line-continuation by
                   4505:        <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
                   4506:        <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
                   4507:        <code class="varname">${i:Q}""</code>.</p>
                   4508: </li>
                   4509: </ul></div>
                   4510: </div>
                   4511: <div class="sect2" lang="en">
                   4512: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4513: <a name="bsd-make-bug-workaround"></a>10.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75      rillig   4514: <p>The pkgsrc bmake program does not handle the following
                   4515:       assignment correctly. In case <code class="varname">_othervar_</code>
                   4516:       contains a ``-'' character, one of the closing braces is included
                   4517:       in <code class="varname">${VAR}</code> after this code executes.</p>
                   4518: <pre class="programlisting">
                   4519:     VAR:=   ${VAR:N${_othervar_:C/-//}}
1.1       grant    4520: </pre>
1.75      rillig   4521: <p>For a more complex code snippet and a workaround, see the
1.76      rillig   4522:       package <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/regress/make-quoting/README.html" target="_top"><code class="filename">regress/make-quoting</code></a>, testcase
1.75      rillig   4523:       <code class="varname">bug1</code>.</p>
                   4524: </div>
                   4525: </div>
                   4526: </div>
                   4527: <div class="chapter" lang="en">
                   4528: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   4529: <a name="plist"></a>Chapter 11. PLIST issues</h2></div></div></div>
1.75      rillig   4530: <div class="toc">
                   4531: <p><b>Table of Contents</b></p>
                   4532: <dl>
1.77      rillig   4533: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
                   4534: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
                   4535: <dt><span class="sect1"><a href="#print-PLIST">11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
                   4536: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
                   4537: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
                   4538: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
                   4539: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
                   4540: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
1.75      rillig   4541: </dl>
                   4542: </div>
1.87    ! wiz      4543: <p>The <code class="filename">PLIST</code> file contains a package's
        !          4544:   &#8220;<span class="quote">packing list</span>&#8221;, i.e. a list of files that belong to
        !          4545:   the package (relative to the <code class="filename">${PREFIX}</code>
        !          4546:   directory it's been installed in) plus some additional statements
        !          4547:   - 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.
        !          4548:   This chapter addresses some issues that need attention when
        !          4549:   dealing with the <code class="filename">PLIST</code> file (or files, see
        !          4550:   below!).</p>
1.75      rillig   4551: <div class="sect1" lang="en">
                   4552: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4553: <a name="rcs-id"></a>11.1. RCS ID</h2></div></div></div>
1.87    ! wiz      4554: <p>Be sure to add a RCS ID line as the first thing in any
        !          4555:     <code class="filename">PLIST</code> file you write:</p>
1.75      rillig   4556: <pre class="programlisting">
1.87    ! wiz      4557:       @comment $NetBSD$
        !          4558:     </pre>
1.75      rillig   4559: </div>
                   4560: <div class="sect1" lang="en">
                   4561: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4562: <a name="automatic-plist-generation"></a>11.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75      rillig   4563: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
1.87    ! wiz      4564:     to output a PLIST that matches any new files since the package
        !          4565:     was extracted.  See <a href="#build.helpful-targets" title="15.16. Other helpful targets">Section 15.16, &#8220;Other helpful targets&#8221;</a> for
        !          4566:     more information on this target.</p>
1.75      rillig   4567: </div>
                   4568: <div class="sect1" lang="en">
                   4569: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4570: <a name="print-PLIST"></a>11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></h2></div></div></div>
1.87    ! wiz      4571: <p>If you have used any of the *-dirs packages, as explained in
        !          4572:     <a href="#faq.common-dirs" title="11.8. Sharing directories between packages">Section 11.8, &#8220;Sharing directories between packages&#8221;</a>, you may have noticed that
        !          4573:     <span><strong class="command">make print-PLIST</strong></span> outputs a set of
        !          4574:     <code class="varname">@comment</code>s instead of real
        !          4575:     <code class="varname">@dirrm</code> lines.  You can also do this for
        !          4576:     specific directories and files, so that the results of that
        !          4577:     command are very close to reality. This helps <span class="emphasis"><em>a
        !          4578:     lot</em></span> during the update of packages.</p>
        !          4579: <p>The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
        !          4580:     of AWK patterns and actions that are used to filter the output of
        !          4581:     print-PLIST.  You can <span class="emphasis"><em>append</em></span> any chunk of AWK
        !          4582:     scripting you like to it, but be careful with quoting.</p>
        !          4583: <p>For example, to get all files inside the
        !          4584:     <code class="filename">libdata/foo</code> directory removed from the
        !          4585:     resulting PLIST:</p>
        !          4586: <pre class="programlisting">
        !          4587:       PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
        !          4588:     </pre>
        !          4589: <p>And to get all the <code class="varname">@dirrm</code> lines referring
        !          4590:     to a specific (shared) directory converted to
        !          4591:     <code class="varname">@comment</code>s:</p>
1.75      rillig   4592: <pre class="programlisting">
1.87    ! wiz      4593:       PRINT_PLIST_AWK+=       /^@dirrm share\/specific/ { print "@comment " $$0; next; }
        !          4594:     </pre>
1.75      rillig   4595: </div>
                   4596: <div class="sect1" lang="en">
                   4597: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4598: <a name="plist.misc"></a>11.4. Variable substitution in PLIST</h2></div></div></div>
1.87    ! wiz      4599: <p>A number of variables are substituted automatically in
        !          4600:     PLISTs when a package is installed on a system. This includes the
        !          4601:     following variables:</p>
1.75      rillig   4602: <div class="variablelist"><dl>
                   4603: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
                   4604: <dd>
                   4605: <p>Some packages like emacs and perl embed information
1.87    ! wiz      4606:          about which architecture they were built on into the
        !          4607:          pathnames where they install their files. To handle this
        !          4608:          case, PLIST will be preprocessed before actually used, and
        !          4609:          the symbol
        !          4610:          &#8220;<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>&#8221; will be
        !          4611:          replaced by what <span><strong class="command">uname -p</strong></span> gives. The
        !          4612:          same is done if the string
        !          4613:          <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
        !          4614:          PLIST somewhere - use this on packages that have GNU
        !          4615:          autoconf-created configure scripts.</p>
1.75      rillig   4616: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   4617: <h3 class="title">Legacy note</h3>
                   4618: <p>There used to be a symbol
1.87    ! wiz      4619:            &#8220;<span class="quote"><code class="varname">$ARCH</code></span>&#8221; that
        !          4620:            was replaced by the output of <span><strong class="command">uname
        !          4621:            -m</strong></span>, but that's no longer supported and has
        !          4622:            been removed.</p>
1.75      rillig   4623: </div>
                   4624: </dd>
                   4625: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
                   4626: <dd>
                   4627: <p>Some packages want to embed the OS name and version
1.87    ! wiz      4628:          into some paths.  To do this, use these variables in the
        !          4629:          <code class="filename">PLIST</code>:
        !          4630:          </p>
1.75      rillig   4631: <div class="itemizedlist"><ul type="disc">
                   4632: <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>
                   4633: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. &#8220;<span class="quote">solaris</span>&#8221;)</p></li>
                   4634: <li><p><code class="varname">${OS_VERSION}</code> - &#8220;<span class="quote"><span><strong class="command">uname -r</strong></span></span>&#8221;</p></li>
                   4635: </ul></div>
                   4636: </dd>
                   4637: </dl></div>
1.87    ! wiz      4638: <p>For a complete list of values which are replaced by
        !          4639:     default, please look in <code class="filename">bsd.pkg.mk</code> (and
        !          4640:     search for <code class="varname">PLIST_SUBST</code>).</p>
        !          4641: <p>If you want to change other variables not listed above, you
        !          4642:     can add variables and their expansions to this variable in the
        !          4643:     following way, similar to <code class="varname">MESSAGE_SUBST</code> (see <a href="#components.optional" title="9.5. Optional files">Section 9.5, &#8220;Optional files&#8221;</a>):</p>
1.75      rillig   4644: <pre class="programlisting">
1.87    ! wiz      4645:       PLIST_SUBST+=   SOMEVAR="somevalue"
        !          4646:     </pre>
1.75      rillig   4647: <p>This replaces all occurrences of &#8220;<span class="quote">${SOMEVAR}</span>&#8221;
1.87    ! wiz      4648:     in the <code class="filename">PLIST</code> with
        !          4649:     &#8220;<span class="quote">somevalue</span>&#8221;.</p>
1.75      rillig   4650: </div>
                   4651: <div class="sect1" lang="en">
                   4652: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4653: <a name="manpage-compression"></a>11.5. Man page compression</h2></div></div></div>
1.75      rillig   4654: <p>Man pages should be installed in compressed form if
1.87    ! wiz      4655:     <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
        !          4656:     and uncompressed otherwise. To handle this in the
        !          4657:     <code class="filename">PLIST</code> file, the suffix &#8220;<span class="quote">.gz</span>&#8221; is
        !          4658:     appended/removed automatically for man pages according to
        !          4659:     <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
        !          4660:     or not, see above for details. This modification of the
        !          4661:     <code class="filename">PLIST</code> file is done on a copy of it, not
        !          4662:     <code class="filename">PLIST</code> itself.</p>
1.75      rillig   4663: </div>
                   4664: <div class="sect1" lang="en">
                   4665: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4666: <a name="using-PLIST_SRC"></a>11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></h2></div></div></div>
1.76      rillig   4667: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.87    ! wiz      4668:     in generating the binary package, set the variable
        !          4669:     <code class="varname">PLIST_SRC</code> to the names of that file(s).
        !          4670:     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
        !          4671:     important. The default for <code class="varname">PLIST_SRC</code> is
        !          4672:     <code class="filename">${PKGDIR}/PLIST</code>.</p>
1.75      rillig   4673: </div>
                   4674: <div class="sect1" lang="en">
                   4675: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4676: <a name="platform-specific-plist"></a>11.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75      rillig   4677: <p>Some packages decide to install a different set of files based on
1.87    ! wiz      4678:     the operating system being used. These differences can be
        !          4679:     automatically handled by using the following files:</p>
1.75      rillig   4680: <div class="itemizedlist"><ul type="disc">
1.76      rillig   4681: <li><p><code class="filename">PLIST.common</code></p></li>
                   4682: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
                   4683: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
                   4684: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
                   4685: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75      rillig   4686: </ul></div>
                   4687: </div>
                   4688: <div class="sect1" lang="en">
                   4689: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4690: <a name="faq.common-dirs"></a>11.8. Sharing directories between packages</h2></div></div></div>
1.87    ! wiz      4691: <p>A &#8220;<span class="quote">shared directory</span>&#8221; is a directory where
        !          4692:     multiple (and unrelated) packages install files.  These
        !          4693:     directories are problematic because you have to add special tricks
        !          4694:     in the PLIST to conditionally remove them, or have some
        !          4695:     centralized package handle them.</p>
        !          4696: <p>Within pkgsrc, you'll find both approaches.  If a directory
        !          4697:     is shared by a few unrelated packages, it's often not worth to add
        !          4698:     an extra package to remove it.  Therefore, one simply does:</p>
        !          4699: <pre class="programlisting">
        !          4700:       @unexec ${RMDIR} %D/path/to/shared/directory 2&gt;/dev/null || ${TRUE}
        !          4701:     </pre>
        !          4702: <p>in the PLISTs of all affected packages, instead of the
        !          4703:     regular "@dirrm" line.</p>
        !          4704: <p>However, if the directory is shared across many packages, two
        !          4705:     different solutions are available:</p>
1.75      rillig   4706: <div class="orderedlist"><ol type="1">
1.87    ! wiz      4707: <li><p>If the packages have a common dependency, the directory
        !          4708:        can be removed in that.  For example, see
        !          4709:        <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/textproc/scrollkeeper/README.html" target="_top"><code class="filename">textproc/scrollkeeper</code></a>, which
        !          4710:        removes the shared directory
        !          4711:        <code class="filename">share/omf</code>.</p></li>
        !          4712: <li><p>If the packages using the directory are not related at
        !          4713:        all (they have no common dependencies), a *-dirs package is
        !          4714:        used.</p></li>
1.75      rillig   4715: </ol></div>
1.87    ! wiz      4716: <p>From now on, we'll discuss the second solution.  To get an
        !          4717:     idea of the *-dirs packages available, issue:</p>
1.75      rillig   4718: <pre class="programlisting">
1.87    ! wiz      4719:       <code class="prompt">%</code> cd .../pkgsrc
        !          4720:       <code class="prompt">%</code> ls -d */*-dirs
        !          4721:     </pre>
        !          4722: <p>Their use from other packages is very simple.  The
        !          4723:     <code class="varname">USE_DIRS</code> variable takes a list of package names
        !          4724:     (without the &#8220;<span class="quote">-dirs</span>&#8221; part) together with the required
        !          4725:     version number (always pick the latest one when writing new
        !          4726:     packages).</p>
        !          4727: <p>For example, if a package installs files under
        !          4728:     <code class="filename">share/applications</code>, it should have the
        !          4729:     following line in it:</p>
        !          4730: <pre class="programlisting">
        !          4731:       USE_DIRS+=      xdg-1.1
        !          4732:     </pre>
        !          4733: <p>After regenerating the PLIST using <span><strong class="command">make
        !          4734:     print-PLIST</strong></span>, you should get the right (commented out)
        !          4735:     lines.</p>
        !          4736: <p>Note that even if your package is using
        !          4737:     <code class="filename">$X11BASE</code>, it must not depend on the
        !          4738:     *-x11-dirs packages.  Just specify the name without that part and
        !          4739:     pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
        !          4740:     care of it.</p>
1.75      rillig   4741: </div>
                   4742: </div>
                   4743: <div class="chapter" lang="en">
                   4744: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   4745: <a name="buildlink"></a>Chapter 12. Buildlink methodology</h2></div></div></div>
1.75      rillig   4746: <div class="toc">
                   4747: <p><b>Table of Contents</b></p>
                   4748: <dl>
1.77      rillig   4749: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
                   4750: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75      rillig   4751: <dd><dl>
1.77      rillig   4752: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
                   4753: <dt><span class="sect2"><a href="#updating-buildlink-depends">12.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   4754: </dl></dd>
1.77      rillig   4755: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
1.75      rillig   4756: <dd><dl>
1.77      rillig   4757: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">12.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
                   4758: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
1.75      rillig   4759: </dl></dd>
                   4760: </dl>
                   4761: </div>
                   4762: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
1.87    ! wiz      4763:   are seen by a package's configure and build processes.  This is implemented
        !          4764:   in a two step process:</p>
1.75      rillig   4765: <div class="orderedlist"><ol type="1">
                   4766: <li><p>Symlink headers and libraries for dependencies into
1.87    ! wiz      4767:       <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
        !          4768:       of <code class="varname">WRKDIR</code>.</p></li>
1.75      rillig   4769: <li><p>Create wrapper scripts that are used in place of the normal compiler
1.87    ! wiz      4770:       tools that translate <code class="option">-I${LOCALBASE}/include</code> and
        !          4771:       <code class="option">-L${LOCALBASE}/lib</code> into references to
        !          4772:       <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
        !          4773:       native compiler on some operating systems look like GCC, so that
        !          4774:       packages that expect GCC won't require modifications to build with
        !          4775:       those native compilers.</p></li>
1.75      rillig   4776: </ol></div>
                   4777: <p>This normalizes the environment in which a package is built so that the
1.87    ! wiz      4778:   package may be built consistently despite what other software may be
        !          4779:   installed. Please note that the normal system header and library paths,
        !          4780:   e.g. <code class="filename">/usr/include</code>,
        !          4781:   <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
        !          4782:   designed to insulate the package build from non-system-supplied
        !          4783:   software.</p>
1.75      rillig   4784: <div class="sect1" lang="en">
                   4785: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4786: <a name="converting-to-buildlink3"></a>12.1. Converting packages to use buildlink3</h2></div></div></div>
1.75      rillig   4787: <p>The process of converting packages to use the buildlink3
1.87    ! wiz      4788:     framework (&#8220;<span class="quote">bl3ifying</span>&#8221;) is fairly straightforward.
        !          4789:     The things to keep in mind are:</p>
1.75      rillig   4790: <div class="orderedlist"><ol type="1">
1.87    ! wiz      4791: <li><p>Ensure that the build always calls the wrapper scripts
        !          4792:        instead of the actual toolchain.  Some packages are tricky,
        !          4793:        and the only way to know for sure is the check
        !          4794:        <code class="filename">${WRKDIR}/.work.log</code> to see if the
        !          4795:        wrappers are being invoked.</p></li>
        !          4796: <li><p>Don't override <code class="varname">PREFIX</code> from within
        !          4797:        the package Makefile, e.g. Java VMs, standalone shells,
        !          4798:        etc., because the code to symlink files into
        !          4799:        <code class="filename">${BUILDLINK_DIR}</code> looks for files
        !          4800:        relative to &#8220;<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>&#8221;.
        !          4801:        </p></li>
        !          4802: <li><p>Remember that <span class="emphasis"><em>only</em></span> the
        !          4803:        <code class="filename">buildlink3.mk</code> files that you list in a
        !          4804:        package's Makefile are added as dependencies for that package.
        !          4805:        </p></li>
1.75      rillig   4806: </ol></div>
1.87    ! wiz      4807: <p>If a dependency on a particular package is required for its libraries and
        !          4808:     headers, then we replace:</p>
1.75      rillig   4809: <pre class="programlisting">
1.87    ! wiz      4810:       DEPENDS+=   foo&gt;=1.1.0:../../category/foo
        !          4811:     </pre>
1.75      rillig   4812: <p>with</p>
                   4813: <pre class="programlisting">
1.87    ! wiz      4814:       .include "../../category/foo/buildlink3.mk"
        !          4815:     </pre>
1.75      rillig   4816: <p>The buildlink3.mk files usually define the required dependencies.
                   4817:     If you need a newer version of the dependency when using buildlink3.mk
1.87    ! wiz      4818:     files, then you can define it in your Makefile; for example:</p>
1.75      rillig   4819: <pre class="programlisting">
1.87    ! wiz      4820:       BUILDLINK_API_DEPENDS.foo+=   foo&gt;=1.1.0
        !          4821:       .include "../../category/foo/buildlink3.mk"
        !          4822:     </pre>
1.76      rillig   4823: <p>There are several <code class="filename">buildlink3.mk</code>
1.87    ! wiz      4824:     files in <code class="filename">pkgsrc/mk</code>
        !          4825:     that handle special package issues:</p>
1.75      rillig   4826: <div class="itemizedlist"><ul type="disc">
1.76      rillig   4827: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.87    ! wiz      4828:        the native or a pkgsrc Berkeley DB implementation based on
        !          4829:        the values of <code class="varname">BDB_ACCEPTED</code> and
        !          4830:        <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76      rillig   4831: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.87    ! wiz      4832:        comes with neither Curses nor NCurses, this will take care
        !          4833:        to install the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/ncurses/README.html" target="_top"><code class="filename">devel/ncurses</code></a> package.</p></li>
1.76      rillig   4834: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.87    ! wiz      4835:        of <code class="varname">KRB5_ACCEPTED</code> to choose between
        !          4836:        adding a dependency on Heimdal or MIT-krb5 for packages that
        !          4837:        require a Kerberos 5 implementation.</p></li>
1.76      rillig   4838: <li><p><code class="filename">motif.buildlink3.mk</code> checks
1.87    ! wiz      4839:        for a system-provided
        !          4840:        Motif installation or adds a dependency on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/lesstif/README.html" target="_top"><code class="filename">x11/lesstif</code></a> or
        !          4841:        <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/openmotif/README.html" target="_top"><code class="filename">x11/openmotif</code></a>.</p></li>
1.76      rillig   4842: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.87    ! wiz      4843:        variables that may be used by packages that use the
        !          4844:        Open Sound System (OSS) API.</p></li>
1.76      rillig   4845: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.87    ! wiz      4846:        either Postgres 7.3 or 7.4, whichever is found installed. See
        !          4847:        the file for more information.</p></li>
1.76      rillig   4848: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.87    ! wiz      4849:        <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
        !          4850:        a dependency on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/pth/README.html" target="_top"><code class="filename">devel/pth</code></a> as needed.</p></li>
1.76      rillig   4851: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.87    ! wiz      4852:        <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
        !          4853:        library.</p></li>
1.75      rillig   4854: </ul></div>
1.76      rillig   4855: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.87    ! wiz      4856:     files provide a more complete
        !          4857:     description of how to use them properly.</p>
1.75      rillig   4858: </div>
                   4859: <div class="sect1" lang="en">
                   4860: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4861: <a name="creating-buildlink3.mk"></a>12.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.87    ! wiz      4862: <p>A package's <code class="filename">buildlink3.mk</code> file is
        !          4863:     included by Makefiles to indicate the need to compile and link
        !          4864:     against header files and libraries provided by the package.  A
        !          4865:     <code class="filename">buildlink3.mk</code> file should always provide
        !          4866:     enough information to add the correct type of dependency
        !          4867:     relationship and include any other
        !          4868:     <code class="filename">buildlink3.mk</code> files that it needs to find
        !          4869:     headers and libraries that it needs in turn.</p>
        !          4870: <p>To generate an initial <code class="filename">buildlink3.mk</code>
        !          4871:     file for further editing, Rene Hexel's <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/createbuildlink/README.html" target="_top"><code class="filename">pkgtools/createbuildlink</code></a>
        !          4872:     package is highly recommended.  For most packages, the following
        !          4873:     command will generate a good starting point for
        !          4874:     <code class="filename">buildlink3.mk</code> files:</p>
        !          4875: <pre class="screen">
        !          4876: <code class="prompt">%</code> <strong class="userinput"><code>cd pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>pkgdir</code></em>
        !          4877: <code class="prompt">%</code> createbuildlink &gt;buildlink3.mk</code></strong>
        !          4878:     </pre>
1.75      rillig   4879: <div class="sect2" lang="en">
                   4880: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4881: <a name="anatomy-of-bl3"></a>12.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75      rillig   4882: <p>The following real-life example
1.87    ! wiz      4883:       <code class="filename">buildlink3.mk</code> is taken
        !          4884:       from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75      rillig   4885: <pre class="programlisting">
1.87    ! wiz      4886:        # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1       grant    4887: 
1.87    ! wiz      4888:        BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH}+
        !          4889:        TIFF_BUILDLINK3_MK:=    ${TIFF_BUILDLINK3_MK}+
1.1       grant    4890: 
1.87    ! wiz      4891:        .if !empty(BUILDLINK_DEPTH:M+)
        !          4892:        BUILDLINK_DEPENDS+=     tiff
        !          4893:        .endif
        !          4894: 
        !          4895:        BUILDLINK_PACKAGES:=    ${BUILDLINK_PACKAGES:Ntiff}
        !          4896:        BUILDLINK_PACKAGES+=    tiff
        !          4897: 
        !          4898:        .if !empty(TIFF_BUILDLINK3_MK:M+)
        !          4899:        BUILDLINK_API_DEPENDS.tiff+=        tiff&gt;=3.6.1
        !          4900:        BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
        !          4901:        .endif  # TIFF_BUILDLINK3_MK
        !          4902: 
        !          4903:        .include "../../devel/zlib/buildlink3.mk"
        !          4904:        .include "../../graphics/jpeg/buildlink3.mk"
        !          4905: 
        !          4906:        BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH:S/+$//}
        !          4907:       </pre>
        !          4908: <p>The header and footer manipulate
        !          4909:       <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
        !          4910:       <code class="filename">buildlink3.mk</code> files and is used to track
        !          4911:       at what depth we are including
        !          4912:       <code class="filename">buildlink3.mk</code> files.</p>
        !          4913: <p>The first section controls if the dependency on
        !          4914:       <em class="replaceable"><code>pkg</code></em> is added.
        !          4915:       <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
        !          4916:       packages for which dependencies are added by
        !          4917:       buildlink3.</p>
        !          4918: <p>The second section advises pkgsrc that the
        !          4919:       <code class="filename">buildlink3.mk</code> file for
        !          4920:       <em class="replaceable"><code>pkg</code></em> has been included at some point.
        !          4921:       <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
        !          4922:       packages for which <code class="filename">buildlink3.mk</code> files
        !          4923:       have been included.  It must <span class="emphasis"><em>always</em></span> be
        !          4924:       appended to within a <code class="filename">buildlink3.mk</code>
        !          4925:       file.</p>
        !          4926: <p>The third section is protected from multiple inclusion
        !          4927:       and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
        !          4928:       added.  Several important variables are set in the section:</p>
        !          4929: <div class="itemizedlist"><ul type="disc">
        !          4930: <li><p><code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
        !          4931:          is the actual dependency recorded in the installed
        !          4932:          package; this should always be set using
        !          4933:          <span><strong class="command">+=</strong></span> to ensure that
        !          4934:          we're appending to any pre-existing list of values.  This
        !          4935:          variable should be set to the first version of the
        !          4936:          package that had an API change.
        !          4937:          </p></li>
        !          4938: <li><p><code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
        !          4939:          is the location of the <em class="replaceable"><code>pkg</code></em>
        !          4940:          pkgsrc directory.</p></li>
        !          4941: <li><p><code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
        !          4942:          (not shown above) controls whether we use
        !          4943:          <code class="varname">BUILD_DEPENDS</code> or
        !          4944:          <code class="varname">DEPENDS</code> to add the dependency on
        !          4945:          <em class="replaceable"><code>pkg</code></em>.  The build dependency is
        !          4946:          selected by setting
        !          4947:          <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
        !          4948:          to &#8220;<span class="quote">build</span>&#8221;.  By default, the full dependency is
        !          4949:          used.</p></li>
        !          4950: <li><p><code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   4951:            and
                   4952:            <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
                   4953:            (not shown above) are lists of subdirectories of
1.76      rillig   4954:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4955:            to add to the header and library search paths.  These
                   4956:            default to &#8220;<span class="quote">include</span>&#8221; and &#8220;<span class="quote">lib</span>&#8221;
1.87    ! wiz      4957:          respectively.</p></li>
        !          4958: <li><p><code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   4959:            (not shown above) is the list of preprocessor flags to add
                   4960:            to <code class="varname">CPPFLAGS</code>, which are passed on to the
                   4961:            configure and build phases.  The &#8220;<span class="quote">-I</span>&#8221; option
                   4962:            should be avoided and instead be handled using
                   4963:            <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
1.87    ! wiz      4964:          above.</p></li>
1.75      rillig   4965: </ul></div>
1.87    ! wiz      4966: <p>The following variables are all optionally defined within
        !          4967:       this second section (protected against multiple inclusion) and
        !          4968:       control which package files are symlinked into
        !          4969:       <code class="filename">${BUILDLINK_DIR}</code> and how their names are
        !          4970:       transformed during the symlinking:</p>
1.75      rillig   4971: <div class="itemizedlist"><ul type="disc">
1.87    ! wiz      4972: <li><p><code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   4973:            (not shown above) is a shell glob pattern relative to
1.76      rillig   4974:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4975:            to be symlinked into
1.76      rillig   4976:            <code class="filename">${BUILDLINK_DIR}</code>,
1.87    ! wiz      4977:          e.g. <code class="filename">include/*.h</code>.</p></li>
        !          4978: <li><p><code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
        !          4979:            (not shown above) is a shell pipeline that
        !          4980:            outputs to stdout a list of files relative to
        !          4981:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
        !          4982:            The resulting files are to be symlinked
        !          4983:            into <code class="filename">${BUILDLINK_DIR}</code>.  By default,
        !          4984:            this takes the <code class="filename">+CONTENTS</code> of a
        !          4985:            <em class="replaceable"><code>pkg</code></em> and filters it through
        !          4986:            <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.</p></li>
        !          4987: <li><p><code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   4988:            (not shown above) is a filter command that filters
1.76      rillig   4989:            <code class="filename">+CONTENTS</code> input into a list of files
1.75      rillig   4990:            relative to
1.76      rillig   4991:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4992:            on stdout.  By default for overwrite packages,
                   4993:            <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76      rillig   4994:            outputs the contents of the <code class="filename">include</code>
                   4995:            and <code class="filename">lib</code> directories in the package
                   4996:            <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75      rillig   4997:            it outputs any libtool archives in
1.87    ! wiz      4998:            <code class="filename">lib</code> directories.</p></li>
        !          4999: <li><p><code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   5000:            (not shown above) is a list of sed arguments used to
                   5001:            transform the name of the source filename into a
                   5002:            destination filename, e.g. <span><strong class="command">-e
1.87    ! wiz      5003:            "s|/curses.h|/ncurses.h|g"</strong></span>.</p></li>
1.75      rillig   5004: </ul></div>
1.87    ! wiz      5005: <p>The last section includes any
        !          5006:       <code class="filename">buildlink3.mk</code> needed for
        !          5007:       <em class="replaceable"><code>pkg</code></em>'s library dependencies.
        !          5008:       Including these <code class="filename">buildlink3.mk</code> files
        !          5009:       means that the headers and libraries for these
        !          5010:       dependencies are also symlinked into
        !          5011:       <code class="filename">${BUILDLINK_DIR}</code>
        !          5012:       whenever the <em class="replaceable"><code>pkg</code></em>
        !          5013:       <code class="filename">buildlink3.mk</code>
        !          5014:       file is included.</p>
1.75      rillig   5015: </div>
                   5016: <div class="sect2" lang="en">
                   5017: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5018: <a name="updating-buildlink-depends"></a>12.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      5019: <p>The situation that requires increasing the dependency listed in
1.75      rillig   5020:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5021:        after a package update is when the API or interface to the
1.87    ! wiz      5022:       header files change.</p>
        !          5023: <p>In this case,
        !          5024:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
        !          5025:       should be adjusted to require at least the new package
        !          5026:       version.  In some cases, the packages that depend on this new
        !          5027:       version may need their <code class="varname">PKGREVISION</code>s
        !          5028:       increased and, if they have <code class="filename">buildlink3.mk</code>
        !          5029:       files, their
        !          5030:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
        !          5031:       adjusted, too.  This is needed so pkgsrc will require the
        !          5032:       correct package dependency and not settle for an older one
        !          5033:       when building the source.</p>
        !          5034: <p><code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
1.75      rillig   5035:        should be increased when the binary interface or sonames
                   5036:        (major number of the library version) of any installed
                   5037:        shared libraries change.  This is needed so that binary
                   5038:        packages made using it will require the correct package
                   5039:        dependency and not settle for an older one which will not
1.87    ! wiz      5040:       contain the necessary shared libraries.</p>
        !          5041: <p>See <a href="#dependencies" title="17.1.6. Handling dependencies">Section 17.1.6, &#8220;Handling dependencies&#8221;</a> for
1.75      rillig   5042:        more information about dependencies on other packages,
                   5043:        including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
1.87    ! wiz      5044:       <code class="varname">ABI_DEPENDS</code> definitions.</p>
        !          5045: <p>Please take careful consideration before adjusting
        !          5046:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
        !          5047:       or
        !          5048:       <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
        !          5049:       as we don't want to cause unneeded package deletions and
        !          5050:       rebuilds.  In many cases, new versions of packages work just
        !          5051:       fine with older dependencies.</p>
        !          5052: <p>Also it is not needed to set
1.75      rillig   5053:        <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5054:        when it is identical to
1.87    ! wiz      5055:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.        </p>
1.75      rillig   5056: </div>
                   5057: </div>
                   5058: <div class="sect1" lang="en">
                   5059: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5060: <a name="writing-builtin.mk"></a>12.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.87    ! wiz      5061: <p>Some packages in pkgsrc install headers and libraries that
1.75      rillig   5062:       coincide with headers and libraries present in the base system.
1.76      rillig   5063:       Aside from a <code class="filename">buildlink3.mk</code> file, these
                   5064:       packages should also include a <code class="filename">builtin.mk</code>
1.75      rillig   5065:       file that includes the necessary checks to decide whether using
                   5066:       the built-in software or the pkgsrc software is
1.87    ! wiz      5067:     appropriate.</p>
        !          5068: <p>The only requirements of a builtin.mk file for
        !          5069:     <em class="replaceable"><code>pkg</code></em> are:</p>
1.75      rillig   5070: <div class="orderedlist"><ol type="1">
1.87    ! wiz      5071: <li><p>It should set
        !          5072:        <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
        !          5073:        to either &#8220;<span class="quote">yes</span>&#8221; or &#8220;<span class="quote">no</span>&#8221;
        !          5074:        after it is included.</p></li>
        !          5075: <li><p>It should <span class="emphasis"><em>not</em></span> override any
        !          5076:        <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
        !          5077:        which is already set before the
        !          5078:        <code class="filename">builtin.mk</code> file is included.</p></li>
        !          5079: <li><p>It should be written to allow multiple inclusion.  This
        !          5080:        is <span class="emphasis"><em>very</em></span> important and takes careful
        !          5081:        attention to <code class="filename">Makefile</code> coding.</p></li>
1.75      rillig   5082: </ol></div>
                   5083: <div class="sect2" lang="en">
                   5084: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5085: <a name="anatomy-of-builtin.mk"></a>12.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</h3></div></div></div>
1.75      rillig   5086: <p>The following is the recommended template for builtin.mk
1.87    ! wiz      5087:       files:</p>
1.75      rillig   5088: <pre class="programlisting">
1.87    ! wiz      5089:        .if !defined(IS_BUILTIN.foo)
        !          5090:        #
        !          5091:        # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
        !          5092:        # genuinely exists in the system or not.
        !          5093:        #
        !          5094:        IS_BUILTIN.foo?=        no
        !          5095: 
        !          5096:        # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
        !          5097:        # version can be determined.
        !          5098:        #
        !          5099:        .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
        !          5100:        BUILTIN_PKG.foo?=       foo-1.0
        !          5101:        .  endif
        !          5102:        .endif  # IS_BUILTIN.foo
        !          5103: 
        !          5104:        .if !defined(USE_BUILTIN.foo)
        !          5105:        USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
        !          5106:        .  if defined(BUILTIN_PKG.foo)
        !          5107:        .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
        !          5108:        .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
        !          5109:        USE_BUILTIN.foo!=                                                       \
        !          5110:        if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then     \
        !          5111:        ${ECHO} "yes";                                            \
        !          5112:        else                                                              \
        !          5113:        ${ECHO} "no";                                             \
        !          5114:        fi
        !          5115:        .      endif
        !          5116:        .    endfor
        !          5117:        .  endif
        !          5118:        .endif  # USE_BUILTIN.foo
        !          5119: 
        !          5120:        CHECK_BUILTIN.foo?=     no
        !          5121:        .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
        !          5122:        #
        !          5123:        # Here we place code that depends on whether USE_BUILTIN.foo is set to
        !          5124:        # "yes" or "no".
        !          5125:        #
        !          5126:        .endif  # CHECK_BUILTIN.foo
        !          5127:       </pre>
        !          5128: <p>The first section sets
        !          5129:       <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
        !          5130:       depending on if <em class="replaceable"><code>pkg</code></em> really exists
        !          5131:       in the base system.  This should not be a base system software
        !          5132:       with similar functionality to <em class="replaceable"><code>pkg</code></em>;
        !          5133:       it should only be &#8220;<span class="quote">yes</span>&#8221; if the actual package is
        !          5134:       included as part of the base system.  This variable is only
        !          5135:       used internally within the <code class="filename">builtin.mk</code>
        !          5136:       file.</p>
        !          5137: <p>The second section sets
        !          5138:       <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
        !          5139:       to the version of <em class="replaceable"><code>pkg</code></em> in the base
        !          5140:       system if it exists (if
        !          5141:       <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
        !          5142:       is &#8220;<span class="quote">yes</span>&#8221;).  This variable is only used internally
        !          5143:       within the <code class="filename">builtin.mk</code> file.</p>
        !          5144: <p>The third section sets
        !          5145:       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
        !          5146:       and is <span class="emphasis"><em>required</em></span> in all
        !          5147:       <code class="filename">builtin.mk</code> files.  The code in this
        !          5148:       section must make the determination whether the built-in
        !          5149:       software is adequate to satisfy the dependencies listed in
        !          5150:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
        !          5151:       This is typically done by comparing
        !          5152:       <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
        !          5153:       against each of the dependencies in
        !          5154:       <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
        !          5155:       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
        !          5156:       <span class="emphasis"><em>must</em></span> be set to the correct value by the
        !          5157:       end of the <code class="filename">builtin.mk</code> file.  Note that
        !          5158:       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
        !          5159:       may be &#8220;<span class="quote">yes</span>&#8221; even if
        !          5160:       <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
        !          5161:       is &#8220;<span class="quote">no</span>&#8221; because we may make the determination
        !          5162:       that the built-in version of the software is similar enough to
        !          5163:       be used as a replacement.</p>
        !          5164: <p>The last section is guarded by
        !          5165:       <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
        !          5166:       and includes code that uses the value of
        !          5167:       <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
        !          5168:       set in the previous section.  This typically includes, e.g.,
        !          5169:       adding additional dependency restrictions and listing additional
        !          5170:       files to symlink into <code class="filename">${BUILDLINK_DIR}</code> (via
        !          5171:       <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).</p>
1.75      rillig   5172: </div>
                   5173: <div class="sect2" lang="en">
                   5174: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5175: <a name="native-or-pkgsrc-preference"></a>12.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.87    ! wiz      5176: <p>When building packages, it's possible to choose whether to set
        !          5177:        a global preference for using either the built-in (native)
        !          5178:        version or the pkgsrc version of software to satisfy a
        !          5179:        dependency.  This is controlled by setting
        !          5180:        <code class="varname">PREFER_PKGSRC</code> and
        !          5181:        <code class="varname">PREFER_NATIVE</code>.  These variables take values
        !          5182:        of either &#8220;<span class="quote">yes</span>&#8221;, &#8220;<span class="quote">no</span>&#8221;, or a list of
        !          5183:        packages.  <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
        !          5184:        use the pkgsrc versions of software, while
        !          5185:        <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
        !          5186:        built-in versions.  Preferences are determined by the most
        !          5187:        specific instance of the package in either
        !          5188:        <code class="varname">PREFER_PKGSRC</code> or
        !          5189:        <code class="varname">PREFER_NATIVE</code>.  If a package is specified
        !          5190:        in neither or in both variables, then
        !          5191:        <code class="varname">PREFER_PKGSRC</code> has precedence over
        !          5192:        <code class="varname">PREFER_NATIVE</code>.  For example, to require
        !          5193:        using pkgsrc versions of software for all but the most basic
        !          5194:       bits on a NetBSD system, you can set:</p>
        !          5195: <pre class="programlisting">
        !          5196:        PREFER_PKGSRC=  yes
        !          5197:        PREFER_NATIVE=  getopt skey tcp_wrappers
        !          5198:       </pre>
        !          5199: <p>A package <span class="emphasis"><em>must</em></span> have a
        !          5200:       <code class="filename">builtin.mk</code>
        !          5201:       file to be listed in <code class="varname">PREFER_NATIVE</code>,
        !          5202:       otherwise it is simply ignored in that list.</p>
1.75      rillig   5203: </div>
                   5204: </div>
                   5205: </div>
                   5206: <div class="chapter" lang="en">
                   5207: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   5208: <a name="pkginstall"></a>Chapter 13. The pkginstall framework</h2></div></div></div>
1.75      rillig   5209: <div class="toc">
                   5210: <p><b>Table of Contents</b></p>
                   5211: <dl>
1.77      rillig   5212: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
1.75      rillig   5213: <dd><dl>
1.77      rillig   5214: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
                   5215: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
1.75      rillig   5216: </dl></dd>
1.77      rillig   5217: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
1.75      rillig   5218: <dd><dl>
1.77      rillig   5219: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
                   5220: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
                   5221: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
                   5222: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
                   5223: </dl></dd>
                   5224: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
                   5225: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">13.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
                   5226: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
                   5227: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
                   5228: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
                   5229: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
                   5230: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">13.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
1.75      rillig   5231: </dl>
                   5232: </div>
                   5233: <p>This chapter describes the framework known as
                   5234: <code class="literal">pkginstall</code>, whose key features are:</p>
                   5235: <div class="itemizedlist"><ul type="disc">
                   5236: <li><p>Generic installation and manipulation of directories and files
                   5237:     outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
                   5238: <li><p>Automatic handling of configuration files during installation,
                   5239:     provided that packages are correctly designed.</p></li>
                   5240: <li><p>Generation and installation of system startup scripts.</p></li>
                   5241: <li><p>Registration of system users and groups.</p></li>
                   5242: <li><p>Registration of system shells.</p></li>
                   5243: <li><p>Automatic updating of fonts databases.</p></li>
                   5244: </ul></div>
                   5245: <p>The following sections inspect each of the above points in detail.</p>
                   5246: <p>You may be thinking that many of the things described here could be
                   5247: easily done with simple code in the package's post-installation target
                   5248: (<code class="literal">post-install</code>).  <span class="emphasis"><em>This is incorrect</em></span>,
                   5249: as the code in them is only executed when building from source.  Machines
                   5250: using binary packages could not benefit from it at all (as the code itself
                   5251: could be unavailable).  Therefore, the only way to achieve any of the items
                   5252: described above is by means of the installation scripts, which are
                   5253: automatically generated by pkginstall.</p>
                   5254: <div class="sect1" lang="en">
                   5255: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5256: <a name="files-and-dirs-outside-prefix"></a>13.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76      rillig   5257: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75      rillig   5258: of files and directories that belong to a package.  The names used in it
1.76      rillig   5259: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75      rillig   5260: which means that it cannot register files outside this directory (absolute
                   5261: path names are not allowed).  Despite this restriction, some packages need
                   5262: to install files outside this location; e.g., under
1.76      rillig   5263: <code class="filename">${VARBASE}</code> or
1.87    ! wiz      5264: <code class="filename">${PKG_SYSCONFDIR}</code>.  The only way to achieve this
        !          5265: is to create such files during installation time by using
        !          5266: installation scripts.</p>
        !          5267: <p>The generic installation scripts are shell scripts that can
        !          5268: contain arbitrary code.  The list of scripts to execute is taken from
        !          5269: the <code class="varname">INSTALL_FILE</code> variable, which defaults to
        !          5270: <code class="filename">INSTALL</code>.  A similar variable exists for package
        !          5271: removal (<code class="varname">DEINSTALL_FILE</code>, whose default is
        !          5272: <code class="filename">DEINSTALL</code>).  These scripts can run arbitrary
        !          5273: commands, so they have the potential to create and manage files
        !          5274: anywhere in the file system.</p>
        !          5275: <p>Using these general installation files is not recommended, but
        !          5276: may be needed in some special cases.  One reason for avoiding them is
        !          5277: that the user has to trust the packager that there is no unwanted or
        !          5278: simply erroneous code included in the installation script. Also,
        !          5279: previously there were many similar scripts for the same functionality,
        !          5280: and fixing a common error involved finding and changing all of
        !          5281: them.</p>
        !          5282: <p>The pkginstall framework offers another, standardized way.  It
        !          5283: provides generic scripts to abstract the manipulation of such files
        !          5284: and directories based on variables set in the package's
        !          5285: <code class="filename">Makefile</code>.  The rest of this section describes
        !          5286: these variables.</p>
1.75      rillig   5287: <div class="sect2" lang="en">
                   5288: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5289: <a name="dirs-outside-prefix"></a>13.1.1. Directory manipulation</h3></div></div></div>
1.75      rillig   5290: <p>The following variables can be set to request the creation of
                   5291: directories anywhere in the file system:</p>
                   5292: <div class="itemizedlist"><ul type="disc">
                   5293: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
                   5294:     contain a list of directories that should be created and should attempt
                   5295:     to be destroyed by the installation scripts.  The difference between
                   5296:     the two is that the latter prompts the administrator to remove any
                   5297:     directories that may be left after deinstallation (because they were
                   5298:     not empty), while the former does not.</p></li>
                   5299: <li>
                   5300: <p><code class="varname">MAKE_DIRS_PERMS</code> and
                   5301:     <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
                   5302:     which directories should be created and should attempt to be destroyed
                   5303:     by the installation scripts.  Each tuple holds the following values,
                   5304:     separated by spaces: the directory name, its owner, its group and its
                   5305:     numerical mode.  For example:</p>
                   5306: <pre class="programlisting">
                   5307:     MAKE_DIRS_PERMS+=         ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1       grant    5308: </pre>
1.75      rillig   5309: <p>The difference between the two is exactly the same as their
                   5310:     non-<code class="varname">PERMS</code> counterparts.</p>
                   5311: </li>
                   5312: </ul></div>
                   5313: </div>
                   5314: <div class="sect2" lang="en">
                   5315: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5316: <a name="files-outside-prefix"></a>13.1.2. File manipulation</h3></div></div></div>
1.75      rillig   5317: <p>Creating non-empty files outside the installation prefix is tricky
1.76      rillig   5318: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75      rillig   5319: To overcome this problem, the only solution is to extract the file in the
                   5320: known place (i.e., inside the installation prefix) and copy it to the
                   5321: appropriate location during installation (done by the installation scripts
                   5322: generated by pkginstall).  We will call the former the <span class="emphasis"><em>master
                   5323: file</em></span> in the following paragraphs, which describe the variables
                   5324: that can be used to automatically and consistently handle files outside the
                   5325: installation prefix:</p>
                   5326: <div class="itemizedlist"><ul type="disc">
                   5327: <li>
                   5328: <p><code class="varname">CONF_FILES</code> and
                   5329:     <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
                   5330:     During installation time, the master file is copied to the target one
                   5331:     if and only if the latter does not exist.  Upon deinstallation, the
                   5332:     target file is removed provided that it was not modified by the
                   5333:     installation.</p>
                   5334: <p>The difference between the two is that the latter prompts the
                   5335:     administrator to remove any files that may be left after
                   5336:     deinstallation (because they were not empty), while the former does
                   5337:     not.</p>
                   5338: </li>
                   5339: <li>
                   5340: <p><code class="varname">CONF_FILES_PERMS</code> and
                   5341:     <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
                   5342:     files as well as their target locations.  For each of them, it also
                   5343:     specifies their owner, their group and their numeric permissions, in
                   5344:     this order.  For example:</p>
                   5345: <pre class="programlisting">
                   5346:     SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1       grant    5347: </pre>
1.75      rillig   5348: <p>The difference between the two is exactly the same as their
                   5349:     non-<code class="varname">PERMS</code> counterparts.</p>
                   5350: </li>
                   5351: </ul></div>
                   5352: </div>
                   5353: </div>
                   5354: <div class="sect1" lang="en">
                   5355: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5356: <a name="conf-files"></a>13.2. Configuration files</h2></div></div></div>
1.75      rillig   5357: <p>Configuration files are special in the sense that they are installed
                   5358: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
                   5359: need special treatment during installation (most of which is automated by
                   5360: pkginstall).  The main concept you must bear in mind is that files marked
                   5361: as configuration files are automatically copied to the right place (somewhere
                   5362: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
                   5363: and only if</em></span> they didn't exist before.  Similarly, they will not
                   5364: be removed if they have local modifications.  This ensures that
                   5365: administrators never lose any custom changes they may have made.</p>
                   5366: <div class="sect2" lang="en">
                   5367: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5368: <a name="conf-files-sysconfdir"></a>13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</h3></div></div></div>
1.75      rillig   5369: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
                   5370: specifies where configuration files shall be installed.  Its contents are
                   5371: set based upon the following variables:</p>
                   5372: <div class="itemizedlist"><ul type="disc">
                   5373: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76      rillig   5374:     directory.  Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75      rillig   5375:     be overridden by the user to point to his preferred location (e.g.,
1.76      rillig   5376:     <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75      rillig   5377:     Packages must not use it directly.</p></li>
                   5378: <li>
                   5379: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
                   5380:     <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
                   5381:     for the package being built shall be installed.  The definition of this
                   5382:     variable only makes sense in the package's
1.76      rillig   5383:     <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75      rillig   5384: <p>As an example, consider the Apache package,
1.76      rillig   5385:     <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/apache2/README.html" target="_top"><code class="filename">www/apache2</code></a>, which places its
1.75      rillig   5386:     configuration files under the
1.76      rillig   5387:     <code class="filename">httpd/</code> subdirectory of
1.75      rillig   5388:     <code class="varname">PKG_SYSCONFBASE</code>.  This should be set in the package
                   5389:     Makefile.</p>
                   5390: </li>
                   5391: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
                   5392:     variable that holds this package's configuration directory (if
                   5393:     different from <code class="varname">PKG_SYSCONFBASE</code>).  It defaults to
                   5394:     <code class="varname">PKGBASE</code>'s value, and is always prefixed with
                   5395:     <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
                   5396: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
                   5397:     directory where the configuration files for the package identified by
                   5398:     <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
                   5399: </ul></div>
                   5400: <p>Based on the above variables, pkginstall determines the value of
                   5401: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
                   5402: variable that can be used within a package to refer to its configuration
                   5403: directory.  The algorithm used to set its value is basically the
                   5404: following:</p>
                   5405: <div class="orderedlist"><ol type="1">
                   5406: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
                   5407:     its value is used.</p></li>
                   5408: <li><p>If the previous variable is not defined but
                   5409:     <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76      rillig   5410:     <code class="filename">Makefile</code>, the resulting value is
                   5411:     <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75      rillig   5412: <li><p>Otherwise, it is set to
1.76      rillig   5413:     <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75      rillig   5414: </ol></div>
1.76      rillig   5415: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.77      rillig   5416: automatically added to <code class="filename">OWN_DIRS</code>.  See <a href="#dirs-outside-prefix" title="13.1.1. Directory manipulation">Section 13.1.1, &#8220;Directory manipulation&#8221;</a> what this means.</p>
1.75      rillig   5417: </div>
                   5418: <div class="sect2" lang="en">
                   5419: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5420: <a name="conf-files-configure"></a>13.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75      rillig   5421: <p>Given that pkgsrc (and users!) expect configuration files to be in a
                   5422: known place, you need to teach each package where it shall install its
                   5423: files.  In some cases you will have to patch the package Makefiles to
                   5424: achieve it.  If you are lucky, though, it may be as easy as passing an
                   5425: extra flag to the configuration script; this is the case of GNU Autoconf-
                   5426: generated files:</p>
                   5427: <pre class="programlisting">
                   5428:     CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1       grant    5429: </pre>
1.75      rillig   5430: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
                   5431: for</em></span> its configuration files, not where they will be originally
                   5432: installed (although the difference is never explicit,
                   5433: unfortunately).</p>
                   5434: </div>
                   5435: <div class="sect2" lang="en">
                   5436: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5437: <a name="conf-files-patching"></a>13.2.3. Patching installations</h3></div></div></div>
1.75      rillig   5438: <p>As said before, pkginstall automatically handles configuration files.
                   5439: This means that <span class="strong"><strong>the packages themselves must not
1.76      rillig   5440: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75      rillig   5441: directly</strong></span>.  Bad news is that many software installation scripts
                   5442: will, out of the box, mess with the contents of that directory.  So what is
                   5443: the correct procedure to fix this issue?</p>
                   5444: <p>You must teach the package (usually by manually patching it) to
                   5445: install any configuration files under the examples hierarchy,
1.76      rillig   5446: <code class="filename">share/examples/${PKGBASE}/</code>.  This way, the
                   5447: <code class="filename">PLIST</code> registers them and the administrator always
1.75      rillig   5448: has the original copies available.</p>
                   5449: <p>Once the required configuration files are in place (i.e., under the
                   5450: examples hierarchy), the pkginstall framework can use them as master copies
                   5451: during the package installation to update what is in
1.76      rillig   5452: <code class="filename">${PKG_SYSCONFDIR}</code>.  To achieve this, the variables
1.75      rillig   5453: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.77      rillig   5454: used.  Check out <a href="#files-outside-prefix" title="13.1.2. File manipulation">Section 13.1.2, &#8220;File manipulation&#8221;</a> for information
1.75      rillig   5455: about their syntax and their purpose.  Here is an example, taken from the
1.76      rillig   5456: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/mail/mutt/README.html" target="_top"><code class="filename">mail/mutt</code></a> package:</p>
1.75      rillig   5457: <pre class="programlisting">
                   5458:     EGDIR=        ${PREFIX}/share/doc/mutt/samples
                   5459:     CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1       grant    5460: </pre>
1.75      rillig   5461: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
                   5462: package and has no meaning outside it.</p>
                   5463: </div>
                   5464: <div class="sect2" lang="en">
                   5465: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5466: <a name="conf-files-disable"></a>13.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75      rillig   5467: <p>The automatic copying of config files can be toggled by setting the
                   5468: environment variable <code class="varname">PKG_CONFIG</code> prior to package
                   5469: installation.</p>
                   5470: </div>
                   5471: </div>
                   5472: <div class="sect1" lang="en">
                   5473: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5474: <a name="rcd-scripts"></a>13.3. System startup scripts</h2></div></div></div>
1.75      rillig   5475: <p>System startup scripts are special files because they must be
                   5476: installed in a place known by the underlying OS, usually outside the
1.77      rillig   5477: installation prefix.  Therefore, the same rules described in <a href="#files-and-dirs-outside-prefix" title="13.1. Files and directories outside the installation prefix">Section 13.1, &#8220;Files and directories outside the installation prefix&#8221;</a> apply, and the same solutions
1.75      rillig   5478: can be used.  However, pkginstall provides a special mechanism to handle
                   5479: these files.</p>
                   5480: <p>In order to provide system startup scripts, the package has
                   5481: to:</p>
                   5482: <div class="orderedlist"><ol type="1">
1.76      rillig   5483: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75      rillig   5484:     the <code class="literal">.sh</code> suffix appended.  Considering the
1.76      rillig   5485:     <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/cups/README.html" target="_top"><code class="filename">print/cups</code></a> package as an example, it has a
                   5486:     <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75      rillig   5487: <li>
                   5488: <p>Tell pkginstall to handle it, appending the name of the script,
                   5489:     without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
                   5490:     Continuing the previous example:</p>
                   5491: <pre class="programlisting">
                   5492:     RCD_SCRIPTS+=   cupsd
1.1       grant    5493: </pre>
1.75      rillig   5494: </li>
                   5495: </ol></div>
                   5496: <p>Once this is done, pkginstall will do the following steps for each
                   5497: script in an automated fashion:</p>
                   5498: <div class="orderedlist"><ol type="1">
                   5499: <li><p>Process the file found in the files directory applying all the
1.76      rillig   5500:     substitutions described in the <code class="filename">FILES_SUBST</code>
1.75      rillig   5501:     variable.</p></li>
                   5502: <li><p>Copy the script from the files directory to the examples
1.76      rillig   5503:     hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>.  Note
1.75      rillig   5504:     that this master file must be explicitly registered in the
1.76      rillig   5505:     <code class="filename">PLIST</code>.</p></li>
1.75      rillig   5506: <li><p>Add code to the installation scripts to copy the startup script
                   5507:     from the examples hierarchy into the system-wide startup scripts
                   5508:     directory.</p></li>
                   5509: </ol></div>
                   5510: <div class="sect2" lang="en">
                   5511: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5512: <a name="rcd-scripts-disable"></a>13.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75      rillig   5513: <p>The automatic copying of config files can be toggled by setting the
                   5514: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
                   5515: installation.  Note that the scripts will be always copied inside the
1.76      rillig   5516: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75      rillig   5517: matter what the value of this variable is.</p>
                   5518: </div>
                   5519: </div>
                   5520: <div class="sect1" lang="en">
                   5521: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5522: <a name="users-and-groups"></a>13.4. System users and groups</h2></div></div></div>
1.75      rillig   5523: <p>If a package needs to create special users and/or groups during
                   5524: installation, it can do so by using the pkginstall framework.</p>
                   5525: <p>Users can be created by adding entries to the
                   5526: <code class="varname">PKG_USERS</code> variable.  Each entry has the following
                   5527: syntax:</p>
                   5528: <pre class="programlisting">
                   5529:     user:group
1.1       grant    5530: </pre>
1.87    ! wiz      5531: <p>Further specification of user details may be done by setting
        !          5532: per-user variables.
        !          5533: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the
        !          5534: numeric UID for the user.
        !          5535: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the
        !          5536: user's description or comment.
        !          5537: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the
        !          5538: user's home directory, and defaults to
        !          5539: <code class="filename">/nonexistent</code> if not specified.
        !          5540: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the
        !          5541: user's shell, and defaults to <code class="filename">/sbinno/login</code> if
        !          5542: not specified.</p>
1.75      rillig   5543: <p>Similarly, groups can be created by adding entries to the
                   5544: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
                   5545: <pre class="programlisting">
                   5546:     group
1.1       grant    5547: </pre>
1.75      rillig   5548: <p>The numeric GID of the group may be set by defining 
                   5549: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
                   5550: <p>If a package needs to create the users and groups at an earlier
                   5551: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
                   5552: either <code class="literal">configure</code> or <code class="literal">build</code> to
                   5553: indicate the phase before which the users and groups are created.  In
                   5554: this case, the numeric UIDs and GIDs of the created users and groups
                   5555: are automatically hardcoded into the final installation scripts.</p>
                   5556: </div>
                   5557: <div class="sect1" lang="en">
                   5558: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5559: <a name="shells"></a>13.5. System shells</h2></div></div></div>
1.75      rillig   5560: <p>Packages that install system shells should register them in the shell
1.76      rillig   5561: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75      rillig   5562: administrator.  This must be done from the installation scripts to keep
                   5563: binary packages working on any system.  pkginstall provides an easy way to
                   5564: accomplish this task.</p>
                   5565: <p>When a package provides a shell interpreter, it has to set the
                   5566: <code class="varname">PKG_SHELL</code> variable to its absolute file name.  This will
                   5567: add some hooks to the installation scripts to handle it.  Consider the
1.76      rillig   5568: following example, taken from <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/shells/zsh/README.html" target="_top"><code class="filename">shells/zsh</code></a>:</p>
1.75      rillig   5569: <pre class="programlisting">
                   5570:     PKG_SHELL=      ${PREFIX}/bin/zsh
1.1       grant    5571: </pre>
1.75      rillig   5572: <div class="sect2" lang="en">
                   5573: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5574: <a name="shells-disable"></a>13.5.1. Disabling shell registration</h3></div></div></div>
1.75      rillig   5575: <p>The automatic registration of shell interpreters can be disabled by
1.76      rillig   5576: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75      rillig   5577: environment variable to <code class="literal">NO</code>.</p>
                   5578: </div>
                   5579: </div>
                   5580: <div class="sect1" lang="en">
                   5581: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5582: <a name="fonts"></a>13.6. Fonts</h2></div></div></div>
1.75      rillig   5583: <p>Packages that install X11 fonts should update the database files
                   5584: that index the fonts within each fonts directory.  This can easily be
                   5585: accomplished within the pkginstall framework.</p>
                   5586: <p>When a package installs X11 fonts, it must list the directories in
                   5587: which fonts are installed in the
                   5588: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
                   5589: where <em class="replaceable"><code>type</code></em> can be one of &#8220;<span class="quote">ttf</span>&#8221;,
                   5590: &#8220;<span class="quote">type1</span>&#8221; or &#8220;<span class="quote">x11</span>&#8221;.  This will add hooks to the
                   5591: installation scripts to run the appropriate commands to update the fonts
                   5592: database files within each of those directories.  For convenience, if the
                   5593: directory path is relative, it is taken to be relative to the package's
1.76      rillig   5594: installation prefix.  Consider the following example, taken from <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/fonts/dbz-ttf/README.html" target="_top"><code class="filename">fonts/dbz-ttf</code></a>:</p>
1.75      rillig   5595: <pre class="programlisting">
                   5596:     FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1       grant    5597: </pre>
1.75      rillig   5598: <div class="sect2" lang="en">
                   5599: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5600: <a name="fonts-disable"></a>13.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75      rillig   5601: <p>The automatic update of fonts databases can be disabled by
1.76      rillig   5602: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75      rillig   5603: environment variable to <code class="literal">NO</code>.</p>
                   5604: </div>
                   5605: </div>
                   5606: </div>
                   5607: <div class="chapter" lang="en">
                   5608: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   5609: <a name="options"></a>Chapter 14. Options handling</h2></div></div></div>
1.75      rillig   5610: <div class="toc">
                   5611: <p><b>Table of Contents</b></p>
                   5612: <dl>
1.77      rillig   5613: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
                   5614: <dt><span class="sect1"><a href="#converting-to-options">14.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
                   5615: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
1.75      rillig   5616: </dl>
                   5617: </div>
                   5618: <p>Many packages have the ability to be built to support different
1.76      rillig   5619: sets of features.  <code class="filename">bsd.options.mk</code> is a framework
1.75      rillig   5620: in pkgsrc that provides generic handling of those options that
                   5621: determine different ways in which the packages can be built.  It's
                   5622: possible for the user to specify exactly which sets of options will be
                   5623: built into a package or to allow a set of global default options
                   5624: apply.</p>
                   5625: <div class="sect1" lang="en">
                   5626: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5627: <a name="global-default-options"></a>14.1. Global default options</h2></div></div></div>
1.75      rillig   5628: <p>Global default options are listed in
                   5629: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
                   5630: that should be built into every package if that option is supported.
1.76      rillig   5631: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75      rillig   5632: </div>
                   5633: <div class="sect1" lang="en">
                   5634: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5635: <a name="converting-to-options"></a>14.2. Converting packages to use <code class="filename">bsd.options.mk</code></h2></div></div></div>
1.75      rillig   5636: <p>The following example shows how
1.76      rillig   5637: <code class="filename">bsd.options.mk</code> should be used
1.75      rillig   5638: by the hypothetical ``wibble'' package, either in the package
1.76      rillig   5639: <code class="filename">Makefile</code>, or in a file,
                   5640: e.g. <code class="filename">options.mk</code>, that is included by the
                   5641: main package <code class="filename">Makefile</code>.</p>
1.75      rillig   5642: <pre class="programlisting">
                   5643:     PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   5644:     PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   5645:     PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   5646:     PKG_OPTIONS_GROUP.database=     mysql pgsql
                   5647:     PKG_SUGGESTED_OPTIONS=          wibble-foo
                   5648:     PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   5649:     PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
1.1       grant    5650: 
1.75      rillig   5651:     .include "../../mk/bsd.prefs.mk"
1.69      rillig   5652: 
1.75      rillig   5653:     # this package was previously named wibble2
                   5654:     .if defined(PKG_OPTIONS.wibble2)
                   5655:     PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   5656:     PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78      rillig   5657:             "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75      rillig   5658:     .endif
1.69      rillig   5659: 
1.75      rillig   5660:     .include "../../mk/bsd.options.mk"
1.69      rillig   5661: 
1.75      rillig   5662:     # Package-specific option-handling
1.69      rillig   5663: 
1.75      rillig   5664:     ###
                   5665:     ### FOO support
                   5666:     ###
                   5667:     .if !empty(PKG_OPTIONS:Mwibble-foo)
                   5668:     CONFIGURE_ARGS+=    --enable-foo
                   5669:     .endif
1.69      rillig   5670: 
1.75      rillig   5671:     ###
                   5672:     ### LDAP support
                   5673:     ###
                   5674:     .if !empty(PKG_OPTIONS:Mldap)
1.77      rillig   5675:     .  include "../../databases/openldap-client/buildlink3.mk"
                   5676:     CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75      rillig   5677:     .endif
1.69      rillig   5678: 
1.75      rillig   5679:     ###
                   5680:     ### database support
                   5681:     ###
                   5682:     .if !empty(PKG_OPTIONS:Mmysql)
                   5683:     .  include "../../mk/mysql.buildlink3.mk"
                   5684:     .endif
                   5685:     .if !empty(PKG_OPTIONS:Mpgsql)
                   5686:     .  include "../../mk/pgsql.buildlink3.mk"
                   5687:     .endif
                   5688: </pre>
                   5689: <p>The first section contains the information about which build
                   5690: options are supported by the package, and any default options settings
                   5691: if needed.</p>
                   5692: <div class="orderedlist"><ol type="1">
                   5693: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
                   5694: <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
                   5695: options.  It should be set to
1.78      rillig   5696: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
                   5697: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
                   5698: at the point where the options are processed.</p></li>
1.75      rillig   5699: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
                   5700: build options supported by the package.</p></li>
                   5701: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
                   5702: list of names of groups of mutually exclusive options.  The options in
                   5703: each group are listed in
                   5704: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
                   5705: The most specific setting of any option from the group takes
                   5706: precedence over all other options in the group.  Options from the
                   5707: groups will be automatically added to
                   5708: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
                   5709: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
                   5710: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
                   5711: packages will fail if no option from the group is
                   5712: selected.</p></li>
                   5713: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
                   5714: of names of sets of options.  At least one option from each set must
                   5715: be selected.  The options in each set are listed in
                   5716: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
                   5717: Options from the sets will be automatically added to
                   5718: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.  Building the package will
                   5719: fail if no option from the set is selected.</p></li>
                   5720: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
                   5721: build options which are enabled by default.</p></li>
                   5722: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
                   5723: of
                   5724: &#8220;<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>&#8221;
1.76      rillig   5725: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75      rillig   5726: their option counterparts.  Pairs should be added with
                   5727: &#8220;<span class="quote">+=</span>&#8221; to keep the listing of global legacy variables.  A
                   5728: warning will be issued if the user uses a legacy
                   5729: variable.</p></li>
                   5730: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
                   5731: of
                   5732: &#8220;<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>&#8221;
                   5733: pairs that map options that have been renamed to their new
                   5734: counterparts.  Pairs should be added with &#8220;<span class="quote">+=</span>&#8221; to keep
                   5735: the listing of global legacy options.  A warning will be issued if
                   5736: the user uses a legacy option.</p></li>
                   5737: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
                   5738: options implied by deprecated variables used.  This can be used for
                   5739: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
                   5740: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
                   5741: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
                   5742: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
                   5743: a list of warnings about deprecated variables or options used, and
                   5744: what to use instead.</p></li>
                   5745: </ol></div>
                   5746: <p>A package should never modify
                   5747: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
                   5748: <code class="varname">PKG_OPTIONS_VAR</code>.  These are strictly user-settable.
                   5749: To suggest a default set of options, use
                   5750: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
                   5751: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76      rillig   5752: including <code class="filename">bsd.options.mk</code>.  If none of
1.75      rillig   5753: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
                   5754: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
                   5755: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
                   5756: happen with platform-specific options if none of them is supported on
                   5757: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
                   5758: empty list and the package is otherwise treated as not using the
                   5759: options framework.</p>
1.76      rillig   5760: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75      rillig   5761: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
                   5762: build options, properly filtered to remove unsupported and duplicate
                   5763: options.</p>
                   5764: <p>The remaining sections contain the logic that is specific to
                   5765: each option.  The correct way to check for an option is to check
                   5766: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
                   5767: <pre class="programlisting">
                   5768:     .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
                   5769: </pre>
                   5770: </div>
                   5771: <div class="sect1" lang="en">
                   5772: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5773: <a name="option-names"></a>14.3. Option Names</h2></div></div></div>
1.75      rillig   5774: <p>Options that enable similar features in different packages (like
                   5775: optional support for a library) should use a common name in all
                   5776: packages that support it (like the name of the library).  If another
                   5777: package already has an option with the same meaning, use the same
                   5778: name.</p>
                   5779: <p>Options that enable features specific to one package, where it's
                   5780: unlikely that another (unrelated) package has the same (or a similar)
                   5781: optional feature, should use a name prefixed with
                   5782: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
                   5783: <p>If a group of related packages share an optional feature
                   5784: specific to that group, prefix it with the name of the
                   5785: &#8220;<span class="quote">main</span>&#8221; package
                   5786: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
                   5787: <p>For new options, add a line to
1.76      rillig   5788: <code class="filename">mk/defaults/options.description</code>.  Lines have two
1.75      rillig   5789: fields, separated by tab.  The first field is the option name, the
                   5790: second its description.  The description should be a whole sentence
                   5791: (starting with an uppercase letter and ending with a period) that
                   5792: describes what enabling the option does.  E. g. &#8220;<span class="quote">Enable ispell
                   5793: support.</span>&#8221; The file is sorted by option names.</p>
                   5794: </div>
                   5795: </div>
                   5796: <div class="chapter" lang="en">
                   5797: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   5798: <a name="build"></a>Chapter 15. The build process</h2></div></div></div>
1.75      rillig   5799: <div class="toc">
                   5800: <p><b>Table of Contents</b></p>
                   5801: <dl>
1.77      rillig   5802: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
                   5803: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
                   5804: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
                   5805: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
                   5806: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
1.81      rillig   5807: <dd><dl>
                   5808: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
                   5809: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
                   5810: </dl></dd>
1.77      rillig   5811: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
                   5812: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
                   5813: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
                   5814: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
                   5815: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
                   5816: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   5817: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   5818: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
                   5819: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   5820: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
                   5821: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
1.75      rillig   5822: </dl>
                   5823: </div>
                   5824: <div class="sect1" lang="en">
                   5825: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5826: <a name="build.intro"></a>15.1. Introduction</h2></div></div></div>
1.75      rillig   5827: <p>This chapter gives a detailed description on how a package is
1.87    ! wiz      5828:     built. Building a package is separated into different
        !          5829:     <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
        !          5830:     <code class="varname">build</code>, <code class="varname">install</code>), all of which are
        !          5831:     described in the following sections. Each phase is splitted into
        !          5832:     so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
        !          5833:     containing phase, prefixed by one of <code class="varname">pre-</code>,
        !          5834:     <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
        !          5835:     <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
        !          5836:     of the actual work is done in the <code class="varname">do-*</code> stages.</p>
1.75      rillig   5837: <p>The basic steps for building a program are always the same.  First
1.87    ! wiz      5838:     the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
        !          5839:     the local system and then extracted. After any pkgsrc-specific patches
        !          5840:     to compile properly are applied, the software can be configured, then
        !          5841:     built (usually by compiling), and finally the generated binaries, etc.
        !          5842:     can be put into place on the system.</p>
1.75      rillig   5843: </div>
                   5844: <div class="sect1" lang="en">
                   5845: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5846: <a name="build.prefix"></a>15.2. Program location</h2></div></div></div>
1.75      rillig   5847: <p>Before outlining the process performed by the NetBSD package system in
1.87    ! wiz      5848:     the next section, here's a brief discussion on where programs are
        !          5849:     installed, and which variables influence this.</p>
1.75      rillig   5850: <p>The automatic variable <code class="varname">PREFIX</code> indicates
1.87    ! wiz      5851:     where all files of the final program shall be installed. It is
        !          5852:     usually set to <code class="varname">LOCALBASE</code>
        !          5853:     (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
        !          5854:     for pkgs in the &#8220;<span class="quote">cross</span>&#8221; category.  The value of
        !          5855:     <code class="varname">PREFIX</code> needs to be put
        !          5856:     into the various places in the program's source where paths to
        !          5857:     these files are encoded.  See <a href="#components.patches" title="9.3. patches/*">Section 9.3, &#8220;patches/*&#8221;</a> and <a href="#fixes.libtool" title="17.3.1. Shared libraries - libtool">Section 17.3.1, &#8220;Shared libraries - libtool&#8221;</a> for more details.</p>
1.75      rillig   5858: <p>When choosing which of these variables to use,
1.87    ! wiz      5859:     follow the following rules:</p>
1.75      rillig   5860: <div class="itemizedlist"><ul type="disc">
                   5861: <li><p><code class="varname">PREFIX</code> always points to the location where the current
1.87    ! wiz      5862:        pkg will be installed.  When referring to a pkg's own installation path,
        !          5863:        use &#8220;<span class="quote">${PREFIX}</span>&#8221;.</p></li>
1.75      rillig   5864: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs are installed.
1.87    ! wiz      5865:        If you need to construct a -I or -L argument to the compiler to find
        !          5866:        includes and libraries installed by another non-X11 pkg, use
        !          5867:        &#8220;<span class="quote">${LOCALBASE}</span>&#8221;. The name
        !          5868:        <code class="varname">LOCALBASE</code> stems from FreeBSD, which
        !          5869:        installed all packages in <code class="filename">/usr/local</code>. As
        !          5870:        pkgsrc leaves <code class="filename">/usr/local</code> for the system
        !          5871:        administrator, this variable is a misnomer.</p></li>
1.75      rillig   5872: <li><p><code class="varname">X11BASE</code> is where the actual X11 distribution (from
1.87    ! wiz      5873:        xsrc, etc.) is installed. When looking for
        !          5874:        <span class="emphasis"><em>standard</em></span> X11 includes (not
        !          5875:        those installed by a pkg), use &#8220;<span class="quote">${X11BASE}</span>&#8221;.</p></li>
1.75      rillig   5876: <li>
                   5877: <p>X11-based packages are special in that they may be installed in
1.87    ! wiz      5878:        either <code class="varname">X11BASE</code> or <code class="varname">LOCALBASE</code>.</p>
1.75      rillig   5879: <p>Usually, X11 packages should be installed under
1.87    ! wiz      5880:        <code class="varname">LOCALBASE</code> whenever possible.  Note that you will
        !          5881:        need to include <code class="filename">../../mk/x11.buildlink3.mk</code>
        !          5882:        in them to request the
        !          5883:        presence of X11 and to get the right compilation flags.</p>
1.75      rillig   5884: <p>Even though, there are some packages that cannot be installed
1.87    ! wiz      5885:        under <code class="varname">LOCALBASE</code>: those that come with app-defaults
        !          5886:        files. These packages are special and they must be placed under
        !          5887:        <code class="varname">X11BASE</code>. To accomplish this, set either
        !          5888:        <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
        !          5889:        your package.</p>
1.75      rillig   5890: <p>Some notes: If you need
1.87    ! wiz      5891:        to find includes or libraries installed by a pkg that has
        !          5892:        <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
        !          5893:        its pkg <code class="filename">Makefile</code>, you need to look in
        !          5894:        <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
        !          5895:        <code class="filename">${LOCALBASE}</code>. To force installation of
        !          5896:        all X11 packages in <code class="varname">LOCALBASE</code>, the
        !          5897:        <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a> package
        !          5898:        is enabled by default.</p>
1.75      rillig   5899: </li>
                   5900: <li><p><code class="varname">X11PREFIX</code> should be used to refer to the installed
1.87    ! wiz      5901:        location of an X11 package. <code class="varname">X11PREFIX</code> will be set to
        !          5902:        <code class="varname">X11BASE</code> if xpkgwedge is not installed,
        !          5903:        and to <code class="varname">LOCALBASE</code> if xpkgwedge is installed.</p></li>
1.75      rillig   5904: <li>
                   5905: <p>If xpkgwedge is installed, it is possible to have some packages installed
1.87    ! wiz      5906:        in <code class="varname">X11BASE</code> and some in <code class="varname">LOCALBASE</code>.
        !          5907:        To determine the prefix of an installed package, the
        !          5908:        <code class="varname">EVAL_PREFIX</code> definition can be used. It takes pairs in the
        !          5909:        format &#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> variable
        !          5910:        <code class="varname">DIRNAME</code> will be set to the prefix of the installed
        !          5911:        package &lt;package&gt;, or &#8220;<span class="quote">${X11PREFIX}</span>&#8221; if the package is
        !          5912:        not installed.</p>
1.75      rillig   5913: <p>This is best illustrated by example.</p>
                   5914: <p>The following lines are taken from
1.87    ! wiz      5915:        <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75      rillig   5916: <pre class="programlisting">
1.87    ! wiz      5917:          EVAL_PREFIX+=           GTKDIR=gtk+
        !          5918:          CONFIGURE_ARGS+=        --with-guile-prefix=${LOCALBASE:Q}
        !          5919:          CONFIGURE_ARGS+=        --with-gtk-prefix=${GTKDIR:Q}
        !          5920:          CONFIGURE_ARGS+=        --enable-multibyte
        !          5921:        </pre>
1.75      rillig   5922: <p>Specific defaults can be defined for the packages evaluated using
1.87    ! wiz      5923:        <code class="varname">EVAL_PREFIX</code>, by using a definition of the form:</p>
1.75      rillig   5924: <pre class="programlisting">
1.87    ! wiz      5925:          GTKDIR_DEFAULT= ${LOCALBASE}
        !          5926:        </pre>
1.75      rillig   5927: <p>where <code class="varname">GTKDIR</code> corresponds
1.87    ! wiz      5928:        to the first definition in
        !          5929:        the <code class="varname">EVAL_PREFIX</code> pair.</p>
1.75      rillig   5930: </li>
1.76      rillig   5931: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.87    ! wiz      5932:        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
        !          5933:        manual pages go into <code class="filename">${PREFIX}/man</code>, not
        !          5934:        <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75      rillig   5935: </ul></div>
                   5936: </div>
                   5937: <div class="sect1" lang="en">
                   5938: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5939: <a name="build.builddirs"></a>15.3. Directories used during the build process</h2></div></div></div>
1.75      rillig   5940: <p>When building a package, a number of directories is used to store
1.87    ! wiz      5941:     source files, temporary files, pkgsrc-internal files, and so on. These
        !          5942:     directories are explained here.</p>
1.75      rillig   5943: <p>Some of the directory variables contain relative pathnames. There
1.87    ! wiz      5944:     are two common base directories for these relative directories:
        !          5945:     <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
        !          5946:     pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
        !          5947:     inside the package itself.</p>
1.75      rillig   5948: <div class="variablelist"><dl>
                   5949: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
                   5950: <dd><p>This is an absolute pathname that points to the pkgsrc
1.87    ! wiz      5951:       root directory. Generally, you don't need
        !          5952:       it.</p></dd>
1.75      rillig   5953: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
                   5954: <dd><p>This is a pathname relative to
1.87    ! wiz      5955:       <code class="varname">PKGSRCDIR</code> that points to the current
        !          5956:       package.</p></dd>
1.75      rillig   5957: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
                   5958: <dd><p>This is an absolute pathname pointing to the directory
1.87    ! wiz      5959:       where all work takes place. The distfiles are extraced to this
        !          5960:       directory. It also contains temporary directories and log files used by
        !          5961:       the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
        !          5962:       the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
1.75      rillig   5963: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
                   5964: <dd><p>This is an absolute pathname pointing to the directory
1.87    ! wiz      5965:       where the distfiles are extracted. It is usually a direct subdirectory
        !          5966:       of <code class="varname">WRKDIR</code>, and often it's the only directory entry
        !          5967:       that isn't hidden. This variable may be changed by a package
        !          5968:       <code class="filename">Makefile</code>.</p></dd>
1.75      rillig   5969: </dl></div>
                   5970: </div>
                   5971: <div class="sect1" lang="en">
                   5972: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5973: <a name="build.running"></a>15.4. Running a phase</h2></div></div></div>
1.75      rillig   5974: <p>You can run a particular phase by typing <span><strong class="command">make
1.87    ! wiz      5975:     phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
        !          5976:     phase. This will automatically run all phases that are required for this
        !          5977:     phase. The default phase is <code class="varname">build</code>, that is, when you
        !          5978:     run <span><strong class="command">make</strong></span> without parameters in a package directory,
        !          5979:     the package will be built, but not installed.</p>
1.75      rillig   5980: </div>
                   5981: <div class="sect1" lang="en">
                   5982: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5983: <a name="build.fetch"></a>15.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.81      rillig   5984: <p>The first step in building a package is to fetch the
                   5985:        distribution files (distfiles) from the sites that are providing
                   5986:        them. This is the task of the <span class="emphasis"><em>fetch</em></span>
                   5987:        phase.</p>
                   5988: <div class="sect2" lang="en">
                   5989: <div class="titlepage"><div><div><h3 class="title">
                   5990: <a name="build.fetch.what"></a>15.5.1. What to fetch and where to get it from</h3></div></div></div>
                   5991: <p>In simple cases, <code class="varname">MASTER_SITES</code> defines
                   5992:        all URLs from where the distfile, whose name is derived from the
                   5993:        <code class="varname">DISTNAME</code> variable, is fetched. The more
                   5994:        complicated cases are described below.</p>
                   5995: <p>The variable <code class="varname">DISTFILES</code> specifies the
                   5996:        list of distfiles that have to be fetched. Its value defaults to
                   5997:        <code class="literal">${DISTNAME}${EXTRACT_SUFX}</code>, so that most
                   5998:        packages don't need to define it at all.
                   5999:        <code class="varname">EXTRACT_SUFX</code> is <code class="literal">.tar.gz</code> by
                   6000:        default, but can be changed freely. Note that if your package
                   6001:        requires additional distfiles to the default one, you cannot
                   6002:        just append the additional filenames using the
                   6003:        <code class="literal">+=</code> operator, but you have write for
                   6004:        example:</p>
                   6005: <pre class="programlisting">
                   6006:     DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   6007: </pre>
                   6008: <p>Each of the distfiles is fetched from a list of sites,
                   6009:        usually <code class="varname">MASTER_SITES</code>. If the package has
                   6010:        multiple <code class="varname">DISTFILES</code> or multiple
                   6011:        <code class="varname">PATCHFILES</code> from different sites, you can set
                   6012:        <code class="varname">SITES.<em class="replaceable"><code>distfile</code></em></code> to
                   6013:        the list of URLs where the file
                   6014:        <code class="filename"><em class="replaceable"><code>distfile</code></em></code>
                   6015:        (including the suffix) can be found.</p>
                   6016: <pre class="programlisting">
                   6017:     DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   6018:     DISTFILES+=     foo-file.tar.gz
                   6019:     SITES.foo-file.tar.gz= \
                   6020:             http://www.somewhere.com/somehow/ \
                   6021:             http://www.somewhereelse.com/mirror/somehow/
                   6022: </pre>
                   6023: <p>When actually fetching the distfiles, each item from
                   6024:        <code class="varname">MASTER_SITES</code> or <code class="varname">SITES.*</code>
                   6025:        gets the name of each distfile appended to it, without an
                   6026:        intermediate slash. Therefore, all site values have to end with
                   6027:        a slash or other separator character. This allows for example to
                   6028:        set <code class="varname">MASTER_SITES</code> to a URL of a CGI script
                   6029:        that gets the name of the distfile as a parameter. In this case,
                   6030:        the definition would look like:</p>
                   6031: <pre class="programlisting">
                   6032:     MASTER_SITES=   http://www.example.com/download.cgi?file=
                   6033: </pre>
                   6034: <p>There are some predefined values for
                   6035:        <code class="varname">MASTER_SITES</code>, which can be used in packages.
                   6036:        The names of the variables should speak for themselves.</p>
                   6037: <pre class="programlisting">
                   6038:     ${MASTER_SITE_APACHE}
                   6039:     ${MASTER_SITE_BACKUP}
                   6040:     ${MASTER_SITE_CYGWIN}
                   6041:     ${MASTER_SITE_DEBIAN}
                   6042:     ${MASTER_SITE_FREEBSD}
                   6043:     ${MASTER_SITE_FREEBSD_LOCAL}
                   6044:     ${MASTER_SITE_GNOME}
                   6045:     ${MASTER_SITE_GNU}
                   6046:     ${MASTER_SITE_GNUSTEP}
                   6047:     ${MASTER_SITE_IFARCHIVE}
                   6048:     ${MASTER_SITE_KDE}
                   6049:     ${MASTER_SITE_MOZILLA}
                   6050:     ${MASTER_SITE_MYSQL}
                   6051:     ${MASTER_SITE_OPENOFFICE}
                   6052:     ${MASTER_SITE_PERL_CPAN}
                   6053:     ${MASTER_SITE_PGSQL}
                   6054:     ${MASTER_SITE_R_CRAN}
                   6055:     ${MASTER_SITE_SOURCEFORGE}
                   6056:     ${MASTER_SITE_SOURCEFORGE_JP}
                   6057:     ${MASTER_SITE_SUNSITE}
                   6058:     ${MASTER_SITE_SUSE}
                   6059:     ${MASTER_SITE_TEX_CTAN}
                   6060:     ${MASTER_SITE_XCONTRIB}
                   6061:     ${MASTER_SITE_XEMACS}
                   6062: </pre>
                   6063: <p>If you choose one of these predefined sites, you may want
                   6064:        to specify a subdirectory of that site. Since these macros may
                   6065:        expand to more than one actual site, you
                   6066:        <span class="emphasis"><em>must</em></span> use the following construct to specify
                   6067:        a subdirectory:</p>
                   6068: <pre class="programlisting">
                   6069:     MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   6070:     MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
                   6071: </pre>
                   6072: <p>Note the trailing slash after the subdirectory
                   6073:        name.</p>
                   6074: </div>
                   6075: <div class="sect2" lang="en">
                   6076: <div class="titlepage"><div><div><h3 class="title">
                   6077: <a name="build.fetch.how"></a>15.5.2. How are the files fetched?</h3></div></div></div>
                   6078: <p>The <span class="emphasis"><em>fetch</em></span> phase makes sure that all
                   6079:        the distfiles exist in a local directory
                   6080:        (<code class="varname">DISTDIR</code>), which can be set by the pkgsrc
                   6081:        user). If the files do not exist, they are fetched using
                   6082:        commands of the form
                   6083: 
                   6084: </p>
1.75      rillig   6085: <pre class="programlisting">
                   6086:     ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
                   6087: </pre>
1.81      rillig   6088: <p>
                   6089: 
                   6090:        where <code class="literal">${site}</code> varies through several
                   6091:        possibilities in turn: first,
                   6092:        <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the sites
                   6093:        specified in either <code class="varname">SITES.file</code> if defined,
                   6094:        else <code class="varname">MASTER_SITES</code> or
                   6095:        <code class="varname">PATCH_SITES</code>, as applies, then finally the
                   6096:        value of <code class="varname">MASTER_SITE_BACKUP</code>. The order of all
                   6097:        except the first can be optionally sorted by the user, via
                   6098:        setting either <code class="varname">MASTER_SORT_AWK</code> or
                   6099:        <code class="varname">MASTER_SORT_REGEX</code>.</p>
                   6100: </div>
1.75      rillig   6101: </div>
                   6102: <div class="sect1" lang="en">
                   6103: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6104: <a name="build.checksum"></a>15.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.75      rillig   6105: <p>After the distfile(s) are fetched, their checksum is generated and
                   6106:            compared with the checksums stored in the distinfo file. If the
                   6107:            checksums don't match, the build is aborted. This is to ensure the same
                   6108:            distfile is used for building, and that the distfile wasn't changed,
                   6109:            e.g. by some malign force, deliberately changed distfiles on the master
                   6110:            distribution site or network lossage.</p>
                   6111: </div>
                   6112: <div class="sect1" lang="en">
                   6113: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6114: <a name="build.extract"></a>15.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75      rillig   6115: <p>When the distfiles are present on the local system, they
                   6116:        need to be extracted, as they usually come in the form of some
                   6117:        compressed archive format.</p>
                   6118: <p>By default, all <code class="varname">DISTFILES</code> are
                   6119:        extracted. If you only need some of them, you can set the
                   6120:        <code class="varname">EXTRACT_ONLY</code> variable to the list of those
                   6121:        files.</p>
                   6122: <p>Extracting the files is usually done by a little program,
1.76      rillig   6123:        <code class="filename">mk/scripts/extract</code>, which already knows how
1.75      rillig   6124:        to extract various archive formats, so most likely you will not
                   6125:        need to change anything here. But if you need, the following
                   6126:        variables may help you:</p>
                   6127: <div class="variablelist"><dl>
                   6128: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
                   6129: <dd><p>Use these variables to override the default
                   6130:        options for an extract command, which are defined in
1.76      rillig   6131:        <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75      rillig   6132: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
                   6133: <dd><p>This variable can be set to
                   6134:        <code class="literal">pax</code>, <code class="literal">tar</code> or an absolute
                   6135:        pathname pointing to the command with which tar archives should
                   6136:        be extracted.</p></dd>
                   6137: </dl></div>
1.76      rillig   6138: <p>If the <code class="filename">extract</code> program doesn't serve
1.75      rillig   6139:        your needs, you can also override the
                   6140:        <code class="varname">EXTRACT_CMD</code> variable, which holds the command
                   6141:        used for extracting the files. This command is executed in the
1.76      rillig   6142:        <code class="filename">${WRKSRC}</code> directory. During execution of
1.75      rillig   6143:        this command, the shell variable <code class="varname">extract_file</code>
                   6144:        holds the absolute pathname of the file that is going to be
                   6145:        extracted.</p>
                   6146: <p>And if that still does not suffice, you can override the
                   6147:        <code class="varname">do-extract</code> target in the package
                   6148:        Makefile.</p>
                   6149: </div>
                   6150: <div class="sect1" lang="en">
                   6151: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6152: <a name="build.patch"></a>15.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75      rillig   6153: <p>After extraction, all the patches named by the
                   6154:            <code class="varname">PATCHFILES</code>, those present in the patches
                   6155:            subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
1.76      rillig   6156:            <code class="filename">/usr/local/patches/graphics/png</code>) are applied.
                   6157:            Patchfiles ending in <code class="filename">.Z</code> or
                   6158:            <code class="filename">.gz</code> are uncompressed before they are applied,
                   6159:            files ending in <code class="filename">.orig</code> or
                   6160:            <code class="filename">.rej</code> are ignored. Any special options to <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>
1.75      rillig   6161:            can be handed in <code class="varname">PATCH_DIST_ARGS</code>.
1.77      rillig   6162:            See <a href="#components.patches" title="9.3. patches/*">Section 9.3, &#8220;patches/*&#8221;</a> for more details.</p>
1.75      rillig   6163: <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 it fail if the
                   6164:            patches apply with some lines of fuzz. Please fix (regen) the patches
                   6165:            so that they apply cleanly. The rationale behind this is that
                   6166:            patches that don't apply cleanly may end up being applied in the wrong
                   6167:            place, and cause severe harm there.</p>
                   6168: </div>
                   6169: <div class="sect1" lang="en">
                   6170: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6171: <a name="build.tools"></a>15.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.75      rillig   6172: <p>This is covered in
1.77      rillig   6173: <a href="#tools" title="Chapter 16. Tools needed for building or running">Chapter 16, <i>Tools needed for building or running</i></a>.
1.75      rillig   6174: </p>
                   6175: </div>
                   6176: <div class="sect1" lang="en">
                   6177: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6178: <a name="build.wrapper"></a>15.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75      rillig   6179: <p>This phase creates wrapper programs for the compilers and
                   6180:        linkers. The following variables can be used to tweak the
                   6181:        wrappers.</p>
                   6182: <div class="variablelist"><dl>
                   6183: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
                   6184: <dd><p>The command used to print progress
                   6185:                messages. Does nothing by default. Set to
                   6186:                <code class="literal">${ECHO}</code> to see the progress
                   6187:                messages.</p></dd>
                   6188: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
                   6189: <dd><p>This variable can be set to
                   6190:                <code class="literal">yes</code> (default) or
                   6191:                <code class="literal">no</code>, depending on whether you want
                   6192:                additional information in the wrapper log
                   6193:                file.</p></dd>
                   6194: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
                   6195: <dd><p>This variable can be set to
                   6196:                <code class="literal">yes</code> or <code class="literal">no</code>,
                   6197:                depending on whether the wrapper should use its cache,
                   6198:                which will improve the speed. The default value is
                   6199:                <code class="literal">yes</code>, but is forced to
                   6200:                <code class="literal">no</code> if the platform does not support
                   6201:                it.</p></dd>
                   6202: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
                   6203: <dd><p>A list of reordering commands. A
                   6204:                reordering command has the form
                   6205:                <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
                   6206:                It ensures that that
                   6207:                <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code>
                   6208:                occurs before
                   6209:                <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
                   6210:                </p></dd>
                   6211: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
                   6212: <dd><p>A list of transformation commands. [TODO:
                   6213:                investigate further]</p></dd>
                   6214: </dl></div>
                   6215: </div>
                   6216: <div class="sect1" lang="en">
                   6217: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6218: <a name="build.configure"></a>15.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75      rillig   6219: <p>Most pieces of software need information on the header files,
                   6220: system calls, and library routines which are available on the platform
                   6221: they run on. The process of determining this information is known as
                   6222: configuration, and is usually automated. In most cases, a script is
                   6223: supplied with the distfiles, and its invocation results in generation of
                   6224: header files, Makefiles, etc.</p>
                   6225: <p>If the package contains a configure script, this can be invoked by
                   6226: setting <code class="varname">HAS_CONFIGURE</code> to &#8220;<span class="quote">yes</span>&#8221;. If the
                   6227: configure script is a GNU autoconf script, you should set
                   6228: <code class="varname">GNU_CONFIGURE</code> to &#8220;<span class="quote">yes</span>&#8221; instead. What
                   6229: happens in the <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
                   6230: <pre class="programlisting">
                   6231:     .for d in ${CONFIGURE_DIRS}
                   6232:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${CONFIGURE_ENV} \
                   6233:                 ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
                   6234:     .endfor
                   6235: </pre>
                   6236: <p><code class="varname">CONFIGURE_DIRS</code> (default: &#8220;<span class="quote">.</span>&#8221;) is a
                   6237: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
                   6238: these directories, the configure script is run with the environment
                   6239: <code class="varname">CONFIGURE_ENV</code> and arguments
                   6240: <code class="varname">CONFIGURE_ARGS</code>. The variables
                   6241: <code class="varname">CONFIGURE_ENV</code>, <code class="varname">CONFIGURE_SCRIPT</code>
                   6242: (default: &#8220;<span class="quote">./configure</span>&#8221;) and
                   6243: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
                   6244: package.</p>
1.76      rillig   6245: <p>If the program uses an <code class="filename">Imakefile</code> for
1.75      rillig   6246: configuration, the appropriate steps can be invoked by setting
                   6247: <code class="varname">USE_IMAKE</code> to &#8220;<span class="quote">yes</span>&#8221;. (If you only want
                   6248: the package installed in <code class="varname">${X11PREFIX}</code> but xmkmf not
                   6249: being run, set <code class="varname">USE_X11BASE</code> instead.)</p>
                   6250: </div>
                   6251: <div class="sect1" lang="en">
                   6252: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6253: <a name="build.build"></a>15.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.75      rillig   6254: <p>For building a package, a rough equivalent of the following code
                   6255: is executed.</p>
                   6256: <pre class="programlisting">
                   6257:     .for d in ${BUILD_DIRS}
                   6258:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${MAKE_ENV} \
                   6259:                 ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
1.87    ! wiz      6260:                     -f ${MAKE_FILE} ${BUILD_TARGET}
1.75      rillig   6261:     .endfor
                   6262: </pre>
                   6263: <p><code class="varname">BUILD_DIRS</code> (default: &#8220;<span class="quote">.</span>&#8221;) is a
                   6264: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
                   6265: these directories, <code class="varname">MAKE_PROGRAM</code> is run with the
                   6266: environment <code class="varname">MAKE_ENV</code> and arguments
                   6267: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
                   6268: <code class="varname">MAKE_ENV</code>, <code class="varname">BUILD_MAKE_FLAGS</code>,
1.87    ! wiz      6269: <code class="varname">MAKE_FILE</code> and <code class="varname">BUILD_TARGET</code> may all
1.75      rillig   6270: be changed by the package.</p>
                   6271: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
                   6272: &#8220;<span class="quote">gmake</span>&#8221; if <code class="varname">USE_TOOLS</code> contains
                   6273: &#8220;<span class="quote">gmake</span>&#8221;, &#8220;<span class="quote">make</span>&#8221; otherwise. The default value
1.87    ! wiz      6274: of <code class="varname">MAKE_FILE</code> is &#8220;<span class="quote">Makefile</span>&#8221;, and
1.75      rillig   6275: <code class="varname">BUILD_TARGET</code> defaults to &#8220;<span class="quote">all</span>&#8221;.</p>
                   6276: </div>
                   6277: <div class="sect1" lang="en">
                   6278: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6279: <a name="build.test"></a>15.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75      rillig   6280: <p>[TODO]</p>
                   6281: </div>
                   6282: <div class="sect1" lang="en">
                   6283: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6284: <a name="build.install"></a>15.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75      rillig   6285: <p>Once the build stage has completed, the final step is to
                   6286:        install the software in public directories, so users can access
                   6287:        the programs and files.</p>
                   6288: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
                   6289:        equivalent of the following code is executed. Additionally,
                   6290:        before and after this code, much magic is performed to do
                   6291:        consistency checks, registering the package, and so on.</p>
                   6292: <pre class="programlisting">
                   6293:     .for d in ${INSTALL_DIRS}
                   6294:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${MAKE_ENV} \
                   6295:                 ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
1.87    ! wiz      6296:                     -f ${MAKE_FILE} ${BUILD_TARGET}
1.75      rillig   6297:     .endfor
                   6298: </pre>
                   6299: <p>The variable's meanings are analogous to the ones in the
                   6300:        <span class="emphasis"><em>build</em></span> phase.
                   6301:        <code class="varname">INSTALL_DIRS</code> defaults to
                   6302:        <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
                   6303:        is &#8220;<span class="quote">install</span>&#8221; by default, plus
                   6304:        &#8220;<span class="quote">install.man</span>&#8221; if <code class="varname">USE_IMAKE</code> is
                   6305:        defined.</p>
                   6306: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
                   6307:        variables are useful. They are all variations of the
                   6308:        <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
                   6309:        permissions preset. <code class="varname">INSTALL</code> is the plain
                   6310:        install command. The specialized variants, together with their
                   6311:        intended use, are:</p>
                   6312: <div class="variablelist"><dl>
                   6313: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
                   6314: <dd><p>directories that contain binaries</p></dd>
                   6315: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
                   6316: <dd><p>directories that contain scripts</p></dd>
                   6317: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
                   6318: <dd><p>directories that contain shared and static libraries</p></dd>
                   6319: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
                   6320: <dd><p>directories that contain data files</p></dd>
                   6321: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
                   6322: <dd><p>directories that contain man pages</p></dd>
                   6323: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
                   6324: <dd><p>binaries that can be stripped from debugging symbols</p></dd>
                   6325: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
                   6326: <dd><p>binaries that cannot be stripped</p></dd>
                   6327: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
                   6328: <dd><p>game binaries</p></dd>
                   6329: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
                   6330: <dd><p>shared and static libraries</p></dd>
                   6331: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
                   6332: <dd><p>data files</p></dd>
                   6333: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
                   6334: <dd><p>data files for games</p></dd>
                   6335: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
                   6336: <dd><p>man pages</p></dd>
                   6337: </dl></div>
                   6338: <p>Some other variables are:</p>
                   6339: <div class="variablelist"><dl>
                   6340: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
                   6341: <dd><p>A list of directories relative to
                   6342:                <code class="varname">PREFIX</code> that are created by pkgsrc at
1.78      rillig   6343:                the beginning of the <span class="emphasis"><em>install</em></span> phase.
                   6344:                If this variable is set,
1.75      rillig   6345:                <code class="varname">NO_MTREE</code>=&#8220;<span class="quote">yes</span>&#8221; is
                   6346:                assumed, which means that the package claims to create
                   6347:                all needed directories itself before installing files to
                   6348:                it. Therefore this variable should only be set in
1.76      rillig   6349:                <code class="filename">Makefile</code>s that are under control of
1.78      rillig   6350:                the package's author. The directories are created with
                   6351:                the correct ownership, depending on their
                   6352:                name.</p></dd>
1.75      rillig   6353: </dl></div>
                   6354: </div>
                   6355: <div class="sect1" lang="en">
                   6356: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6357: <a name="build.package"></a>15.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.75      rillig   6358: <p>[TODO]</p>
                   6359: </div>
                   6360: <div class="sect1" lang="en">
                   6361: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6362: <a name="build.helpful-targets"></a>15.16. Other helpful targets</h2></div></div></div>
1.75      rillig   6363: <div class="variablelist"><dl>
                   6364: <dt><span class="term">pre/post-*</span></dt>
1.87    ! wiz      6365: <dd><p>For any of the main targets described in the previous
        !          6366:          section, two auxiliary targets exist with
        !          6367:          &#8220;<span class="quote">pre-</span>&#8221; and &#8220;<span class="quote">post-</span>&#8221; used as a
        !          6368:          prefix for the main target's name.  These targets are
        !          6369:          invoked before and after the main target is called, allowing
        !          6370:          extra configuration or installation steps be performed from
        !          6371:          a package's Makefile, for example, which a program's
        !          6372:          configure script or install target omitted.</p></dd>
1.75      rillig   6373: <dt><span class="term">do-*</span></dt>
1.87    ! wiz      6374: <dd><p>Should one of the main targets do the wrong thing, and
        !          6375:          should there be no variable to fix this, you can redefine it
        !          6376:          with the do-* target.  (Note that redefining the target
        !          6377:          itself instead of the do-* target is a bad idea, as the
        !          6378:          pre-* and post-* targets won't be called anymore, etc.) You
        !          6379:          will not usually need to do this.</p></dd>
1.75      rillig   6380: <dt><span class="term">reinstall</span></dt>
1.87    ! wiz      6381: <dd><p>If you did a <span><strong class="command">make install</strong></span> and you
        !          6382:          noticed some file was not installed properly, you can repeat
        !          6383:          the installation with this target, which will ignore the
        !          6384:          &#8220;<span class="quote">already installed</span>&#8221; flag.</p></dd>
1.75      rillig   6385: <dt><span class="term">deinstall</span></dt>
                   6386: <dd>
                   6387: <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 current directory,
1.87    ! wiz      6388:          effectively de-installing the package. The following variables can
        !          6389:          be used to tune the behaviour:</p>
1.75      rillig   6390: <div class="variablelist"><dl>
                   6391: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
                   6392: <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>
                   6393: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
                   6394: <dd><p>Remove all packages that require (depend on) the given package.
1.87    ! wiz      6395:                This can be used to remove any packages that may have been pulled in
        !          6396:                by a given package, e.g. if <span><strong class="command">make deinstall
        !          6397:                DEINSTALLDEPENDS=1</strong></span> is done in
        !          6398:                <code class="filename">pkgsrc/x11/kde</code>, this is likely to remove whole
        !          6399:                KDE. Works by adding &#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> command line.</p></dd>
1.75      rillig   6400: </dl></div>
                   6401: </dd>
                   6402: <dt><span class="term">update</span></dt>
                   6403: <dd>
                   6404: <p>This target causes the current package to be updated to the latest
1.87    ! wiz      6405:          version.  The package and all depending packages first get de-installed,
        !          6406:          then current versions of the corresponding packages get compiled and
        !          6407:          installed.  This is similar to manually noting which packages are
        !          6408:          currently installed, then performing a series of <span><strong class="command">make
        !          6409:          deinstall</strong></span> and <span><strong class="command">make install</strong></span> (or whatever
        !          6410:          <code class="varname">UPDATE_TARGET</code> is set to) for these packages.</p>
1.75      rillig   6411: <p>You can use the &#8220;<span class="quote">update</span>&#8221; target to resume package
1.87    ! wiz      6412:          updating in case a previous <span><strong class="command">make update</strong></span> was interrupted
        !          6413:          for some reason.  However, in this case, make sure you don't call
        !          6414:          <span><strong class="command">make clean</strong></span> or otherwise remove the list of dependent
        !          6415:          packages in <code class="varname">WRKDIR</code>.  Otherwise, you lose the
        !          6416:          ability to automatically update the current package along with the
        !          6417:          dependent packages you have installed.</p>
1.75      rillig   6418: <p>Resuming an interrupted <span><strong class="command">make update</strong></span> will only work as
1.87    ! wiz      6419:          long as the package tree remains unchanged.  If the source code for
        !          6420:          one of the packages to be updated has been changed, resuming
        !          6421:          <span><strong class="command">make update</strong></span> will most certainly fail!</p>
1.75      rillig   6422: <p>The following variables can be used either on the command line or in
1.87    ! wiz      6423:          <code class="filename">/etc/mk.conf</code> to alter the behaviour of
        !          6424:          <span><strong class="command">make update</strong></span>:</p>
1.75      rillig   6425: <div class="variablelist"><dl>
                   6426: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
                   6427: <dd><p>Install target to recursively use for the updated package and the
1.87    ! wiz      6428:                dependent packages.  Defaults to <code class="varname">DEPENDS_TARGET</code> if set,
        !          6429:                &#8220;<span class="quote">install</span>&#8221; otherwise for <span><strong class="command">make update</strong></span>.
        !          6430:                e.g. <span><strong class="command">make update UPDATE_TARGET=package</strong></span></p></dd>
1.75      rillig   6431: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
                   6432: <dd><p>Don't clean up after updating.  Useful if you want to leave the
1.87    ! wiz      6433:                work sources of the updated packages around for inspection or
        !          6434:                other purposes.  Be sure you eventually clean up the source
        !          6435:                tree (see the &#8220;<span class="quote">clean-update</span>&#8221; target below) or you may
        !          6436:                run into troubles with old source code still lying around on your
        !          6437:                next <span><strong class="command">make</strong></span> or <span><strong class="command">make update</strong></span>.</p></dd>
1.75      rillig   6438: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
                   6439: <dd><p>Deinstall each package before installing (making
1.87    ! wiz      6440:                <code class="varname">DEPENDS_TARGET</code>). This may be necessary if the
        !          6441:                &#8220;<span class="quote">clean-update</span>&#8221; target (see below) was called after
        !          6442:                interrupting a running <span><strong class="command">make update</strong></span>.</p></dd>
1.75      rillig   6443: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
                   6444: <dd><p>Allows you to disable recursion and hardcode the target for
1.87    ! wiz      6445:                packages.  The default is &#8220;<span class="quote">update</span>&#8221; for the update target,
        !          6446:                facilitating a recursive update of prerequisite packages.
        !          6447:                Only set <code class="varname">DEPENDS_TARGET</code> if you want to disable
        !          6448:                recursive updates. Use <code class="varname">UPDATE_TARGET</code> instead to just
        !          6449:                set a specific target for each package to be installed during
        !          6450:                <span><strong class="command">make update</strong></span> (see above).</p></dd>
1.75      rillig   6451: </dl></div>
                   6452: </dd>
                   6453: <dt><span class="term">clean-update</span></dt>
                   6454: <dd>
                   6455: <p>Clean the source tree for all packages that would get updated if
1.87    ! wiz      6456:          <span><strong class="command">make update</strong></span> was called from the current directory.
        !          6457:          This target should not be used if the current package (or any of its
        !          6458:          depending packages) have already been de-installed (e.g., after calling
        !          6459:          <span><strong class="command">make update</strong></span>) or you may lose some packages you intended
        !          6460:          to update. As a rule of thumb: only use this target
        !          6461:          <span class="emphasis"><em>before</em></span> the first time you run
        !          6462:          <span><strong class="command">make update</strong></span> and only if you have a dirty package tree
        !          6463:          (e.g., if you used <code class="varname">NOCLEAN</code>).</p>
1.75      rillig   6464: <p>If you are unsure about whether your tree is clean, you can either
1.87    ! wiz      6465:          perform a <span><strong class="command">make clean</strong></span> at the top of the tree, or use
        !          6466:          the following sequence of commands from the directory of the package
        !          6467:          you want to update (<span class="emphasis"><em>before</em></span> running
        !          6468:          <span><strong class="command">make update</strong></span> for the first time, otherwise you lose
        !          6469:          all the packages you wanted to update!):</p>
        !          6470: <pre class="screen">
        !          6471: <code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
1.75      rillig   6472: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
1.87    ! wiz      6473: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong>
        !          6474:          </pre>
1.75      rillig   6475: <p>The following variables can be used either on the command line or in
1.87    ! wiz      6476:          <code class="filename">/etc/mk.conf</code> to alter the behaviour of
        !          6477:          <span><strong class="command">make clean-update</strong></span>:</p>
1.75      rillig   6478: <div class="variablelist"><dl>
                   6479: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
                   6480: <dd><p>After <span><strong class="command">make clean</strong></span>, do not reconstruct the list of
1.87    ! wiz      6481:                directories to update for this package.  Only use this if <span><strong class="command">make
        !          6482:                update</strong></span> successfully installed all packages you wanted to
        !          6483:                update.  Normally, this is done automatically on <span><strong class="command">make
        !          6484:                update</strong></span>, but may have been suppressed by the
        !          6485:                <code class="varname">NOCLEAN</code> variable (see above).</p></dd>
1.75      rillig   6486: </dl></div>
                   6487: </dd>
                   6488: <dt><span class="term">info</span></dt>
                   6489: <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.87    ! wiz      6490:          package. You can use this to check which version of a package is
        !          6491:          installed.</p></dd>
1.75      rillig   6492: <dt><span class="term">readme</span></dt>
1.76      rillig   6493: <dd><p>This target generates a <code class="filename">README.html</code> file, which
1.75      rillig   6494:            can be viewed using a browser such as
1.83      wiz      6495:            <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> or
1.76      rillig   6496:            <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/links/README.html" target="_top"><code class="filename">www/links</code></a>.
1.75      rillig   6497:            The generated files contain references to any
                   6498:            packages which are in the <code class="varname">PACKAGES</code> directory on
                   6499:            the local host. The generated files can be made to refer to URLs based on
                   6500:            <code class="varname">FTP_PKG_URL_HOST</code> and
                   6501:            <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I wanted to generate
1.76      rillig   6502:            <code class="filename">README.html</code> files which pointed to binary packages
1.75      rillig   6503:            on the local machine, in the directory
1.76      rillig   6504:            <code class="filename">/usr/packages</code>, set
1.75      rillig   6505:            <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
                   6506:            <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
                   6507:            <code class="varname">${PACKAGES}</code> directory and its subdirectories will be
                   6508:            searched for all the binary packages.</p></dd>
                   6509: <dt><span class="term">readme-all</span></dt>
1.76      rillig   6510: <dd><p>Use this target to create a file <code class="filename">README-all.html</code>
1.87    ! wiz      6511:          which contains a list of all packages currently available in the NetBSD
        !          6512:          Packages Collection, together with the category they belong to and a
        !          6513:          short description. This file is compiled from the
        !          6514:          <code class="filename">pkgsrc/*/README.html</code> files, so be sure to run
        !          6515:          this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make readme</strong></span>.</p></dd>
1.75      rillig   6516: <dt><span class="term">cdrom-readme</span></dt>
                   6517: <dd><p>This is very much the same as the &#8220;<span class="quote">readme</span>&#8221; target (see
1.87    ! wiz      6518:          above), but is to be used when generating a pkgsrc tree to be written
        !          6519:          to a CD-ROM.  This target also produces
        !          6520:          <code class="filename">README.html</code> files, and can be made to refer
        !          6521:          to URLs based on <code class="varname">CDROM_PKG_URL_HOST</code> and
        !          6522:          <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
1.75      rillig   6523: <dt><span class="term">show-distfiles</span></dt>
1.87    ! wiz      6524: <dd><p>This target shows which distfiles and patchfiles are
        !          6525:          needed to build the package (<code class="varname">ALLFILES</code>,
        !          6526:          which contains all <code class="varname">DISTFILES</code> and
        !          6527:          <code class="varname">PATCHFILES</code>, but not
        !          6528:          <code class="filename">patches/*</code>).</p></dd>
1.75      rillig   6529: <dt><span class="term">show-downlevel</span></dt>
                   6530: <dd><p>This target shows nothing if the package is not installed. If a version
1.87    ! wiz      6531:          of this package is installed, but is not the version provided in this
        !          6532:          version of pkgsrc, then a warning message is displayed. This target can
        !          6533:          be used to show which of your installed packages are downlevel, and so
        !          6534:          the old versions can be deleted, and the current ones added.</p></dd>
1.75      rillig   6535: <dt><span class="term">show-pkgsrc-dir</span></dt>
                   6536: <dd><p>This target shows the directory in the pkgsrc hierarchy from which the
1.87    ! wiz      6537:          package can be built and installed. This may not be the same directory
        !          6538:          as the one from which the package was installed. This target is intended
        !          6539:          to be used by people who may wish to upgrade many packages on a single
        !          6540:          host, and can be invoked from the top-level pkgsrc Makefile by using the
        !          6541:          &#8220;<span class="quote">show-host-specific-pkgs</span>&#8221; target.</p></dd>
1.75      rillig   6542: <dt><span class="term">show-installed-depends</span></dt>
                   6543: <dd><p>This target shows which installed packages match the current package's
1.87    ! wiz      6544:          <code class="varname">DEPENDS</code>. Useful if out of date dependencies are
        !          6545:          causing build problems.</p></dd>
1.75      rillig   6546: <dt><span class="term">check-shlibs</span></dt>
                   6547: <dd><p>After a package is installed, check all its binaries and (on ELF
1.87    ! wiz      6548:          platforms) shared libraries to see if they find the shared libs they need.
        !          6549:          Run by default if <code class="varname">PKG_DEVELOPER</code> is set in
        !          6550:          <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75      rillig   6551: <dt><span class="term">print-PLIST</span></dt>
                   6552: <dd>
                   6553: <p>After a &#8220;<span class="quote">make install</span>&#8221; from a new or
1.87    ! wiz      6554:          upgraded pkg, this prints out an attempt to generate a new
        !          6555:          <code class="filename">PLIST</code> from a <span><strong class="command">find -newer
        !          6556:          work/.extract_done</strong></span>.  An attempt is made to care
        !          6557:          for shared libs etc., but it is
        !          6558:          <span class="emphasis"><em>strongly</em></span> recommended to review the
        !          6559:          result before putting it into
        !          6560:          <code class="filename">PLIST</code>. On upgrades, it's useful to
        !          6561:          diff the output of this command against an already
        !          6562:          existing <code class="filename">PLIST</code> file.</p>
1.75      rillig   6563: <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 other
1.87    ! wiz      6564:          methods that don't update file access times, be sure to
        !          6565:          add these files manually to your
        !          6566:          <code class="filename">PLIST</code>, as the &#8220;<span class="quote">find
        !          6567:          -newer</span>&#8221; command used by this target won't catch
        !          6568:          them!</p>
        !          6569: <p>See <a href="#print-PLIST" title="11.3. Tweaking output of make print-PLIST">Section 11.3, &#8220;Tweaking output of <span><strong class="command">make print-PLIST</strong></span>&#8221;</a> for more
        !          6570:          information on this target.</p>
1.75      rillig   6571: </dd>
                   6572: <dt><span class="term">bulk-package</span></dt>
                   6573: <dd>
                   6574: <p>Used to do bulk builds. If an appropriate binary package already exists,
1.87    ! wiz      6575:          no action is taken. If not, this target will compile, install and
        !          6576:          package it (and its depends, if <code class="varname">PKG_DEPENDS</code> is
        !          6577:          set properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, &#8220;Configuration&#8221;</a>).
        !          6578:          After creating the binary
        !          6579:          package, the sources, the just-installed package and its required
        !          6580:          packages are removed, preserving free disk space.</p>
1.75      rillig   6581: <p><span class="emphasis"><em>Beware that this target may deinstall all
1.87    ! wiz      6582:          packages installed on a system!</em></span></p>
1.75      rillig   6583: </dd>
                   6584: <dt><span class="term">bulk-install</span></dt>
                   6585: <dd>
                   6586: <p>Used during bulk-installs to install required packages. If an
1.87    ! wiz      6587:          up-to-date binary package is available, it will be installed via
        !          6588:          <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, <span><strong class="command">make bulk-package</strong></span> will be executed,
        !          6589:          but the installed binary won't be removed.</p>
        !          6590: <p>A binary package is considered &#8220;<span class="quote">up-to-date</span>&#8221; to be
        !          6591:          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:</p>
1.75      rillig   6592: <div class="itemizedlist"><ul type="disc">
1.76      rillig   6593: <li><p>None of the package's files (<code class="filename">Makefile</code>,
1.87    ! wiz      6594:              ...) were modified since it was built.</p></li>
1.75      rillig   6595: <li><p>None of the package's required (binary) packages were
1.87    ! wiz      6596:              modified since it was built.</p></li>
1.75      rillig   6597: </ul></div>
                   6598: <p><span class="emphasis"><em>Beware that this target may deinstall all
1.87    ! wiz      6599:          packages installed on a system!</em></span></p>
1.75      rillig   6600: </dd>
                   6601: </dl></div>
                   6602: </div>
                   6603: </div>
                   6604: <div class="chapter" lang="en">
                   6605: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   6606: <a name="tools"></a>Chapter 16. Tools needed for building or running</h2></div></div></div>
1.75      rillig   6607: <div class="toc">
                   6608: <p><b>Table of Contents</b></p>
                   6609: <dl>
1.77      rillig   6610: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
                   6611: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
                   6612: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
1.75      rillig   6613: </dl>
                   6614: </div>
1.87    ! wiz      6615: <p>The <code class="varname">USE_TOOLS</code> definition is used both internally
1.75      rillig   6616: by pkgsrc and also for individual packages to define what commands
                   6617: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
                   6618: or for later run-time of an installed packaged (such as
                   6619: <code class="varname">DEPENDS</code>).
                   6620: If the native system provides an adequate tool, then in many cases, a pkgsrc
1.87    ! wiz      6621: package will not be used.</p>
        !          6622: <p>When building a package, the replacement tools are
1.75      rillig   6623: made available in a directory (as symlinks or wrapper scripts)
                   6624: that is early in the executable search path. Just like the buildlink
1.87    ! wiz      6625: system, this helps with consistent builds.</p>
        !          6626: <p>A tool may be needed to help build a specific package. For example,
        !          6627: perl, GNU make (gmake) or yacc may be needed.</p>
        !          6628: <p>Also a tool may be needed, for example, because the native system's supplied
1.75      rillig   6629: tool may be inefficient for building a package with pkgsrc.
                   6630: For example, a package may need GNU awk, bison (instead of
1.87    ! wiz      6631: yacc) or a better sed.</p>
        !          6632: <p>The tools used by a package can be listed by running
        !          6633: <span><strong class="command">make show-tools</strong></span>.</p>
1.75      rillig   6634: <div class="sect1" lang="en">
                   6635: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6636: <a name="pkgsrc-tools"></a>16.1. Tools for pkgsrc builds</h2></div></div></div>
1.87    ! wiz      6637: <p>The default set of tools used by pkgsrc is defined in
1.76      rillig   6638: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75      rillig   6639: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
                   6640: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
                   6641: These can be seen by running:
1.87    ! wiz      6642: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.</p>
        !          6643: <p>If a package needs a specific program to build
1.75      rillig   6644: then the <code class="varname">USE_TOOLS</code> variable can be used
1.87    ! wiz      6645: to define the tools needed.</p>
1.75      rillig   6646: </div>
                   6647: <div class="sect1" lang="en">
                   6648: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6649: <a name="package-tools"></a>16.2. Tools needed by packages</h2></div></div></div>
1.87    ! wiz      6650: <p>In the following examples, the :pkgsrc means to use the pkgsrc version
1.75      rillig   6651: and not the native version for a build dependency.
                   6652: And the :run means that it is used for a
                   6653: run-time dependencies also (and becomes a DEPENDS).
                   6654: The default is a build dependency which can be set with
                   6655: :build. (So in this example, it is the same as gmake:build
1.87    ! wiz      6656: and pkg-config:build.)</p>
1.75      rillig   6657: <pre class="programlisting">
                   6658: USE_TOOLS+=     mktemp:pkgsrc
                   6659: USE_TOOLS+=     gmake perl:run pkg-config
                   6660: </pre>
1.87    ! wiz      6661: <p>When using the tools framework, a
1.75      rillig   6662: <code class="varname">TOOLS_PATH.foo</code> variable is defined
                   6663: which contains the full path to the appropriate tool. For example,
                   6664: <code class="varname">TOOLS_PATH.bash</code> could be &#8220;<span class="quote">/bin/bash</span>&#8221;
1.87    ! wiz      6665: on Linux systems.</p>
        !          6666: <p>If you always need a pkgsrc version of the
1.75      rillig   6667: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
                   6668: </p>
                   6669: </div>
                   6670: <div class="sect1" lang="en">
                   6671: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6672: <a name="platform-tools"></a>16.3. Tools provided by platforms</h2></div></div></div>
1.87    ! wiz      6673: <p>When improving or porting pkgsrc to a new platform, have a look
1.75      rillig   6674: at (or create) the corresponding platform specific make file fragment under
1.76      rillig   6675: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75      rillig   6676: the name of the common tools. For example:</p>
                   6677: <pre class="programlisting">
                   6678: .if exists(/usr/bin/bzcat)
                   6679: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   6680: .elif exists(/usr/bin/bzip2)
                   6681: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   6682: .endif
1.69      rillig   6683: 
1.75      rillig   6684: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   6685: </pre>
                   6686: </div>
                   6687: </div>
                   6688: <div class="chapter" lang="en">
                   6689: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   6690: <a name="fixes"></a>Chapter 17. Making your package work</h2></div></div></div>
1.75      rillig   6691: <div class="toc">
                   6692: <p><b>Table of Contents</b></p>
                   6693: <dl>
1.77      rillig   6694: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
1.75      rillig   6695: <dd><dl>
1.78      rillig   6696: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
                   6697: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">17.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
                   6698: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
                   6699: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
                   6700: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
                   6701: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
                   6702: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
                   6703: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
                   6704: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
                   6705: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
                   6706: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
1.79      rillig   6707: <dt><span class="sect2"><a href="#fixes.subst">17.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
1.77      rillig   6708: </dl></dd>
                   6709: <dt><span class="sect1"><a href="#fixes.fetch">17.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
                   6710: <dd><dl>
                   6711: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
                   6712: <dt><span class="sect2"><a href="#modified-distfiles-same-name">17.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
                   6713: </dl></dd>
                   6714: <dt><span class="sect1"><a href="#fixes.configure">17.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   6715: <dd><dl>
                   6716: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
                   6717: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
                   6718: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
                   6719: </dl></dd>
1.87    ! wiz      6720: <dt><span class="sect1"><a href="#programming-languages">17.4. Programming languages</a></span></dt>
1.77      rillig   6721: <dd><dl>
1.87    ! wiz      6722: <dt><span class="sect2"><a href="#basic-programming-languages">17.4.1. C, C++, and Fortran</a></span></dt>
        !          6723: <dt><span class="sect2"><a href="#java-programming-language">17.4.2. Java</a></span></dt>
        !          6724: <dt><span class="sect2"><a href="#perl-scripts">17.4.3. Packages containing perl scripts</a></span></dt>
        !          6725: <dt><span class="sect2"><a href="#other-programming-languages">17.4.4. Other programming languages</a></span></dt>
        !          6726: </dl></dd>
        !          6727: <dt><span class="sect1"><a href="#fixes.build">17.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
        !          6728: <dd><dl>
        !          6729: <dt><span class="sect2"><a href="#fixes.build.cpp">17.5.1. Compiling C and C++ code conditionally</a></span></dt>
        !          6730: <dt><span class="sect2"><a href="#compiler-bugs">17.5.2. How to handle compiler bugs</a></span></dt>
        !          6731: <dt><span class="sect2"><a href="#undefined-reference">17.5.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
        !          6732: <dt><span class="sect2"><a href="#out-of-memory">17.5.4. Running out of memory</a></span></dt>
        !          6733: </dl></dd>
        !          6734: <dt><span class="sect1"><a href="#fixes.install">17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
        !          6735: <dd><dl>
        !          6736: <dt><span class="sect2"><a href="#install-scripts">17.6.1. Creating needed directories</a></span></dt>
        !          6737: <dt><span class="sect2"><a href="#where-to-install-documentation">17.6.2. Where to install documentation</a></span></dt>
        !          6738: <dt><span class="sect2"><a href="#installing-score-files">17.6.3. Installing score files</a></span></dt>
        !          6739: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
        !          6740: <dt><span class="sect2"><a href="#perl-modules">17.6.5. Packages installing perl modules</a></span></dt>
        !          6741: <dt><span class="sect2"><a href="#faq.info-files">17.6.6. Packages installing info files</a></span></dt>
        !          6742: <dt><span class="sect2"><a href="#manpages">17.6.7. Packages installing man pages</a></span></dt>
        !          6743: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.8. Packages installing GConf2 data files</a></span></dt>
        !          6744: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.9. Packages installing scrollkeeper data files</a></span></dt>
        !          6745: <dt><span class="sect2"><a href="#x11-fonts">17.6.10. Packages installing X11 fonts</a></span></dt>
        !          6746: <dt><span class="sect2"><a href="#gtk2-modules">17.6.11. Packages installing GTK2 modules</a></span></dt>
        !          6747: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.12. Packages installing SGML or XML data</a></span></dt>
        !          6748: <dt><span class="sect2"><a href="#mime-database">17.6.13. Packages installing extensions to the MIME database</a></span></dt>
        !          6749: <dt><span class="sect2"><a href="#intltool">17.6.14. Packages using intltool</a></span></dt>
        !          6750: <dt><span class="sect2"><a href="#startup-scripts">17.6.15. Packages installing startup scripts</a></span></dt>
        !          6751: <dt><span class="sect2"><a href="#tex-packages">17.6.16. Packages installing TeX modules</a></span></dt>
        !          6752: <dt><span class="sect2"><a href="#emulation-packages">17.6.17. Packages supporting running binaries in
        !          6753:     emulation</a></span></dt>
        !          6754: <dt><span class="sect2"><a href="#hicolor-theme">17.6.18. Packages installing hicolor theme icons</a></span></dt>
        !          6755: <dt><span class="sect2"><a href="#desktop-files">17.6.19. Packages installing desktop files</a></span></dt>
1.75      rillig   6756: </dl></dd>
1.87    ! wiz      6757: <dt><span class="sect1"><a href="#punting">17.7. Marking packages as having problems</a></span></dt>
1.75      rillig   6758: </dl>
                   6759: </div>
                   6760: <div class="sect1" lang="en">
                   6761: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6762: <a name="general-operation"></a>17.1. General operation</h2></div></div></div>
1.75      rillig   6763: <div class="sect2" lang="en">
                   6764: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6765: <a name="portability-of-packages"></a>17.1.1. Portability of packages</h3></div></div></div>
                   6766: <p>One appealing feature of pkgsrc is that it runs on many
1.87    ! wiz      6767:     different platforms. As a result, it is important to ensure,
        !          6768:     where possible, that packages in pkgsrc are portable. This
        !          6769:     chapter mentions some particular details you should pay
        !          6770:     attention to while working on pkgsrc.</p>
1.78      rillig   6771: </div>
                   6772: <div class="sect2" lang="en">
                   6773: <div class="titlepage"><div><div><h3 class="title">
                   6774: <a name="pulling-vars-from-etc-mk.conf"></a>17.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></h3></div></div></div>
                   6775: <p>The pkgsrc user can configure pkgsrc by overriding several
1.87    ! wiz      6776:     variables in the file pointed to by <code class="varname">MAKECONF</code>,
        !          6777:     which is <code class="filename">/etc/mk.conf</code> by default. When you
        !          6778:     want to use those variables in the preprocessor directives of
        !          6779:     <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
        !          6780:     <code class="literal">.for</code>), you need to include the file
        !          6781:     <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
        !          6782:     loads the user preferences.</p>
1.78      rillig   6783: <p>But note that some variables may not be completely defined
1.87    ! wiz      6784:     after <code class="filename">../../mk/bsd.prefs.mk</code> has been
        !          6785:     included, as they may contain references to variables that are
        !          6786:     not yet defined. In shell commands this is no problem, since
        !          6787:     variables are actually macros, which are only expanded when they
        !          6788:     are used. But in the preprocessor directives mentioned above and
        !          6789:     in dependency lines (of the form <code class="literal">target:
        !          6790:     dependencies</code>) the variables are expanded at load
        !          6791:     time.</p>
1.78      rillig   6792: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   6793: <h3 class="title">Note</h3>
                   6794: <p>Currently there is no exhaustive list of all
1.87    ! wiz      6795:     variables that tells you whether they can be used at load time
        !          6796:     or only at run time, but it is in preparation.</p>
1.78      rillig   6797: </div>
                   6798: </div>
                   6799: <div class="sect2" lang="en">
                   6800: <div class="titlepage"><div><div><h3 class="title">
                   6801: <a name="user-interaction"></a>17.1.3. User interaction</h3></div></div></div>
                   6802: <p>Occasionally, packages require interaction from the user, and this can be
1.87    ! wiz      6803:     in a number of ways:</p>
1.78      rillig   6804: <div class="itemizedlist"><ul type="disc">
1.79      rillig   6805: <li><p>When fetching the distfiles, some packages require user
1.87    ! wiz      6806:        interaction such as entering username/password or accepting a
        !          6807:        license on a web page.</p></li>
1.78      rillig   6808: <li><p>When extracting the distfiles, some packages may ask for passwords.</p></li>
                   6809: <li><p>help to configure the package before it is built</p></li>
                   6810: <li><p>help during the build process</p></li>
                   6811: <li><p>help during the installation of a package</p></li>
                   6812: </ul></div>
                   6813: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is provided to notify
1.87    ! wiz      6814:     the pkgsrc mechanism of an interactive stage which will be needed, and
        !          6815:     this should be set in the package's <code class="filename">Makefile</code>, e.g.:</p>
1.75      rillig   6816: <pre class="programlisting">
1.87    ! wiz      6817:       INTERACTIVE_STAGE=      build
        !          6818:     </pre>
1.78      rillig   6819: <p>Multiple interactive stages can be specified:</p>
1.75      rillig   6820: <pre class="programlisting">
1.87    ! wiz      6821:       INTERACTIVE_STAGE=      configure install
        !          6822:     </pre>
1.75      rillig   6823: </div>
                   6824: <div class="sect2" lang="en">
                   6825: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6826: <a name="handling-licenses"></a>17.1.4. Handling licenses</h3></div></div></div>
                   6827: <p>A package may be covered by a license which the user has
1.87    ! wiz      6828:     or has not agreed to accept.  For these cases, pkgsrc contains
        !          6829:     a mechanism to note that a package is covered by a particular
        !          6830:     license, and the package cannot be built unless the user has
        !          6831:     accepted the license.  (Installation of binary packages are
        !          6832:     not currently subject to this mechanism.)  Packages with
        !          6833:     licenses that are either Open Source according to the Open
        !          6834:     Source Initiative or Free according to the Free Software
        !          6835:     Foundation will not be marked with a license tag.  Packages
        !          6836:     with licenses that have not been determined to meet either
        !          6837:     definition will be marked with a license tag referring to the
        !          6838:     license.  This will prevent building unless pkgsrc is informed
        !          6839:     that the license is acceptable, and enables displaying the
        !          6840:     license.</p>
1.78      rillig   6841: <p>The license tag mechanism is intended to address
1.87    ! wiz      6842:     copyright-related issues surrounding building, installing and
        !          6843:     using a package, and not to address redistribution issues (see
        !          6844:     <code class="varname">RESTRICTED</code> and
        !          6845:     <code class="varname">NO_SRC_ON_FTP</code>, etc.).  However, the above
        !          6846:     definition of licenses for which tags are not needed implies
        !          6847:     that packages with redistribution restrictions should have
        !          6848:     tags.</p>
        !          6849: <p>Denoting that a package is covered by a particular license
        !          6850:     is done by placing the license in
        !          6851:     <code class="filename">pkgsrc/licenses</code> and setting the
        !          6852:     <code class="varname">LICENSE</code> variable to a string identifying the
        !          6853:     license, e.g. in <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>:</p>
        !          6854: <pre class="programlisting">
        !          6855:       LICENSE=        xv-license
        !          6856:     </pre>
        !          6857: <p>When trying to build, the user will get a notice that the
        !          6858:     package is covered by a license which has not been
        !          6859:     accepted:</p>
        !          6860: <pre class="programlisting">
        !          6861:       <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
        !          6862:       ===&gt; xv-3.10anb9 has an unacceptable license: xv-license.
        !          6863:       ===&gt;     To view the license, enter "/usr/bin/make show-license".
        !          6864:       ===&gt;     To indicate acceptance, add this line to your /etc/mk.conf:
        !          6865:       ===&gt;     ACCEPTABLE_LICENSES+=xv-license
        !          6866:       *** Error code 1
        !          6867:     </pre>
1.78      rillig   6868: <p>The license can be viewed with <span><strong class="command">make
1.87    ! wiz      6869:     show-license</strong></span>, and if it is considered appropriate,
        !          6870:     the line printed above can be added to
        !          6871:     <code class="filename">/etc/mk.conf</code> to indicate acceptance of
        !          6872:     the particular license:</p>
1.78      rillig   6873: <pre class="programlisting">
1.87    ! wiz      6874:       ACCEPTABLE_LICENSES+=xv-license
        !          6875:     </pre>
1.78      rillig   6876: <p>When adding a package with a new license, the license
1.87    ! wiz      6877:     text should be added to <code class="filename">pkgsrc/licenses</code>
        !          6878:     for displaying. A list of known licenses can be seen in this
        !          6879:     directory as well as by looking at the list of (commented
        !          6880:     out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
        !          6881:     settings in
        !          6882:     <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
1.78      rillig   6883: <p>The use of <code class="varname">LICENSE=shareware</code>,
1.87    ! wiz      6884:     <code class="varname">LICENSE=no-commercial-use</code>, and similar
        !          6885:     language is deprecated because it does not crisply refer to
        !          6886:     a particular license text.  Another problem with such usage
        !          6887:     is that it does not enable a user to denote acceptance of
        !          6888:     the license for a single package without accepting the same
        !          6889:     license text for another package.  In particular, this can
        !          6890:     be inappropriate when e.g. one accepts a particular license to
        !          6891:     indicate to pkgsrc that a fee has been paid.</p>
1.75      rillig   6892: </div>
                   6893: <div class="sect2" lang="en">
                   6894: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6895: <a name="restricted-packages"></a>17.1.5. Restricted packages</h3></div></div></div>
1.75      rillig   6896: <p>Some licenses restrict how software may be re-distributed.
1.87    ! wiz      6897:     In order to satisfy these restrictions, the package system
        !          6898:     defines five make variables that can be set to note these
        !          6899:     restrictions:</p>
1.75      rillig   6900: <div class="itemizedlist"><ul type="disc">
                   6901: <li>
                   6902: <p><code class="varname">RESTRICTED</code></p>
                   6903: <p>This variable should be set whenever a restriction
1.87    ! wiz      6904:        exists (regardless of its kind).  Set this variable to a
        !          6905:        string containing the reason for the restriction.</p>
1.75      rillig   6906: </li>
                   6907: <li>
                   6908: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
                   6909: <p>Binaries may not be placed on CD-ROM.  Set this
1.87    ! wiz      6910:        variable to <code class="varname">${RESTRICTED}</code> whenever a
        !          6911:        binary package may not be included on a CD-ROM.</p>
1.75      rillig   6912: </li>
                   6913: <li>
                   6914: <p><code class="varname">NO_BIN_ON_FTP</code></p>
                   6915: <p>Binaries may not be placed on an FTP server.  Set
1.87    ! wiz      6916:        this variable to <code class="varname">${RESTRICTED}</code>
        !          6917:        whenever a binary package may not not be made available
        !          6918:        on the Internet.</p>
1.75      rillig   6919: </li>
                   6920: <li>
                   6921: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
                   6922: <p>Distfiles may not be placed on CD-ROM.  Set this
1.87    ! wiz      6923:        variable to <code class="varname">${RESTRICTED}</code> if
        !          6924:        re-distribution of the source code or other distfile(s) is
        !          6925:        not allowed on CD-ROMs.</p>
1.75      rillig   6926: </li>
                   6927: <li>
                   6928: <p><code class="varname">NO_SRC_ON_FTP</code></p>
                   6929: <p>Distfiles may not be placed on FTP.  Set this variable
1.87    ! wiz      6930:        to <code class="varname">${RESTRICTED}</code> if re-distribution of
        !          6931:        the source code or other distfile(s) via the Internet is not
        !          6932:        allowed.  If this variable is not set, the distfile(s) will
        !          6933:        be mirrored on ftp.NetBSD.org.</p>
1.75      rillig   6934: </li>
                   6935: </ul></div>
                   6936: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
1.87    ! wiz      6937:     <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
        !          6938:     generic make variables to denote restrictions is deprecated,
        !          6939:     because they unconditionally prevent users from generating
        !          6940:     binary packages!</p>
1.75      rillig   6941: </div>
                   6942: <div class="sect2" lang="en">
                   6943: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6944: <a name="dependencies"></a>17.1.6. Handling dependencies</h3></div></div></div>
1.75      rillig   6945: <p>Your package may depend on some other package being present
1.87    ! wiz      6946:     - and there are various ways of expressing this
        !          6947:     dependency. pkgsrc supports the <code class="varname">BUILD_DEPENDS</code>
        !          6948:     and <code class="varname">DEPENDS</code> definitions, the
        !          6949:     <code class="varname">USE_TOOLS</code> definition, as well as
        !          6950:     dependencies via <code class="filename">buildlink3.mk</code>, which is
        !          6951:     the preferred way to handle dependencies, and which uses the
        !          6952:     variables named above. See <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a> for more
        !          6953:     information.</p>
1.75      rillig   6954: <p>The basic difference between the two variables is as
1.87    ! wiz      6955:     follows: The <code class="varname">DEPENDS</code> definition registers
        !          6956:     that pre-requisite in the binary package so it will be pulled in
        !          6957:     when the binary package is later installed, whilst the
        !          6958:     <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
        !          6959:     dependency that is only needed for building the package.</p>
1.75      rillig   6960: <p>This means that if you only need a package present whilst
1.87    ! wiz      6961:     you are building, it should be noted as a
        !          6962:     <code class="varname">BUILD_DEPENDS</code>.</p>
1.75      rillig   6963: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
1.87    ! wiz      6964:     <code class="varname">DEPENDS</code> definition is:</p>
1.75      rillig   6965: <pre class="programlisting">
1.87    ! wiz      6966:       &lt;pre-req-package-name&gt;:../../&lt;category&gt;/&lt;pre-req-package&gt;
        !          6967:     </pre>
1.75      rillig   6968: <p>Please note that the &#8220;<span class="quote">pre-req-package-name</span>&#8221;
1.87    ! wiz      6969:     may include any of the wildcard version numbers recognized by
        !          6970:     <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   6971: <div class="orderedlist"><ol type="1">
                   6972: <li>
                   6973: <p>If your package needs another package's binaries or
1.87    ! wiz      6974:        libraries to build or run, and if that package has a
        !          6975:        <code class="filename">buildlink3.mk</code> file available, use it:</p>
1.75      rillig   6976: <pre class="programlisting">
1.87    ! wiz      6977:          .include "../../graphics/jpeg/buildlink3.mk"
        !          6978:        </pre>
1.75      rillig   6979: </li>
                   6980: <li>
                   6981: <p>If your package needs to use another package to build
1.87    ! wiz      6982:        itself and there is no <code class="filename">buildlink3.mk</code>
        !          6983:        file available, use the <code class="varname">BUILD_DEPENDS</code>
        !          6984:        definition:</p>
1.75      rillig   6985: <pre class="programlisting">
1.87    ! wiz      6986:          BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
        !          6987:        </pre>
1.75      rillig   6988: </li>
                   6989: <li>
                   6990: <p>If your package needs a library with which to link and
1.76      rillig   6991:        again there is no <code class="filename">buildlink3.mk</code> file
1.87    ! wiz      6992:        available, this is specified using the
        !          6993:        <code class="varname">DEPENDS</code> definition. For example:</p>
1.75      rillig   6994: <pre class="programlisting">
1.87    ! wiz      6995:          DEPENDS+=       xpm-3.4j:../../graphics/xpm
        !          6996:        </pre>
1.75      rillig   6997: <p>You can also use wildcards in package dependences:</p>
                   6998: <pre class="programlisting">
1.87    ! wiz      6999:          DEPENDS+=       xpm-[0-9]*:../../graphics/xpm
        !          7000:        </pre>
1.75      rillig   7001: <p>Note that such wildcard dependencies are retained when
1.87    ! wiz      7002:        creating binary packages.  The dependency is checked when
        !          7003:        installing the binary package and any package which matches
        !          7004:        the pattern will be used.  Wildcard dependencies should be
        !          7005:        used with care.</p>
1.75      rillig   7006: <p>The &#8220;<span class="quote">-[0-9]*</span>&#8221; should be used instead of
1.87    ! wiz      7007:        &#8220;<span class="quote">-*</span>&#8221; to avoid potentially ambiguous matches
        !          7008:        such as &#8220;<span class="quote">tk-postgresql</span>&#8221; matching a
        !          7009:        &#8220;<span class="quote">tk-*</span>&#8221; <code class="varname">DEPENDS</code>.</p>
1.75      rillig   7010: <p>Wildcards can also be used to specify that a package
1.87    ! wiz      7011:        will only build against a certain minimum version of a
        !          7012:        pre-requisite:</p>
1.75      rillig   7013: <pre class="programlisting">
1.87    ! wiz      7014:          DEPENDS+=       tiff&gt;=3.5.4:../../graphics/tiff
        !          7015:        </pre>
1.75      rillig   7016: <p>This means that the package will build against version
1.87    ! wiz      7017:        3.5.4 of the tiff library or newer.  Such a dependency may
        !          7018:        be warranted if, for example, the API of the library has
        !          7019:        changed with version 3.5.4 and a package would not compile
        !          7020:        against an earlier version of tiff.</p>
1.75      rillig   7021: <p>Please note that such dependencies should only be
1.87    ! wiz      7022:        updated if a package requires a newer pre-requisite, but
        !          7023:        not to denote recommendations such as 
        !          7024:        ABI changes that do not prevent a package from building
        !          7025:        correctly.  Such recommendations can be expressed using
        !          7026:        <code class="varname">ABI_DEPENDS</code>:</p>
1.75      rillig   7027: <pre class="programlisting">
1.87    ! wiz      7028:          ABI_DEPENDS+=   tiff&gt;=3.6.1:../../graphics/tiff
        !          7029:        </pre>
1.75      rillig   7030: <p>In addition to the above <code class="varname">DEPENDS</code>
1.87    ! wiz      7031:        line, this denotes that while a package will build against
        !          7032:        tiff&gt;=3.5.4, at least version 3.6.1 is recommended.
        !          7033:        <code class="varname">ABI_DEPENDS</code> entries will be turned into
        !          7034:        dependencies unless explicitly ignored (in which case a
        !          7035:        warning will be printed).</p>
1.75      rillig   7036: <p>To ignore these ABI dependency recommendations and just
1.87    ! wiz      7037:        use the required <code class="varname">DEPENDS</code>, set
        !          7038:        <code class="varname">USE_ABI_DEPENDS=NO</code>.   This may make
        !          7039:        it easier and faster to update packages built using pkgsrc,
        !          7040:        since older compatible dependencies can continue to be
        !          7041:        used. This is useful for people who watch their rebuilds
        !          7042:        very carefully; it is not very good as a general-purpose
        !          7043:        hammer.  If you use it, you need to be mindful of possible
        !          7044:        ABI changes, including those from the underlying OS.</p>
1.75      rillig   7045: <p>Packages that are built with recommendations ignored
1.87    ! wiz      7046:        may not be uploaded to ftp.NetBSD.org by developers and
        !          7047:        should not be used across different systems that may have
        !          7048:        different versions of binary packages installed.</p>
1.75      rillig   7049: <p>For security fixes, please update the package
1.87    ! wiz      7050:        vulnerabilities file. See <a href="#security-handling" title="17.1.10. Handling packages with security problems">Section 17.1.10, &#8220;Handling packages with security problems&#8221;</a> for more
        !          7051:        information.</p>
1.75      rillig   7052: </li>
                   7053: <li>
                   7054: <p>If your package needs some executable to be able to run
1.87    ! wiz      7055:        correctly and if there's no
        !          7056:        <code class="filename">buildlink3.mk</code> file, this is specified
        !          7057:        using the <code class="varname">DEPENDS</code> variable. The
        !          7058:        <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/lyx/README.html" target="_top"><code class="filename">print/lyx</code></a> package needs to
        !          7059:        be able to execute the latex binary from the teTeX package
        !          7060:        when it runs, and that is specified:</p>
1.75      rillig   7061: <pre class="programlisting">
1.87    ! wiz      7062:          DEPENDS+=        teTeX-[0-9]*:../../print/teTeX
        !          7063:        </pre>
1.75      rillig   7064: <p>The comment about wildcard dependencies from previous
1.87    ! wiz      7065:        paragraph applies here, too.</p>
1.75      rillig   7066: </li>
                   7067: </ol></div>
                   7068: <p>If your package needs files from another package to build,
1.87    ! wiz      7069:     add the relevant distribution files to
        !          7070:     <code class="varname">DISTFILES</code>, so they will be extracted
        !          7071:     automatically. See the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/ghostscript/README.html" target="_top"><code class="filename">print/ghostscript</code></a> package for an example.
        !          7072:     (It relies on the jpeg sources being present in source form
        !          7073:     during the build.)</p>
1.75      rillig   7074: <p>Please also note the <code class="varname">BUILD_USES_MSGFMT</code>
1.87    ! wiz      7075:     and <code class="varname">BUILD_USES_GETTEXT_M4</code> definitions, which
        !          7076:     are provided as convenience definitions.  The former works out
        !          7077:     whether <a href="http://netbsd.gw.com/cgi-bin/man-cgi?msgfmt+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">msgfmt</span>(1)</span></a> is part of the base system, and, if it isn't,
        !          7078:     installs the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/gettext/README.html" target="_top"><code class="filename">devel/gettext</code></a> package.
        !          7079:     The latter adds a build dependency on either an installed
        !          7080:     version of an older gettext package, or if it isn't, installs the
        !          7081:     <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/gettext-m4/README.html" target="_top"><code class="filename">devel/gettext-m4</code></a> package.</p>
1.75      rillig   7082: </div>
                   7083: <div class="sect2" lang="en">
                   7084: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7085: <a name="conflicts"></a>17.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75      rillig   7086: <p>Your package may conflict with other packages a user might
1.87    ! wiz      7087:     already have installed on his system, e.g. if your package
        !          7088:     installs the same set of files like another package in our
        !          7089:     pkgsrc tree.</p>
1.75      rillig   7090: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
1.87    ! wiz      7091:     space-separated list of packages (including version string) your
        !          7092:     package conflicts with.</p>
1.76      rillig   7093: <p>For example, <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/Xaw3d/README.html" target="_top"><code class="filename">x11/Xaw3d</code></a>
1.87    ! wiz      7094:     and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/Xaw-Xpm/README.html" target="_top"><code class="filename">x11/Xaw-Xpm</code></a>
        !          7095:     install the same shared library, thus you set in
        !          7096:     <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
        !          7097: <pre class="programlisting">
        !          7098:       CONFLICTS=      Xaw-Xpm-[0-9]*
        !          7099:     </pre>
        !          7100: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:</p>
1.75      rillig   7101: <pre class="programlisting">
1.87    ! wiz      7102:       CONFLICTS=      Xaw3d-[0-9]*
        !          7103:     </pre>
1.75      rillig   7104: <p>Packages will automatically conflict with other packages
1.87    ! wiz      7105:     with the name prefix and a different version
        !          7106:     string. &#8220;<span class="quote">Xaw3d-1.5</span>&#8221; e.g. will automatically
        !          7107:     conflict with the older version &#8220;<span class="quote">Xaw3d-1.3</span>&#8221;.</p>
1.75      rillig   7108: </div>
                   7109: <div class="sect2" lang="en">
                   7110: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7111: <a name="not-building-packages"></a>17.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75      rillig   7112: <p>There are several reasons why a package might be
1.87    ! wiz      7113:     instructed to not build under certain circumstances. If the
        !          7114:     package builds and runs on most platforms, the exceptions
        !          7115:     should be noted with <code class="varname">NOT_FOR_PLATFORM</code>.  If
        !          7116:     the package builds and runs on a small handful of platforms,
        !          7117:     set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
        !          7118:     Both <code class="varname">ONLY_FOR_PLATFORM</code> and
        !          7119:     <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
        !          7120:     (OS-version-platform) that can use glob-style
        !          7121:     wildcards.</p>
1.75      rillig   7122: <p>If the package should be skipped (for example, because it
1.87    ! wiz      7123:     provides functionality already provided by the system), set
        !          7124:     <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.
        !          7125:     If the package should fail because some preconditions are not
        !          7126:     met, set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
        !          7127:     message.</p>
1.75      rillig   7128: </div>
                   7129: <div class="sect2" lang="en">
                   7130: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7131: <a name="undeletable-packages"></a>17.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75      rillig   7132: <p>To ensure that a package may not be deleted, once it has been
1.87    ! wiz      7133:     installed, the <code class="varname">PKG_PRESERVE</code> definition should
        !          7134:     be set in the package Makefile. This will be carried into any
        !          7135:     binary package that is made from this pkgsrc entry. A
        !          7136:     &#8220;<span class="quote">preserved</span>&#8221; package will
        !          7137:     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
        !          7138:     &#8220;<span class="quote">-f</span>&#8221; option is used.</p>
1.75      rillig   7139: </div>
                   7140: <div class="sect2" lang="en">
                   7141: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7142: <a name="security-handling"></a>17.1.10. Handling packages with security problems</h3></div></div></div>
1.75      rillig   7143: <p>When a vulnerability is found, this should be noted in
1.87    ! wiz      7144:     <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
        !          7145:     and after committing that file, use <span><strong class="command">make upload</strong></span>
        !          7146:     in the same directory to update the file on ftp.NetBSD.org.</p>
1.75      rillig   7147: <p>After fixing the vulnerability by a patch, its
1.87    ! wiz      7148:     <code class="varname">PKGREVISION</code> should be increased (this
        !          7149:     is of course not necessary if the problem is fixed by using
        !          7150:     a newer release of the software).</p>
1.75      rillig   7151: <p>Also, if the fix should be applied to the stable pkgsrc
1.87    ! wiz      7152:     branch, be sure to submit a pullup request!</p>
1.75      rillig   7153: <p>Binary packages already on ftp.NetBSD.org will be handled
1.87    ! wiz      7154:     semi-automatically by a weekly cron job.</p>
1.75      rillig   7155: </div>
                   7156: <div class="sect2" lang="en">
                   7157: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7158: <a name="bumping-pkgrevision"></a>17.1.11. How to handle incrementing versions when fixing an existing package</h3></div></div></div>
1.75      rillig   7159: <p>When making fixes to an existing package it can be useful
1.87    ! wiz      7160:     to change the version number in <code class="varname">PKGNAME</code>. To
        !          7161:     avoid conflicting with future versions by the original author, a
        !          7162:     &#8220;<span class="quote">nb1</span>&#8221;, &#8220;<span class="quote">nb2</span>&#8221;, ... suffix can be used
        !          7163:     on package versions by setting <code class="varname">PKGREVISION=1</code>
        !          7164:     (2, ...). The &#8220;<span class="quote">nb</span>&#8221; is treated like a
        !          7165:     &#8220;<span class="quote">.</span>&#8221; by the package tools. e.g.</p>
        !          7166: <pre class="programlisting">
        !          7167:       DISTNAME=       foo-17.42
        !          7168:       PKGREVISION=    9
        !          7169:     </pre>
1.75      rillig   7170: <p>will result in a <code class="varname">PKGNAME</code> of
1.87    ! wiz      7171:     &#8220;<span class="quote">foo-17.42nb9</span>&#8221;. If you want to use the original
        !          7172:     value of <code class="varname">PKGNAME</code> without the &#8220;<span class="quote">nbX</span>&#8221;
        !          7173:     suffix, e.g. for setting <code class="varname">DIST_SUBDIR</code>, use
        !          7174:     <code class="varname">PKGNAME_NOREV</code>.</p>
1.75      rillig   7175: <p>When a new release of the package is released, the
1.87    ! wiz      7176:     <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
        !          7177:     minor release of the above package, things should be like:</p>
1.75      rillig   7178: <pre class="programlisting">
1.87    ! wiz      7179:       DISTNAME=       foo-17.43
        !          7180:     </pre>
        !          7181: <p><code class="varname">PKGREVISION</code> should be incremented for any
        !          7182:     non-trivial change in the resulting binary package.  Without a
        !          7183:     <code class="varname">PKGREVISION</code> bump, someone with the previous
        !          7184:     version installed has no way of knowing that their package is out
        !          7185:     of date.  Thus, changes without increasing
        !          7186:     <code class="varname">PKGREVISION</code> are essentially labeled "this is so
        !          7187:     trivial that no reasonable person would want to upgrade", and this
        !          7188:     is the rough test for when increasing
        !          7189:     <code class="varname">PKGREVISION</code> is appropriate.  Examples of
        !          7190:     changes that do not merit increasing
        !          7191:     <code class="varname">PKGREVISION</code> are:</p>
        !          7192: <pre class="programlisting">
        !          7193:       Changing <code class="varname">HOMEPAGE</code>, <code class="varname">MAINTAINER</code>,
        !          7194:       or comments in Makefile.
        !          7195:       Changing build variables if the resulting binary package is the same.
        !          7196:       Changing <code class="filename">DESCR</code>.
        !          7197:       Adding <code class="varname">PKG_OPTIONS</code> if the default options don't change.
        !          7198:     </pre>
        !          7199: <p>Examples of changes that do merit an increase to
        !          7200:     <code class="varname">PKGREVISION</code> include:</p>
        !          7201: <pre class="programlisting">
        !          7202:       Security fixes
        !          7203:       Changes or additions to a patch file
        !          7204:       Changes to the <code class="filename">PLIST</code>
        !          7205:     </pre>
1.78      rillig   7206: <p>PKGREVISION must also be incremented when dependencies have ABI
                   7207:     changes.</p>
1.75      rillig   7208: </div>
1.79      rillig   7209: <div class="sect2" lang="en">
                   7210: <div class="titlepage"><div><div><h3 class="title">
                   7211: <a name="fixes.subst"></a>17.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
                   7212: <p>When you want to replace the same text in multiple files
1.87    ! wiz      7213:     or when the replacement text varies, patches alone cannot help.
        !          7214:     This is where the SUBST framework comes in. It provides an
        !          7215:     easy-to-use interface for replacing text in files.
        !          7216:     Example:</p>
        !          7217: <pre class="programlisting">
        !          7218:       SUBST_CLASSES+=                 fix-paths
        !          7219:       SUBST_STAGE.fix-paths=          pre-configure
        !          7220:       SUBST_MESSAGE.fix-paths=        Fixing absolute paths.
        !          7221:       SUBST_FILES.fix-paths=          src/*.c
        !          7222:       SUBST_FILES.fix-paths+=         scripts/*.sh
        !          7223:       SUBST_SED.fix-paths=            -e 's,"/usr/local,"${PREFIX},g'
        !          7224:       SUBST_SED.fix-paths+=           -e 's,"/var/log,"${VARBASE}/log,g'
        !          7225:     </pre>
1.79      rillig   7226: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
1.87    ! wiz      7227:     that are used to identify the different SUBST blocks that are
        !          7228:     defined. The SUBST framework is heavily used by pkgsrc, so it is
        !          7229:     important to always use the <code class="literal">+=</code> operator with
        !          7230:     this variable. Otherwise some substitutions may be
        !          7231:     skipped.</p>
1.79      rillig   7232: <p>The remaining variables of each SUBST block are
1.87    ! wiz      7233:     parameterized with the identifier from the first line
        !          7234:     (<code class="literal">fix-paths</code> in this case.) They can be seen as
        !          7235:     parameters to a function call.</p>
1.79      rillig   7236: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
1.87    ! wiz      7237:     which the replacement will take place. All combinations of
        !          7238:     <code class="literal">pre-</code>, <code class="literal">do-</code> and
        !          7239:     <code class="literal">post-</code> together with a phase name are
        !          7240:     possible, though only few are actually used. Most commonly used
        !          7241:     are <code class="literal">post-patch</code> and
        !          7242:     <code class="literal">pre-configure</code>. Of these two,
        !          7243:     <code class="literal">pre-configure</code> should be preferred because
        !          7244:     then it is possible to run <span><strong class="command">bmake patch</strong></span> and
        !          7245:     have the state after applying the patches but before making any
        !          7246:     other changes. This is especially useful when you are debugging
        !          7247:     a package in order to create new patches for it. Similarly,
        !          7248:     <code class="literal">post-build</code> is preferred over
        !          7249:     <code class="literal">pre-install</code>, because the install phase should
        !          7250:     generally be kept as simple as possible. When you use
        !          7251:     <code class="literal">post-build</code>, you have the same files in the
        !          7252:     working directory that will be installed later, so you can check
        !          7253:     if the substitution has succeeded.</p>
1.79      rillig   7254: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
1.87    ! wiz      7255:     that is printed just before the substitution is done.</p>
1.79      rillig   7256: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
1.87    ! wiz      7257:     globbing patterns that specifies the files in which the
        !          7258:     substitution will take place. The patterns are interpreted
        !          7259:     relatively to the <code class="varname">WRKSRC</code> directory.</p>
1.79      rillig   7260: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
1.87    ! wiz      7261:     <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
        !          7262:     command should be prefixed with <code class="literal">-e</code>, so that
        !          7263:     all SUBST blocks look uniform.</p>
1.79      rillig   7264: <p>There are some more variables, but they are so seldomly
1.87    ! wiz      7265:     used that they are only documented in the
        !          7266:     <code class="filename">mk/subst.mk</code> file.</p>
1.79      rillig   7267: </div>
1.75      rillig   7268: </div>
                   7269: <div class="sect1" lang="en">
                   7270: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   7271: <a name="fixes.fetch"></a>17.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.75      rillig   7272: <div class="sect2" lang="en">
                   7273: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7274: <a name="no-plain-download"></a>17.2.1. Packages whose distfiles aren't available for plain downloading</h3></div></div></div>
1.75      rillig   7275: <p>If you need to download from a dynamic URL you can set
1.87    ! wiz      7276:     <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
        !          7277:     fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
        !          7278:     with the name of each file to download as an argument, expecting
        !          7279:     it to output the URL of the directory from which to download
        !          7280:     it. <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/ns-cult3d/README.html" target="_top"><code class="filename">graphics/ns-cult3d</code></a> is an
        !          7281:     example of this usage.</p>
1.75      rillig   7282: <p>If the download can't be automated, because the user must
1.87    ! wiz      7283:     submit personal information to apply for a password, or must pay
        !          7284:     for the source, or whatever, you can set
        !          7285:     <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
        !          7286:     displayed to the user before aborting the build. Example:</p>
        !          7287: <pre class="programlisting">
        !          7288:       FETCH_MESSAGE=  "Please download the files"
        !          7289:       FETCH_MESSAGE+= "    "${DISTFILES:Q}
        !          7290:       FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
        !          7291:     </pre>
1.75      rillig   7292: </div>
                   7293: <div class="sect2" lang="en">
                   7294: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7295: <a name="modified-distfiles-same-name"></a>17.2.2. How to handle modified distfiles with the 'old' name</h3></div></div></div>
1.75      rillig   7296: <p>Sometimes authors of a software package make some
1.87    ! wiz      7297:     modifications after the software was released, and they put up a
        !          7298:     new distfile without changing the package's version number. If a
        !          7299:     package is already in pkgsrc at that time, the checksum will
        !          7300:     no longer match. The contents of the new distfile should be
        !          7301:     compared against the old one before changing anything, to make
        !          7302:     sure the distfile was really updated on purpose, and that
        !          7303:     no trojan horse or so crept in.
        !          7304:     Then, the correct way to work around this is to
        !          7305:     set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
        !          7306:     usually based on <code class="varname">PKGNAME_NOREV</code>. All
        !          7307:     <code class="varname">DISTFILES</code> and
        !          7308:     <code class="varname">PATCHFILES</code> for this package will be put in that 
        !          7309:     subdirectory of the local distfiles directory.  In case this
        !          7310:     happens more often, <code class="varname">PKGNAME</code> can be used (thus
        !          7311:     including the <code class="filename">nbX</code> suffix) or a date stamp
        !          7312:     can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
        !          7313:     Do not forget regenerating the <code class="filename">distinfo</code> file
        !          7314:     after that, since it contains the <code class="varname">DIST_SUBDIR</code>
        !          7315:     path in the filenames.
        !          7316:     Furthermore, a mail to the package's authors seems appropriate
        !          7317:     telling them that changing distfiles after releases without
        !          7318:     changing the file names is not good practice.</p>
1.75      rillig   7319: </div>
                   7320: </div>
                   7321: <div class="sect1" lang="en">
                   7322: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   7323: <a name="fixes.configure"></a>17.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75      rillig   7324: <div class="sect2" lang="en">
                   7325: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7326: <a name="fixes.libtool"></a>17.3.1. Shared libraries - libtool</h3></div></div></div>
1.75      rillig   7327: <p>pkgsrc supports many different machines, with different
1.87    ! wiz      7328:     object formats like a.out and ELF, and varying abilities to do
        !          7329:     shared library and dynamic loading at all. To accompany this,
        !          7330:     varying commands and options have to be passed to the
        !          7331:     compiler, linker, etc. to get the Right Thing, which can be
        !          7332:     pretty annoying especially if you don't have all the machines
        !          7333:     at your hand to test things.  The
        !          7334:     <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/libtool/README.html" target="_top"><code class="filename">devel/libtool</code></a> pkg
        !          7335:     can help here, as it just &#8220;<span class="quote">knows</span>&#8221; how to build
        !          7336:     both static and dynamic libraries from a set of source files,
        !          7337:     thus being platform-independent.</p>
        !          7338: <p>Here's how to use libtool in a package in seven simple
        !          7339:     steps:</p>
1.75      rillig   7340: <div class="orderedlist"><ol type="1">
                   7341: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
1.87    ! wiz      7342:        Makefile.</p></li>
1.75      rillig   7343: <li><p>For library objects, use &#8220;<span class="quote">${LIBTOOL} --mode=compile
1.87    ! wiz      7344:        ${CC}</span>&#8221; in place of &#8220;<span class="quote">${CC}</span>&#8221;. You could even
        !          7345:        add it to the definition of <code class="varname">CC</code>, if only
        !          7346:        libraries are being built in a given Makefile. This one command
        !          7347:        will build both PIC and non-PIC library objects, so you need not
        !          7348:        have separate shared and non-shared library rules.</p></li>
1.75      rillig   7349: <li>
                   7350: <p>For the linking of the library, remove any
1.87    ! wiz      7351:        &#8220;<span class="quote">ar</span>&#8221;, &#8220;<span class="quote">ranlib</span>&#8221;, and &#8220;<span class="quote">ld
        !          7352:        -Bshareable</span>&#8221; commands, and instead use:</p>
1.75      rillig   7353: <pre class="programlisting">
1.87    ! wiz      7354:          ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
        !          7355:          -rpath ${PREFIX}/lib -version-info major:minor
        !          7356:        </pre>
1.75      rillig   7357: <p>Note that the library is changed to have a
1.87    ! wiz      7358:        <code class="filename">.la</code> extension, and the objects are
        !          7359:        changed to have a <code class="filename">.lo</code>
        !          7360:        extension. Change <code class="varname">OBJS</code> as
        !          7361:        necessary. This automatically creates all of the
        !          7362:        <code class="filename">.a</code>,
        !          7363:        <code class="filename">.so.major.minor</code>, and ELF symlinks (if
        !          7364:        necessary) in the build directory. Be sure to include
        !          7365:        &#8220;<span class="quote">-version-info</span>&#8221;, especially when major and
        !          7366:        minor are zero, as libtool will otherwise strip off the
        !          7367:        shared library version.</p>
1.75      rillig   7368: <p>From the libtool manual:</p>
                   7369: <pre class="programlisting">
1.87    ! wiz      7370:          So, libtool library versions are described by three integers:
1.69      rillig   7371: 
1.87    ! wiz      7372:          CURRENT
        !          7373:          The most recent interface number that this library implements.
1.69      rillig   7374: 
1.87    ! wiz      7375:          REVISION
        !          7376:          The implementation number of the CURRENT interface.
1.69      rillig   7377: 
1.87    ! wiz      7378:          AGE
        !          7379:          The difference between the newest and oldest interfaces that
        !          7380:          this library implements.  In other words, the library implements
        !          7381:          all the interface numbers in the range from number `CURRENT -
        !          7382:          AGE' to `CURRENT'.
1.1       grant    7383: 
1.87    ! wiz      7384:          If two libraries have identical CURRENT and AGE numbers, then the
        !          7385:          dynamic linker chooses the library with the greater REVISION number.
        !          7386:        </pre>
1.75      rillig   7387: <p>The &#8220;<span class="quote">-release</span>&#8221; option will produce
1.87    ! wiz      7388:        different results for a.out and ELF (excluding symlinks)
        !          7389:        in only one case. An ELF library of the form
        !          7390:        &#8220;<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;
        !          7391:        will have a symlink of
        !          7392:        &#8220;<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;
        !          7393:        on an a.out platform. This is handled
        !          7394:        automatically.</p>
1.75      rillig   7395: <p>The &#8220;<span class="quote">-rpath argument</span>&#8221; is the install
1.87    ! wiz      7396:        directory of the library being built.</p>
1.76      rillig   7397: <p>In the <code class="filename">PLIST</code>, include only the
1.87    ! wiz      7398:        <code class="filename">.la</code> file, the other files will be
        !          7399:        added automatically.</p>
1.75      rillig   7400: </li>
                   7401: <li>
1.76      rillig   7402: <p>When linking shared object (<code class="filename">.so</code>)
1.87    ! wiz      7403:        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
        !          7404:        shared libraries, use &#8220;<span class="quote">-module
        !          7405:        -avoid-version</span>&#8221; to prevent them getting version
        !          7406:        tacked on.</p>
1.76      rillig   7407: <p>The <code class="filename">PLIST</code> file gets the
1.87    ! wiz      7408:        <code class="filename">foo.so</code> entry.</p>
1.75      rillig   7409: </li>
                   7410: <li>
                   7411: <p>When linking programs that depend on these libraries
1.87    ! wiz      7412:        <span class="emphasis"><em>before</em></span> they are installed, preface
        !          7413:        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}
        !          7414:        --mode=link</span>&#8221;, and it will find the correct
        !          7415:        libraries (static or shared), but please be aware that
        !          7416:        libtool will not allow you to specify a relative path in
        !          7417:        -L (such as &#8220;<span class="quote">-L../somelib</span>&#8221;), because it
        !          7418:        expects you to change that argument to be the
        !          7419:        <code class="filename">.la</code> file. e.g.</p>
1.75      rillig   7420: <pre class="programlisting">
1.87    ! wiz      7421:          ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
        !          7422:        </pre>
1.75      rillig   7423: <p>should be changed to:</p>
                   7424: <pre class="programlisting">
1.87    ! wiz      7425:          ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
        !          7426:        </pre>
1.75      rillig   7427: <p>and it will do the right thing with the libraries.</p>
                   7428: </li>
                   7429: <li>
                   7430: <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      7431:        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}
        !          7432:        --mode=install</span>&#8221;, and change the library name to
        !          7433:        <code class="filename">.la</code>. e.g.</p>
1.75      rillig   7434: <pre class="programlisting">
1.87    ! wiz      7435:          ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
        !          7436:        </pre>
1.76      rillig   7437: <p>This will install the static <code class="filename">.a</code>,
1.87    ! wiz      7438:        shared library, any needed symlinks, and run
        !          7439:        <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   7440: </li>
1.76      rillig   7441: <li><p>In your <code class="filename">PLIST</code>, include only
1.87    ! wiz      7442:        the <code class="filename">.la</code>
        !          7443:        file (this is a change from previous behaviour).</p></li>
1.75      rillig   7444: </ol></div>
                   7445: </div>
                   7446: <div class="sect2" lang="en">
                   7447: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7448: <a name="using-libtool"></a>17.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75      rillig   7449: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
1.87    ! wiz      7450:     package Makefile. This will override the package's own libtool
        !          7451:     in most cases.  For older libtool using packages,  libtool is
        !          7452:     made by ltconfig script during the do-configure step; you can
        !          7453:     check the libtool script location by doing <span><strong class="command">make
        !          7454:     configure; find work*/ -name libtool</strong></span>.</p>
1.75      rillig   7455: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
1.87    ! wiz      7456:     scripts, relative to <code class="varname">WRKSRC</code>, to override.  By
        !          7457:     default, it is set to &#8220;<span class="quote">libtool */libtool
        !          7458:     */*/libtool</span>&#8221;.  If this does not match the location of the
        !          7459:     package's libtool script(s), set it as appropriate.</p>
1.76      rillig   7460: <p>If you do not need <code class="filename">*.a</code> static
1.87    ! wiz      7461:     libraries built and installed, then use
        !          7462:     <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
1.75      rillig   7463: <p>If your package makes use of the platform-independent library
1.87    ! wiz      7464:     for loading dynamic shared objects, that comes with libtool
        !          7465:     (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
        !          7466: <p>Some packages use libtool incorrectly so that the package
        !          7467:     may not work or build in some circumstances. Some of the more
        !          7468:     common errors are:</p>
1.75      rillig   7469: <div class="itemizedlist"><ul type="disc">
                   7470: <li>
                   7471: <p>The inclusion of a shared object (-module) as a dependent library in an
1.87    ! wiz      7472:        executable or library. This in itself isn't a problem if one of two things
        !          7473:        has been done:</p>
1.75      rillig   7474: <div class="orderedlist"><ol type="1">
                   7475: <li><p>The shared object is named correctly, i.e.
1.87    ! wiz      7476:            <code class="filename">libfoo.la</code>, not
        !          7477:            <code class="filename">foo.la</code></p></li>
1.75      rillig   7478: <li><p>The -dlopen option is used when linking an executable.</p></li>
                   7479: </ol></div>
                   7480: </li>
                   7481: <li><p>The use of libltdl without the correct calls to initialisation routines.
1.87    ! wiz      7482:        The function lt_dlinit() should be called and the macro
        !          7483:        <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
        !          7484:        executables.</p></li>
1.75      rillig   7485: </ul></div>
                   7486: </div>
                   7487: <div class="sect2" lang="en">
                   7488: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7489: <a name="autoconf-automake"></a>17.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75      rillig   7490: <p>If a package needs GNU autoconf or automake to be executed
1.87    ! wiz      7491:     to regenerate the configure script and Makefile.in makefile
        !          7492:     templates, then they should be executed in a pre-configure
        !          7493:     target.</p>
1.75      rillig   7494: <p>For packages that need only autoconf:</p>
                   7495: <pre class="programlisting">
1.87    ! wiz      7496:       AUTOCONF_REQD=  2.50            # if default version is not good enough
        !          7497:       USE_TOOLS+=     autoconf        # use "autoconf213" for autoconf-2.13
        !          7498:       ...
1.1       grant    7499: 
1.87    ! wiz      7500:       pre-configure:
        !          7501:       cd ${WRKSRC}; autoconf
1.1       grant    7502: 
1.87    ! wiz      7503:       ...
        !          7504:     </pre>
1.75      rillig   7505: <p>and for packages that need automake and autoconf:</p>
                   7506: <pre class="programlisting">
1.87    ! wiz      7507:       AUTOMAKE_REQD=  1.7.1           # if default version is not good enough
        !          7508:       USE_TOOLS+=     automake        # use "automake14" for automake-1.4
        !          7509:       ...
        !          7510: 
        !          7511:       pre-configure:
        !          7512:       cd ${WRKSRC};                          \
        !          7513:       aclocal; autoheader;                   \
        !          7514:       automake -a --foreign -i; autoconf
1.1       grant    7515: 
1.87    ! wiz      7516:       ...
        !          7517:     </pre>
1.75      rillig   7518: <p>Packages which use GNU Automake will almost certainly
1.87    ! wiz      7519:     require GNU Make.</p>
1.75      rillig   7520: <p>There are times when the configure process makes
1.87    ! wiz      7521:     additional changes to the generated files, which then causes
        !          7522:     the build process to try to re-execute the automake sequence.
        !          7523:     This is prevented by touching various files in the configure
        !          7524:     stage. If this causes problems with your package you can set
        !          7525:     <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
        !          7526:     Makefile.</p>
1.75      rillig   7527: </div>
                   7528: </div>
                   7529: <div class="sect1" lang="en">
                   7530: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.87    ! wiz      7531: <a name="programming-languages"></a>17.4. Programming languages</h2></div></div></div>
        !          7532: <div class="sect2" lang="en">
        !          7533: <div class="titlepage"><div><div><h3 class="title">
        !          7534: <a name="basic-programming-languages"></a>17.4.1. C, C++, and Fortran</h3></div></div></div>
        !          7535: <p>Compilers for the C, C++, and Fortran languages comes with
        !          7536:     the NetBSD base system.  By default, pkgsrc assumes that a package
        !          7537:     is written in C and will hide all other compilers (via the wrapper
        !          7538:     framework, see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p>
        !          7539: <p>To declare which language's compiler a package needs, set
        !          7540:     the <code class="varname">USE_LANGUAGES</code> variable. Allowed values
        !          7541:     currently are &#8220;<span class="quote">c</span>&#8221;, &#8220;<span class="quote">c++</span>&#8221;, and
        !          7542:     &#8220;<span class="quote">fortran</span>&#8221; (and any combination).  The default is
        !          7543:     &#8220;<span class="quote">c</span>&#8221;.  Packages using GNU configure scripts, even if
        !          7544:     written in C++, usually need a C compiler for the configure
        !          7545:     phase.</p>
        !          7546: </div>
        !          7547: <div class="sect2" lang="en">
        !          7548: <div class="titlepage"><div><div><h3 class="title">
        !          7549: <a name="java-programming-language"></a>17.4.2. Java</h3></div></div></div>
        !          7550: <p>If a program is written in Java, use the Java framework in
        !          7551:     pkgsrc.  The package must include
        !          7552:     <code class="filename">../../mk/java-vm.mk</code>.  This Makefile fragment
        !          7553:     provides the following variables:</p>
        !          7554: <div class="itemizedlist"><ul type="disc">
        !          7555: <li><p><code class="varname">USE_JAVA</code> defines if a build
        !          7556:       dependency on the JDK is added.  If
        !          7557:       <code class="varname">USE_JAVA</code> is set to &#8220;<span class="quote">run</span>&#8221;, then
        !          7558:       there is only a runtime dependency on the JDK.  The default is
        !          7559:       &#8220;<span class="quote">yes</span>&#8221;, which also adds a build dependency on the
        !          7560:       JDK.</p></li>
        !          7561: <li><p>Set <code class="varname">USE_JAVA2</code> to declare that
        !          7562:       a package needs a Java2 implementation.  The supported values
        !          7563:       are &#8220;<span class="quote">yes</span>&#8221;, &#8220;<span class="quote">1.4</span>&#8221;, and
        !          7564:       &#8220;<span class="quote">1.5</span>&#8221;.  &#8220;<span class="quote">yes</span>&#8221; accepts any Java2
        !          7565:       implementation, &#8220;<span class="quote">1.4</span>&#8221; insists on versions 1.4 or
        !          7566:       above, and &#8220;<span class="quote">1.5</span>&#8221; only accepts versions 1.5 or
        !          7567:       above. This variable is not set by default.</p></li>
        !          7568: </ul></div>
        !          7569: </div>
        !          7570: <div class="sect2" lang="en">
        !          7571: <div class="titlepage"><div><div><h3 class="title">
        !          7572: <a name="perl-scripts"></a>17.4.3. Packages containing perl scripts</h3></div></div></div>
        !          7573: <p>If your package contains interpreted perl scripts, add
        !          7574:     &#8220;<span class="quote">perl</span>&#8221; to the <code class="varname">USE_TOOLS</code> variable
        !          7575:     and set <code class="varname">REPLACE_PERL</code> to ensure that the proper
        !          7576:     interpreter path is set. <code class="varname">REPLACE_PERL</code> should
        !          7577:     contain a list of scripts, relative to <code class="varname">WRKSRC</code>,
        !          7578:     that you want adjusted.  Every occurrence of
        !          7579:     <code class="filename">*/bin/perl</code> will be replaced with the full
        !          7580:     path to the perl executable.</p>
        !          7581: <p>If a particular version of perl is needed, set the
        !          7582:     <code class="varname">PERL5_REQD</code> variable to the version number.  The
        !          7583:     default is &#8220;<span class="quote">5.0</span>&#8221;.</p>
        !          7584: <p>See <a href="#perl-modules" title="17.6.5. Packages installing perl modules">Section 17.6.5, &#8220;Packages installing perl modules&#8221;</a> for information
        !          7585:     about handling perl modules.</p>
        !          7586: </div>
        !          7587: <div class="sect2" lang="en">
        !          7588: <div class="titlepage"><div><div><h3 class="title">
        !          7589: <a name="other-programming-languages"></a>17.4.4. Other programming languages</h3></div></div></div>
        !          7590: <p>Currently, there is no special handling for other languages
        !          7591:     in pkgsrc.  If a compiler package provides a
        !          7592:     <code class="filename">buildlink3.mk</code> file, include that, otherwise
        !          7593:     just add a (build) dependency on the appropriate compiler
        !          7594:     package.</p>
        !          7595: </div>
        !          7596: </div>
        !          7597: <div class="sect1" lang="en">
        !          7598: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
        !          7599: <a name="fixes.build"></a>17.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.77      rillig   7600: <p>The most common failures when building a package are that
                   7601:        some platforms do not provide certain header files, functions or
                   7602:        libraries, or they provide the functions in a library that the
                   7603:        original package author didn't know. To work around this, you
                   7604:        can rewrite the source code in most cases so that it does not
                   7605:        use the missing functions or provides a replacement function.</p>
                   7606: <div class="sect2" lang="en">
                   7607: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      7608: <a name="fixes.build.cpp"></a>17.5.1. Compiling C and C++ code conditionally</h3></div></div></div>
1.77      rillig   7609: <p>If a package already comes with a GNU configure script, the
                   7610:        preferred way to fix the build failure is to change the
                   7611:        configure script, not the code. In the other cases, you can
                   7612:        utilize the C preprocessor, which defines certain macros
                   7613:        depending on the operating system and hardware architecture it
                   7614:        compiles for. These macros can be queried using for example
                   7615:        <code class="varname">#if defined(__i386)</code>. Almost every operating
                   7616:        system, hardware architecture and compiler has its own macro.
                   7617:        For example, if the macros <code class="varname">__GNUC__</code>,
                   7618:        <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
                   7619:        are all defined, you know that you are using NetBSD on an i386
                   7620:        compatible CPU, and your compiler is GCC.</p>
                   7621: <p>The list of the following macros for hardware and
                   7622:        operating system depends on the compiler that is used. For
                   7623:        example, if you want to conditionally compile code on Solaris,
                   7624:        don't use <code class="varname">__sun__</code>, as the SunPro compiler
                   7625:        does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75      rillig   7626: <div class="sect3" lang="en">
                   7627: <div class="titlepage"><div><div><h4 class="title">
1.87    ! wiz      7628: <a name="fixes.build.cpp.os"></a>17.5.1.1. C preprocessor macros to identify the operating system</h4></div></div></div>
1.75      rillig   7629: <p>To distinguish between 4.4 BSD-derived systems and the
                   7630:         rest of the world, you should use the following code.</p>
                   7631: <pre class="programlisting">
                   7632:     #include &lt;sys/param.h&gt;
                   7633:     #if (defined(BSD) &amp;&amp; BSD &gt;= 199306)
                   7634:       /* BSD-specific code goes here */
                   7635:     #else
                   7636:       /* non-BSD-specific code goes here */
                   7637:     #endif
                   7638: </pre>
1.77      rillig   7639: <p>If this distinction is not fine enough, you can also test
                   7640:        for the following macros.</p>
1.75      rillig   7641: <pre class="programlisting">
                   7642:     FreeBSD     __FreeBSD__
                   7643:     DragonFly   __DragonFly__
                   7644:     Interix     __INTERIX
                   7645:     Linux       linux, __linux, __linux__
                   7646:     NetBSD      __NetBSD__
                   7647:     OpenBSD     __OpenBSD__
                   7648:     Solaris     sun, __sun
                   7649: </pre>
                   7650: </div>
                   7651: <div class="sect3" lang="en">
                   7652: <div class="titlepage"><div><div><h4 class="title">
1.87    ! wiz      7653: <a name="fixes.build.cpp.arch"></a>17.5.1.2. C preprocessor macros to identify the hardware architecture</h4></div></div></div>
1.75      rillig   7654: <pre class="programlisting">
                   7655:     i386        i386, __i386, __i386__
                   7656:     MIPS        __mips
                   7657:     SPARC       sparc, __sparc
                   7658: </pre>
                   7659: </div>
                   7660: <div class="sect3" lang="en">
                   7661: <div class="titlepage"><div><div><h4 class="title">
1.87    ! wiz      7662: <a name="fixes.build.cpp.compiler"></a>17.5.1.3. C preprocessor macros to identify the compiler</h4></div></div></div>
1.75      rillig   7663: <pre class="programlisting">
                   7664:     GCC         __GNUC__ (major version), __GNUC_MINOR__
                   7665:     SunPro      __SUNPRO_C (0x570 for version 5.7)
1.81      rillig   7666:     SunPro C++  __SUNPRO_CC (0x580 for version 5.8)
1.75      rillig   7667: </pre>
                   7668: </div>
                   7669: </div>
1.78      rillig   7670: <div class="sect2" lang="en">
                   7671: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      7672: <a name="compiler-bugs"></a>17.5.2. How to handle compiler bugs</h3></div></div></div>
1.78      rillig   7673: <p>Some source files trigger bugs in the compiler, based on
1.87    ! wiz      7674:         combinations of compiler version and architecture and almost
        !          7675:         always relation to optimisation being enabled.  Common symptoms
        !          7676:         are gcc internal errors or never finishing compiling a
1.78      rillig   7677:        file.</p>
                   7678: <p>Typically, a workaround involves testing the
                   7679:         <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
                   7680:         optimisation for that combination of file,
                   7681:        <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
1.87    ! wiz      7682:        in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
1.78      rillig   7683:        number of examples.</p>
                   7684: </div>
                   7685: <div class="sect2" lang="en">
                   7686: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      7687: <a name="undefined-reference"></a>17.5.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</h3></div></div></div>
1.78      rillig   7688: <p>This compiler error often means that a package did not
                   7689:        link to a shared library it needs. The following functions are
                   7690:        known to cause this error message over and over.</p>
                   7691: <div class="informaltable">
                   7692: <a name="undefined-reference-functions"></a><table border="1">
                   7693: <colgroup>
                   7694: <col>
                   7695: <col>
                   7696: <col>
                   7697: </colgroup>
                   7698: <thead><tr>
                   7699: <th>Function</th>
                   7700: <th>Library</th>
                   7701: <th>Affected platforms</th>
                   7702: </tr></thead>
                   7703: <tbody>
                   7704: <tr>
                   7705: <td>accept, bind, connect</td>
                   7706: <td>-lsocket</td>
                   7707: <td>Solaris</td>
                   7708: </tr>
                   7709: <tr>
                   7710: <td>crypt</td>
                   7711: <td>-lcrypt</td>
                   7712: <td>DragonFly, NetBSD</td>
                   7713: </tr>
                   7714: <tr>
                   7715: <td>dlopen, dlsym</td>
                   7716: <td>-ldl</td>
                   7717: <td>Linux</td>
                   7718: </tr>
                   7719: <tr>
                   7720: <td>gethost*</td>
                   7721: <td>-lnsl</td>
                   7722: <td>Solaris</td>
                   7723: </tr>
                   7724: <tr>
                   7725: <td>inet_aton</td>
                   7726: <td>-lresolv</td>
                   7727: <td>Solaris</td>
                   7728: </tr>
                   7729: <tr>
                   7730: <td>nanosleep, sem_*, timer_*</td>
                   7731: <td>-lrt</td>
                   7732: <td>Solaris</td>
                   7733: </tr>
                   7734: <tr>
                   7735: <td>openpty</td>
                   7736: <td>-lutil</td>
                   7737: <td>Linux</td>
                   7738: </tr>
                   7739: </tbody>
                   7740: </table>
                   7741: </div>
                   7742: <p>To fix these linker errors, it is often sufficient to say
1.87    ! wiz      7743:     <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
        !          7744:     -l<em class="replaceable"><code>foo</code></em></code> to the package
        !          7745:     <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
        !          7746:     bmake</strong></span>.</p>
        !          7747: </div>
        !          7748: <div class="sect2" lang="en">
        !          7749: <div class="titlepage"><div><div><h3 class="title">
        !          7750: <a name="out-of-memory"></a>17.5.4. Running out of memory</h3></div></div></div>
        !          7751: <p>Sometimes packages fail to build because the compiler runs
        !          7752:     into an operating system specific soft limit.  With the
        !          7753:     <code class="varname">UNLIMIT_RESOURCES</code> variable pkgsrc can be told
        !          7754:     to unlimit the resources.  Currently, the allowed values are
        !          7755:     &#8220;<span class="quote">datasize</span>&#8221; and &#8220;<span class="quote">stacksize</span>&#8221; (or both).
        !          7756:     Setting this variable is similar to running the shell builtin
        !          7757:     <span><strong class="command">ulimit</strong></span> command to raise the maximum data
        !          7758:     segment size or maximum stack size of a process, respectively, to
        !          7759:     their hard limits.</p>
1.78      rillig   7760: </div>
1.75      rillig   7761: </div>
                   7762: <div class="sect1" lang="en">
                   7763: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.87    ! wiz      7764: <a name="fixes.install"></a>17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75      rillig   7765: <div class="sect2" lang="en">
                   7766: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      7767: <a name="install-scripts"></a>17.6.1. Creating needed directories</h3></div></div></div>
1.78      rillig   7768: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
1.87    ! wiz      7769:     with some operating systems cannot create more than one
        !          7770:     directory at a time. As such, you should call
        !          7771:     <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
        !          7772: <pre class="programlisting">
        !          7773:       ${INSTALL_DATA_DIR} ${PREFIX}/dir1
        !          7774:       ${INSTALL_DATA_DIR} ${PREFIX}/dir2
        !          7775:     </pre>
1.78      rillig   7776: <p>You can also just append &#8220;<span class="quote"><code class="literal">dir1
1.87    ! wiz      7777:     dir2</code></span>&#8221; to the
        !          7778:     <code class="varname">INSTALLATION_DIRS</code> variable, which will
        !          7779:     automatically do the right thing.</p>
1.75      rillig   7780: </div>
                   7781: <div class="sect2" lang="en">
                   7782: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      7783: <a name="where-to-install-documentation"></a>17.6.2. Where to install documentation</h3></div></div></div>
1.83      wiz      7784: <p>In general, documentation should be installed into
1.87    ! wiz      7785:     <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
        !          7786:     <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
        !          7787:     includes the version number of the package).</p>
1.84      wiz      7788: <p>Many modern packages using GNU autoconf allow to set the
1.87    ! wiz      7789:     directory where HTML documentation is installed with the
        !          7790:     &#8220;<span class="quote">--with-html-dir</span>&#8221; option. Sometimes using this flag
        !          7791:     is needed because otherwise the documentation ends up in
        !          7792:     <code class="filename">${PREFIX}/share/doc/html</code> or other
        !          7793:     places.</p>
        !          7794: <p>An exception to the above is that library API documentation
        !          7795:     generated with the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/textproc/gtk-doc/README.html" target="_top"><code class="filename">textproc/gtk-doc</code></a> tools, for use by special
        !          7796:     browsers (devhelp) should be left at their default location, which
        !          7797:     is <code class="filename">${PREFIX}/share/gtk-doc</code>.  Such
        !          7798:     documentation can be recognized from files ending in
        !          7799:     <code class="filename">.devhelp</code> or <code class="filename">.devhelp2</code>.
        !          7800:     (It is also acceptable to install such files in
        !          7801:     <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
        !          7802:     <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code>; the
        !          7803:     <code class="filename">.devhelp*</code> file must be directly in that
        !          7804:     directory then, no additional subdirectory level is allowed in
        !          7805:     this case. This is usually achieved by using
        !          7806:     &#8220;<span class="quote">--with-html-dir=${PREFIX}/share/doc</span>&#8221;.
        !          7807:     <code class="filename">${PREFIX}/share/gtk-doc</code> is preferred
        !          7808:     though.)</p>
1.75      rillig   7809: </div>
                   7810: <div class="sect2" lang="en">
                   7811: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      7812: <a name="installing-score-files"></a>17.6.3. Installing score files</h3></div></div></div>
1.75      rillig   7813: <p>Certain packages, most of them in the games category, install
1.87    ! wiz      7814:     a score file that allows all users on the system to record their
        !          7815:     highscores.  In order for this to work, the binaries need to be
        !          7816:     installed setgid and the score files owned by the appropriate
        !          7817:     group and/or owner (traditionally the "games" user/group).  The
        !          7818:     following variables, documented in more detail in
        !          7819:     <code class="filename">mk/defaults/mk.conf</code>, control this
        !          7820:     behaviour: <code class="varname">SETGIDGAME</code>,
        !          7821:     <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
        !          7822:     <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
1.75      rillig   7823: <p>Note that per default, setgid installation of games is
1.87    ! wiz      7824:     disabled;  setting <code class="varname">SETGIDGAME=YES</code> will set all
        !          7825:     the other variables accordingly.</p>
1.75      rillig   7826: <p>A package should therefor never hard code file ownership or
1.87    ! wiz      7827:     access permissions but rely on <code class="varname">INSTALL_GAME</code> and
        !          7828:     <code class="varname">INSTALL_GAME_DATA</code> to set these
        !          7829:     correctly.</p>
1.75      rillig   7830: </div>
                   7831: <div class="sect2" lang="en">
                   7832: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      7833: <a name="hardcoded-paths"></a>17.6.4. Packages with hardcoded paths to other interpreters</h3></div></div></div>
        !          7834: <p>Your package may also contain scripts with hardcoded paths to
        !          7835:       other interpreters besides (or as well as) perl.  To correct the
        !          7836:       full pathname to the script interpreter, you need to set the
        !          7837:       following definitions in your <code class="filename">Makefile</code> (we
        !          7838:     shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
        !          7839: <pre class="programlisting">
        !          7840:       REPLACE_INTERPRETER+=   tcl
        !          7841:       REPLACE.tcl.old=        .*/bin/tclsh
        !          7842:       REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
        !          7843:       REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
        !          7844:       # relative to ${WRKSRC}, just as in REPLACE_PERL
        !          7845:     </pre>
1.75      rillig   7846: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   7847: <h3 class="title">Note</h3>
                   7848: <p>Before March 2006, these variables were called
1.87    ! wiz      7849:     <code class="varname">_REPLACE.*</code> and
        !          7850:     <code class="varname">_REPLACE_FILES.*</code>.</p>
1.75      rillig   7851: </div>
                   7852: </div>
                   7853: <div class="sect2" lang="en">
                   7854: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      7855: <a name="perl-modules"></a>17.6.5. Packages installing perl modules</h3></div></div></div>
1.75      rillig   7856: <p>Makefiles of packages providing perl5 modules should include
1.87    ! wiz      7857:     the Makefile fragment
        !          7858:     <code class="filename">../../lang/perl5/module.mk</code>.  It provides a
        !          7859:     <span><strong class="command">do-configure</strong></span> target for the standard perl
        !          7860:     configuration for such modules as well as various hooks to tune
        !          7861:     this configuration.  See comments in this file for
        !          7862:     details.</p>
1.75      rillig   7863: <p>Perl5 modules will install into different places depending
1.87    ! wiz      7864:     on the version of perl used during the build process.  To
        !          7865:     address this, pkgsrc will append lines to the
        !          7866:     <code class="filename">PLIST</code> corresponding to the files listed in
        !          7867:     the installed <code class="filename">.packlist</code> file generated by
        !          7868:     most perl5 modules.  This is invoked by defining
        !          7869:     <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
        !          7870:     paths to packlist files, e.g.:</p>
1.75      rillig   7871: <pre class="programlisting">
1.87    ! wiz      7872:       PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
        !          7873:     </pre>
1.75      rillig   7874: <p>The variables <code class="varname">PERL5_SITELIB</code>,
1.87    ! wiz      7875:     <code class="varname">PERL5_SITEARCH</code>, and
        !          7876:     <code class="varname">PERL5_ARCHLIB</code> represent the three locations
        !          7877:     in which perl5 modules may be installed, and may be used by
        !          7878:     perl5 packages that don't have a packlist.  These three
        !          7879:     variables are also substituted for in the
        !          7880:     <code class="filename">PLIST</code>.</p>
1.75      rillig   7881: </div>
                   7882: <div class="sect2" lang="en">
                   7883: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      7884: <a name="faq.info-files"></a>17.6.6. Packages installing info files</h3></div></div></div>
1.75      rillig   7885: <p>Some packages install info files or use the
1.87    ! wiz      7886:     &#8220;<span class="quote">makeinfo</span>&#8221;  or &#8220;<span class="quote">install-info</span>&#8221;
        !          7887:     commands.  <code class="varname">INFO_FILES</code> should be defined in
        !          7888:     the package Makefile so that <code class="filename">INSTALL</code> and
        !          7889:     <code class="filename">DEINSTALL</code> scripts will be generated to
        !          7890:     handle registration of the info files in the Info directory
        !          7891:     file. The &#8220;<span class="quote">install-info</span>&#8221; command used for the info
        !          7892:     files registration is either provided by the system, or by a
        !          7893:     special purpose package automatically added as dependency if
        !          7894:     needed.</p>
1.75      rillig   7895: <p><code class="varname">PKGINFODIR</code> is the directory under
1.87    ! wiz      7896:     <code class="filename">${PREFIX}</code> where info files are primarily
        !          7897:     located. <code class="varname">PKGINFODIR</code> defaults to
        !          7898:     &#8220;<span class="quote">info</span>&#8221; and can be overridden by the user.</p>
1.75      rillig   7899: <p>The info files for the package should be listed in the
1.87    ! wiz      7900:     package <code class="filename">PLIST</code>; however any split info files
        !          7901:     need not be listed.</p>
1.75      rillig   7902: <p>A package which needs the &#8220;<span class="quote">makeinfo</span>&#8221; command
1.87    ! wiz      7903:     at build time must add &#8220;<span class="quote">makeinfo</span>&#8221; to
        !          7904:     <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
        !          7905:     version of the &#8220;<span class="quote">makeinfo</span>&#8221; command is needed it
        !          7906:     should be noted with the <code class="varname">TEXINFO_REQD</code>
        !          7907:     variable in the package <code class="filename">Makefile</code>. By
        !          7908:     default, a minimum version of 3.12 is required. If the system
        !          7909:     does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
        !          7910:     does not match the required minimum, a build dependency on the
        !          7911:     <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/gtexinfo/README.html" target="_top"><code class="filename">devel/gtexinfo</code></a> package will
        !          7912:     be added automatically.</p>
1.75      rillig   7913: <p>The build and installation process of the software provided
1.87    ! wiz      7914:     by the package should not use the
        !          7915:     <span><strong class="command">install-info</strong></span> command as the registration of
        !          7916:     info files is the task of the package
        !          7917:     <code class="filename">INSTALL</code> script, and it must use the
        !          7918:     appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
1.75      rillig   7919: <p>To achieve this goal, the pkgsrc infrastructure creates
1.87    ! wiz      7920:     overriding scripts for the <span><strong class="command">install-info</strong></span> and
        !          7921:     <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
        !          7922:     in <code class="varname">PATH</code>.</p>
1.75      rillig   7923: <p>The script overriding <span><strong class="command">install-info</strong></span> has
1.87    ! wiz      7924:     no effect except the logging of a message. The script overriding
        !          7925:     <span><strong class="command">makeinfo</strong></span> logs a message and according to the
        !          7926:     value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
        !          7927:     <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
1.75      rillig   7928: </div>
                   7929: <div class="sect2" lang="en">
                   7930: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      7931: <a name="manpages"></a>17.6.7. Packages installing man pages</h3></div></div></div>
1.81      rillig   7932: <p>All packages that install manual pages should install them
1.87    ! wiz      7933:     into the same directory, so that there is one common place to look
        !          7934:     for them. In pkgsrc, this place is
        !          7935:     <code class="literal">${PREFIX}/${PKGMANDIR}</code>, and this expression
        !          7936:     should be used in packages. The default for
        !          7937:     <code class="varname">PKGMANDIR</code> is
        !          7938:     &#8220;<span class="quote"><code class="filename">man</code></span>&#8221;. Another often-used value
        !          7939:     is &#8220;<span class="quote"><code class="filename">share/man</code></span>&#8221;.</p>
1.75      rillig   7940: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   7941: <h3 class="title">Note</h3>
1.87    ! wiz      7942: <p>The support for a custom <code class="varname">PKGMANDIR</code>
        !          7943:     is far from complete.</p>
1.75      rillig   7944: </div>
1.81      rillig   7945: <p>The <code class="filename">PLIST</code> files can just use
1.87    ! wiz      7946:     <code class="filename">man/</code> as the top level directory for the man
        !          7947:     page file entries, and the pkgsrc framework will convert as
        !          7948:     needed. In all other places, the correct
        !          7949:     <code class="varname">PKGMANDIR</code> must be used.</p>
        !          7950: <p>Packages that are
        !          7951:     configured with <code class="varname">GNU_CONFIGURE</code> set as
        !          7952:     &#8220;<span class="quote">yes</span>&#8221;, by default will use the
        !          7953:     <code class="filename">./configure</code>
        !          7954:     --mandir switch to set where the man pages should be installed.
        !          7955:     The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
        !          7956:     to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.</p>
        !          7957: <p>Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
        !          7958:     use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
        !          7959:     to &#8220;<span class="quote">no</span>&#8221;.
        !          7960:     Or if the <code class="filename">./configure</code> script uses
        !          7961:     a non-standard use of --mandir, you can set
        !          7962:     <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.</p>
1.77      rillig   7963: <p>See <a href="#manpage-compression" title="11.5. Man page compression">Section 11.5, &#8220;Man page compression&#8221;</a> for
1.87    ! wiz      7964:     information on installation of compressed manual pages.</p>
1.75      rillig   7965: </div>
                   7966: <div class="sect2" lang="en">
                   7967: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      7968: <a name="gconf2-data-files"></a>17.6.8. Packages installing GConf2 data files</h3></div></div></div>
        !          7969: <p>If a package installs <code class="filename">.schemas</code> or
        !          7970:     <code class="filename">.entries</code> files, used by GConf2,
        !          7971:     you need to take some extra steps to make sure they get registered
        !          7972:     in the database:</p>
1.75      rillig   7973: <div class="orderedlist"><ol type="1">
1.76      rillig   7974: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
1.87    ! wiz      7975:        instead of its <code class="filename">buildlink3.mk</code> file.  This
        !          7976:        takes care of rebuilding the GConf2 database at installation and
        !          7977:        deinstallation time, and tells the package where to install
        !          7978:        GConf2 data files using some standard configure arguments.  It
        !          7979:        also disallows any access to the database directly from the
        !          7980:        package.</p></li>
1.75      rillig   7981: <li><p>Ensure that the package installs its
1.87    ! wiz      7982:        <code class="filename">.schemas</code> files under
        !          7983:        <code class="filename">${PREFIX}/share/gconf/schemas</code>.  If they get
        !          7984:        installed under <code class="filename">${PREFIX}/etc</code>, you will
        !          7985:        need to manually patch the package.</p></li>
1.75      rillig   7986: <li><p>Check the PLIST and remove any entries under the etc/gconf
1.87    ! wiz      7987:        directory, as they will be handled automatically.  See
        !          7988:        <a href="#faq.conf" title="7.14. How do I change the location of configuration files?">Section 7.14, &#8220;How do I change the location of configuration files?&#8221;</a> for more information.</p></li>
1.75      rillig   7989: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.87    ! wiz      7990:        your <code class="filename">Makefile</code> with a list of all
        !          7991:        <code class="filename">.schemas</code> files installed by the package, if
        !          7992:        any.  Names must not contain any directories in them.</p></li>
1.75      rillig   7993: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.87    ! wiz      7994:        your <code class="filename">Makefile</code> with a
        !          7995:        list of all <code class="filename">.entries</code> files installed by the
        !          7996:        package, if any. Names must not contain any directories in
        !          7997:        them.</p></li>
1.75      rillig   7998: </ol></div>
                   7999: </div>
                   8000: <div class="sect2" lang="en">
                   8001: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      8002: <a name="scrollkeeper-data-files"></a>17.6.9. Packages installing scrollkeeper data files</h3></div></div></div>
        !          8003: <p>If a package installs <code class="filename">.omf</code> files, used by
        !          8004:     scrollkeeper, you need to take some extra steps to make sure they
        !          8005:     get registered in the database:</p>
1.75      rillig   8006: <div class="orderedlist"><ol type="1">
                   8007: <li><p>Include
1.87    ! wiz      8008:        <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
        !          8009:        instead of its <code class="filename">buildlink3.mk</code> file.  This
        !          8010:        takes care of rebuilding the scrollkeeper database at
        !          8011:        installation and deinstallation time, and disallows any access
        !          8012:        to it directly from the package.</p></li>
1.75      rillig   8013: <li><p>Check the PLIST and remove any entries under the
1.87    ! wiz      8014:        <code class="filename">libdata/scrollkeeper</code> directory, as they
        !          8015:        will be handled automatically.</p></li>
1.76      rillig   8016: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.87    ! wiz      8017:        the PLIST.  It will be handled by scrollkeeper.</p></li>
1.75      rillig   8018: </ol></div>
                   8019: </div>
                   8020: <div class="sect2" lang="en">
                   8021: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      8022: <a name="x11-fonts"></a>17.6.10. Packages installing X11 fonts</h3></div></div></div>
1.75      rillig   8023: <p>If a package installs font files, you will need to rebuild
1.87    ! wiz      8024:     the fonts database in the directory where they get installed at
        !          8025:     installation and deinstallation time.  This can be automatically
        !          8026:     done by using the pkginstall framework.</p>
1.75      rillig   8027: <p>You can list the directories where fonts are installed in the
1.87    ! wiz      8028:     <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
        !          8029:     variables, where <em class="replaceable"><code>type</code></em> can be one of
        !          8030:     &#8220;<span class="quote">ttf</span>&#8221;, &#8220;<span class="quote">type1</span>&#8221; or &#8220;<span class="quote">x11</span>&#8221;.
        !          8031:     Also make sure that the database file
        !          8032:     <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75      rillig   8033: <p>Note that you should not create new directories for fonts;
1.87    ! wiz      8034:     instead use the standard ones to avoid that the user needs to
        !          8035:     manually configure his X server to find them.</p>
1.75      rillig   8036: </div>
                   8037: <div class="sect2" lang="en">
                   8038: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      8039: <a name="gtk2-modules"></a>17.6.11. Packages installing GTK2 modules</h3></div></div></div>
1.75      rillig   8040: <p>If a package installs GTK2 immodules or loaders, you need to
1.87    ! wiz      8041:     take some extra steps to get them registered in the GTK2 database
        !          8042:     properly:</p>
1.75      rillig   8043: <div class="orderedlist"><ol type="1">
                   8044: <li><p>Include
1.87    ! wiz      8045:       <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
        !          8046:       <code class="filename">buildlink3.mk</code> file.  This takes care of
        !          8047:       rebuilding the database at installation and deinstallation time.</p></li>
        !          8048: <li><p>Set <code class="varname">GTK2_IMMODULES=YES</code> if
        !          8049:       your package installs GTK2 immodules.</p></li>
        !          8050: <li><p>Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
        !          8051:       GTK2 loaders.</p></li>
1.75      rillig   8052: <li>
1.87    ! wiz      8053: <p>Patch the package to not touch any of the GTK2
        !          8054:       databases directly.  These are:</p>
1.75      rillig   8055: <div class="itemizedlist"><ul type="disc">
1.76      rillig   8056: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
                   8057: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75      rillig   8058: </ul></div>
                   8059: </li>
1.87    ! wiz      8060: <li><p>Check the <code class="filename">PLIST</code> and remove
        !          8061:       any entries under the <code class="filename">libdata/gtk-2.0</code>
        !          8062:       directory, as they will be handled automatically.</p></li>
1.75      rillig   8063: </ol></div>
                   8064: </div>
                   8065: <div class="sect2" lang="en">
                   8066: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      8067: <a name="sgml-xml-data"></a>17.6.12. Packages installing SGML or XML data</h3></div></div></div>
1.75      rillig   8068: <p>If a package installs SGML or XML data files that need to be
1.87    ! wiz      8069:     registered in system-wide catalogs (like DTDs, sub-catalogs,
        !          8070:     etc.), you need to take some extra steps:</p>
1.75      rillig   8071: <div class="orderedlist"><ol type="1">
                   8072: <li><p>Include
1.87    ! wiz      8073:        <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
        !          8074:        your <code class="filename">Makefile</code>, which takes care of
        !          8075:        registering those files in system-wide catalogs at
        !          8076:        installation and deinstallation time.</p></li>
1.75      rillig   8077: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
1.87    ! wiz      8078:        any SGML catalogs installed by the package.</p></li>
1.75      rillig   8079: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
1.87    ! wiz      8080:        any XML catalogs installed by the package.</p></li>
1.75      rillig   8081: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
1.87    ! wiz      8082:        to be added to the SGML catalog.  These come in groups of
        !          8083:        three strings; see xmlcatmgr(1) for more information
        !          8084:        (specifically, arguments recognized by the 'add' action).
        !          8085:        Note that you will normally not use this variable.</p></li>
1.75      rillig   8086: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
1.87    ! wiz      8087:        to be added to the XML catalog.  These come in groups of three
        !          8088:        strings; see xmlcatmgr(1) for more information (specifically,
        !          8089:        arguments recognized by the 'add' action).  Note that you will
        !          8090:        normally not use this variable.</p></li>
1.75      rillig   8091: </ol></div>
                   8092: </div>
                   8093: <div class="sect2" lang="en">
                   8094: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      8095: <a name="mime-database"></a>17.6.13. Packages installing extensions to the MIME database</h3></div></div></div>
1.75      rillig   8096: <p>If a package provides extensions to the MIME database by
1.87    ! wiz      8097:     installing <code class="filename">.xml</code> files inside
        !          8098:     <code class="filename">${PREFIX}/share/mime/packages</code>, you
        !          8099:     need to take some extra steps to ensure that the database is kept
        !          8100:     consistent with respect to these new files:</p>
1.75      rillig   8101: <div class="orderedlist"><ol type="1">
                   8102: <li><p>Include
1.87    ! wiz      8103:        <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
        !          8104:        (avoid using the <code class="filename">buildlink3.mk</code> file from
        !          8105:        this same directory, which is reserved for inclusion from
        !          8106:        other <code class="filename">buildlink3.mk</code> files).  It takes
        !          8107:        care of rebuilding the MIME database at installation and
        !          8108:        deinstallation time, and disallows any access to it directly
        !          8109:        from the package.</p></li>
1.75      rillig   8110: <li><p>Check the PLIST and remove any entries under the
1.87    ! wiz      8111:        <code class="filename">share/mime</code> directory,
        !          8112:        <span class="emphasis"><em>except</em></span> for files saved under
        !          8113:        <code class="filename">share/mime/packages</code>.  The former are
        !          8114:        handled automatically by
        !          8115:        the update-mime-database program, but the latter are
        !          8116:        package-dependent and must be removed by the package that
        !          8117:        installed them in the first place.</p></li>
1.76      rillig   8118: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.87    ! wiz      8119:        from the PLIST.  They will be handled by the shared-mime-info
        !          8120:        package.</p></li>
1.75      rillig   8121: </ol></div>
                   8122: </div>
                   8123: <div class="sect2" lang="en">
                   8124: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      8125: <a name="intltool"></a>17.6.14. Packages using intltool</h3></div></div></div>
1.75      rillig   8126: <p>If a package uses intltool during its build, include the
1.87    ! wiz      8127:     <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
        !          8128:     which forces it to use the intltool package provided by pkgsrc,
        !          8129:     instead of the one bundled with the distribution file.</p>
1.75      rillig   8130: <p>This tracks intltool's build-time dependencies and uses the
1.87    ! wiz      8131:     latest available version; this way, the package benefits of any
        !          8132:     bug fixes that may have appeared since it was released.</p>
1.75      rillig   8133: </div>
                   8134: <div class="sect2" lang="en">
                   8135: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      8136: <a name="startup-scripts"></a>17.6.15. Packages installing startup scripts</h3></div></div></div>
1.75      rillig   8137: <p>If a package contains a rc.d script, it won't be copied into
1.87    ! wiz      8138:     the startup directory by default, but you can enable it, by adding
        !          8139:     the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
        !          8140:     <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
        !          8141:     into <code class="filename">/etc/rc.d</code> when a package is installed, and
        !          8142:     it will automatically remove the scripts when the package is
        !          8143:     deinstalled.</p>
1.75      rillig   8144: </div>
                   8145: <div class="sect2" lang="en">
                   8146: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      8147: <a name="tex-packages"></a>17.6.16. Packages installing TeX modules</h3></div></div></div>
1.75      rillig   8148: <p>If a package installs TeX packages into the texmf tree,
1.87    ! wiz      8149:     the <code class="filename">ls-R</code> database of the tree needs to be
        !          8150:     updated.</p>
1.75      rillig   8151: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   8152: <h3 class="title">Note</h3>
                   8153: <p>Except the main TeX packages such as teTeX-texmf,
1.87    ! wiz      8154:     packages should install files
        !          8155:     into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
        !          8156:     not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
1.75      rillig   8157: </div>
                   8158: <div class="orderedlist"><ol type="1">
                   8159: <li><p>Include
1.87    ! wiz      8160:       <code class="filename">../../print/teTeX/module.mk</code> instead
        !          8161:       of <code class="filename">../../mk/tex.buildlink3.mk</code>.  This
        !          8162:       takes care of rebuilding the <code class="filename">ls-R</code>
        !          8163:       database at installation and deinstallation time.</p></li>
1.75      rillig   8164: <li>
                   8165: <p>If your package installs files into a texmf
1.87    ! wiz      8166:       tree other than the one
        !          8167:       at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
        !          8168:       set <code class="varname">TEXMFDIRS</code> to the list of all texmf
        !          8169:       trees that need database update.</p>
1.75      rillig   8170: <p>If your package also installs font map files that need
1.87    ! wiz      8171:       to be registered using <span><strong class="command">updmap</strong></span>,
        !          8172:       set <code class="varname">TEX_FONTMAPS</code> to the list of all
        !          8173:       such font map files.  Then <span><strong class="command">updmap</strong></span> will
        !          8174:       be run automatically at installation/deinstallation to
        !          8175:       enable/disable font map files for TeX output
        !          8176:       drivers.</p>
1.75      rillig   8177: </li>
1.76      rillig   8178: <li><p>Make sure that none of <code class="filename">ls-R</code>
1.87    ! wiz      8179:       databases are included in <code class="filename">PLIST</code>, as
        !          8180:       they will be removed only by the teTeX-bin package.</p></li>
1.75      rillig   8181: </ol></div>
                   8182: </div>
1.85      jmmv     8183: <div class="sect2" lang="en">
                   8184: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      8185: <a name="emulation-packages"></a>17.6.17. Packages supporting running binaries in
        !          8186:     emulation</h3></div></div></div>
        !          8187: <p>There are some packages that provide libraries and
        !          8188:     executables for running binaries from a one operating system
        !          8189:     on a different one (if the latter supports it).  One example
        !          8190:     is running Linux binaries on NetBSD.</p>
        !          8191: <p>The <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>
        !          8192:     helps in extracting and packaging Linux rpm packages.</p>
        !          8193: <p>The <code class="varname">CHECK_SHLIBS</code> can be set to no to
        !          8194:     avoid the <span><strong class="command">check-shlibs</strong></span> target, which tests
        !          8195:     if all libraries for each installed executable can be found by
        !          8196:     the dynamic linker.  Since the standard dynamic linker is run,
        !          8197:     this fails for emulation packages, because the libraries used
        !          8198:     by the emulation are not in the standard directories.</p>
        !          8199: </div>
        !          8200: <div class="sect2" lang="en">
        !          8201: <div class="titlepage"><div><div><h3 class="title">
        !          8202: <a name="hicolor-theme"></a>17.6.18. Packages installing hicolor theme icons</h3></div></div></div>
1.85      jmmv     8203: <p>If a package installs images under the
1.87    ! wiz      8204:     <code class="filename">share/icons/hicolor</code> and/or updates the
        !          8205:     <code class="filename">share/icons/hicolor/icon-theme.cache</code>
        !          8206:     database, you need to take some extra steps to make sure that the
        !          8207:     shared theme directory is handled appropriately and that the cache
        !          8208:     database is rebuilt:</p>
1.85      jmmv     8209: <div class="orderedlist"><ol type="1">
                   8210: <li><p>Include
1.87    ! wiz      8211:        <code class="filename">../../graphics/hicolor-icon-theme/buildlink3.mk</code>.</p></li>
        !          8212: <li><p>Check the <code class="filename">PLIST</code> and remove the
        !          8213:        entry that refers to the theme cache.</p></li>
1.85      jmmv     8214: <li><p>Ensure that the PLIST does not remove the shared icon
                   8215:          directories from the <code class="filename">share/icons/hicolor</code>
                   8216:          hierarchy because they will be handled automatically.</p></li>
                   8217: </ol></div>
                   8218: <p>The best way to verify that the PLIST is correct with
                   8219:       respect to the last two points is to regenerate it using
                   8220:       <span><strong class="command">make print-PLIST</strong></span>.</p>
                   8221: </div>
                   8222: <div class="sect2" lang="en">
                   8223: <div class="titlepage"><div><div><h3 class="title">
1.87    ! wiz      8224: <a name="desktop-files"></a>17.6.19. Packages installing desktop files</h3></div></div></div>
1.85      jmmv     8225: <p>If a package installs <code class="filename">.desktop</code> files
                   8226:       under <code class="filename">share/applications</code> and these include
                   8227:       MIME information, you need to take extra steps to ensure that they
                   8228:       are registered into the MIME database:</p>
                   8229: <div class="orderedlist"><ol type="1">
                   8230: <li><p>Include
                   8231:          <code class="filename">../../sysutils/desktop-file-utils/desktopdb.mk</code>.</p></li>
                   8232: <li><p>Check the PLIST and remove the entry that refers to the
                   8233:          <code class="filename">share/applications/mimeinfo.cache</code> file.
                   8234:          It will be handled automatically.</p></li>
                   8235: </ol></div>
                   8236: <p>The best way to verify that the PLIST is correct with
                   8237:       respect to the last point is to regenerate it using <span><strong class="command">make
                   8238:       print-PLIST</strong></span>.</p>
1.75      rillig   8239: </div>
                   8240: </div>
1.87    ! wiz      8241: <div class="sect1" lang="en">
        !          8242: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
        !          8243: <a name="punting"></a>17.7. Marking packages as having problems</h2></div></div></div>
        !          8244: <p>In some cases one does not have the time to solve a problem
        !          8245:   immediately.  There are currently two ways to declare that one knows
        !          8246:   that a package has problems.</p>
        !          8247: <div class="itemizedlist"><ul type="disc">
        !          8248: <li><p>The first way is to plainly mark it as broken.  For
        !          8249:     this, one just sets the variable <code class="varname">BROKEN</code> to the
        !          8250:     reason why the package is broken (similar to the
        !          8251:     <code class="varname">RESTRICTED</code> variable).  A user trying to build
        !          8252:     the package will immediately be shown this message, and the build
        !          8253:     will not be even tried.</p></li>
        !          8254: <li><p>After each pkgsrc freeze period (a time when the
        !          8255:     tree is stabilized and a new pkgsrc branch is cut), the packages
        !          8256:     that were not building in the official branch build on the latest
        !          8257:     NetBSD release will be marked as broken on that branch.  This is
        !          8258:     done by setting the <code class="varname">BROKEN_IN</code> variable to the
        !          8259:     branch name (or appending the branch name to it).  If a user tries
        !          8260:     to build such a package and the build fails, the user gets a
        !          8261:     message that says that the package was broken on the respective
        !          8262:     branch(es).</p></li>
        !          8263: </ul></div>
        !          8264: <p>Both types of packages are removed from pkgsrc in irregular
        !          8265:   intervals.</p>
        !          8266: </div>
1.75      rillig   8267: </div>
                   8268: <div class="chapter" lang="en">
                   8269: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   8270: <a name="debug"></a>Chapter 18. Debugging</h2></div></div></div>
1.75      rillig   8271: <p>To check out all the gotchas when building a package, here are the steps
                   8272:     that I do in order to get a package working. Please note this is basically
                   8273:     the same as what was explained in the previous sections, only with some
                   8274:     debugging aids.</p>
                   8275: <div class="itemizedlist"><ul type="disc">
                   8276: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code>
1.76      rillig   8277:        in <code class="filename">/etc/mk.conf</code></p></li>
1.75      rillig   8278: <li>
1.76      rillig   8279: <p>Install <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>,
1.75      rillig   8280:         create a directory for a new package, change into it, then run
                   8281:         <span><strong class="command">url2pkg</strong></span>:</p>
                   8282: <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>
                   8283: <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>
                   8284: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
                   8285: </li>
1.76      rillig   8286: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
                   8287: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.87    ! wiz      8288: <li><p>Run <span><strong class="command">make configure</strong></span></p></li>
1.75      rillig   8289: <li><p>Add any dependencies glimpsed from documentation and the
                   8290:        configure step to the package's
1.76      rillig   8291:        <code class="filename">Makefile</code>.</p></li>
1.75      rillig   8292: <li>
                   8293: <p>Make the package compile, doing multiple rounds of</p>
                   8294: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
                   8295: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
                   8296: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
                   8297: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
                   8298: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
                   8299: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
                   8300: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
                   8301: <p>Doing as non-root user will ensure that no files are modified that
                   8302:        shouldn't be, especially during the build
                   8303:        phase. <span><strong class="command">mkpatches</strong></span>,
                   8304:        <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
1.76      rillig   8305:        from the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>
1.87    ! wiz      8306:        package.</p>
1.75      rillig   8307: </li>
1.76      rillig   8308: <li><p>Look at the <code class="filename">Makefile</code>, fix if necessary;
1.77      rillig   8309:        see <a href="#components.Makefile" title="9.1. Makefile">Section 9.1, &#8220;<code class="filename">Makefile</code>&#8221;</a>.</p></li>
1.75      rillig   8310: <li>
1.76      rillig   8311: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75      rillig   8312: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
                   8313: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST &gt;PLIST</code></strong>
                   8314: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
                   8315: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
                   8316: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.76      rillig   8317: <p>You usually need to be <code class="username">root</code> to do this.
1.75      rillig   8318:        Look if there are any files left:</p>
                   8319: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
                   8320: <p>If this reveals any files that are missing in
1.76      rillig   8321:        <code class="filename">PLIST</code>, add them.</p>
1.75      rillig   8322: </li>
                   8323: <li>
1.76      rillig   8324: <p>Now that the <code class="filename">PLIST</code> is OK,
1.75      rillig   8325:        install the package again and make a binary package:</p>
                   8326: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
                   8327: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
                   8328: </li>
                   8329: <li>
                   8330: <p>Delete the installed package:</p>
                   8331: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete blub</code></strong></pre>
                   8332: </li>
                   8333: <li>
                   8334: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span> command,
                   8335:        which shouldn't find anything now:</p>
                   8336: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
                   8337: </li>
                   8338: <li>
                   8339: <p>Reinstall the binary package:</p>
                   8340: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../blub.tgz</code></strong></pre>
                   8341: </li>
                   8342: <li><p>Play with it. Make sure everything works.</p></li>
                   8343: <li>
                   8344: <p>Run <span><strong class="command">pkglint</strong></span> from
1.76      rillig   8345:         <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>,
1.75      rillig   8346:        and fix the problems it reports:</p>
                   8347: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
                   8348: </li>
                   8349: <li><p>Submit (or commit, if you have cvs access);
1.77      rillig   8350:        see <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a>.</p></li>
1.75      rillig   8351: </ul></div>
                   8352: </div>
                   8353: <div class="chapter" lang="en">
                   8354: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   8355: <a name="submit"></a>Chapter 19. Submitting and Committing</h2></div></div></div>
1.75      rillig   8356: <div class="toc">
                   8357: <p><b>Table of Contents</b></p>
                   8358: <dl>
1.77      rillig   8359: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
                   8360: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                   8361: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
                   8362: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
                   8363: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
                   8364: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig   8365: </dl>
                   8366: </div>
                   8367: <div class="sect1" lang="en">
                   8368: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8369: <a name="submitting-binary-packages"></a>19.1. Submitting binary packages</h2></div></div></div>
1.75      rillig   8370: <p>Our policy is that we accept binaries only from pkgsrc
                   8371:        developers to guarantee that the packages don't contain any
                   8372:        trojan horses etc. This is not to annoy anyone but rather to
                   8373:        protect our users! You're still free to put up your home-made
                   8374:        binary packages and tell the world where to get them. NetBSD
                   8375:        developers doing bulk builds and wanting to upload them please
                   8376:        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>
                   8377: </div>
                   8378: <div class="sect1" lang="en">
                   8379: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8380: <a name="submitting-your-package"></a>19.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75      rillig   8381: <p>First, check that your package is complete, compiles and
1.77      rillig   8382:        runs well; see <a href="#debug" title="Chapter 18. Debugging">Chapter 18, <i>Debugging</i></a> and the rest of this
1.75      rillig   8383:        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   8384:        archive that contains all files that make up the package.
1.87    ! wiz      8385:        Finally, send this package to the pkgsrc bug tracking system,
        !          8386:        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
        !          8387:        that, go to the web page
        !          8388:        <a href="http://www.NetBSD.org/Misc/send-pr.html" target="_top">http://www.NetBSD.org/Misc/send-pr.html</a>,
        !          8389:        which contains some instructions and a link to a form, where you
        !          8390:        can submit packages.</p>
        !          8391: <p>In the form of the problem report, the category should be
        !          8392:        &#8220;<span class="quote">pkg</span>&#8221;, the synopsis should include the package name
        !          8393:        and version number, and the description field should contain a
        !          8394:        short description of your package (contents of the COMMENT
        !          8395:        variable or DESCR file are OK). The uuencoded package data should
        !          8396:        go into the &#8220;<span class="quote">fix</span>&#8221; field.</p>
1.75      rillig   8397: <p>If you want to submit several packages, please send a
                   8398:        separate PR for each one, it's easier for us to track things
                   8399:        that way.</p>
                   8400: <p>Alternatively, you can also import new packages into
                   8401:        pkgsrc-wip (&#8220;<span class="quote">pkgsrc work-in-progress</span>&#8221;); see the
                   8402:        homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
                   8403:        for details.</p>
                   8404: </div>
                   8405: <div class="sect1" lang="en">
                   8406: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8407: <a name="general-notes-for-changes"></a>19.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75      rillig   8408: <p>Please note all package additions, updates, moves, and
1.76      rillig   8409:        removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75      rillig   8410:        important to keep this file up to date and conforming to the
                   8411:        existing format, because it will be used by scripts to
                   8412:        automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
                   8413:        sites. Additionally, check the
1.76      rillig   8414:        <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75      rillig   8415:        for the package you updated or removed, in case it was mentioned
                   8416:        there.</p>
                   8417: <p>When the <code class="varname">PKGREVISION</code> of a package is
                   8418:        bumped, the change should appear in
1.76      rillig   8419:        <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75      rillig   8420:        related or otherwise relevant. Mass bumps that result from a
                   8421:        dependency being updated should not be mentioned. In all other
                   8422:        cases it's the developer's decision.</p>
                   8423: <p>There is a make target that helps in creating proper
1.76      rillig   8424:   <code class="filename">CHANGES</code> entries:  <span><strong class="command">make
1.75      rillig   8425:   changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
                   8426:   and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76      rillig   8427:   usage is to first make sure that your <code class="filename">CHANGES</code>
1.75      rillig   8428:   file is up-to-date (to avoid having to resolve conflicts later-on)
                   8429:   and then to <span><strong class="command">cd</strong></span> to the package directory.  For
                   8430:   package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
                   8431:   For new packages, or package moves or removals, set the
                   8432:   <code class="varname">CTYPE</code> variable on the command line to "Added",
                   8433:   "Moved", or "Removed".  You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76      rillig   8434:   in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75      rillig   8435:   not the same as your NetBSD login name. Don't forget to commit
1.76      rillig   8436:   the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75      rillig   8437: </div>
                   8438: <div class="sect1" lang="en">
                   8439: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8440: <a name="committing-importing"></a>19.4. Committing: Importing a package into CVS</h2></div></div></div>
1.87    ! wiz      8441: <p>This section is only of interest for pkgsrc developers with write
1.75      rillig   8442:   access to the pkgsrc repository. Please remember that cvs
                   8443:   imports files relative to the current working directory, and that
                   8444:   the pathname that you
                   8445:   give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
                   8446:   to place the files in the repository.  Newly created packages should be
                   8447:   imported with a vendor tag of &#8220;<span class="quote">TNF</span>&#8221; and a release tag of
1.87    ! wiz      8448:   &#8220;<span class="quote">pkgsrc-base</span>&#8221;, e.g:</p>
1.75      rillig   8449: <pre class="programlisting">
                   8450:     <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
                   8451:     <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
                   8452: </pre>
1.87    ! wiz      8453: <p>Remember to move the directory from which you imported out of
1.75      rillig   8454:   the way, or cvs will complain the next time you &#8220;<span class="quote">cvs
                   8455:   update</span>&#8221; your source tree.  Also don't forget to add the new
1.87    ! wiz      8456:   package to the category's <code class="filename">Makefile</code>.</p>
        !          8457: <p>The commit message of the initial import should include part of the
1.76      rillig   8458:   <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.87    ! wiz      8459:   what the package is/does.</p>
        !          8460: <p>For new packages, &#8220;<span class="quote">cvs import</span>&#8221; is preferred to &#8220;<span class="quote">cvs
1.75      rillig   8461:   add</span>&#8221; because the former gets everything with a single command,
1.87    ! wiz      8462:   and provides a consistent tag.</p>
1.75      rillig   8463: </div>
                   8464: <div class="sect1" lang="en">
                   8465: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8466: <a name="updating-package"></a>19.5. Updating a package to a newer version</h2></div></div></div>
1.87    ! wiz      8467: <p>Please always put a concise, appropriate and relevant summary of the
1.75      rillig   8468:   changes between old and new versions into the commit log when updating
1.87    ! wiz      8469:   a package. There are various reasons for this:</p>
1.75      rillig   8470: <div class="itemizedlist"><ul type="disc">
1.87    ! wiz      8471: <li><p>A URL is volatile, and can change over time. It may go away completely
        !          8472:   or its information may be overwritten by newer information.</p></li>
        !          8473: <li><p>Having the change information between old and new versions in our CVS
        !          8474:   repository is very useful for people who use either cvs or anoncvs.</p></li>
        !          8475: <li><p>Having the change information between old and new versions in our CVS
1.75      rillig   8476:   repository is very useful for people who read the pkgsrc-changes mailing
                   8477:   list, so that they can make tactical decisions about when to upgrade
1.87    ! wiz      8478:   the package.</p></li>
1.75      rillig   8479: </ul></div>
1.87    ! wiz      8480: <p>Please also recognize that, just because a new version of a package
1.75      rillig   8481:   has been released, it should not automatically be upgraded in the CVS
                   8482:   repository.  We prefer to be conservative in the packages that are
                   8483:   included in pkgsrc - development or beta packages are not really the
                   8484:   best thing for most places in which pkgsrc is used. Please use your
                   8485:   judgement about what should go into pkgsrc, and bear in mind that
1.87    ! wiz      8486:   stability is to be preferred above new and possibly untested features.</p>
1.75      rillig   8487: </div>
                   8488: <div class="sect1" lang="en">
                   8489: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8490: <a name="moving-package"></a>19.6. Moving a package in pkgsrc</h2></div></div></div>
1.75      rillig   8491: <div class="orderedlist"><ol type="1">
                   8492: <li><p>Make a copy of the directory somewhere else.</p></li>
                   8493: <li>
                   8494: <p>Remove all CVS dirs.</p>
1.87    ! wiz      8495: <p>Alternatively to the first two steps you can also do:</p>
1.75      rillig   8496: <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      8497: <p>and use that for further work.</p>
1.75      rillig   8498: </li>
                   8499: <li><p>Fix <code class="varname">CATEGORIES</code> and any
                   8500: <code class="varname">DEPENDS</code> paths that just did &#8220;<span class="quote">../package</span>&#8221;
                   8501: instead of &#8220;<span class="quote">../../category/package</span>&#8221;.</p></li>
                   8502: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
                   8503: place.</p></li>
                   8504: <li>
                   8505: <p>Check if any package depends on it:
                   8506: </p>
                   8507: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   8508: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
                   8509: </li>
                   8510: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
                   8511: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76      rillig   8512: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
                   8513: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75      rillig   8514: <li>
                   8515: <p>Commit the changed and removed files:</p>
                   8516: <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      8517: <p>(and any packages from step 5, of course).</p>
1.75      rillig   8518: </li>
                   8519: </ol></div>
                   8520: </div>
                   8521: </div>
                   8522: <div class="chapter" lang="en">
                   8523: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   8524: <a name="devfaq"></a>Chapter 20. Frequently Asked Questions</h2></div></div></div>
1.75      rillig   8525: <p>This section contains the answers to questions that may
                   8526:        arise when you are writing a package. If you don't find your
                   8527:        question answered here, first have a look in the other chapters,
                   8528:        and if you still don't have the answer, ask on the
                   8529:        <code class="literal">pkgsrc-users</code> mailing list.</p>
                   8530: <div class="qandaset">
                   8531: <dl>
1.87    ! wiz      8532: <dt>20.1. <a href="#id2699100">What is the difference between
1.75      rillig   8533:        MAKEFLAGS, .MAKEFLAGS and
                   8534:        MAKE_FLAGS?</a>
                   8535: </dt>
1.87    ! wiz      8536: <dt>20.2. <a href="#id2699137">What is the difference between
1.75      rillig   8537:        MAKE, GMAKE and
                   8538:        MAKE_PROGRAM?</a>
                   8539: </dt>
1.87    ! wiz      8540: <dt>20.3. <a href="#id2699175">What is the difference between
1.75      rillig   8541:        CC, PKG_CC and
                   8542:        PKGSRC_COMPILER?</a>
                   8543: </dt>
1.87    ! wiz      8544: <dt>20.4. <a href="#id2699212">What is the difference between
1.75      rillig   8545:        BUILDLINK_LDFLAGS,
                   8546:        BUILDLINK_LDADD and
                   8547:        BUILDLINK_LIBS?</a>
                   8548: </dt>
1.87    ! wiz      8549: <dt>20.5. <a href="#id2699230">Why does make show-var
1.75      rillig   8550:        VARNAME=BUILDLINK_PREFIX.foo
                   8551:        say it's empty?</a>
                   8552: </dt>
1.87    ! wiz      8553: <dt>20.6. <a href="#id2699258">What does
1.78      rillig   8554:        ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
                   8555:        don't understand the := inside
                   8556:        it.</a>
                   8557: </dt>
1.87    ! wiz      8558: <dt>20.7. <a href="#id2699401">Which mailing lists are there for package
1.78      rillig   8559:        developers?</a>
                   8560: </dt>
1.87    ! wiz      8561: <dt>20.8. <a href="#id2699437">Where is the pkgsrc
1.80      rillig   8562:        documentation?</a>
                   8563: </dt>
1.75      rillig   8564: </dl>
                   8565: <table border="0" summary="Q and A Set">
                   8566: <col align="left" width="1%">
                   8567: <tbody>
                   8568: <tr class="question">
                   8569: <td align="left" valign="top">
1.87    ! wiz      8570: <a name="id2699100"></a><a name="id2699101"></a><b>20.1.</b>
1.75      rillig   8571: </td>
                   8572: <td align="left" valign="top"><p>What is the difference between
                   8573:        <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
                   8574:        <code class="varname">MAKE_FLAGS</code>?</p></td>
                   8575: </tr>
                   8576: <tr class="answer">
1.83      wiz      8577: <td align="left" valign="top"></td>
1.75      rillig   8578: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
                   8579:        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
                   8580:        <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
                   8581:        the <code class="varname">MAKE_PROGRAM</code> when building the
                   8582:        package. [FIXME: What is .MAKEFLAGS for?]</p></td>
                   8583: </tr>
                   8584: <tr class="question">
                   8585: <td align="left" valign="top">
1.87    ! wiz      8586: <a name="id2699137"></a><a name="id2699138"></a><b>20.2.</b>
1.75      rillig   8587: </td>
                   8588: <td align="left" valign="top"><p>What is the difference between
                   8589:        <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
                   8590:        <code class="varname">MAKE_PROGRAM</code>?</p></td>
                   8591: </tr>
                   8592: <tr class="answer">
1.83      wiz      8593: <td align="left" valign="top"></td>
1.75      rillig   8594: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
                   8595:        <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
                   8596:        infrastructure. <code class="varname">GMAKE</code> is the path to GNU
                   8597:        Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
                   8598:        use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
                   8599:        Make program that is used for building the
                   8600:        package.</p></td>
                   8601: </tr>
                   8602: <tr class="question">
                   8603: <td align="left" valign="top">
1.87    ! wiz      8604: <a name="id2699175"></a><a name="id2699176"></a><b>20.3.</b>
1.75      rillig   8605: </td>
                   8606: <td align="left" valign="top"><p>What is the difference between
                   8607:        <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
                   8608:        <code class="varname">PKGSRC_COMPILER</code>?</p></td>
                   8609: </tr>
                   8610: <tr class="answer">
1.83      wiz      8611: <td align="left" valign="top"></td>
1.75      rillig   8612: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
                   8613:        compiler, which can be configured by the pkgsrc user.
                   8614:        <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
                   8615:        <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
                   8616:        path to a compiler, but the type of compiler that should be
1.76      rillig   8617:        used. See <code class="filename">mk/compiler.mk</code> for more
1.75      rillig   8618:        information about the latter variable.</p></td>
                   8619: </tr>
                   8620: <tr class="question">
                   8621: <td align="left" valign="top">
1.87    ! wiz      8622: <a name="id2699212"></a><a name="id2699213"></a><b>20.4.</b>
1.75      rillig   8623: </td>
                   8624: <td align="left" valign="top"><p>What is the difference between
                   8625:        <code class="varname">BUILDLINK_LDFLAGS</code>,
                   8626:        <code class="varname">BUILDLINK_LDADD</code> and
                   8627:        <code class="varname">BUILDLINK_LIBS</code>?</p></td>
                   8628: </tr>
                   8629: <tr class="answer">
1.83      wiz      8630: <td align="left" valign="top"></td>
1.75      rillig   8631: <td align="left" valign="top"><p>[FIXME]</p></td>
                   8632: </tr>
                   8633: <tr class="question">
                   8634: <td align="left" valign="top">
1.87    ! wiz      8635: <a name="id2699230"></a><a name="id2699232"></a><b>20.5.</b>
1.75      rillig   8636: </td>
                   8637: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
                   8638:        VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
                   8639:        say it's empty?</p></td>
                   8640: </tr>
                   8641: <tr class="answer">
1.83      wiz      8642: <td align="left" valign="top"></td>
1.75      rillig   8643: <td align="left" valign="top"><p>For optimization reasons, some variables are only
                   8644:        available in the &#8220;<span class="quote">wrapper</span>&#8221; phase and later. To
                   8645:        &#8220;<span class="quote">simulate</span>&#8221; the wrapper phase, append
                   8646:        <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
                   8647:        command.</p></td>
                   8648: </tr>
1.78      rillig   8649: <tr class="question">
                   8650: <td align="left" valign="top">
1.87    ! wiz      8651: <a name="id2699258"></a><a name="id2699259"></a><b>20.6.</b>
1.78      rillig   8652: </td>
                   8653: <td align="left" valign="top"><p>What does
                   8654:        <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
                   8655:        don't understand the <code class="literal">:=</code> inside
                   8656:        it.</p></td>
                   8657: </tr>
                   8658: <tr class="answer">
1.83      wiz      8659: <td align="left" valign="top"></td>
1.78      rillig   8660: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
                   8661:        assignment operator, like you might expect at first sight.
                   8662:        Instead, it is a degenerate form of
                   8663:        <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
                   8664:        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
                   8665:        may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
                   8666:        case of <code class="varname">MASTER_SITE_*</code>,
                   8667:        <em class="replaceable"><code>old_string</code></em> is the empty string and
                   8668:        <em class="replaceable"><code>new_string</code></em> is
                   8669:        <code class="literal">package/</code>. That's where the
                   8670:        <code class="literal">:</code> and the <code class="literal">=</code> fall
                   8671:        together.</p></td>
                   8672: </tr>
                   8673: <tr class="question">
                   8674: <td align="left" valign="top">
1.87    ! wiz      8675: <a name="id2699401"></a><a name="id2699402"></a><b>20.7.</b>
1.78      rillig   8676: </td>
                   8677: <td align="left" valign="top"><p>Which mailing lists are there for package
                   8678:        developers?</p></td>
                   8679: </tr>
                   8680: <tr class="answer">
1.83      wiz      8681: <td align="left" valign="top"></td>
1.78      rillig   8682: <td align="left" valign="top"><div class="variablelist"><dl>
                   8683: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
                   8684: <dd><p>This is a list for technical discussions related
                   8685:        to pkgsrc development, e.g. soliciting feedback for changes to
                   8686:        pkgsrc infrastructure, proposed new features, questions related
                   8687:        to porting pkgsrc to a new platform, advice for maintaining a
                   8688:        package, patches that affect many packages, help requests moved
                   8689:        from pkgsrc-users when an infrastructure bug is found,
                   8690:        etc.</p></dd>
                   8691: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
                   8692: <dd><p>All bug reports in category "pkg" sent with
                   8693:        <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
                   8694:        directly; use one of the other mailing
                   8695:        lists.</p></dd>
                   8696: </dl></div></td>
                   8697: </tr>
1.80      rillig   8698: <tr class="question">
                   8699: <td align="left" valign="top">
1.87    ! wiz      8700: <a name="id2699437"></a><a name="id2699438"></a><b>20.8.</b>
1.80      rillig   8701: </td>
                   8702: <td align="left" valign="top"><p>Where is the pkgsrc
                   8703:        documentation?</p></td>
                   8704: </tr>
                   8705: <tr class="answer">
1.83      wiz      8706: <td align="left" valign="top"></td>
1.80      rillig   8707: <td align="left" valign="top">
                   8708: <p>There are many places where you can find
                   8709:        documentation about pkgsrc:</p>
                   8710: <div class="itemizedlist"><ul type="disc">
                   8711: <li><p>The pkgsrc guide (this document) is a collection
                   8712:        of chapters that explain large parts of pkgsrc, but some
                   8713:        chapters tend to be outdated. Which ones they are is hard to
                   8714:        say.</p></li>
                   8715: <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
                   8716:        about certain features, announcements of new parts of the pkgsrc
                   8717:        infrastructure and sometimes even announcements that a certain
                   8718:        feature has been marked as obsolete. The benefit here is that
                   8719:        each message has a date appended to it.</p></li>
                   8720: <li><p>Many of the files in the
                   8721:        <code class="filename">mk/</code> directory start with a comment that
                   8722:        describes the purpose of the file and how it can be used by the
                   8723:        pkgsrc user and package authors.</p></li>
                   8724: <li><p>The CVS log messages are a rich source of
                   8725:        information, but they tend to be highly abbreviated, especially
                   8726:        for actions that occur often. Some contain a detailed
                   8727:        description of what has changed, but they are geared towards the
                   8728:        other pkgsrc developers, not towards an average pkgsrc user.
                   8729:        They also only document <span class="emphasis"><em>changes</em></span>, so if you
                   8730:        don't know what has been before, these messages may not be worth
                   8731:        too much to you.</p></li>
                   8732: <li><p>Some parts of pkgsrc are only &#8220;<span class="quote">implicitly
                   8733:        documented</span>&#8221;, that is the documentation exists only in the
                   8734:        mind of the developer who wrote the code. To get this
                   8735:        information, use the the <span><strong class="command">cvs annotate</strong></span> command
                   8736:        to see who has written it and ask on the
                   8737:        <code class="literal">tech-pkg</code> mailing list, so that others can
                   8738:        find your questions later (see above). To be sure that the
                   8739:        developer in charge reads the mail, you may CC him or
                   8740:        her.</p></li>
                   8741: </ul></div>
                   8742: </td>
                   8743: </tr>
1.75      rillig   8744: </tbody>
                   8745: </table>
                   8746: </div>
                   8747: </div>
1.85      jmmv     8748: <div class="chapter" lang="en">
                   8749: <div class="titlepage"><div><div><h2 class="title">
                   8750: <a name="gnome"></a>Chapter 21. GNOME packaging and porting</h2></div></div></div>
                   8751: <div class="toc">
                   8752: <p><b>Table of Contents</b></p>
                   8753: <dl>
                   8754: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
                   8755: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
                   8756: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
                   8757: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
                   8758: </dl>
                   8759: </div>
                   8760: <p>Quoting <a href="http://www.gnome.org/" target="_top">GNOME's web
                   8761: site</a>:</p>
                   8762: <div class="blockquote"><blockquote class="blockquote"><p>The GNOME project provides two things: The GNOME desktop
                   8763:   environment, an intuitive and attractive desktop for users, and the
                   8764:   GNOME development platform, an extensive framework for building
                   8765:   applications that integrate into the rest of the desktop.</p></blockquote></div>
                   8766: <p>pkgsrc provides a seamless way to automatically build and install
                   8767: a complete GNOME environment <span class="emphasis"><em>under many different
                   8768: platforms</em></span>.  We can say with confidence that pkgsrc is one of
                   8769: the most advanced build and packaging systems for GNOME due to its
                   8770: included technologies buildlink3, the wrappers and tools framework and
                   8771: automatic configuration file management.  Lots of efforts are put into
                   8772: achieving a completely clean deinstallation of installed software
                   8773: components.</p>
                   8774: <p>Given that pkgsrc is <a href="http://www.NetBSD.org/" target="_top">NetBSD</a>'s official packaging system,
                   8775: the above also means that great efforts are put into making GNOME work
                   8776: under this operating system.  Recently, <a href="http://www.dragonflybsd.org/" target="_top">DragonFly BSD</a> also adopted
                   8777: pkgsrc as its preferred packaging system, contributing lots of
                   8778: portability fixes to make GNOME build and install under it.</p>
                   8779: <p>This chapter is aimed at pkgsrc developers and other people
                   8780: interested in helping our GNOME porting and packaging efforts.  It
                   8781: provides instructions on how to manage the existing packages and some
                   8782: important information regarding their internals.</p>
                   8783: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   8784: <h3 class="title">We need your help!</h3>
                   8785: <p>Should you have some spare cycles to devote to NetBSD, pkgsrc
                   8786:   and GNOME and are willing to learn new exciting stuff, please jump
                   8787:   straight to the <a href="http://www.NetBSD.org/contrib/projects.html#gnome" target="_top">pending
                   8788:   work</a> list!  There is still a long way to go to get a
                   8789:   fully-functional GNOME desktop under NetBSD and we need your help to
                   8790:   achieve it!</p>
                   8791: </div>
                   8792: <div class="sect1" lang="en">
                   8793: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8794: <a name="meta-packages"></a>21.1. Meta packages</h2></div></div></div>
                   8795: <p>pkgsrc includes three GNOME-related meta packages:</p>
                   8796: <div class="itemizedlist"><ul type="disc">
                   8797: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>: Provides
                   8798:     the core GNOME desktop environment.  It only includes the necessary
                   8799:     bits to get it to boot correctly, although it may lack important
                   8800:     functionality for daily operation.  The idea behind this package is
                   8801:     to let end users build their own configurations on top of this one,
                   8802:     first installing this meta package to achieve a functional setup and
                   8803:     then adding individual applications.</p></li>
                   8804: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome/README.html" target="_top"><code class="filename">meta-pkgs/gnome</code></a>: Provides a
                   8805:     complete installation of the GNOME platform and desktop as defined
                   8806:     by the GNOME project; this is based on the components distributed in
                   8807:     the <code class="filename">platform/x.y/x.y.z/sources</code> and
                   8808:     <code class="filename">desktop/x.y/x.y.z/sources</code> directories of the
                   8809:     official FTP server.  Developer-only tools found in those
                   8810:     directories are not installed unless required by some other
                   8811:     component to work properly.  Similarly, packages from the bindings
                   8812:     set (<code class="filename">bindings/x.y/x.y.z/sources</code>) are not pulled
                   8813:     in unless required as a dependency for an end-user component.  This
                   8814:     package "extends" <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>.</p></li>
                   8815: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a>:
                   8816:     Installs all the tools required to build a GNOME component when
                   8817:     fetched from the CVS repository.  These are required to let the
                   8818:     <span><strong class="command">autogen.sh</strong></span> scripts work appropriately.</p></li>
                   8819: </ul></div>
                   8820: <p>In all these packages, the <code class="varname">DEPENDS</code> lines are
                   8821: sorted in a way that eases updates: a package may depend on other
                   8822: packages listed before it but not on any listed after it.  It is very
                   8823: important to keep this order to ease updates so... <span class="emphasis"><em>do not
                   8824: change it to alphabetical sorting!</em></span></p>
                   8825: </div>
                   8826: <div class="sect1" lang="en">
                   8827: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8828: <a name="new-package"></a>21.2. Packaging a GNOME application</h2></div></div></div>
                   8829: <p>Almost all GNOME applications are written in C and use a common
                   8830: set of tools as their build system.  Things get different with the new
                   8831: bindings to other languages (such as Python), but the following will
                   8832: give you a general idea on the minimum required tools:</p>
                   8833: <div class="itemizedlist"><ul type="disc">
                   8834: <li>
                   8835: <p>Almost all GNOME applications use the GNU Autotools as their
                   8836:     build system.  As a general rule you will need to tell this to your
                   8837:     package:</p>
                   8838: <pre class="programlisting">GNU_CONFIGURE=yes
                   8839: USE_LIBTOOL=yes
                   8840: USE_TOOLS+=gmake</pre>
                   8841: </li>
                   8842: <li>
                   8843: <p>If the package uses pkg-config to detect dependencies, add this
                   8844:     tool to the list of required utilities:</p>
                   8845: <pre class="programlisting">USE_TOOLS+=pkg-config</pre>
                   8846: <p>Also use <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/verifypc/README.html" target="_top"><code class="filename">pkgtools/verifypc</code></a> at
                   8847:     the end of the build process to ensure that you did not miss to
                   8848:     specify any dependency in your package and that the version
                   8849:     requirements are all correct.</p>
                   8850: </li>
                   8851: <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
                   8852:     to handle dependencies and to force the package to use the latest
                   8853:     available version.</p></li>
                   8854: <li>
                   8855: <p>If the package uses gtk-doc (a documentation generation
                   8856:     utility), do <span class="emphasis"><em>not</em></span> add a dependency on it.  The
                   8857:     tool is rather big and the distfile should come with pregenerated
                   8858:     documentation anyway; if it does not, it is a bug that you ought to
                   8859:     report.  For such packages you should disable gtk-doc (unless it is
                   8860:     the default) and change the location of installed HTML files:</p>
                   8861: <pre class="programlisting">CONFIGURE_ARGS+=--disable-gtk-doc
                   8862: CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/doc</pre>
                   8863: </li>
                   8864: </ul></div>
                   8865: <p>GNOME uses multiple <span class="emphasis"><em>shared</em></span> directories and
                   8866: files under the installation prefix to maintain databases.  In this
                   8867: context, shared means that those exact same directories and files are
                   8868: used among several different packages, leading to conflicts in the
                   8869: <code class="filename">PLIST</code>.  pkgsrc currently includes functionality to
                   8870: handle the most common cases, so you have to forget about using
                   8871: <code class="literal">@unexec ${RMDIR}</code> lines in your file lists and
                   8872: omitting shared files from them.  If you find yourself doing those,
                   8873: <span class="emphasis"><em>your package is most likely incorrect</em></span>.</p>
                   8874: <p>The following table lists the common situations that result in
                   8875: using shared directories or files.  For each of them, the appropriate
                   8876: solution is given.  After applying the solution be sure to
                   8877: <span class="emphasis"><em>regenerate the package's file list</em></span> with
                   8878: <span><strong class="command">make print-PLIST</strong></span> and ensure it is correct.</p>
                   8879: <div class="table">
                   8880: <a name="plist-handling"></a><p class="title"><b>Table 21.1. PLIST handling for GNOME packages</b></p>
                   8881: <div class="table-contents"><table summary="PLIST handling for GNOME packages" border="1">
                   8882: <colgroup>
                   8883: <col>
                   8884: <col>
                   8885: </colgroup>
                   8886: <thead><tr>
                   8887: <th>If the package...</th>
                   8888: <th>Then...</th>
                   8889: </tr></thead>
                   8890: <tbody>
                   8891: <tr>
                   8892: <td>Installs OMF files under <code class="filename">share/omf</code>.</td>
1.87    ! wiz      8893: <td>See <a href="#scrollkeeper-data-files" title="17.6.9. Packages installing scrollkeeper data files">Section 17.6.9, &#8220;Packages installing scrollkeeper data files&#8221;</a>.</td>
1.85      jmmv     8894: </tr>
                   8895: <tr>
                   8896: <td>Installs icons under the
                   8897:         <code class="filename">share/icons/hicolor</code> hierarchy or updates
                   8898:         <code class="filename">share/icons/hicolor/icon-theme.cache</code>.</td>
1.87    ! wiz      8899: <td>See <a href="#hicolor-theme" title="17.6.18. Packages installing hicolor theme icons">Section 17.6.18, &#8220;Packages installing hicolor theme icons&#8221;</a>.</td>
1.85      jmmv     8900: </tr>
                   8901: <tr>
                   8902: <td>Installs files under
                   8903:         <code class="filename">share/mime/packages</code>.</td>
1.87    ! wiz      8904: <td>See <a href="#mime-database" title="17.6.13. Packages installing extensions to the MIME database">Section 17.6.13, &#8220;Packages installing extensions to the MIME database&#8221;</a>.</td>
1.85      jmmv     8905: </tr>
                   8906: <tr>
                   8907: <td>Installs <code class="filename">.desktop</code> files under
                   8908:         <code class="filename">share/applications</code> and these include MIME
                   8909:         information.</td>
1.87    ! wiz      8910: <td>See <a href="#desktop-files" title="17.6.19. Packages installing desktop files">Section 17.6.19, &#8220;Packages installing desktop files&#8221;</a>.</td>
1.85      jmmv     8911: </tr>
                   8912: </tbody>
                   8913: </table></div>
                   8914: </div>
                   8915: <br class="table-break">
                   8916: </div>
                   8917: <div class="sect1" lang="en">
                   8918: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8919: <a name="full-update"></a>21.3. Updating GNOME to a newer version</h2></div></div></div>
                   8920: <p>When seeing GNOME as a whole, there are two kinds of
                   8921: updates:</p>
                   8922: <div class="variablelist"><dl>
                   8923: <dt><span class="term">Major update</span></dt>
                   8924: <dd>
                   8925: <p>Given that there is still a very long way for GNOME 3 (if it
                   8926:       ever appears), we consider a major update one that goes from a
                   8927:       <code class="literal">2.X</code> version to a <code class="literal">2.Y</code> one,
                   8928:       where <code class="literal">Y</code> is even and greater than
                   8929:       <code class="literal">X</code>.  These are hard to achieve because they
                   8930:       introduce lots of changes in the components' code and almost all
                   8931:       GNOME distfiles are updated to newer versions.  Some of them can
                   8932:       even break API and ABI compatibility with the previous major
                   8933:       version series.  As a result, the update needs to be done all at
                   8934:       once to minimize breakage.</p>
                   8935: <p>A major update typically consists of around 80 package
                   8936:       updates and the addition of some new ones.</p>
                   8937: </dd>
                   8938: <dt><span class="term">Minor update</span></dt>
                   8939: <dd>
                   8940: <p>We consider a minor update one that goes from a
                   8941:       <code class="literal">2.A.X</code> version to a <code class="literal">2.A.Y</code>
                   8942:       one where <code class="literal">Y</code> is greater than
                   8943:       <code class="literal">X</code>.  These are easy to achieve because they do
                   8944:       not update all GNOME components, can be done in an incremental way
                   8945:       and do not break API nor ABI compatibility.</p>
                   8946: <p>A minor update typically consists of around 50 package
                   8947:       updates, although the numbers here may vary a lot.</p>
                   8948: </dd>
                   8949: </dl></div>
                   8950: <p>In order to update the GNOME components in pkgsrc to a new stable
                   8951: release (either major or minor), the following steps should be
                   8952: followed:</p>
                   8953: <div class="orderedlist"><ol type="1">
                   8954: <li>
                   8955: <p>Get a list of all the tarballs that form the new release by
                   8956:     using the following commands.  These will leave the full list of the
                   8957:     components's distfiles into the <code class="filename">list.txt</code>
                   8958:     file:</p>
                   8959: <pre class="screen"><code class="prompt">$ </code><strong class="userinput"><code>echo ls "*.tar.bz2" | \
                   8960:     ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   8961:     awk '{ print $9 }' &gt;list.txt</code></strong>
                   8962: <code class="prompt">$ </code><strong class="userinput"><code>echo ls "*.tar.bz2" | \
                   8963:     ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   8964:     awk '{ print $9 }' &gt;&gt;list.txt</code></strong></pre>
                   8965: </li>
                   8966: <li><p>Open each meta package's <code class="filename">Makefile</code> and
                   8967:     bump their version to the release you are updating them to.  The
                   8968:     three meta packages should be always consistent with versioning.
                   8969:     Obviously remove any <code class="varname">PKGREVISION</code>s that might be
                   8970:     in them.</p></li>
                   8971: <li>
                   8972: <p>For each meta package, update all its
                   8973:     <code class="varname">DEPENDS</code> lines to match the latest versions as
                   8974:     shown by the above commands.  Do <span class="emphasis"><em>not</em></span> list any
                   8975:     newer version (even if found in the FTP) because the meta packages
                   8976:     are supposed to list the exact versions that form a specific GNOME
                   8977:     release.  Exceptions are permitted here if a newer version solves a
                   8978:     serious issue in the overall desktop experience; these typically
                   8979:     come in the form of a revision bump in pkgsrc, not in newer versions
                   8980:     from the developers.</p>
                   8981: <p>Packages not listed in the <code class="filename">list.txt</code> file
                   8982:     should be updated to the latest version available (if found in
                   8983:     pkgsrc).  This is the case, for example, of the dependencies on the
                   8984:     GNU Autotools in the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a> meta package.</p>
                   8985: </li>
                   8986: <li>
                   8987: <p>Generate a patch from the modified meta packages and extract the
                   8988:     list of "new" lines.  This will provide you an outline on what
                   8989:     packages need to be updated in pkgsrc and in what order:</p>
                   8990: <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>
                   8991: </li>
                   8992: <li><p>For major desktop updates it is recommended to zap all your
                   8993:     installed packages and start over from scratch at this point.</p></li>
                   8994: <li><p>Now comes the longest step by far: iterate over the contents
                   8995:     of <code class="filename">todo.txt</code> and update the packages listed in
                   8996:     it in order.  For major desktop updates none of these should be
                   8997:     commited until the entire set is completed because there are chances
                   8998:     of breaking not-yet-updated packages.</p></li>
                   8999: <li><p>Once the packages are up to date and working, commit them to
                   9000:     the tree one by one with appropriate log messages.  At the end,
                   9001:     commit the three meta package updates and all the corresponding
                   9002:     changes to the <code class="filename">doc/CHANGES-&lt;YEAR&gt;</code> and
                   9003:     <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>
                   9004: </ol></div>
                   9005: </div>
                   9006: <div class="sect1" lang="en">
                   9007: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9008: <a name="patching"></a>21.4. Patching guidelines</h2></div></div></div>
                   9009: <p>GNOME is a very big component in pkgsrc which approaches 100
                   9010: packages.  Please, it is very important that you always, always,
                   9011: <span class="strong"><strong>always</strong></span> feed back any portability
                   9012: fixes you do to a GNOME package to the mainstream developers (see <a href="#components.patches.feedback" title="9.3.2. Feedback to the author">Section 9.3.2, &#8220;Feedback to the author&#8221;</a>).  This is the only way to get
                   9013: their attention on portability issues and to ensure that future versions
                   9014: can be built out-of-the box on NetBSD.  The less custom patches in
                   9015: pkgsrc, the easier further updates are.  Those developers in charge of
                   9016: issuing major GNOME updates will be grateful if you do that.</p>
                   9017: <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
                   9018: Bugzilla</a>.  Not all components use these to track bugs, but most
                   9019: of them do.  Do not be short on your reports: always provide detailed
                   9020: explanations of the current failure, how it can be improved to achieve
                   9021: maximum portability and, if at all possible, provide a patch against CVS
                   9022: head.  The more verbose you are, the higher chances of your patch being
                   9023: accepted.</p>
                   9024: <p>Also, please avoid using preprocessor magic to fix portability
                   9025: issues.  While the FreeBSD GNOME people are doing a great job in porting
                   9026: GNOME to their operating system, the official GNOME sources are now
                   9027: plagued by conditionals that check for <code class="varname">__FreeBSD__</code>
                   9028: and similar macros.  This hurts portability.  Please see our patching
                   9029: guidelines (<a href="#components.patches.guidelines" title="9.3.1. Patching guidelines">Section 9.3.1, &#8220;Patching guidelines&#8221;</a>) for more
                   9030: details.</p>
                   9031: </div>
                   9032: </div>
1.75      rillig   9033: </div>
                   9034: <div class="part" lang="en">
                   9035: <div class="titlepage"><div><div><h1 class="title">
                   9036: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
                   9037: <div class="partintro" lang="en">
                   9038: <div></div>
                   9039: <p>This part of the guide deals with everything
                   9040:        from the infrastructure that is behind the interfaces described
                   9041:        in the developer's guide. A casual package maintainer should not
                   9042:        need anything from this part.</p>
                   9043: <div class="toc">
                   9044: <p><b>Table of Contents</b></p>
                   9045: <dl>
1.85      jmmv     9046: <dt><span class="chapter"><a href="#infr.design">22. Design of the pkgsrc infrastructure</a></span></dt>
1.75      rillig   9047: <dd><dl>
1.85      jmmv     9048: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
                   9049: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
                   9050: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.75      rillig   9051: <dd><dl>
1.85      jmmv     9052: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
                   9053: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.75      rillig   9054: </dl></dd>
1.85      jmmv     9055: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
                   9056: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig   9057: <dd><dl>
1.85      jmmv     9058: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
                   9059: <dt><span class="sect2"><a href="#infr.design.intf.action">22.5.2. Actions taken on behalf of parameters</a></span></dt>
1.81      rillig   9060: </dl></dd>
1.85      jmmv     9061: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.81      rillig   9062: <dd><dl>
1.85      jmmv     9063: <dt><span class="sect2"><a href="#infr.order.prefs">22.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
                   9064: <dt><span class="sect2"><a href="#infr.order.pkg">22.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75      rillig   9065: </dl></dd>
                   9066: </dl></dd>
1.85      jmmv     9067: <dt><span class="chapter"><a href="#regression">23. Regression tests</a></span></dt>
1.75      rillig   9068: <dd><dl>
1.85      jmmv     9069: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
                   9070: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
                   9071: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75      rillig   9072: <dd><dl>
1.85      jmmv     9073: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
                   9074: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75      rillig   9075: </dl></dd>
                   9076: </dl></dd>
1.85      jmmv     9077: <dt><span class="chapter"><a href="#porting">24. Porting pkgsrc</a></span></dt>
1.75      rillig   9078: <dd><dl>
1.85      jmmv     9079: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
                   9080: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75      rillig   9081: </dl></dd>
                   9082: </dl>
                   9083: </div>
                   9084: </div>
                   9085: <div class="chapter" lang="en">
                   9086: <div class="titlepage"><div><div><h2 class="title">
1.85      jmmv     9087: <a name="infr.design"></a>Chapter 22. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75      rillig   9088: <div class="toc">
                   9089: <p><b>Table of Contents</b></p>
                   9090: <dl>
1.85      jmmv     9091: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
                   9092: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
                   9093: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.81      rillig   9094: <dd><dl>
1.85      jmmv     9095: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
                   9096: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.81      rillig   9097: </dl></dd>
1.85      jmmv     9098: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
                   9099: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig   9100: <dd><dl>
1.85      jmmv     9101: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
                   9102: <dt><span class="sect2"><a href="#infr.design.intf.action">22.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75      rillig   9103: </dl></dd>
1.85      jmmv     9104: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.75      rillig   9105: <dd><dl>
1.85      jmmv     9106: <dt><span class="sect2"><a href="#infr.order.prefs">22.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
                   9107: <dt><span class="sect2"><a href="#infr.order.pkg">22.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75      rillig   9108: </dl></dd>
                   9109: </dl>
                   9110: </div>
                   9111: <p>The pkgsrc infrastructure consists of many small Makefile
                   9112:        fragments. Each such fragment needs a properly specified
                   9113:        interface. This chapter explains how such an interface looks
                   9114:        like.</p>
                   9115: <div class="sect1" lang="en">
                   9116: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9117: <a name="infr.vardef"></a>22.1. The meaning of variable definitions</h2></div></div></div>
1.81      rillig   9118: <p>Whenever a variable is defined in the pkgsrc
                   9119:        infrastructure, the location and the way of definition provide
                   9120:        much information about the intended use of that variable.
                   9121:        Additionally, more documentation may be found in a header
                   9122:        comment or in this pkgsrc guide.</p>
                   9123: <p>A special file is
                   9124:        <code class="filename">mk/defaults/mk.conf</code>, which lists all
                   9125:        variables that are intended to be user-defined. They are either
                   9126:        defined using the <code class="literal">?=</code> operator or they are
                   9127:        left undefined because defining them to anything would
                   9128:        effectively mean &#8220;<span class="quote">yes</span>&#8221;. All these variables may be
                   9129:        overridden by the pkgsrc user in the <code class="varname">MAKECONF</code>
                   9130:        file.</p>
                   9131: <p>Outside this file, the following conventions apply:
                   9132:        Variables that are defined using the <code class="literal">?=</code>
                   9133:        operator may be overridden by a package.</p>
                   9134: <p>Variables that are defined using the <code class="literal">=</code>
                   9135:        operator may be used read-only at run-time.</p>
                   9136: <p>Variables whose name starts with an underscore must not be
                   9137:        accessed outside the pkgsrc infrastructure at all. They may
                   9138:        change without further notice.</p>
                   9139: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   9140: <h3 class="title">Note</h3>
                   9141: <p>These conventions are currently not applied
                   9142:        consistently to the complete pkgsrc
                   9143:        infrastructure.</p>
                   9144: </div>
                   9145: </div>
                   9146: <div class="sect1" lang="en">
                   9147: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9148: <a name="infr.vardef.problems"></a>22.2. Avoiding problems before they arise</h2></div></div></div>
1.81      rillig   9149: <p>All variables that contain lists of things should default
                   9150:        to being empty. Two examples that do not follow this rule are
                   9151:        <code class="varname">USE_LANGUAGES</code> and
                   9152:        <code class="varname">DISTFILES</code>. These variables cannot simply be
                   9153:        modified using the <code class="literal">+=</code> operator in package
                   9154:        <code class="filename">Makefile</code>s (or other files included by
                   9155:        them), since there is no guarantee whether the variable is
                   9156:        already set or not, and what its value is. In the case of
                   9157:        <code class="varname">DISTFILES</code>, the packages &#8220;<span class="quote">know</span>&#8221;
                   9158:        the default value and just define it as in the following
                   9159:        example.</p>
                   9160: <pre class="programlisting">
                   9161:     DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   9162: </pre>
                   9163: <p>Because of the selection of this default value, the same
                   9164:        value appears in many package Makefiles. Similarly for
                   9165:        <code class="varname">USE_LANGUAGES</code>, but in this case the default
                   9166:        value (&#8220;<span class="quote"><code class="literal">c</code></span>&#8221;) is so short that it
                   9167:        doesn't stand out. Nevertheless it is mentioned in many
                   9168:        files.</p>
                   9169: </div>
                   9170: <div class="sect1" lang="en">
                   9171: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9172: <a name="infr.var"></a>22.3. Variable evaluation</h2></div></div></div>
1.75      rillig   9173: <div class="sect2" lang="en">
                   9174: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9175: <a name="infr.var.load"></a>22.3.1. At load time</h3></div></div></div>
1.75      rillig   9176: <p>Variable evaluation takes place either at load time or at
                   9177:        runtime, depending on the context in which they occur. The
                   9178:        contexts where variables are evaluated at load time are:</p>
                   9179: <div class="itemizedlist"><ul type="disc">
                   9180: <li><p>The right hand side of the <code class="literal">:=</code>
                   9181:        and <code class="literal">!=</code> operators,</p></li>
                   9182: <li><p>Make directives like <code class="literal">.if</code> or
                   9183:        <code class="literal">.for</code>,</p></li>
                   9184: <li><p>Dependency lines.</p></li>
                   9185: </ul></div>
                   9186: <p>A special exception are references to the iteration
                   9187:        variables of <code class="literal">.for</code> loops, which are expanded
                   9188:        inline, no matter in which context they appear.</p>
                   9189: <p>As the values of variables may change during load time,
                   9190:        care must be taken not to evaluate them by accident. Typical
                   9191:        examples for variables that should not be evaluated at load time
                   9192:        are <code class="varname">DEPENDS</code> and
                   9193:        <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
                   9194:        clear, here is an example:</p>
                   9195: <pre class="programlisting">
                   9196:     CONFIGURE_ARGS=         # none
                   9197:     CFLAGS=                 -O
                   9198:     CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
1.1       grant    9199: 
1.75      rillig   9200:     CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
1.1       grant    9201: 
1.75      rillig   9202:     CFLAGS+=                -Wall
                   9203:        </pre>
                   9204: <p>This code shows how the use of the <code class="literal">:=</code>
                   9205:        operator can quickly lead to unexpected results. The first
                   9206:        paragraph is fairly common code. The second paragraph evaluates
                   9207:        the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
                   9208:        <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
                   9209:        <code class="literal">-Wall</code> is appended to the
                   9210:        <code class="varname">CFLAGS</code>, but this addition will not appear in
                   9211:        <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
                   9212:        paragraphs from above typically occur in completely unrelated
                   9213:        files.</p>
                   9214: </div>
                   9215: <div class="sect2" lang="en">
                   9216: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9217: <a name="infr.var.run"></a>22.3.2. At runtime</h3></div></div></div>
1.75      rillig   9218: <p>After all the files have been loaded, the values of the
                   9219:        variables cannot be changed anymore. Variables that are used in
                   9220:        the shell commands are expanded at this point.</p>
                   9221: </div>
                   9222: </div>
                   9223: <div class="sect1" lang="en">
                   9224: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9225: <a name="infr.varspec"></a>22.4. How can variables be specified?</h2></div></div></div>
1.78      rillig   9226: <p>There are many ways in which the definition and use of a
                   9227:        variable can be restricted in order to detect bugs and
                   9228:        violations of the (mostly unwritten) policies. See the
                   9229:        <code class="literal">pkglint</code> developer's documentation for further
                   9230:        details.</p>
                   9231: </div>
                   9232: <div class="sect1" lang="en">
                   9233: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9234: <a name="infr.design.intf"></a>22.5. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76      rillig   9235: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75      rillig   9236:        of the following classes. Cases where a file falls into more
                   9237:        than one class should be avoided as it often leads to subtle
                   9238:        bugs.</p>
                   9239: <div class="sect2" lang="en">
                   9240: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9241: <a name="infr.design.intf.proc"></a>22.5.1. Procedures with parameters</h3></div></div></div>
1.75      rillig   9242: <p>In a traditional imperative programming language some of
1.76      rillig   9243:        the <code class="filename">.mk</code> files could be described as
1.87    ! wiz      9244:        procedures. They take some input parameters and&#8212;after
        !          9245:        inclusion&#8212;provide a result in output parameters. Since all
1.76      rillig   9246:        variables in <code class="filename">Makefile</code>s have global scope
1.75      rillig   9247:        care must be taken not to use parameter names that have already
                   9248:        another meaning. For example, <code class="varname">PKGNAME</code> is a
                   9249:        bad choice for a parameter name.</p>
                   9250: <p>Procedures are completely evaluated at preprocessing time.
                   9251:        That is, when calling a procedure all input parameters must be
                   9252:        completely resolvable. For example,
                   9253:        <code class="varname">CONFIGURE_ARGS</code> should never be an input
                   9254:        parameter since it is very likely that further text will be
                   9255:        added after calling the procedure, which would effectively apply
                   9256:        the procedure to only a part of the variable. Also, references
                   9257:        to other variables wit will be modified after calling the
                   9258:        procedure.</p>
                   9259: <p>A procedure can declare its output parameters either as
                   9260:        suitable for use in preprocessing directives or as only
                   9261:        available at runtime. The latter alternative is for variables
                   9262:        that contain references to other runtime variables.</p>
                   9263: <p>Procedures shall be written such that it is possible to
                   9264:        call the procedure more than once. That is, the file must not
                   9265:        contain multiple-inclusion guards.</p>
                   9266: <p>Examples for procedures are
1.76      rillig   9267:        <code class="filename">mk/bsd.options.mk</code> and
                   9268:        <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75      rillig   9269:        that the parameters are evaluated at load time, they should be
                   9270:        assigned using the <code class="literal">:=</code> operator, which should
                   9271:        be used only for this purpose.</p>
                   9272: </div>
                   9273: <div class="sect2" lang="en">
                   9274: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9275: <a name="infr.design.intf.action"></a>22.5.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75      rillig   9276: <p>Action files take some input parameters and may define
                   9277:        runtime variables. They shall not define loadtime variables.
                   9278:        There are action files that are included implicitly by the
                   9279:        pkgsrc infrastructure, while other must be included
                   9280:        explicitly.</p>
                   9281: <p>An example for action files is
1.76      rillig   9282:        <code class="filename">mk/subst.mk</code>.</p>
1.75      rillig   9283: </div>
                   9284: </div>
1.81      rillig   9285: <div class="sect1" lang="en">
                   9286: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9287: <a name="infr.order"></a>22.6. The order in which files are loaded</h2></div></div></div>
1.81      rillig   9288: <p>Package <code class="filename">Makefile</code>s usually consist of
                   9289:        a set of variable definitions, and include the file
                   9290:        <code class="filename">../../mk/bsd.pkg.mk</code> in the very last line.
                   9291:        Before that, they may also include various other
                   9292:        <code class="filename">*.mk</code> files if they need to query the
                   9293:        availability of certain features like the type of compiler or
                   9294:        the X11 implementation. Due to the heavy use of preprocessor
                   9295:        directives like <code class="literal">.if</code> and
                   9296:        <code class="literal">.for</code>, the order in which the files are loaded
                   9297:        matters.</p>
                   9298: <p>This section describes at which point the various files
                   9299:        are loaded and gives reasons for that order.</p>
                   9300: <div class="sect2" lang="en">
                   9301: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9302: <a name="infr.order.prefs"></a>22.6.1. The order in <code class="filename">bsd.prefs.mk</code></h3></div></div></div>
1.81      rillig   9303: <p>The very first action in <code class="filename">bsd.pkg.mk</code>
                   9304:        is to define some essential variables like
                   9305:        <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code> and
                   9306:        <code class="varname">MACHINE_ARCH</code>.</p>
                   9307: <p>Then, the user settings are loaded from the file specified
                   9308:        in <code class="varname">MAKECONF</code>. If the bmake command from pkgsrc
                   9309:        is used, <code class="varname">MAKECONF</code> defaults to
                   9310:        <code class="filename"><em class="replaceable"><code>${prefix}</code></em>/etc/mk.conf</code>.
                   9311:        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
                   9312:        <code class="filename">/etc/mk.conf</code>. After that, those variables
                   9313:        that have not been overridden by the user are loaded from
                   9314:        <code class="filename">mk/defaults/mk.conf</code>.</p>
                   9315: <p>After the user settings, the system settings and platform
                   9316:        settings are loaded, which may override the user
                   9317:        settings.</p>
                   9318: <p>Then, the tool definitions are loaded. The tool wrappers
                   9319:        are not yet in effect. This only happens when building a
                   9320:        package, so the proper variables must be used instead of the
                   9321:        direct tool names.</p>
                   9322: <p>As the last steps, some essential variables from the
                   9323:        wrapper and the package system flavor are loaded, as well as the
                   9324:        variables that have been cached in earlier phases of a package
                   9325:        build.</p>
                   9326: </div>
                   9327: <div class="sect2" lang="en">
                   9328: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9329: <a name="infr.order.pkg"></a>22.6.2. The order in <code class="filename">bsd.pkg.mk</code></h3></div></div></div>
1.81      rillig   9330: <p>First, <code class="filename">bsd.prefs.mk</code> is loaded.</p>
                   9331: <p>Then, the various <code class="filename">*-vars.mk</code> files are
                   9332:        loaded, which fill default values for those variables that have
                   9333:        not been defined by the the package. These variables may later
                   9334:        be used even in unrelated files.</p>
                   9335: <p>Then, the file <code class="filename">bsd.pkg.error.mk</code>
                   9336:        provides the target <code class="literal">error-check</code> that is added
                   9337:        as a special dependency to all other targets that use
                   9338:        <code class="varname">DELAYED_ERROR_MSG</code> or
                   9339:        <code class="varname">DELAYED_WARNING_MSG</code>.</p>
                   9340: <p>Then, the package-specific hacks from
                   9341:        <code class="filename">hacks.mk</code> are included.</p>
                   9342: <p>Then, various other files follow. Most of them don't have
                   9343:        any dependencies on what they need to have included before or
                   9344:        after them, though some do.</p>
                   9345: <p>The code to check <code class="varname">PKG_FAIL_REASON</code> and
                   9346:        <code class="varname">PKG_SKIP_REASON</code> is then executed, which
                   9347:        restricts the use of these variables to all the files that have
                   9348:        been included before. Appearances in later files will be
                   9349:        silently ignored.</p>
                   9350: <p>Then, the files for the main targets are included, in the
                   9351:        order of later execution, though the actual order should not
                   9352:        matter.</p>
                   9353: <p>At last, some more files are included that don't set any
                   9354:        interesting variables but rather just define make targets to be
                   9355:        executed.</p>
                   9356: </div>
                   9357: </div>
1.75      rillig   9358: </div>
                   9359: <div class="chapter" lang="en">
                   9360: <div class="titlepage"><div><div><h2 class="title">
1.85      jmmv     9361: <a name="regression"></a>Chapter 23. Regression tests</h2></div></div></div>
1.75      rillig   9362: <div class="toc">
                   9363: <p><b>Table of Contents</b></p>
                   9364: <dl>
1.85      jmmv     9365: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
                   9366: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
                   9367: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75      rillig   9368: <dd><dl>
1.85      jmmv     9369: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
                   9370: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75      rillig   9371: </dl></dd>
                   9372: </dl>
                   9373: </div>
                   9374: <p>The pkgsrc infrastructure consists of a large codebase,
                   9375:        and there are many corners where every little bit of a file is
                   9376:        well thought out, making pkgsrc likely to fail as soon as
                   9377:        anything is changed near those parts. To prevent most changes
                   9378:        from breaking anything, a suite of regression tests should go
                   9379:        along with every important part of the pkgsrc infrastructure.
                   9380:        This chapter describes how regression tests work in pkgsrc and
                   9381:        how you can add new tests.</p>
                   9382: <div class="sect1" lang="en">
                   9383: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9384: <a name="regression.descr"></a>23.1. The regression tests framework</h2></div></div></div>
1.75      rillig   9385: <p></p>
                   9386: </div>
                   9387: <div class="sect1" lang="en">
                   9388: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9389: <a name="regression.run"></a>23.2. Running the regression tests</h2></div></div></div>
1.76      rillig   9390: <p>You first need to install the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_regress/README.html" target="_top"><code class="filename">pkgtools/pkg_regress</code></a> package, which
1.75      rillig   9391:        provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
                   9392:        can simply run that command, which will run all tests in the
1.76      rillig   9393:        <code class="filename">regress</code> category.</p>
1.75      rillig   9394: </div>
                   9395: <div class="sect1" lang="en">
                   9396: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9397: <a name="regression.new"></a>23.3. Adding a new regression test</h2></div></div></div>
1.76      rillig   9398: <p>Every directory in the <code class="filename">regress</code>
                   9399:        category that contains a file called <code class="filename">spec</code>
1.75      rillig   9400:        is considered a regression test. This file is a shell program
                   9401:        that is included by the <span><strong class="command">pkg_regress</strong></span> command.
                   9402:        The following functions can be overridden to suit your
                   9403:        needs.</p>
                   9404: <div class="sect2" lang="en">
                   9405: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9406: <a name="regression.fun.override"></a>23.3.1. Overridable functions</h3></div></div></div>
1.75      rillig   9407: <p>These functions do not take any parameters. They are all
                   9408:        called in &#8220;<span class="quote">set -e</span>&#8221; mode, so you should be careful
                   9409:        to check the exitcodes of any commands you run in the
                   9410:        test.</p>
                   9411: <div class="variablelist"><dl>
                   9412: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
                   9413: <dd><p>This function prepares the environment for the
                   9414:        test. By default it does nothing.</p></dd>
                   9415: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
                   9416: <dd><p>This function runs the actual test. By default,
                   9417:        it calls <code class="varname">TEST_MAKE</code> with the arguments
                   9418:        <code class="varname">MAKEARGS_TEST</code> and writes its output including
                   9419:        error messages into the file
                   9420:        <code class="varname">TEST_OUTFILE</code>.</p></dd>
                   9421: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
                   9422: <dd><p>This function is run after the test and is
                   9423:        typically used to compare the actual output from the one that is
                   9424:        expected. It can make use of the various helper functions from
                   9425:        the next section.</p></dd>
                   9426: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
                   9427: <dd><p>This function cleans everything up after the
                   9428:        test has been run. By default it does nothing.</p></dd>
                   9429: </dl></div>
                   9430: </div>
                   9431: <div class="sect2" lang="en">
                   9432: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9433: <a name="regression.fun.helper"></a>23.3.2. Helper functions</h3></div></div></div>
1.75      rillig   9434: <div class="variablelist"><dl>
                   9435: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
                   9436: <dd><p>This function compares the exitcode of the
                   9437:        <span><strong class="command">do_test()</strong></span> function with its first parameter.
                   9438:        If they differ, the test will fail.</p></dd>
                   9439: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
                   9440: <dd><p>This function checks for each of its parameters
                   9441:        if the output from <span><strong class="command">do_test()</strong></span> matches the
                   9442:        extended regular expression. If it does not, the test will
                   9443:        fail.</p></dd>
                   9444: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
                   9445: <dd><p>This function checks for each of its parameters
                   9446:        if the output from <span><strong class="command">do_test()</strong></span> does
                   9447:        <span class="emphasis"><em>not</em></span> match the extended regular expression.
                   9448:        If any of the regular expressions matches, the test will
                   9449:        fail.</p></dd>
                   9450: </dl></div>
                   9451: </div>
                   9452: </div>
                   9453: </div>
                   9454: <div class="chapter" lang="en">
                   9455: <div class="titlepage"><div><div><h2 class="title">
1.85      jmmv     9456: <a name="porting"></a>Chapter 24. Porting pkgsrc</h2></div></div></div>
1.75      rillig   9457: <div class="toc">
                   9458: <p><b>Table of Contents</b></p>
                   9459: <dl>
1.85      jmmv     9460: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
                   9461: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75      rillig   9462: </dl>
                   9463: </div>
                   9464: <p>The pkgsrc system has already been ported to many
                   9465:        operating systems, hardware architectures and compilers. This
                   9466:        chapter explains the necessary steps to make pkgsrc even more
                   9467:        portable.</p>
                   9468: <div class="sect1" lang="en">
                   9469: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9470: <a name="porting.opsys"></a>24.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75      rillig   9471: <p>To port pkgsrc to a new operating system (called
                   9472:        <code class="literal">MyOS</code> in this example), you need to touch the
                   9473:        following files:</p>
                   9474: <div class="variablelist"><dl>
1.76      rillig   9475: <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   9476: <dd><p>This file contains some basic definitions, for
                   9477:        example the name of the C
                   9478:        compiler.</p></dd>
1.76      rillig   9479: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75      rillig   9480: <dd><p>Insert code that defines the variables
                   9481:        <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
                   9482:        <code class="varname">LOWER_OS_VERSION</code>,
                   9483:        <code class="varname">LOWER_VENDOR</code>,
                   9484:        <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
                   9485:        <code class="varname">APPEND_ELF</code>, and the other variables that
                   9486:        appear in this file.</p></dd>
1.76      rillig   9487: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75      rillig   9488: <dd><p>This file contains the platform-specific
                   9489:        definitions that are used by pkgsrc. Start by copying one of the
                   9490:        other files and edit it to your
                   9491:        needs.</p></dd>
1.76      rillig   9492: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75      rillig   9493: <dd><p>This file contains a list of directories,
                   9494:        together with their permission bits and ownership. These
                   9495:        directories will be created automatically with every package
                   9496:        that does not explicitly set <code class="varname">NO_MTREE</code>. There
                   9497:        have been some discussions about whether this file is needed at
                   9498:        all, but with no result.</p></dd>
1.76      rillig   9499: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75      rillig   9500: <dd><p>Just copy one of the pre-existing x11.dist files
                   9501:        to your
1.76      rillig   9502:        <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
                   9503: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75      rillig   9504: <dd><p>On some operating systems, the tools that are
                   9505:        provided with the base system are not good enough for pkgsrc.
                   9506:        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
                   9507:        narrow limit on the line length they can process. Therefore
                   9508:        pkgsrc brings its own tools, which can be enabled
                   9509:        here.</p></dd>
1.76      rillig   9510: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75      rillig   9511: <dd><p>This file defines the paths to all the tools
                   9512:        that are needed by one or the other package in pkgsrc, as well
                   9513:        as by pkgsrc itself. Find out where these tools are on your
                   9514:        platform and add them.</p></dd>
                   9515: </dl></div>
                   9516: <p>Now, you should be able to build some basic packages, like
1.76      rillig   9517:        <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/lang/perl5/README.html" target="_top"><code class="filename">lang/perl5</code></a>, <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a>.</p>
1.75      rillig   9518: </div>
                   9519: <div class="sect1" lang="en">
                   9520: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9521: <a name="porting.compiler"></a>24.2. Adding support for a new compiler</h2></div></div></div>
1.75      rillig   9522: <p>TODO</p>
                   9523: </div>
                   9524: </div>
                   9525: </div>
                   9526: <div class="appendix" lang="en">
                   9527: <div class="titlepage"><div><div><h2 class="title">
                   9528: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
                   9529: <div class="toc">
                   9530: <p><b>Table of Contents</b></p>
                   9531: <dl>
                   9532: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
                   9533: <dd><dl>
                   9534: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
                   9535: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
                   9536: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
                   9537: <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>
                   9538: </dl></dd>
                   9539: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
                   9540: </dl>
                   9541: </div>
                   9542: <p>We checked to find a piece of software that wasn't in the packages
                   9543:     collection, and picked GNU bison. Quite why someone would want to have
                   9544:     <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
                   9545:     present in the tree is beyond us, but it's useful for the purposes of
                   9546:     this exercise.</p>
                   9547: <div class="sect1" lang="en">
                   9548: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9549: <a name="example-files"></a>A.1. files</h2></div></div></div>
                   9550: <div class="sect2" lang="en">
                   9551: <div class="titlepage"><div><div><h3 class="title">
                   9552: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
                   9553: <pre class="programlisting">
1.51      rillig   9554:     # $NetBSD$
                   9555:     #
1.1       grant    9556: 
1.51      rillig   9557:     DISTNAME=       bison-1.25
                   9558:     CATEGORIES=     devel
                   9559:     MASTER_SITES=   ${MASTER_SITE_GNU}
1.1       grant    9560: 
1.51      rillig   9561:     MAINTAINER=     thorpej@NetBSD.org
                   9562:     HOMEPAGE=       http://www.gnu.org/software/bison/bison.html
                   9563:     COMMENT=        GNU yacc clone
1.1       grant    9564: 
1.51      rillig   9565:     GNU_CONFIGURE=  yes
                   9566:     INFO_FILES=     bison.info
1.1       grant    9567: 
1.51      rillig   9568:     .include "../../mk/bsd.pkg.mk"
1.1       grant    9569: </pre>
1.75      rillig   9570: </div>
                   9571: <div class="sect2" lang="en">
                   9572: <div class="titlepage"><div><div><h3 class="title">
                   9573: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
                   9574: <pre class="programlisting">
1.51      rillig   9575:     GNU version of yacc.  Can make re-entrant parsers, and numerous other
1.75      rillig   9576:     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   9577:     of the NetBSD source tree is beyond me.
1.1       grant    9578: </pre>
1.75      rillig   9579: </div>
                   9580: <div class="sect2" lang="en">
                   9581: <div class="titlepage"><div><div><h3 class="title">
                   9582: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
                   9583: <pre class="programlisting">
1.51      rillig   9584:     @comment $NetBSD$
                   9585:     bin/bison
                   9586:     man/man1/bison.1.gz
                   9587:     share/bison.simple
                   9588:     share/bison.hairy
1.1       grant    9589: </pre>
1.75      rillig   9590: </div>
                   9591: <div class="sect2" lang="en">
                   9592: <div class="titlepage"><div><div><h3 class="title">
                   9593: <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>
                   9594: <p>The NetBSD package system comes with
1.76      rillig   9595:         <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>
1.75      rillig   9596:        which helps to check the contents of these
                   9597:        files. After installation it is quite easy to use, just change to the
                   9598:        directory of the package you wish to examine and execute
                   9599:        <span><strong class="command">pkglint</strong></span>:</p>
                   9600: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
                   9601: looks fine.</pre>
                   9602: <p>Depending on the supplied command line arguments (see pkglint(1)),
                   9603:        more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
                   9604:        -Wall</strong></span> for a very thorough check.</p>
                   9605: </div>
                   9606: </div>
                   9607: <div class="sect1" lang="en">
                   9608: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9609: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
                   9610: <p>Create the directory where the package lives,
                   9611:       plus any auxiliary directories:</p>
                   9612: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
                   9613: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
                   9614: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
                   9615: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76      rillig   9616: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.77      rillig   9617:       <code class="filename">PLIST</code> (see <a href="#components" title="Chapter 9. Package components - files, directories and contents">Chapter 9, <i>Package components - files, directories and contents</i></a>)
1.75      rillig   9618:       then continue with fetching the distfile:</p>
                   9619: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1       grant    9620: &gt;&gt; bison-1.25.tar.gz doesn't seem to exist on this system.
                   9621: &gt;&gt; Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   9622: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   9623: ftp: Error retrieving file: 500 Internal error
                   9624: 
                   9625: &gt;&gt; Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   9626: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   9627: ftp: Error retrieving file: 500 Internal error
                   9628: 
                   9629: &gt;&gt; Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   9630: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75      rillig   9631: Successfully retrieved file.</pre>
                   9632: <p>Generate the checksum of the distfile into
1.76      rillig   9633:       <code class="filename">distinfo</code>:</p>
1.75      rillig   9634: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makesum</code></strong></pre>
                   9635: <p>Now compile:</p>
                   9636: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1       grant    9637: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   9638: ===&gt;  Extracting for bison-1.25
                   9639: ===&gt;  Patching for bison-1.25
                   9640: ===&gt;   Ignoring empty patch directory
                   9641: ===&gt;  Configuring for bison-1.25
                   9642: creating cache ./config.cache
                   9643: checking for gcc... cc
                   9644: checking whether we are using GNU C... yes
                   9645: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   9646: checking how to run the C preprocessor... cc -E
                   9647: checking for minix/config.h... no
                   9648: checking for POSIXized ISC... no
                   9649: checking whether cross-compiling... no
                   9650: checking for ANSI C header files... yes
                   9651: checking for string.h... yes
                   9652: checking for stdlib.h... yes
                   9653: checking for memory.h... yes
                   9654: checking for working const... yes
                   9655: checking for working alloca.h... no
                   9656: checking for alloca... yes
                   9657: checking for strerror... yes
                   9658: updating cache ./config.cache
                   9659: creating ./config.status
                   9660: creating Makefile
                   9661: ===&gt;  Building for bison-1.25
                   9662: 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
                   9663: 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
                   9664: 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
                   9665: 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
                   9666: 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   9667: 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    9668: 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
                   9669: 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
                   9670: 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
                   9671: 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
                   9672: 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
                   9673: 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
                   9674: 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
                   9675: 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
                   9676: 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
                   9677: 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
                   9678: 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
                   9679: 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
                   9680: 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
                   9681: 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
                   9682: 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
                   9683: 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
                   9684: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   9685: rm -f bison.s1
1.75      rillig   9686: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" &lt; ./bison.simple &gt; bison.s1</pre>
                   9687: <p>Everything seems OK, so install the files:</p>
                   9688: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1       grant    9689: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   9690: ===&gt;  Installing for bison-1.25
                   9691: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   9692: rm -f /usr/pkg/bin/bison
                   9693: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   9694: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   9695: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   9696: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   9697: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   9698: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   9699: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75      rillig   9700: ===&gt;  Registering installation for bison-1.25</pre>
                   9701: <p>You can now use bison, and also - if you decide so - remove it with
                   9702:       <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
                   9703:       binary package, do this now:</p>
                   9704: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1       grant    9705: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   9706: ===&gt;  Building package for bison-1.25
                   9707: Creating package bison-1.25.tgz
                   9708: Registering depends:.
1.75      rillig   9709: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
                   9710: <p>Now that you don't need the source and object files
                   9711:       any more, clean up:</p>
                   9712: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
                   9713: ===&gt;  Cleaning for bison-1.25</pre>
                   9714: </div>
                   9715: </div>
                   9716: <div class="appendix" lang="en">
                   9717: <div class="titlepage"><div><div><h2 class="title">
                   9718: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
                   9719: <div class="toc">
                   9720: <p><b>Table of Contents</b></p>
                   9721: <dl>
                   9722: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
                   9723: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
                   9724: </dl>
                   9725: </div>
                   9726: <div class="sect1" lang="en">
                   9727: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9728: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
                   9729: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1       grant    9730: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   9731: =&gt; figlet221.tar.gz doesn't seem to exist on this system.
                   9732: =&gt; Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   9733: =&gt; [172219 bytes]
                   9734: Connected to ftp.plig.net.
                   9735: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   9736: 331 Guest login ok, send your complete e-mail address as password.
                   9737: 230-You are user #5 of 500 simultaneous users allowed.
                   9738: 230-
1.68      rillig   9739: 230-  ___ _             _ _
                   9740: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
1.1       grant    9741: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   9742: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   9743: 230-         |_|   |_|     |___|         |___|
                   9744: 230-
                   9745: 230-** Welcome to ftp.plig.org **
                   9746: 230-
                   9747: 230-Please note that all transfers from this FTP site are logged. If you
                   9748: 230-do not like this, please disconnect now.
                   9749: 230-
                   9750: 230-This arhive is available via
                   9751: 230-
                   9752: 230-HTTP:  http://ftp.plig.org/
                   9753: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   9754: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   9755: 230-
                   9756: 230-Please email comments, bug reports and requests for packages to be
1.68      rillig   9757: 230-mirrored to ftp-admin@plig.org.
1.1       grant    9758: 230-
                   9759: 230-
                   9760: 230 Logged in anonymously.
                   9761: Remote system type is UNIX.
                   9762: Using binary mode to transfer files.
                   9763: 200 Type okay.
                   9764: 250 "/pub" is new cwd.
                   9765: 250-"/pub/figlet" is new cwd.
                   9766: 250-
                   9767: 250-Welcome to the figlet archive at ftp.figlet.org
1.68      rillig   9768: 250-
1.75      rillig   9769: 250-   ftp://ftp.figlet.org/pub/figlet/
1.1       grant    9770: 250-
                   9771: 250-The official FIGlet web page is:
1.75      rillig   9772: 250-   http://www.figlet.org/
1.1       grant    9773: 250-
                   9774: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   9775: 250-contribute a font or something else, you can email us.
1.68      rillig   9776: 250
1.1       grant    9777: 250 "/pub/figlet/program" is new cwd.
                   9778: 250 "/pub/figlet/program/unix" is new cwd.
                   9779: local: figlet221.tar.gz remote: figlet221.tar.gz
                   9780: 502 Unimplemented command.
                   9781: 227 Entering Passive Mode (195,40,6,41,246,104)
                   9782: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   9783: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   9784: 226 Transfer completed.
                   9785: 172219 bytes received in 00:02 (75.99 KB/s)
                   9786: 221 Goodbye.
                   9787: =&gt; Checksum OK for figlet221.tar.gz.
                   9788: ===&gt; Extracting for figlet-2.2.1nb2
                   9789: ===&gt; Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   9790: ===&gt; Patching for figlet-2.2.1nb2
                   9791: ===&gt; Applying pkgsrc patches for figlet-2.2.1nb2
                   9792: ===&gt; Overriding tools for figlet-2.2.1nb2
                   9793: ===&gt; Creating toolchain wrappers for figlet-2.2.1nb2
                   9794: ===&gt; Configuring for figlet-2.2.1nb2
                   9795: ===&gt; Building for figlet-2.2.1nb2
                   9796: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   9797: chmod a+x figlet
                   9798: gcc -O2 -o chkfont chkfont.c
                   9799: =&gt; Unwrapping files-to-be-installed.
1.14      xtraeme  9800: <code class="prompt">#</code>
1.75      rillig   9801: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1       grant    9802: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   9803: ===&gt; Installing for figlet-2.2.1nb2
                   9804: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   9805: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   9806: mkdir -p /usr/pkg/share/figlet
                   9807: cp figlet /usr/pkg/bin
                   9808: cp chkfont /usr/pkg/bin
                   9809: chmod 555 figlist showfigfonts
                   9810: cp figlist /usr/pkg/bin
                   9811: cp showfigfonts /usr/pkg/bin
                   9812: cp fonts/*.flf /usr/pkg/share/figlet
                   9813: cp fonts/*.flc /usr/pkg/share/figlet
                   9814: cp figlet.6 /usr/pkg/man/man6
                   9815: ===&gt; Registering installation for figlet-2.2.1nb2
1.75      rillig   9816: <code class="prompt">#</code></pre>
                   9817: </div>
                   9818: <div class="sect1" lang="en">
                   9819: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9820: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
                   9821: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1       grant    9822: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   9823: ===&gt; Packaging figlet-2.2.1nb2
                   9824: ===&gt; Building binary package for figlet-2.2.1nb2
                   9825: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   9826: Using SrcDir value of /usr/pkg
1.68      rillig   9827: Registering depends:.
1.75      rillig   9828: <code class="prompt">#</code></pre>
                   9829: </div>
                   9830: </div>
                   9831: <div class="appendix" lang="en">
                   9832: <div class="titlepage"><div><div><h2 class="title">
1.76      rillig   9833: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
                   9834: <div class="toc">
                   9835: <p><b>Table of Contents</b></p>
                   9836: <dl>
                   9837: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
                   9838: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
                   9839: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
                   9840: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
                   9841: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
                   9842: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
                   9843: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                   9844: source packages</a></span></dt>
                   9845: </dl>
                   9846: </div>
                   9847: <p>As in other big projects, the directory layout of pkgsrc
                   9848:        is quite complex for newbies. This chapter explains where you
                   9849:        find things on the FTP server. The base directory on
                   9850:        <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>.
                   9851:        This directory contains some subdirectories, which are explained
                   9852:        below.</p>
                   9853: <div class="sect1" lang="en">
                   9854: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9855: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
                   9856: <p>For those who only want to manage binary packages on
                   9857:        systems other than NetBSD, we provide the package management
                   9858:        tools in a separate, small tar file.</p>
                   9859: </div>
                   9860: <div class="sect1" lang="en">
                   9861: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9862: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
                   9863: <p>The directory <code class="filename">distfiles</code> contains lots
                   9864:        of archive files from all pkgsrc packages, which are mirrored
                   9865:        here. The subdirectories are called after their package names
                   9866:        and are used when the distributed files have names that don't
                   9867:        explicitly contain a version number or are otherwise too generic
                   9868:        (for example <code class="filename">release.tar.gz</code>).</p>
                   9869: </div>
                   9870: <div class="sect1" lang="en">
                   9871: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9872: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
                   9873: <p>This directory is currently not in use.</p>
                   9874: </div>
                   9875: <div class="sect1" lang="en">
                   9876: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9877: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
                   9878: <p>This directory contains things that individual pkgsrc
                   9879:        developers find worth publishing.</p>
                   9880: </div>
                   9881: <div class="sect1" lang="en">
                   9882: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9883: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
                   9884: <p>These directories contain binary packages. Those
                   9885:        directories that have a branch name
                   9886:        (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
                   9887:        contain packages from that particular branch. The directory
                   9888:        <code class="filename">packages</code> contains binary packages from
                   9889:        pkgsrc-current. (However, this does not necessarily mean that
                   9890:        the packages are still current anymore.)</p>
                   9891: <p>Below the <code class="filename">packages*</code> directories are
                   9892:        directories that distinguish the packages by operating system
                   9893:        and version, the next directory level specifies the hardware
                   9894:        architecture.</p>
                   9895: <p>In each of the platform-specific directories, there is a
                   9896:        whole binary packages collection. It has a directory called
                   9897:        <code class="filename">All</code> which contains all binary packages.
                   9898:        Besides that, there are various category directories that
                   9899:        contain symbolic links to the real binary packages.</p>
                   9900: </div>
                   9901: <div class="sect1" lang="en">
                   9902: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9903: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
                   9904: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                   9905: source packages</h2></div></div></div>
                   9906: <p>These directories contain the &#8220;<span class="quote">real</span>&#8221; pkgsrc,
                   9907:        that is the files that define how to create binary packages from
                   9908:        source archives.</p>
                   9909: <p>The directory <code class="filename">pkgsrc</code> contains a
                   9910:        snapshot of the CVS repository, which is updated on a regularly
                   9911:        basis. The file <code class="filename">pkgsrc.tar.gz</code> contains the
                   9912:        same as the directory, ready to be downloaded as a whole.</p>
                   9913: <p>In the directories for the quarterly branches, there is an
                   9914:        additional file called
                   9915:        <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
                   9916:        which contains the state of pkgsrc when it was branched.</p>
                   9917: </div>
1.75      rillig   9918: </div>
                   9919: <div class="appendix" lang="en">
                   9920: <div class="titlepage"><div><div><h2 class="title">
                   9921: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
                   9922: <div class="toc">
                   9923: <p><b>Table of Contents</b></p>
                   9924: <dl>
1.79      rillig   9925: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75      rillig   9926: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
                   9927: </dl>
                   9928: </div>
1.79      rillig   9929: <p>This section contains information on editing the pkgsrc
                   9930:        guide itself.</p>
1.75      rillig   9931: <div class="sect1" lang="en">
                   9932: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79      rillig   9933: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
                   9934: <p>The pkgsrc guide's source code is stored in
                   9935:        <code class="filename">pkgsrc/doc/guide/files</code>, and several files
                   9936:        are created from it:</p>
                   9937: <div class="itemizedlist"><ul type="disc">
                   9938: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
                   9939: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
                   9940: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/</a></p></li>
                   9941: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</a>:
                   9942:        The PDF version of the pkgsrc guide.</p></li>
                   9943: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</a>:
                   9944:        PostScript version of the pkgsrc guide.</p></li>
1.75      rillig   9945: </ul></div>
                   9946: </div>
                   9947: <div class="sect1" lang="en">
                   9948: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9949: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
1.79      rillig   9950: <p>The procedure to edit the pkgsrc guide is:</p>
                   9951: <div class="procedure"><ol type="1">
                   9952: <li><p>Make sure you have the packages needed to
1.83      wiz      9953:        regenerate the pkgsrc guide (and other XML-based NetBSD
1.79      rillig   9954:        documentation) installed. These are <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/netbsd-doc/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc</code></a> for creating the
                   9955:        ASCII and HTML versions, and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/netbsd-doc-print/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc-print</code></a> for the
                   9956:        PostScript and PDF versions. You will need both packages
                   9957:        installed, to make sure documentation is consistent across all
                   9958:        formats.</p></li>
                   9959: <li><p>Run <span><strong class="command">cd doc/guide</strong></span> to get to the
                   9960:        right directory. All further steps will take place
                   9961:        here.</p></li>
                   9962: <li><p>Edit the XML file(s) in
                   9963:        <code class="filename">files/</code>.</p></li>
                   9964: <li><p>Run <span><strong class="command">bmake</strong></span> to check the pkgsrc
                   9965:        guide for valid XML and to build the final output files. If you
                   9966:        get any errors at this stage, you can just edit the files, as
                   9967:        there are only symbolic links in the working directory, pointing
                   9968:        to the files in <code class="filename">files/</code>.</p></li>
                   9969: <li><p><span><strong class="command">(cd files &amp;&amp; cvs
                   9970:        commit)</strong></span></p></li>
                   9971: <li><p>Run <span><strong class="command">bmake clean &amp;&amp; bmake</strong></span> to
                   9972:        regenerate the output files with the proper RCS
                   9973:        Ids.</p></li>
1.83      wiz      9974: <li><p>Run <span><strong class="command">bmake regenerate</strong></span> to
                   9975:        regenerate the files in both <code class="filename">pkgsrc/doc</code> and
                   9976:        <code class="filename">htdocs</code>.</p></li>
                   9977: <li><p>If you have added, removed or renamed some chapters,
                   9978:        you need to synchronize them using <span><strong class="command">cvs add</strong></span> or
                   9979:        <span><strong class="command">cvs delete</strong></span> in the htdocs
                   9980:        directory.</p></li>
1.79      rillig   9981: </ol></div>
1.75      rillig   9982: </div>
                   9983: </div>
                   9984: </div></body>
1.1       grant    9985: </html>

CVSweb <webmaster@jp.NetBSD.org>