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

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>
                    310: <dt><span class="sect1"><a href="#fixes.build">17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                    311: <dd><dl>
1.78      rillig    312: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
                    313: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
                    314: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
                    315: </dl></dd>
                    316: <dt><span class="sect1"><a href="#fixes.install">17.5. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                    317: <dd><dl>
                    318: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
                    319: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
                    320: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
                    321: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
                    322: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
                    323: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
                    324: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
                    325: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
                    326: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
                    327: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
                    328: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
                    329: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
                    330: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
                    331: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
                    332: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
                    333: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
                    334: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.85      jmmv      335: <dt><span class="sect2"><a href="#hicolor-theme">17.5.18. Packages installing hicolor theme icons</a></span></dt>
                    336: <dt><span class="sect2"><a href="#desktop-files">17.5.19. Packages installing desktop files</a></span></dt>
1.77      rillig    337: </dl></dd>
                    338: </dl></dd>
                    339: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
                    340: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
                    341: <dd><dl>
                    342: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
                    343: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                    344: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
                    345: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
                    346: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
                    347: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig    348: </dl></dd>
1.77      rillig    349: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.85      jmmv      350: <dt><span class="chapter"><a href="#gnome">21. GNOME packaging and porting</a></span></dt>
                    351: <dd><dl>
                    352: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
                    353: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
                    354: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
                    355: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
                    356: </dl></dd>
1.75      rillig    357: </dl></dd>
                    358: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
                    359: <dd><dl>
1.85      jmmv      360: <dt><span class="chapter"><a href="#infr.design">22. Design of the pkgsrc infrastructure</a></span></dt>
1.75      rillig    361: <dd><dl>
1.85      jmmv      362: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
                    363: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
                    364: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.81      rillig    365: <dd><dl>
1.85      jmmv      366: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
                    367: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.81      rillig    368: </dl></dd>
1.85      jmmv      369: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
                    370: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig    371: <dd><dl>
1.85      jmmv      372: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
                    373: <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    374: </dl></dd>
1.85      jmmv      375: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.75      rillig    376: <dd><dl>
1.85      jmmv      377: <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>
                    378: <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    379: </dl></dd>
                    380: </dl></dd>
1.85      jmmv      381: <dt><span class="chapter"><a href="#regression">23. Regression tests</a></span></dt>
1.75      rillig    382: <dd><dl>
1.85      jmmv      383: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
                    384: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
                    385: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75      rillig    386: <dd><dl>
1.85      jmmv      387: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
                    388: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75      rillig    389: </dl></dd>
                    390: </dl></dd>
1.85      jmmv      391: <dt><span class="chapter"><a href="#porting">24. Porting pkgsrc</a></span></dt>
1.75      rillig    392: <dd><dl>
1.85      jmmv      393: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
                    394: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75      rillig    395: </dl></dd>
                    396: </dl></dd>
                    397: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
                    398: <dd><dl>
                    399: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
                    400: <dd><dl>
                    401: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
                    402: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
                    403: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
                    404: <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>
                    405: </dl></dd>
                    406: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
                    407: </dl></dd>
                    408: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
                    409: <dd><dl>
                    410: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
                    411: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
                    412: </dl></dd>
1.76      rillig    413: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
                    414: <dd><dl>
                    415: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
                    416: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
                    417: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
                    418: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
                    419: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
                    420: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
                    421: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                    422: source packages</a></span></dt>
                    423: </dl></dd>
1.75      rillig    424: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
                    425: <dd><dl>
1.79      rillig    426: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75      rillig    427: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
                    428: </dl></dd>
                    429: </dl>
                    430: </div>
1.82      rillig    431: <div class="list-of-tables">
                    432: <p><b>List of Tables</b></p>
                    433: <dl>
                    434: <dt>1.1. <a href="#supported-platforms">Platforms supported by pkgsrc</a>
                    435: </dt>
                    436: <dt>3.1. <a href="#binary-kits">Binary kits and available packages</a>
                    437: </dt>
1.85      jmmv      438: <dt>9.1. <a href="#patch-examples">Patching examples</a>
                    439: </dt>
                    440: <dt>21.1. <a href="#plist-handling">PLIST handling for GNOME packages</a>
                    441: </dt>
1.82      rillig    442: </dl>
                    443: </div>
1.75      rillig    444: <div class="chapter" lang="en">
                    445: <div class="titlepage"><div><div><h2 class="title">
                    446: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
                    447: <div class="toc">
                    448: <p><b>Table of Contents</b></p>
                    449: <dl>
                    450: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82      rillig    451: <dd><dl>
                    452: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
                    453: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
                    454: </dl></dd>
1.75      rillig    455: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
                    456: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.78      rillig    457: <dd><dl>
                    458: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
1.82      rillig    459: <dt><span class="sect2"><a href="#term.roles">1.3.2. Roles involved in pkgsrc</a></span></dt>
1.78      rillig    460: </dl></dd>
1.75      rillig    461: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
                    462: </dl>
                    463: </div>
                    464: <div class="sect1" lang="en">
                    465: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    466: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
1.82      rillig    467: <p>There is a lot of software freely available for Unix-based
                    468: systems, which is usually available in form of the source code. Before
                    469: such software can be used, it needs to be configured to the local
                    470: system, compiled and installed, and this is exactly what The NetBSD
                    471: Packages Collection (pkgsrc) does. pkgsrc also has some basic commands
                    472: to handle binary packages, so that not every user has to build the
                    473: packages for himself, which is a time-costly task.</p>
1.75      rillig    474: <p>pkgsrc currently contains several thousand packages,
                    475:       including:</p>
                    476: <div class="itemizedlist"><ul type="disc">
1.76      rillig    477: <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    478:          web server</p></li>
1.83      wiz       479: <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    480:          web browser</p></li>
1.76      rillig    481: <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    482:          Desktop Environment</p></li>
1.76      rillig    483: <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    484:          Desktop Environment</p></li>
                    485: </ul></div>
                    486: <p>...just to name a few.</p>
                    487: <p>pkgsrc has built-in support for handling varying dependencies,
                    488:       such as pthreads and X11, and extended features such as IPv6 support on
                    489:       a range of platforms.</p>
1.82      rillig    490: <div class="sect2" lang="en">
                    491: <div class="titlepage"><div><div><h3 class="title">
                    492: <a name="why-pkgsrc"></a>1.1.1. Why pkgsrc?</h3></div></div></div>
                    493: <p>
                    494: pkgsrc provides the following key features:
                    495: </p>
                    496: <div class="itemizedlist"><ul type="disc">
                    497: <li><p>Easy building of software from source as well as the creation
                    498:   and installation of binary packages. The source and latest
                    499:   patches are retrieved from a master or mirror download site, checksum
                    500:   verified, then built on your system. Support for binary-only
                    501:   distributions is available for both native platforms and NetBSD
                    502:   emulated platforms.</p></li>
                    503: <li><p>All packages are installed in a consistent directory tree,
                    504:   including binaries, libraries, man pages and other
                    505:   documentation.</p></li>
                    506: <li><p>Package dependencies, including when performing package updates,
                    507:   are handled automatically. The configuration files of various
                    508:   packages are handled automatically during updates, so local changes
                    509:   are preserved.</p></li>
                    510: <li><p>Like NetBSD, pkgsrc is designed with portability in mind and
                    511:   consists of highly portable code. This allows the greatest speed of
                    512:   development when porting to new a platform. This portability also
                    513:   ensures that pkgsrc is <span class="emphasis"><em>consistent across all
                    514:   platforms</em></span>.</p></li>
                    515: <li><p>The installation prefix, acceptable software licenses,
                    516:   international encryption requirements and build-time options for a
                    517:   large number of packages are all set in a simple, central
                    518:   configuration file.</p></li>
                    519: <li><p>The entire source (not including the distribution files) is
                    520:   freely available under a BSD license, so you may extend and adapt
                    521:   pkgsrc to your needs. Support for local packages and patches is
                    522:   available right out of the box, so you can configure it specifically
                    523:   for your environment.</p></li>
                    524: </ul></div>
                    525: </div>
                    526: <div class="sect2" lang="en">
                    527: <div class="titlepage"><div><div><h3 class="title">
                    528: <a name="intro.platforms"></a>1.1.2. Supported platforms</h3></div></div></div>
                    529: <p>pkgsrc consists of both a source distribution and a binary
                    530: distribution for these operating systems. After retrieving the required
                    531: source or binaries, you can be up and running with pkgsrc in just
                    532: minutes!</p>
1.75      rillig    533: <p>pkgsrc was derived from FreeBSD's ports system, and
                    534:       initially developed for NetBSD only. Since then, pkgsrc has
                    535:       grown a lot, and now supports the following platforms:</p>
1.82      rillig    536: <div class="table">
                    537: <a name="supported-platforms"></a><p class="title"><b>Table 1.1. Platforms supported by pkgsrc</b></p>
1.83      wiz       538: <div class="table-contents"><table summary="Platforms supported by pkgsrc" border="1">
1.82      rillig    539: <colgroup>
                    540: <col>
                    541: <col>
                    542: </colgroup>
                    543: <thead><tr>
                    544: <th>Platform</th>
                    545: <th>Date Support Added</th>
                    546: </tr></thead>
                    547: <tbody>
                    548: <tr>
                    549: <td><a href="http://www.NetBSD.org/" target="_top">NetBSD</a></td>
                    550: <td align="center">Aug 1997</td>
                    551: </tr>
                    552: <tr>
                    553: <td><a href="http://wwws.sun.com/software/solaris/" target="_top">Solaris</a></td>
                    554: <td align="center">Mar 1999</td>
                    555: </tr>
                    556: <tr>
                    557: <td><a href="http://www.kernel.org/" target="_top">Linux</a></td>
                    558: <td align="center">Jun 1999</td>
                    559: </tr>
                    560: <tr>
                    561: <td>
                    562:           <a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
                    563:           (<a href="http://developer.apple.com/macosx/" target="_top">Mac OS X</a>)
                    564:         </td>
                    565: <td align="center">Oct 2001</td>
                    566: </tr>
                    567: <tr>
                    568: <td><a href="http://www.freebsd.org/" target="_top">FreeBSD</a></td>
                    569: <td align="center">Nov 2002</td>
                    570: </tr>
                    571: <tr>
                    572: <td><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></td>
                    573: <td align="center">Nov 2002</td>
                    574: </tr>
                    575: <tr>
                    576: <td><a href="http://www.sgi.com/software/irix/" target="_top">IRIX</a></td>
                    577: <td align="center">Dec 2002</td>
                    578: </tr>
                    579: <tr>
                    580: <td>BSD/OS</td>
                    581: <td align="center">Dec 2003</td>
                    582: </tr>
                    583: <tr>
                    584: <td><a href="http://www-1.ibm.com/servers/aix/" target="_top">AIX</a></td>
                    585: <td align="center">Dec 2003</td>
                    586: </tr>
                    587: <tr>
                    588: <td>
                    589:           <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a>
                    590:           (Microsoft Windows Services for Unix)
                    591:         </td>
                    592: <td align="center">Mar 2004</td>
                    593: </tr>
                    594: <tr>
                    595: <td><a href="http://www.dragonflybsd.org/" target="_top">DragonFlyBSD</a></td>
                    596: <td align="center">Oct 2004</td>
                    597: </tr>
                    598: <tr>
                    599: <td><a href="http://www.tru64.org/" target="_top">OSF/1</a></td>
                    600: <td align="center">Nov 2004</td>
                    601: </tr>
                    602: </tbody>
1.83      wiz       603: </table></div>
1.82      rillig    604: </div>
1.83      wiz       605: <br class="table-break">
1.82      rillig    606: </div>
1.75      rillig    607: </div>
                    608: <div class="sect1" lang="en">
                    609: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    610: <a name="overview"></a>1.2. Overview</h2></div></div></div>
                    611: <p>This document is divided into three parts. The first,
                    612:        <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
                    613:        describes how one can use one of the packages in the Package
                    614:        Collection, either by installing a precompiled binary package,
                    615:        or by building one's own copy using the NetBSD package system. 
                    616:        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
                    617:        package so it can be easily built by other NetBSD users without
                    618:        knowing about the package's building details. The third part,
                    619:        <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
                    620:        is intended for those who want to understand how pkgsrc is
                    621:        implemented.</p>
                    622: <p>This document is available in various formats:
                    623:        <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>
                    624: </div>
                    625: <div class="sect1" lang="en">
                    626: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    627: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
                    628: <p>There has been a lot of talk about &#8220;<span class="quote">ports</span>&#8221;,
                    629:       &#8220;<span class="quote">packages</span>&#8221;, etc. so far. Here is a description of all the
                    630:       terminology used within this document.</p>
                    631: <div class="variablelist"><dl>
                    632: <dt><span class="term">Package</span></dt>
                    633: <dd><p>A set of files and building instructions
                    634:            that describe what's necessary
                    635:            to build a certain piece of software using
                    636:             pkgsrc. Packages are traditionally stored under
1.76      rillig    637:            <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75      rillig    638: <dt><span class="term">The NetBSD package system</span></dt>
                    639: <dd><p>
                    640:            This is the former name of &#8220;<span class="quote">pkgsrc</span>&#8221;.  It is
                    641:            part of the NetBSD operating system and can be bootstrapped to
                    642:            run on non-NetBSD operating systems as well.  It handles
                    643:            building (compiling), installing, and removing of
                    644:            packages.
                    645:            </p></dd>
                    646: <dt><span class="term">Distfile</span></dt>
                    647: <dd><p>This term describes the file or files that are
                    648:            provided by the author of the piece of software to
                    649:            distribute his work. All the changes necessary to build on
                    650:            NetBSD are reflected in the corresponding package. Usually
                    651:            the distfile is in the form of a compressed tar-archive,
                    652:            but other types are possible, too. Distfiles are usually
                    653:            stored below
1.76      rillig    654:            <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75      rillig    655: <dt><span class="term">Port</span></dt>
                    656: <dd><p>This is the term used by FreeBSD and OpenBSD people
                    657:            for what we call a package.
                    658:            In NetBSD terminology, &#8220;<span class="quote">port</span>&#8221; refers to a different
                    659:            architecture.</p></dd>
                    660: <dt><span class="term">Precompiled/binary package</span></dt>
                    661: <dd>
                    662: <p>A set of binaries built with pkgsrc from a distfile
1.76      rillig    663:            and stuffed together in a single <code class="filename">.tgz</code>
1.75      rillig    664:            file so it can be installed on machines of the same
                    665:            machine architecture without the need to
                    666:            recompile. Packages are usually generated in
1.76      rillig    667:            <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75      rillig    668:            an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
                    669: <p>Sometimes, this is referred to by the term &#8220;<span class="quote">package</span>&#8221; too,
                    670:            especially in the context of precompiled packages.</p>
                    671: </dd>
                    672: <dt><span class="term">Program</span></dt>
                    673: <dd><p>The piece of software to be installed which will be constructed from
                    674:            all the files in the distfile by the actions defined in the
                    675:            corresponding package.</p></dd>
                    676: </dl></div>
                    677: <div class="sect2" lang="en">
                    678: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig    679: <a name="term.abbrev"></a>1.3.1. Commonly used abbreviations</h3></div></div></div>
                    680: <div class="variablelist"><dl>
                    681: <dt><span class="term">ICE</span></dt>
                    682: <dd><p>Internal Compiler
                    683:        Error</p></dd>
                    684: </dl></div>
                    685: </div>
                    686: <div class="sect2" lang="en">
                    687: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig    688: <a name="term.roles"></a>1.3.2. Roles involved in pkgsrc</h3></div></div></div>
1.75      rillig    689: <div class="variablelist"><dl>
                    690: <dt><span class="term">pkgsrc users</span></dt>
                    691: <dd>
                    692: <p>The
                    693:        pkgsrc users are people who use the packages provided by pkgsrc.
                    694:        Typically they are system administrators. The people using the
                    695:        software that is inside the packages (maybe called &#8220;<span class="quote">end
                    696:        users</span>&#8221;) are not covered by the pkgsrc guide.</p>
                    697: <p>There are two kinds of pkgsrc users: Some only want to
                    698:        install pre-built binary packages. Others build the pkgsrc
                    699:        packages from source, either for installing them directly or for
                    700:        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
                    701:        documentation.</p>
                    702: </dd>
                    703: <dt><span class="term">package maintainers</span></dt>
                    704: <dd><p>A
                    705:        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>
                    706: <dt><span class="term">infrastructure developers</span></dt>
                    707: <dd><p>These people are involved in all those files
1.76      rillig    708:        that live in the <code class="filename">mk/</code> directory and below.
1.75      rillig    709:        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,
                    710:        too.</p></dd>
                    711: </dl></div>
                    712: </div>
                    713: </div>
                    714: <div class="sect1" lang="en">
                    715: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    716: <a name="typography"></a>1.4. Typography</h2></div></div></div>
                    717: <p>When giving examples for commands, shell prompts are used to
                    718:       show if the command should/can be issued as root, or if
                    719:       &#8220;<span class="quote">normal</span>&#8221; user privileges are sufficient. We use a
                    720:       <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
                    721:       shell prompt, assuming they use the C-shell or tcsh.</p>
                    722: </div>
                    723: </div>
                    724: <div class="part" lang="en">
                    725: <div class="titlepage"><div><div><h1 class="title">
                    726: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
                    727: <div class="toc">
                    728: <p><b>Table of Contents</b></p>
                    729: <dl>
                    730: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
                    731: <dd><dl>
                    732: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                    733: <dd><dl>
                    734: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                    735: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                    736: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                    737: </dl></dd>
                    738: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                    739: <dd><dl>
                    740: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                    741: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                    742: </dl></dd>
                    743: </dl></dd>
                    744: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
                    745: <dd><dl>
1.82      rillig    746: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
                    747: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
                    748: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
                    749: <dd><dl>
                    750: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
                    751: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
                    752: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
                    753: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
                    754: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
                    755: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
                    756: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75      rillig    757: </dl></dd>
                    758: </dl></dd>
                    759: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
                    760: <dd><dl>
                    761: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                    762: <dd><dl>
                    763: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                    764: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82      rillig    765: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
                    766: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
                    767: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
                    768: <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>
                    769: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
                    770: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75      rillig    771: </dl></dd>
                    772: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                    773: <dd><dl>
                    774: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                    775: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                    776: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                    777: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
                    778: </dl></dd>
                    779: </dl></dd>
                    780: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
                    781: <dd><dl>
                    782: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                    783: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78      rillig    784: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
                    785: <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>
                    786: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
                    787: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75      rillig    788: </dl></dd>
                    789: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
                    790: <dd><dl>
                    791: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                    792: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                    793: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                    794: <dd><dl>
                    795: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                    796: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                    797: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                    798: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                    799: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                    800: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                    801: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                    802: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                    803: </dl></dd>
                    804: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                    805: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                    806: </dl></dd>
                    807: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
                    808: <dd><dl>
                    809: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                    810: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
                    811: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
                    812: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
                    813: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
                    814: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                    815: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                    816: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
                    817: <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>
                    818: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
                    819: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does &#8220;<span class="quote">Don't know how to make
                    820: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
                    821: <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>
                    822: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
                    823: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
                    824: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
                    825: <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    826: <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    827: </dl></dd>
                    828: </dl>
                    829: </div>
                    830: <div class="chapter" lang="en">
                    831: <div class="titlepage"><div><div><h2 class="title">
                    832: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
                    833: <div class="toc">
                    834: <p><b>Table of Contents</b></p>
                    835: <dl>
                    836: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                    837: <dd><dl>
                    838: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                    839: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                    840: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                    841: </dl></dd>
                    842: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                    843: <dd><dl>
                    844: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                    845: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                    846: </dl></dd>
                    847: </dl>
                    848: </div>
                    849: <p>The most common location where pkgsrc is installed is
1.76      rillig    850:        <code class="filename">/usr/pkgsrc</code> for the &#8220;<span class="quote">package
                    851:        sources</span>&#8221; and <code class="filename">/usr/pkg</code> for the
1.75      rillig    852:        installed binary packages. You are though free to install the
                    853:        sources and binary packages wherever you want in your
                    854:        filesystem, provided that both paths do not contain white-space
                    855:        or other characters that are interpreted specially by the shell
                    856:        and some other programs. A safe bet is to use only letters,
                    857:        digits, underscores and dashes in the names.</p>
                    858: <div class="sect1" lang="en">
                    859: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    860: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
                    861: <p>Before you download any pkgsrc files, you should decide
                    862:        whether you want the <span class="emphasis"><em>current</em></span> branch or the
                    863:        <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
                    864:        quarterly basis from the current branch and only gets modified
                    865:        for security updates. The names of the stable branches are built
                    866:        from the year and the quarter, for example
                    867:        <code class="literal">2006Q1</code>.</p>
                    868: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
                    869:        want to download pkgsrc. You can get it as a tar file, via SUP,
                    870:        or via CVS. All three ways are described here.</p>
                    871: <div class="sect2" lang="en">
                    872: <div class="titlepage"><div><div><h3 class="title">
                    873: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
                    874: <p>The primary download location for all pkgsrc files is
                    875:        <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
                    876:        number of subdirectories for different purposes, which are
1.76      rillig    877:        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    878: <p>The tar file for the current branch is in the directory
1.76      rillig    879:        <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    880:        It is autogenerated daily.</p>
                    881: <p>The tar file for the stable branch 2006Q1 is in the
1.76      rillig    882:        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    883: <p>After downloading the tar file, change to the directory
                    884:        where you want to have pkgsrc. This is usually
1.76      rillig    885:        <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75      rillig    886:        pkgsrc.tar.gz</strong></span> to extract the files.</p>
                    887: </div>
                    888: <div class="sect2" lang="en">
                    889: <div class="titlepage"><div><div><h3 class="title">
                    890: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
                    891: <p>As an alternative to the tar file, you can get pkgsrc via
                    892:        the Software Update Protocol, SUP. To do so, make sure your
                    893:        supfile has a line
1.1       grant     894: 
1.75      rillig    895: </p>
                    896: <pre class="programlisting">
1.51      rillig    897:     release=pkgsrc
1.1       grant     898: </pre>
1.75      rillig    899: <p>
1.1       grant     900: 
1.75      rillig    901:        in it, see the examples in
1.76      rillig    902:        <code class="filename">/usr/share/examples/supfiles</code>, and that the
                    903:        <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75      rillig    904:        run <span><strong class="command">sup -v
                    905:        <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
                    906: </div>
                    907: <div class="sect2" lang="en">
                    908: <div class="titlepage"><div><div><h3 class="title">
                    909: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
                    910: <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>
                    911:        installed. To do an initial (full) checkout of pkgsrc, you first
                    912:        have to set some environment variables. For the C-Shell,
                    913:        type:</p>
                    914: <pre class="screen">
                    915:     <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
                    916:     <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
                    917: </pre>
                    918: <p>Or, the same for the bourne shell:</p>
                    919: <pre class="screen">
                    920:     <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
                    921:     <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
                    922:     <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
                    923: </pre>
                    924: <p>Then, you change to the directory where you want to have
                    925:        your copy of pkgsrc. In most cases this is
1.76      rillig    926:        <code class="filename">/usr</code>. In that directory you run the
1.75      rillig    927:        checkout command, which is <span><strong class="command">cvs -q checkout -P
                    928:        pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
                    929:        checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
                    930:        branch. This command will create a directory called
1.76      rillig    931:        <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75      rillig    932:        it.</p>
                    933: </div>
                    934: </div>
                    935: <div class="sect1" lang="en">
                    936: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    937: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
                    938: <p>The preferred way to keep pkgsrc up-to-date is via CVS
                    939:        (which also works if you have first installed it via a tar
                    940:        file). It saves bandwidth and hard disk activity, compared to
                    941:        downloading the tar file again.</p>
                    942: <div class="sect2" lang="en">
                    943: <div class="titlepage"><div><div><h3 class="title">
                    944: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
                    945: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
                    946: <h3 class="title">Warning</h3>
1.77      rillig    947: <p>When updating from a tar file, you first need to
                    948:        completely remove the old pkgsrc directory. Otherwise those
                    949:        files that have been removed from pkgsrc in the mean time will
                    950:        not be removed on your local disk, resulting in inconsistencies.
                    951:        When removing the old files, any changes that you have done to
                    952:        the pkgsrc files will be lost after updating. Therefore updating
                    953:        via CVS is strongly recommended.</p>
1.75      rillig    954: </div>
1.82      rillig    955: <p>Note that by default the distfiles and the binary packages
                    956:        are saved in the pkgsrc tree, so don't forget to rescue them
                    957:        before updating. You can also configure pkgsrc to use other than
                    958:        the default directories by setting the
                    959:        <code class="varname">DISTDIR</code> and <code class="varname">PACKAGES</code>
                    960:        variables. See <a href="#configuring" title="Chapter 5. Configuring pkgsrc">Chapter 5, <i>Configuring pkgsrc</i></a> for the details.</p>
1.75      rillig    961: <p>To update pkgsrc from a tar file, download the tar file as
                    962:        explained above. Then, make sure that you have not made any
                    963:        changes to the files in the pkgsrc directory. Remove the pkgsrc
                    964:        directory and extract the new tar file. Done.</p>
                    965: </div>
                    966: <div class="sect2" lang="en">
                    967: <div class="titlepage"><div><div><h3 class="title">
                    968: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
                    969: <p>To update pkgsrc via CVS, make sure the environment
                    970:        variable <code class="varname">CVS_RSH</code> is set as above. Then,
                    971:        change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77      rillig    972:        -dP</strong></span>.</p>
1.75      rillig    973: <div class="sect3" lang="en">
                    974: <div class="titlepage"><div><div><h4 class="title">
                    975: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
                    976: <p>When updating pkgsrc, the CVS program keeps track of the
                    977:        branch you selected. But if you, for whatever reason, want to
                    978:        switch from the stable branch to the current one, you can do it
                    979:        by adding the option &#8220;<span class="quote">-A</span>&#8221; after the
                    980:        &#8220;<span class="quote">update</span>&#8221; keyword. To switch from the current branch
                    981:        back to the stable branch, add the
                    982:        &#8220;<span class="quote">-rpkgsrc-2006Q1</span>&#8221; option.</p>
                    983: </div>
                    984: <div class="sect3" lang="en">
                    985: <div class="titlepage"><div><div><h4 class="title">
                    986: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
                    987: <p>When you update pkgsrc, the CVS program will only touch
                    988:        those files that are registered in the CVS repository. That
                    989:        means that any packages that you created on your own will stay
                    990:        unmodified. If you change files that are managed by CVS, later
                    991:        updates will try to merge your changes with those that have been
                    992:        done by others. See the CVS manual, chapter
                    993:        &#8220;<span class="quote">update</span>&#8221; for details.</p>
                    994: </div>
                    995: </div>
                    996: </div>
                    997: </div>
                    998: <div class="chapter" lang="en">
                    999: <div class="titlepage"><div><div><h2 class="title">
                   1000: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
                   1001: <div class="toc">
                   1002: <p><b>Table of Contents</b></p>
                   1003: <dl>
1.82      rillig   1004: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
                   1005: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
                   1006: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
                   1007: <dd><dl>
                   1008: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
                   1009: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
                   1010: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
                   1011: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
                   1012: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
                   1013: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
                   1014: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75      rillig   1015: </dl></dd>
                   1016: </dl>
                   1017: </div>
                   1018: <div class="sect1" lang="en">
                   1019: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82      rillig   1020: <a name="binarydist"></a>3.1. Binary distribution</h2></div></div></div>
                   1021: <p>
                   1022: We provide a bootstrap kit in both source and binary form for other
                   1023: platforms than NetBSD, consisting of the pkg administration tools and other
                   1024: tools required to use pkgsrc and build packages.
                   1025: </p>
                   1026: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1027: <h3 class="title">Note</h3>
                   1028: <p>
                   1029: Older binary snapshots are available in the
                   1030: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/archive/" target="_top">bootstrap-pkgsrc/archive</a>
                   1031: directory on ftp.NetBSD.org.</p>
                   1032: </div>
                   1033: <div class="table">
                   1034: <a name="binary-kits"></a><p class="title"><b>Table 3.1. Binary kits and available packages</b></p>
1.83      wiz      1035: <div class="table-contents"><table summary="Binary kits and available packages" border="1">
1.82      rillig   1036: <colgroup>
                   1037: <col>
                   1038: <col>
                   1039: <col>
                   1040: <col>
                   1041: </colgroup>
                   1042: <thead><tr>
                   1043: <th>Platform</th>
                   1044: <th>Latest snapshot</th>
                   1045: <th>Binary kit</th>
                   1046: <th>Binary packages</th>
                   1047: </tr></thead>
                   1048: <tbody>
                   1049: <tr>
                   1050: <td class="osname">Darwin 5.5/powerpc (Mac OS X 10.1.5)</td>
                   1051: <td class="date">20021209</td>
                   1052: <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>
                   1053: <td class="binary-pkgs-url"> </td>
                   1054: </tr>
                   1055: <tr>
                   1056: <td class="osname">Darwin 6.6/powerpc (Mac OS X 10.2.6)</td>
                   1057: <td class="date">20030623</td>
                   1058: <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>
                   1059: <td class="binary-pkgs-url"> </td>
                   1060: </tr>
                   1061: <tr>
                   1062: <td class="osname">Darwin 7.6/powerpc (Mac OS X 10.3.6)</td>
                   1063: <td class="date">20041219</td>
                   1064: <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>
                   1065: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Darwin-7.6/" target="_top">binary packages</a></td>
                   1066: </tr>
                   1067: <tr>
                   1068: <td class="osname">Darwin 7.8/powerpc (Mac OS X 10.3.8)</td>
                   1069: <td class="date">20050320</td>
                   1070: <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>
                   1071: <td class="binary-pkgs-url"> </td>
                   1072: </tr>
                   1073: <tr>
                   1074: <td class="osname">Darwin 8.1/powerpc (Mac OS X 10.4.1)</td>
                   1075: <td class="date">20050625</td>
                   1076: <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>
                   1077: <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>
                   1078: </tr>
                   1079: <tr>
                   1080: <td class="osname">Debian GNU Linux/i386</td>
                   1081: <td class="date">20031023</td>
                   1082: <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>
                   1083: <td class="binary-pkgs-url"> </td>
                   1084: </tr>
                   1085: <tr>
                   1086: <td class="osname">Fedora Core 2 Linux/i386</td>
                   1087: <td class="date">20050618</td>
                   1088: <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>
                   1089: <td class="binary-pkgs-url"> </td>
                   1090: </tr>
                   1091: <tr>
                   1092: <td class="osname">Fedora Core 4 Linux/i386</td>
                   1093: <td class="date">20060105</td>
                   1094: <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>
                   1095: <td class="binary-pkgs-url"> </td>
                   1096: </tr>
                   1097: <tr>
                   1098: <td class="osname">FreeBSD 3.5/i386</td>
                   1099: <td class="date">20030411</td>
                   1100: <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>
                   1101: <td class="binary-pkgs-url"> </td>
                   1102: </tr>
                   1103: <tr>
                   1104: <td class="osname">FreeBSD 4.7/i386</td>
                   1105: <td class="date">20021211</td>
                   1106: <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>
                   1107: <td class="binary-pkgs-url"> </td>
                   1108: </tr>
                   1109: <tr>
                   1110: <td class="osname">FreeBSD 5.0/i386</td>
                   1111: <td class="date">20030411</td>
                   1112: <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>
                   1113: <td class="binary-pkgs-url"> </td>
                   1114: </tr>
                   1115: <tr>
                   1116: <td class="osname">FreeBSD 5.1/i386</td>
                   1117: <td class="date">20030630</td>
                   1118: <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>
                   1119: <td class="binary-pkgs-url"> </td>
                   1120: </tr>
                   1121: <tr>
                   1122: <td class="osname">FreeBSD 5.2.1/i386</td>
                   1123: <td class="date">20040227</td>
                   1124: <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>
                   1125: <td class="binary-pkgs-url"> </td>
                   1126: </tr>
                   1127: <tr>
                   1128: <td class="osname">FreeBSD 5.3/i386</td>
                   1129: <td class="date">20050119</td>
                   1130: <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>
                   1131: <td class="binary-pkgs-url"> </td>
                   1132: </tr>
                   1133: <tr>
                   1134: <td class="osname">Interix 3.5</td>
                   1135: <td class="date">20051010</td>
                   1136: <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>
                   1137: <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>
                   1138: </tr>
                   1139: <tr>
                   1140: <td class="osname">IRIX 6.5 n32-bit ABI</td>
                   1141: <td class="date">20040911</td>
                   1142: <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>
                   1143: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/n32/" target="_top">binary packages</a></td>
                   1144: </tr>
                   1145: <tr>
                   1146: <td class="osname">IRIX 6.5 64-bit ABI</td>
                   1147: <td class="date">20040912</td>
                   1148: <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>
                   1149: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/64/" target="_top">binary packages</a></td>
                   1150: </tr>
                   1151: <tr>
                   1152: <td class="osname">OpenBSD 3.2/i386</td>
                   1153: <td class="date">20030420</td>
                   1154: <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>
                   1155: <td class="binary-pkgs-url"> </td>
                   1156: </tr>
                   1157: <tr>
                   1158: <td class="osname">OpenBSD 3.3/i386</td>
                   1159: <td class="date">20030503</td>
                   1160: <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>
                   1161: <td class="binary-pkgs-url"> </td>
                   1162: </tr>
                   1163: <tr>
                   1164: <td class="osname">OpenBSD 3.5/i386</td>
                   1165: <td class="date">20040507</td>
                   1166: <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>
                   1167: <td class="binary-pkgs-url"> </td>
                   1168: </tr>
                   1169: <tr>
                   1170: <td class="osname">Slackware Linux 8.1/i386</td>
                   1171: <td class="date">20030417</td>
                   1172: <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>
                   1173: <td class="binary-pkgs-url"> </td>
                   1174: </tr>
                   1175: <tr>
                   1176: <td class="osname">Slackware Linux 9/i386</td>
                   1177: <td class="date">20031023</td>
                   1178: <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>
                   1179: <td class="binary-pkgs-url"> </td>
                   1180: </tr>
                   1181: <tr>
                   1182: <td class="osname">Solaris 8/sparc</td>
                   1183: <td class="date">20050220</td>
                   1184: <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>
                   1185: <td class="binary-pkgs-url"> </td>
                   1186: </tr>
                   1187: <tr>
                   1188: <td class="osname">Solaris 8/i386</td>
                   1189: <td class="date">20050220</td>
                   1190: <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>
                   1191: <td class="binary-pkgs-url"> </td>
                   1192: </tr>
                   1193: <tr>
                   1194: <td class="osname">Solaris 9/sparc</td>
                   1195: <td class="date">20041208</td>
                   1196: <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>
                   1197: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/SunOS-5.9/sparc/" target="_top">binary packages</a></td>
                   1198: </tr>
                   1199: <tr>
                   1200: <td class="osname">Solaris 9/i386</td>
                   1201: <td class="date">20030411</td>
                   1202: <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>
                   1203: <td class="binary-pkgs-url"> </td>
                   1204: </tr>
                   1205: </tbody>
1.83      wiz      1206: </table></div>
1.82      rillig   1207: </div>
1.83      wiz      1208: <br class="table-break"><p>
1.82      rillig   1209: Simply download the binary kit for your platform, and extract it into
                   1210: <code class="filename">/</code> e.g.
                   1211: </p>
                   1212: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
                   1213: <code class="prompt">#</code> <strong class="userinput"><code>gzip -c -d /tmp/bootstrap-pkgsrc-SunOS-5.9-sparc-20031023.tar.gz \
                   1214:   | tar -xpf -</code></strong></pre>
                   1215: <p>
                   1216: Of course, as with any binary distributions, you should verify the
                   1217: checksum against the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/SUM" target="_top">SUM</a>
                   1218: or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/CKSUM" target="_top">CKSUM</a>
                   1219: file and inspect the contents before extracting it.
                   1220: </p>
                   1221: </div>
                   1222: <div class="sect1" lang="en">
                   1223: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1224: <a name="bootstrapping-pkgsrc"></a>3.2. Bootstrapping pkgsrc</h2></div></div></div>
                   1225: <p>Installing the bootstrap kit from source should be as simple as:</p>
1.75      rillig   1226: <pre class="screen">
                   1227: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
                   1228: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
                   1229: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong></pre>
                   1230: <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
                   1231:       pkgsrc before bootstrapping. The given
                   1232:       <span><strong class="command">bootstrap</strong></span> command will use the defaults of
1.76      rillig   1233:       <code class="filename">/usr/pkg</code> for the
1.75      rillig   1234:       <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1.76      rillig   1235:       and <code class="filename">/var/db/pkg</code> for the package database
1.75      rillig   1236:       directory where pkgsrc will do its internal bookkeeping.
                   1237:       However, these can also be set using command-line
                   1238:       arguments.</p>
                   1239: <p>Binary packages for the pkgsrc tools and an initial set of packages is
                   1240:       available for supported platforms. An up-to-date list of these can be
                   1241:       found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
                   1242:       Note that this only works for privileged builds that install
1.76      rillig   1243:       into <code class="filename">/usr/pkg</code>.</p>
1.75      rillig   1244: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1245: <h3 class="title">Note</h3>
                   1246: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
                   1247:        Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
                   1248:        For examples in this guide, use <span><strong class="command">bmake</strong></span>
                   1249:        instead of &#8220;<span class="quote">make</span>&#8221;.</p>
                   1250: </div>
                   1251: </div>
                   1252: <div class="sect1" lang="en">
                   1253: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82      rillig   1254: <a name="platform-specific-notes"></a>3.3. Platform-specific notes</h2></div></div></div>
1.75      rillig   1255: <p>Here are some platform-specific notes you should be aware of.</p>
                   1256: <div class="sect2" lang="en">
                   1257: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1258: <a name="darwin"></a>3.3.1. Darwin (Mac OS X)</h3></div></div></div>
1.85      jmmv     1259: <p>Darwin 5.x and up are supported. There are two methods of using
1.82      rillig   1260:        pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.3.1.1. Using a disk image">disk
                   1261:          image</a>, or a <a href="#platform.osx-ufs" title="3.3.1.2. Using a UFS partition">UFS
1.75      rillig   1262:          partition</a>.</p>
                   1263: <p>Before you start, you will need to download and install the Mac OS X Developer
                   1264:        Tools from Apple's Developer Connection.  See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
                   1265:        for details.  Also, make sure you install X11 for Mac OS X and the X11 SDK
                   1266:        from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
                   1267:        if you intend to build packages that use the X11 Window System.</p>
                   1268: <p>If you already have a UFS partition, or have a spare partition
                   1269:        that you can format as UFS, it is recommended to use that instead of
                   1270:        the disk image. It'll be somewhat faster and will mount automatically
                   1271:        at boot time, where you must manually mount a disk image.</p>
                   1272: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1273: <h3 class="title">Note</h3>
1.85      jmmv     1274: <p>You cannot use an ordinary HFS+ file system for pkgsrc, because pkgsrc currently
                   1275:          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   1276: </div>
                   1277: <div class="sect3" lang="en">
                   1278: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1279: <a name="platform.osx-image"></a>3.3.1.1. Using a disk image</h4></div></div></div>
1.75      rillig   1280: <p>Create the disk image:</p>
                   1281: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1.85      jmmv     1282: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
                   1283: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage mount ~/Documents/NetBSD</code></strong>
1.75      rillig   1284: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
1.85      jmmv     1285: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1286: <h3 class="title">Note</h3>
                   1287: <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>
                   1288: </div>
                   1289: <p>Allow suid and synchronous writes:</p>
                   1290: <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   1291: </div>
                   1292: <div class="sect3" lang="en">
                   1293: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1294: <a name="platform.osx-ufs"></a>3.3.1.2. Using a UFS partition</h4></div></div></div>
1.76      rillig   1295: <p>By default, <code class="filename">/usr</code> will be on your root file
1.75      rillig   1296:          system, normally HFS+. It is possible to use the default
1.76      rillig   1297:          <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
                   1298:          by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1.75      rillig   1299:          file system. Obviously, another symlink is required if you want to
                   1300:          place the package database directory outside the
                   1301:          <span class="emphasis"><em>prefix</em></span>. e.g.</p>
                   1302: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
                   1303: <p>If you created your partitions at the time of installing Mac OS X
                   1304:          and formatted the target partition as UFS, it should automatically
1.76      rillig   1305:          mount on <code class="filename">/Volumes/&lt;volume name&gt;</code> when the
1.75      rillig   1306:          machine boots. If you are (re)formatting a partition as UFS, you need
                   1307:          to ensure that the partition map correctly reflects
                   1308:          &#8220;<span class="quote">Apple_UFS</span>&#8221; and not &#8220;<span class="quote">Apple_HFS</span>&#8221;.</p>
                   1309: <p>The problem is that none of the disk tools will let you touch a
                   1310:          disk that is booted from. You can unmount the partition, but even if
                   1311:          you newfs it, the partition type will be incorrect and the
                   1312:          automounter won't mount it. It can be mounted manually, but it won't
                   1313:          appear in Finder.</p>
                   1314: <p>You'll need to boot off of the OS X Installation (User) CD.  When
                   1315:          the Installation program starts, go up to the menu and select Disk
                   1316:          Utility.  Now, you will be able to select the partition you want
                   1317:          to be UFS, and Format it Apple UFS. Quit the Disk Utility, quit the
                   1318:          installer which will reboot your machine. The new UFS file system
                   1319:          will appear in Finder.</p>
                   1320: <p>Be aware that the permissions on the new file system will be writable
                   1321:          by root only.</p>
                   1322: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
                   1323:          Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
                   1324: </div>
                   1325: </div>
                   1326: <div class="sect2" lang="en">
                   1327: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1328: <a name="freebsd"></a>3.3.2. FreeBSD</h3></div></div></div>
1.75      rillig   1329: <p>
                   1330:        FreeBSD 4.7 and 5.0 have been tested and are supported, other versions
                   1331:        may work.</p>
                   1332: <p>Care should be taken so that the tools that this kit installs do not conflict
                   1333:        with the FreeBSD userland tools. There are several steps:</p>
                   1334: <div class="orderedlist"><ol type="1">
                   1335: <li><p>FreeBSD stores its ports pkg database in
1.76      rillig   1336:            <code class="filename">/var/db/pkg</code>. It is therefore
1.75      rillig   1337:            recommended that you choose a different location (e.g.
1.76      rillig   1338:            <code class="filename">/usr/pkgdb</code>) by
1.75      rillig   1339:            using the --pkgdbdir option to the bootstrap script.</p></li>
                   1340: <li>
                   1341: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
                   1342:            good idea to move them out of the way to avoid confusion, e.g.</p>
                   1343: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
                   1344: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
                   1345: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
                   1346: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
                   1347: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
                   1348: </li>
1.76      rillig   1349: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
                   1350:            <code class="filename">/etc/mk.conf.example</code> file
1.75      rillig   1351:            when you use the bootstrap script.</p></li>
                   1352: </ol></div>
                   1353: </div>
                   1354: <div class="sect2" lang="en">
                   1355: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1356: <a name="interix"></a>3.3.3. Interix</h3></div></div></div>
1.75      rillig   1357: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
                   1358:        providing a Unix-like environment with a tighter kernel integration than
                   1359:        available with Cygwin.  It is part of the Windows Services for Unix
                   1360:        package, available for free for any licensed copy of Windows 2000, XP
                   1361:        (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>
                   1362: <p>Services for Unix 3.5, current as of this writing, has been tested.  3.0
                   1363:        or 3.1 may work, but are not officially supported.  (The main difference
                   1364:        in 3.0/3.1 is lack of pthreads.)</p>
                   1365: <div class="sect3" lang="en">
                   1366: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1367: <a name="platform.interix-sfu-install"></a>3.3.3.1. When installing Interix/SFU</h4></div></div></div>
1.75      rillig   1368: <p>At an absolute minimum, the following packages must be installed from
                   1369:          the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
                   1370: <div class="itemizedlist"><ul type="disc">
                   1371: <li><p>Utilities -&gt; Base Utilities</p></li>
                   1372: <li><p>Interix GNU Components -&gt; (all)</p></li>
                   1373: <li><p>Remote Connectivity</p></li>
                   1374: <li><p>Interix SDK</p></li>
                   1375: </ul></div>
                   1376: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
                   1377:          "UNIX Perl".  That is Perl 5.6 without shared module support, installed to
                   1378:          /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
                   1379:          pkgsrc (or from a binary package).</p>
                   1380: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
                   1381:          not need to be installed, but Remote Connectivity itself should be
                   1382:          installed in order to have a working inetd.</p>
                   1383: <p>During installation you may be asked whether to enable setuid
                   1384:          behavior for Interix programs, and whether to make pathnames default to
                   1385:          case-sensitive.  Setuid should be enabled, and case-sensitivity MUST be
                   1386:          enabled.  (Without case-sensitivity, a large number of packages including
                   1387:          perl will not build.)</p>
                   1388: <p>NOTE:  Newer Windows service packs change the way binary execution
                   1389:          works (via the Data Execution Prevention feature).  In order to use
                   1390:          pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
                   1391:          POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
                   1392:          must be installed.  Hotfixes are available from Microsoft through a
                   1393:          support contract; however, a NetBSD developer has made most Interix
                   1394:          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>
                   1395: </div>
                   1396: <div class="sect3" lang="en">
                   1397: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1398: <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   1399: <p>If SFU is already installed and you wish to alter these settings to work
                   1400:          with pkgsrc, note the following things.</p>
                   1401: <div class="itemizedlist"><ul type="disc">
                   1402: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
                   1403:              Windows Services for UNIX, then click Change.  In the installer, choose
                   1404:              Add or Remove, then uncheck Utilities-&gt;UNIX Perl.</p></li>
                   1405: <li>
                   1406: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
                   1407:              change the following registry key:</p>
                   1408: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
                   1409: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
                   1410: </li>
                   1411: <li>
                   1412: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
                   1413:              following registry key:</p>
                   1414: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
                   1415: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
                   1416: </li>
                   1417: </ul></div>
                   1418: </div>
                   1419: <div class="sect3" lang="en">
                   1420: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1421: <a name="platform.interix-notes"></a>3.3.3.3. Important notes for using pkgsrc</h4></div></div></div>
1.75      rillig   1422: <p>The package manager (either the pkgsrc "su" user, or the user
                   1423:          running "pkg_add") must be a member of the local Administrators
                   1424:          group.  Such a user must also be used to run the bootstrap.  This is
                   1425:          slightly relaxed from the normal pkgsrc requirement of "root".</p>
                   1426: <p>The package manager should use a umask of 002.  "make install" will
                   1427:          automatically complain if this is not the case.  This ensures that
                   1428:          directories written in /var/db/pkg are Administrators-group writeable.</p>
                   1429: <p>The popular Interix binary packages from http://www.interopsystems.com/
                   1430:          use an older version of pkgsrc's pkg_* tools.  Ideally, these should
                   1431:          NOT be used in conjunction with pkgsrc.  If you choose to use them at
                   1432:          the same time as the pkgsrc packages, ensure that you use the proper
                   1433:          pkg_* tools for each type of binary package.</p>
                   1434: <p>The TERM setting used for DOS-type console windows (including those
                   1435:          invoked by the csh and ksh startup shortcuts) is "interix".  Most systems
                   1436:          don't have a termcap/terminfo entry for it, but the following .termcap
                   1437:          entry provides adequate emulation in most cases:</p>
                   1438: <pre class="programlisting">
                   1439:     interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
                   1440: </pre>
                   1441: </div>
                   1442: <div class="sect3" lang="en">
                   1443: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1444: <a name="platform.interix-limits"></a>3.3.3.4. Limitations of the Interix platform</h4></div></div></div>
1.75      rillig   1445: <p>Though Interix suffices as a familiar and flexible substitute
                   1446:          for a full Unix-like platform, it has some drawbacks that should
                   1447:          be noted for those desiring to make the most of Interix.</p>
                   1448: <div class="itemizedlist"><ul type="disc">
                   1449: <li>
                   1450: <p><span class="strong"><strong>X11:</strong></span></p>
                   1451: <p>Interix comes with the standard set of X11R6 client libraries,
                   1452:            and can run X11 based applications, but it does
                   1453:            <span class="emphasis"><em>not</em></span> come with an X server.  Some options are
                   1454:            <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
                   1455:            <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
                   1456:            (available in a trimmed version for Interix from Interop Systems as the
                   1457:            <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
                   1458:            and the free X11 server included with
                   1459:            <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
                   1460: <p>Also, StarNet Communications has graciously provided a free
                   1461:            version of their X-Win32 product that accepts connections only
                   1462:            from localhost:
                   1463:            <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
                   1464:            recommended by the maintainer of Interix pkgsrc support.</p>
                   1465: </li>
                   1466: <li>
                   1467: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
                   1468: <p>Because Interix runs in a completely different NT subsystem from
                   1469:            Win32 applications, it does not currently support various X11
                   1470:            protocol extensions for acceleration (such as MIT-SHM or DGA).
                   1471:            Most interactive applications to a local X server will run
                   1472:            reasonably fast, but full motion video and other graphics
                   1473:            intensive applications may require a faster-than-expected CPU.</p>
                   1474: </li>
                   1475: <li>
                   1476: <p><span class="strong"><strong>Audio:</strong></span></p>
                   1477: <p>Interix has no native support for audio output.  For audio
                   1478:            support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
                   1479:            audio system on Interix.  Unlike on most platforms, the
1.76      rillig   1480:            <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
1.75      rillig   1481:            <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
                   1482:            server component.  To output audio via an Interix host, the
1.76      rillig   1483:            <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
1.75      rillig   1484:            must also be installed.</p>
                   1485: </li>
                   1486: <li>
                   1487: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
                   1488: <p>Direct device access is not currently supported in Interix, so it
                   1489:            is not currently possible to access CD/DVD drives, USB devices,
                   1490:            or SCSI devices through non-filesystem means.  Among other things,
                   1491:            this makes it impossible to use Interix directly for CD/DVD
                   1492:            burning.</p>
                   1493: </li>
                   1494: <li>
                   1495: <p><span class="strong"><strong>Tape drives:</strong></span></p>
                   1496: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
                   1497:            drives are also not directly accessible in Interix.  However,
                   1498:            support is in work to make tape drive access possible by using
                   1499:            Cygwin as a bridge (similarly to audio bridged via Cygwin's
                   1500:            esound server).</p>
                   1501: </li>
                   1502: </ul></div>
                   1503: </div>
                   1504: <div class="sect3" lang="en">
                   1505: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1506: <a name="platform.interix-knownissues"></a>3.3.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1.75      rillig   1507: <p>It is not necessary, in general, to have a "root" user on the
                   1508:          Windows system; any member of the local Administrators group will
                   1509:          suffice.  However, some packages currently assume that the user
                   1510:          named "root" is the privileged user.  To accommodate these, you
                   1511:          may create such a user; make sure it is in the local group
                   1512:          Administrators (or your language equivalent).</p>
                   1513: <p>"pkg_add" creates directories of mode 0755, not 0775, in
                   1514:          $PKG_DBDIR.  For the time being, install packages as the local
                   1515:          Administrator (or your language equivalent), or run the following
                   1516:          command after installing a package to work around the issue:</p>
                   1517: <pre class="screen">
                   1518: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong></pre>
                   1519: </div>
                   1520: </div>
                   1521: <div class="sect2" lang="en">
                   1522: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1523: <a name="irix"></a>3.3.4. IRIX</h3></div></div></div>
1.75      rillig   1524: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
                   1525:        compiler (cc/c89).  Please set the <code class="varname">CC</code> environment variable
                   1526:        according to your preference.  If you do not have a license for the MIPSpro
                   1527:        compiler suite, you can download a gcc tardist file from <a href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
                   1528: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
                   1529:        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>,
                   1530:        etc.</p>
1.86    ! schwarz  1531: <p>At this point in time, pkgsrc only supports one ABI at a time.  That is, you cannot
1.75      rillig   1532:        switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI.  If
                   1533:        you start out using "abi=n32", that's what all your packages will be built
                   1534:        with.</p>
                   1535: <p>Therefore, please make sure that you have no conflicting
                   1536:        <code class="varname">CFLAGS</code> in your environment or the
1.76      rillig   1537:        <code class="filename">/etc/mk.conf</code>.  Particularly, make sure that you do not
1.75      rillig   1538:        try to link n32 object files with lib64 or vice versa.  Check your
1.76      rillig   1539:        <code class="filename">/etc/compiler.defaults</code>!</p>
1.75      rillig   1540: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
                   1541:        please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
                   1542:        as it appears that IRIX linker occasionally runs into issues when trying to
                   1543:        link over a network-mounted file system.</p>
                   1544: <p>The bootstrapping process should set all the right options for programs such
                   1545:        as imake(1), but you may want to set some options depending on your local
1.76      rillig   1546:        setup.  Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1.75      rillig   1547:        course, your compiler's man pages for details.</p>
                   1548: <p>If you are using SGI's MIPSPro compiler, please set
1.1       grant    1549: 
1.75      rillig   1550: </p>
                   1551: <pre class="programlisting">
                   1552:     PKGSRC_COMPILER=        mipspro
                   1553: </pre>
                   1554: <p>
1.1       grant    1555: 
1.76      rillig   1556:         in <code class="filename">/etc/mk.conf</code>.  Otherwise, pkgsrc will assume you
1.75      rillig   1557:         are using gcc and may end up passing invalid flags to the compiler.  Note that
1.76      rillig   1558:         bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1.75      rillig   1559:         default.</p>
                   1560: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
                   1561:         but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
                   1562:         to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1.76      rillig   1563:         <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1.75      rillig   1564:         '--preserve-path' flag.</p>
                   1565: </div>
                   1566: <div class="sect2" lang="en">
                   1567: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1568: <a name="linux"></a>3.3.5. Linux</h3></div></div></div>
1.75      rillig   1569: <p>
                   1570:         Some versions of Linux (for example Debian GNU/Linux) need either
                   1571:         libtermcap or libcurses (libncurses).  Installing the distributions
                   1572:         libncurses-dev package (or equivalent) should fix the problem.</p>
                   1573: <p>
                   1574:         pkgsrc supports both gcc (GNU Compiler Collection) and icc (Intel C++
                   1575:         Compiler). gcc is the default. icc 8.0 and 8.1 on i386 have been tested.
                   1576:       </p>
                   1577: <p>To bootstrap using icc, assuming the default icc installation
                   1578:         directory:</p>
                   1579: <pre class="programlisting">
                   1580:     env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
                   1581:             ac_cv___attribute__=yes ./bootstrap
                   1582: </pre>
                   1583: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1584: <h3 class="title">Note</h3>
                   1585: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
                   1586: </div>
                   1587: <p>icc supports __attribute__, but the GNU configure test uses a nested
                   1588:         function, which icc does not support. #undef'ing __attribute__ has the
                   1589:         unfortunate side-effect of breaking many of the Linux header files, which
                   1590:         cannot be compiled properly without __attribute__. The test must be
                   1591:         overridden so that __attribute__ is assumed supported by the
                   1592:         compiler.</p>
                   1593: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.76      rillig   1594:         in <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   1595: <pre class="programlisting">
                   1596:     PKGSRC_COMPILER=        icc
                   1597: </pre>
                   1598: <p>The default installation directory for icc is
1.76      rillig   1599:         <code class="filename">/opt/intel_cc_80</code>, which
1.75      rillig   1600:         is also the pkgsrc default. If you have installed it into a different
                   1601:         directory, set <code class="varname">ICCBASE</code> in
1.76      rillig   1602:         <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   1603: <pre class="programlisting">
                   1604:     ICCBASE=                /opt/icc
                   1605: </pre>
                   1606: <p>pkgsrc uses the static linking method of the runtime libraries
                   1607:         provided by icc, so binaries can be run on other systems which do not
                   1608:         have the shared libraries installed.</p>
                   1609: <p>Libtool, however, extracts a list of libraries from the <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>
                   1610:         command run when linking a C++ shared library and records it, throwing
                   1611:         away the -Bstatic and -Bdynamic options interspersed between the libraries.
                   1612:         This means that libtool-linked C++ shared libraries will have a
                   1613:         runtime dependency on the icc libraries until this is fixed in libtool.
                   1614:       </p>
                   1615: </div>
                   1616: <div class="sect2" lang="en">
                   1617: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1618: <a name="openbsd"></a>3.3.6. OpenBSD</h3></div></div></div>
1.75      rillig   1619: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
                   1620: <p>Care should be taken so that the tools that this kit installs do not conflict
                   1621:        with the OpenBSD userland tools. There are several steps:</p>
                   1622: <div class="orderedlist"><ol type="1">
                   1623: <li><p>OpenBSD stores its ports pkg database in
1.76      rillig   1624:            <code class="filename">/var/db/pkg</code>. It is therefore
1.75      rillig   1625:            recommended that you choose a different location (e.g.
1.76      rillig   1626:            <code class="filename">/usr/pkgdb</code>) by
1.75      rillig   1627:            using the --pkgdbdir option to the bootstrap script.</p></li>
                   1628: <li>
                   1629: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
                   1630:            good idea to move them out of the way to avoid confusion, e.g.</p>
                   1631: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
                   1632: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
                   1633: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
                   1634: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
                   1635: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
                   1636: </li>
                   1637: <li>
1.76      rillig   1638: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
                   1639:            <code class="filename">/etc/mk.conf.example</code> file
1.75      rillig   1640:            when you use the bootstrap script. OpenBSD's make program uses
1.76      rillig   1641:            <code class="filename">/etc/mk.conf</code>
1.75      rillig   1642:            as well. You can work around this by enclosing all the pkgsrc-specific parts
                   1643:            of the file with:</p>
                   1644: <pre class="programlisting">
                   1645:     .ifdef BSD_PKG_MK
                   1646:     # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
                   1647:     .else
                   1648:     # OpenBSD stuff
1.1       grant    1649:     .endif
                   1650: </pre>
1.75      rillig   1651: </li>
                   1652: </ol></div>
                   1653: </div>
                   1654: <div class="sect2" lang="en">
                   1655: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1656: <a name="solaris"></a>3.3.7. Solaris</h3></div></div></div>
1.75      rillig   1657: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
                   1658:         You will need a working C compiler. Both gcc 2.95.3 and
                   1659:         Sun WorkShop 5 have been tested.</p>
                   1660: <p>The following packages are required on Solaris 8 for the bootstrap
                   1661:        process and to build packages.</p>
                   1662: <div class="itemizedlist"><ul type="disc">
                   1663: <li><p>SUNWsprot</p></li>
                   1664: <li><p>SUNWarc</p></li>
                   1665: <li><p>SUNWbtool</p></li>
                   1666: <li><p>SUNWtoo</p></li>
                   1667: <li><p>SUNWlibm</p></li>
                   1668: </ul></div>
1.78      rillig   1669: <p>Please note that the use of GNU binutils on Solaris is
                   1670:        <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1.75      rillig   1671: <p>Whichever compiler you use, please ensure the compiler tools and
                   1672:          your $prefix are in your <code class="varname">PATH</code>. This includes
1.76      rillig   1673:          <code class="filename">/usr/ccs/{bin,lib}</code>
                   1674:          and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75      rillig   1675: <div class="sect3" lang="en">
                   1676: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1677: <a name="solaris-gcc-note"></a>3.3.7.1. If you are using gcc</h4></div></div></div>
1.75      rillig   1678: <p>It makes life much simpler if you only use the same gcc consistently
                   1679:          for building all packages.</p>
                   1680: <p>It is recommended that an external gcc be used only for bootstrapping,
                   1681:          then either build gcc from
1.76      rillig   1682:          <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
1.75      rillig   1683:          package, then remove gcc used during bootstrapping.</p>
                   1684: <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>
                   1685: </div>
                   1686: <div class="sect3" lang="en">
                   1687: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1688: <a name="solaris-sun-workshop-note"></a>3.3.7.2. If you are using Sun WorkShop</h4></div></div></div>
1.75      rillig   1689: <p>You will need at least the following packages installed (from WorkShop
                   1690:          5.0)</p>
                   1691: <div class="itemizedlist"><ul type="disc">
                   1692: <li><p>SPROcc
                   1693:                - Sun WorkShop Compiler C 5.0</p></li>
                   1694: <li><p>SPROcpl
                   1695:                - Sun WorkShop Compiler C++ 5.0</p></li>
                   1696: <li><p>SPROild
                   1697:                - Sun WorkShop Incremental Linker</p></li>
                   1698: <li><p>SPROlang
                   1699:                - Sun WorkShop Compilers common components</p></li>
                   1700: </ul></div>
                   1701: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.76      rillig   1702:          optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
1.75      rillig   1703:          e.g.:</p>
                   1704: <pre class="programlisting">
                   1705:     CC=     cc
                   1706:     CXX=    CC
                   1707:     CPP=    /usr/ccs/lib/cpp
1.1       grant    1708: </pre>
1.75      rillig   1709: </div>
                   1710: <div class="sect3" lang="en">
                   1711: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1712: <a name="solaris-sunpro-64"></a>3.3.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1.75      rillig   1713: <p>Building 64-bit binaries is a little trickier. First, you
                   1714:        need to bootstrap pkgsrc in 64-bit mode. One problem here is
                   1715:        that while building one of the programs in the bootstrap kit
1.76      rillig   1716:        (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75      rillig   1717:        variable is not honored, even if it is set in the environment.
                   1718:        To work around this bug, you can create a simple shell script
1.76      rillig   1719:        called <code class="filename">cc64</code> and put it somewhere in the
1.75      rillig   1720:        <code class="varname">PATH</code>:</p>
                   1721: <pre class="programlisting">
                   1722:     #! /bin/sh
                   1723:     exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
1.1       grant    1724: </pre>
1.75      rillig   1725: <p>Then, pass the definition for <code class="varname">CC</code> in the
                   1726:        environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
                   1727: <pre class="programlisting">
                   1728:     <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
                   1729:     <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
                   1730: </pre>
                   1731: <p>After bootstrapping, there are two alternative ways,
                   1732:        depending on whether you want to find bugs in packages or get
                   1733:        your system ready quickly. If you just want a running system,
1.76      rillig   1734:        add the following lines to your <code class="filename">mk.conf</code>
1.75      rillig   1735:        file:</p>
                   1736: <pre class="programlisting">
                   1737:     CC=                     cc64
                   1738:     CXX=                    CC64
                   1739:     PKGSRC_COMPILER=        sunpro
1.1       grant    1740: </pre>
1.75      rillig   1741: <p>This way, all calls to the compiler will be intercepted by
                   1742:        the above wrapper and therefore get the necessary ABI options
                   1743:        automatically. (Don't forget to create the shell script
1.76      rillig   1744:        <code class="filename">CC64</code>, too.)</p>
1.75      rillig   1745: <p>To find packages that ignore the user-specified
                   1746:        <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76      rillig   1747:        the following lines to your <code class="filename">mk.conf</code>
1.75      rillig   1748:        file:</p>
                   1749: <pre class="programlisting">
                   1750:     CC=                     cc
                   1751:     CXX=                    CC
                   1752:     PKGSRC_COMPILER=        sunpro
                   1753:     CFLAGS=                 -xtarget=ultra -xarch=v9
                   1754:     CXXFLAGS=               -xtarget=ultra -xarch=v9
                   1755:     LDFLAGS=                -xtarget=ultra -xarch=v9
1.1       grant    1756: </pre>
1.75      rillig   1757: <p>Packages that don't use the flags provided in the
                   1758:        configuration file will try to build 32-bit binaries and fail
                   1759:        during linking. Detecting this is useful to prevent bugs on
                   1760:        other platforms where the error would not show up but pass
                   1761:        silently.</p>
                   1762: </div>
                   1763: <div class="sect3" lang="en">
                   1764: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1765: <a name="plat.sunos.problems"></a>3.3.7.4. Common problems</h4></div></div></div>
1.75      rillig   1766: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.76      rillig   1767:        <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1.75      rillig   1768:        The workaround is to use another shell for the configure
1.76      rillig   1769:        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
                   1770:        to your <code class="filename">mk.conf</code>:</p>
1.75      rillig   1771: <pre class="programlisting">
                   1772:     CONFIG_SHELL=   ${LOCALBASE}/bin/bash
                   1773:     WRAPPER_SHELL=  ${LOCALBASE}/bin/bash
1.1       grant    1774: </pre>
1.76      rillig   1775: <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   1776: </div>
                   1777: </div>
                   1778: </div>
                   1779: </div>
                   1780: <div class="chapter" lang="en">
                   1781: <div class="titlepage"><div><div><h2 class="title">
                   1782: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
                   1783: <div class="toc">
                   1784: <p><b>Table of Contents</b></p>
                   1785: <dl>
                   1786: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                   1787: <dd><dl>
                   1788: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                   1789: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82      rillig   1790: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
                   1791: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
                   1792: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
                   1793: <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>
                   1794: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
                   1795: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75      rillig   1796: </dl></dd>
                   1797: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                   1798: <dd><dl>
                   1799: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                   1800: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                   1801: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                   1802: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
                   1803: </dl></dd>
                   1804: </dl>
                   1805: </div>
                   1806: <p>Basically, there are two ways of using pkgsrc. The first
                   1807:        is to only install the package tools and to use binary packages
                   1808:        that someone else has prepared. This is the &#8220;<span class="quote">pkg</span>&#8221;
                   1809:        in pkgsrc. The second way is to install the &#8220;<span class="quote">src</span>&#8221;
                   1810:        of pkgsrc, too. Then you are able to build your own packages,
                   1811:        and you can still use binary packages from someone else.</p>
                   1812: <div class="sect1" lang="en">
                   1813: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1814: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
                   1815: <p>To use binary packages, you need some tools to manage
                   1816:        them. On NetBSD, these tools are already installed. On all other
                   1817:        operating systems, you need to install them first. For the
                   1818:        following platforms, prebuilt versions of the package tools
                   1819:        are available and can simply be downloaded and unpacked in the
1.76      rillig   1820:        <code class="filename">/</code> directory:</p>
1.75      rillig   1821: <div class="informaltable">
                   1822: <a name="binary-bootstrap-kits"></a><table border="1">
                   1823: <colgroup>
                   1824: <col>
                   1825: <col>
                   1826: </colgroup>
                   1827: <thead><tr>
                   1828: <th>Platform</th>
                   1829: <th>URL</th>
                   1830: </tr></thead>
                   1831: <tbody>
                   1832: <tr>
                   1833: <td>Solaris 9</td>
1.76      rillig   1834: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75      rillig   1835: </tr>
                   1836: <tr>
                   1837: <td>Solaris 10</td>
1.76      rillig   1838: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75      rillig   1839: </tr>
                   1840: </tbody>
                   1841: </table>
                   1842: </div>
1.82      rillig   1843: <p>These pre-built package tools use
1.76      rillig   1844:        <code class="filename">/usr/pkg</code> for the base directory, and
                   1845:        <code class="filename">/var/db/pkg</code> for the database of installed
1.75      rillig   1846:        packages. If you cannot use these directories for whatever
                   1847:        reasons (maybe because you're not root), you have to build the
1.82      rillig   1848:        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   1849: <div class="sect2" lang="en">
                   1850: <div class="titlepage"><div><div><h3 class="title">
                   1851: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
                   1852: <p>To install binary packages, you first need to know from
                   1853:        where to get them. You can get them on CD-ROMs, DVDs, or via FTP
                   1854:        or HTTP.</p>
1.81      rillig   1855: <p>The binary packages can be found at the following
                   1856:        locations.</p>
1.75      rillig   1857: <div class="informaltable">
                   1858: <a name="binary-packages"></a><table border="1">
                   1859: <colgroup>
                   1860: <col>
                   1861: <col>
                   1862: </colgroup>
                   1863: <thead><tr>
                   1864: <th>Platform</th>
                   1865: <th>URL</th>
                   1866: </tr></thead>
                   1867: <tbody>
                   1868: <tr>
1.81      rillig   1869: <td>NetBSD</td>
                   1870: <td><code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/</code></td>
                   1871: </tr>
                   1872: <tr>
1.75      rillig   1873: <td>Solaris 9</td>
1.76      rillig   1874: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75      rillig   1875: </tr>
                   1876: <tr>
                   1877: <td>Solaris 10</td>
1.76      rillig   1878: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75      rillig   1879: </tr>
                   1880: </tbody>
                   1881: </table>
                   1882: </div>
1.81      rillig   1883: <p>Most of these directories contain binary packages for
                   1884:        multiple platforms. Select the appropriate subdirectories,
1.75      rillig   1885:        according to your machine architecture and operating system,
1.76      rillig   1886:        until you find a directory called <code class="filename">All</code>. This
1.75      rillig   1887:        directory contains all the binary packages. Further, there are
                   1888:        subdirectories for categories that contain symbolic links that
                   1889:        point to the actual binary package in
1.76      rillig   1890:        <code class="filename">../All</code>. This directory layout is used for
1.75      rillig   1891:        all package repositories, no matter if they are accessed via
                   1892:        HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
                   1893: </div>
                   1894: <div class="sect2" lang="en">
                   1895: <div class="titlepage"><div><div><h3 class="title">
                   1896: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
                   1897: <p> If you have the files on a CD-ROM or downloaded them to
                   1898:         your hard disk, you can install them with the following command
                   1899:         (be sure to <span><strong class="command">su</strong></span> to root first):</p>
                   1900: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
                   1901: <p> If you have FTP access and you don't want to download the
                   1902:         packages via FTP prior to installation, you can do this
                   1903:         automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:
                   1904:         </p>
1.82      rillig   1905: <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   1906: <p>Note that any prerequisite packages needed to run the
                   1907:         package in question will be installed, too, assuming they are
                   1908:         present where you install from. </p>
                   1909: <p>To save some typing, you can set the
                   1910:         <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
                   1911:        list of paths (including remote URLs); trailing slashes are not allowed.
                   1912:        </p>
1.76      rillig   1913: <p>Additionally to the <code class="filename">All</code> directory
                   1914:         there exists a <code class="filename">vulnerable</code> directory to
1.75      rillig   1915:         which binary packages with known vulnerabilities are
                   1916:         moved, since removing them could cause missing dependencies. To
1.76      rillig   1917:         use these packages, add the <code class="filename">vulnerable</code>
1.75      rillig   1918:         directory to your <code class="varname">PKG_PATH</code>. However, you should run
1.76      rillig   1919:         <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   1920:        especially after installing new packages, and verify that the
                   1921:        vulnerabilities are acceptable for your configuration. An example
                   1922:         <code class="varname">PKG_PATH</code> would be:
1.76      rillig   1923:       <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   1924:         Please note that semicolon (';') is a shell meta-character, so
                   1925:         you'll probably have to quote it.</p>
                   1926: <p>After you've installed packages, be sure to have
1.76      rillig   1927:         <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1.75      rillig   1928:         <code class="varname">PATH</code> so you can actually start the just
                   1929:         installed program. </p>
                   1930: </div>
                   1931: <div class="sect2" lang="en">
                   1932: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1933: <a name="using.pkg_delete"></a>4.1.3. Deinstalling packages</h3></div></div></div>
                   1934: <p>To deinstall a package, it does not matter whether it was
                   1935:        installed from source code or from a binary package. The
                   1936:        <span><strong class="command">pkg_delete</strong></span> command does not know it anyway.
                   1937:        To delete a package, you can just run <span><strong class="command">pkg_delete
                   1938:        <em class="replaceable"><code>package-name</code></em></strong></span>. The package
                   1939:        name can be given with or without version number. Wildcards can
                   1940:        also be used to deinstall a set of packages, for example
                   1941:        <code class="literal">*emacs*</code>. Be sure to include them in quotes,
                   1942:        so that the shell does not expand them before
                   1943:        <code class="literal">pkg_delete</code> sees them.</p>
                   1944: <p>The <code class="option">-r</code> option is very powerful: it
                   1945:        removes all the packages that require the package in question
                   1946:        and then removes the package itself. For example:
                   1947: 
                   1948: </p>
                   1949: <pre class="screen">
                   1950:     <code class="prompt">#</code> <strong class="userinput"><code>pkg_delete -r jpeg</code></strong>
                   1951: </pre>
                   1952: <p>
                   1953: 
                   1954:        will remove jpeg and all the packages that used it; this allows
                   1955:        upgrading the jpeg package.</p>
                   1956: </div>
                   1957: <div class="sect2" lang="en">
                   1958: <div class="titlepage"><div><div><h3 class="title">
                   1959: <a name="using.pkg_info"></a>4.1.4. Getting information about installed packages</h3></div></div></div>
                   1960: <p>The <span><strong class="command">pkg_info</strong></span> shows information about
                   1961:        installed packages or binary package files.</p>
                   1962: </div>
                   1963: <div class="sect2" lang="en">
                   1964: <div class="titlepage"><div><div><h3 class="title">
                   1965: <a name="vulnerabilities"></a>4.1.5. Checking for security vulnerabilities in installed packages</h3></div></div></div>
                   1966: <p>
                   1967: The NetBSD Security-Officer and Packages Groups maintain a list of
                   1968: known security vulnerabilities to packages which are (or have been)
                   1969: included in pkgsrc.  The list is available from the NetBSD
                   1970: FTP site at <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities</a>.
                   1971: </p>
                   1972: <p>
                   1973: 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>, 
                   1974: this list can be downloaded
                   1975: automatically, and a security audit of all packages installed on a system
                   1976: can take place.
                   1977: </p>
                   1978: <p>
                   1979: There are two components to 
                   1980: <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
                   1981: component, &#8220;<span class="quote">download-vulnerability-list</span>&#8221;, is for downloading
                   1982: the list of vulnerabilities from the NetBSD FTP site.  The second
                   1983: component, &#8220;<span class="quote">audit-packages</span>&#8221;, checks to see if any of your
                   1984: installed packages are vulnerable.  If a package is vulnerable, you
                   1985: will see output similar to the following:
                   1986: </p>
                   1987: <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
                   1988: http://www.samba.org/samba/whatsnew/macroexploit.html</pre>
                   1989: <p>
                   1990: 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
                   1991: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
                   1992: file daily, and include a package audit in the daily security script.
                   1993: 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>
                   1994: 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>.
                   1995: </p>
                   1996: </div>
                   1997: <div class="sect2" lang="en">
                   1998: <div class="titlepage"><div><div><h3 class="title">
                   1999: <a name="pkg_versions"></a>4.1.6. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
                   2000: <p>
                   2001: 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 
                   2002: <span><strong class="command">lintpkgsrc</strong></span> with the &#8220;<span class="quote">-i</span>&#8221;
                   2003: argument to check if your packages are up-to-date, e.g.
                   2004: </p>
                   2005: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
                   2006: ...
                   2007: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00</pre>
                   2008: <p>You can then use <span><strong class="command">make update</strong></span> to update the
                   2009: package on your system and rebuild any dependencies.
                   2010: </p>
                   2011: </div>
                   2012: <div class="sect2" lang="en">
                   2013: <div class="titlepage"><div><div><h3 class="title">
                   2014: <a name="using.pkg_admin"></a>4.1.7. Other administrative functions</h3></div></div></div>
                   2015: <p>The <span><strong class="command">pkg_admin</strong></span> executes various
                   2016:        administrative functions on the package system.</p>
                   2017: </div>
                   2018: <div class="sect2" lang="en">
                   2019: <div class="titlepage"><div><div><h3 class="title">
                   2020: <a name="a-word-of-warning"></a>4.1.8. A word of warning</h3></div></div></div>
1.75      rillig   2021: <p>Please pay very careful attention to the warnings
                   2022:         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
                   2023:         inherent dangers of installing binary packages which you did
                   2024:         not create yourself, and the security holes that can be
                   2025:         introduced onto your system by indiscriminate adding of such
                   2026:         files.</p>
                   2027: <p>The same warning of course applies to every package you
                   2028:       install from source when you haven't completely read and
                   2029:       understood the source code of the package, the compiler that
                   2030:       is used to build the package and all the other tools that are
                   2031:       involved.</p>
                   2032: </div>
                   2033: </div>
                   2034: <div class="sect1" lang="en">
                   2035: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2036: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1.82      rillig   2037: <p>
                   2038: After obtaining pkgsrc, the <code class="filename">pkgsrc</code> directory
                   2039: now contains a set of packages, organized into categories. You can browse
                   2040: the online index of packages, or run <span><strong class="command">make readme</strong></span>
                   2041: from the <code class="filename">pkgsrc</code> directory to build local
                   2042: <code class="filename">README.html</code> files for all packages, viewable with any web browser such as
                   2043: <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      2044: <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   2045: <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages is
                   2046: <code class="filename">/usr/pkg</code>. If you wish to change this, you should do
                   2047: so by setting <code class="varname">LOCALBASE</code> in
                   2048: <code class="filename">mk.conf</code>. You should not try to use multiple
                   2049: different <code class="varname">LOCALBASE</code> definitions on the same system
                   2050: (inside a chroot is an exception). </p>
                   2051: <p>The rest of this chapter assumes that the package is already in pkgsrc. If it
1.75      rillig   2052:       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
                   2053:       how to create your own packages.</p>
                   2054: <div class="sect2" lang="en">
                   2055: <div class="titlepage"><div><div><h3 class="title">
                   2056: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1.82      rillig   2057: <p>To build packages from source, you need a working C
                   2058:       compiler. On NetBSD, you need to install the
                   2059:       &#8220;<span class="quote">comp</span>&#8221; and the &#8220;<span class="quote">text</span>&#8221; distribution
                   2060:       sets. If you want to build X11-related packages, the
                   2061:       &#8220;<span class="quote">xbase</span>&#8221; and &#8220;<span class="quote">xcomp</span>&#8221; distribution
                   2062:       sets are required, too.</p>
1.75      rillig   2063: </div>
                   2064: <div class="sect2" lang="en">
                   2065: <div class="titlepage"><div><div><h3 class="title">
                   2066: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
                   2067: <p>The first step for building a package is downloading the
                   2068:       distfiles (i.e. the unmodified source). If they have not yet been
                   2069:       downloaded, pkgsrc will fetch them automatically.</p>
1.82      rillig   2070: <p>
                   2071: If you have all files that you need in the
                   2072: <code class="filename">distfiles</code> directory,
                   2073: you don't need to connect. If the distfiles are on CD-ROM, you can
                   2074: mount the CD-ROM on <code class="filename">/cdrom</code> and add:
                   2075: </p>
                   2076: <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
                   2077: <p>
                   2078: to your <code class="filename">mk.conf</code>.
                   2079: </p>
1.75      rillig   2080: <p>You can overwrite some of the major distribution sites to fit to sites
                   2081:         that are close to your own.  Have a look at
1.76      rillig   2082:         <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find some examples
1.85      jmmv     2083:         &mdash; in particular, look for the <code class="varname">MASTER_SORT</code>,
1.75      rillig   2084:         <code class="varname">MASTER_SORT_REGEX</code> and
                   2085:         <code class="varname">INET_COUNTRY</code> definitions.  This may save some of your
                   2086:         bandwidth and time.</p>
                   2087: <p>You can change these settings either in your shell's environment, or,
                   2088:         if you want to keep the settings, by editing the
1.76      rillig   2089:         <code class="filename">/etc/mk.conf</code> file,
1.75      rillig   2090:         and adding the definitions there.</p>
1.82      rillig   2091: <p>
                   2092: If a package depends on many other packages (such as
                   2093: <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 
                   2094: alternate between periods of
                   2095: downloading source, and compiling. To ensure you have all the source
                   2096: downloaded initially you can run the command:
                   2097: </p>
                   2098: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
                   2099: <p>
                   2100: which will output and run a set of shell commands to fetch the
                   2101: necessary files into the <code class="filename">distfiles</code> directory.  You can
                   2102: also choose to download the files manually.
                   2103: </p>
1.75      rillig   2104: </div>
                   2105: <div class="sect2" lang="en">
                   2106: <div class="titlepage"><div><div><h3 class="title">
                   2107: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1.82      rillig   2108: <p>
                   2109: Once the software has downloaded, any patches will be applied, then it
                   2110: will be compiled for you. This may take some time depending on your
                   2111: computer, and how many other packages the software depends on and their
                   2112: compile time.
                   2113: </p>
1.75      rillig   2114: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   2115: <h3 class="title">Note</h3>
                   2116: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
                   2117:         use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
                   2118:         &#8220;<span class="quote">make</span>&#8221; in the examples in this guide.</p>
                   2119: </div>
                   2120: <p>For example, type </p>
                   2121: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
                   2122: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong></pre>
                   2123: <p>at the shell prompt to build the various components of the
1.82      rillig   2124:         package.</p>
                   2125: <p>The next stage is to actually install the newly compiled
                   2126:        program onto your system. Do this by entering:
                   2127: 
                   2128: </p>
                   2129: <pre class="screen">
                   2130:     <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
                   2131: </pre>
                   2132: <p>
                   2133: 
                   2134:        while you are still in the directory for whatever package you
                   2135:        are installing.</p>
                   2136: <p>Installing the package on your system may require you to
                   2137:        be root.  However, pkgsrc has a
1.75      rillig   2138:         <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
1.82      rillig   2139:         to only become root for the actual installation step.</p>
                   2140: <p>That's it, the software should now be installed and setup for use.
                   2141: You can now enter:
                   2142: 
                   2143: </p>
                   2144: <pre class="screen">
                   2145:     <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
                   2146: </pre>
                   2147: <p>
                   2148: 
                   2149:        to remove the compiled files in the work directory, as you shouldn't need
                   2150:        them any more. If other packages were also added to your system
                   2151:        (dependencies) to allow your program to compile, you can tidy these up
                   2152:        also with the command:</p>
                   2153: <pre class="screen">
                   2154:     <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
                   2155: </pre>
1.75      rillig   2156: <p>Taking the figlet utility as an example, we can install it on our
                   2157:         system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
                   2158: <p>The program is installed under the default root of the packages tree -
1.76      rillig   2159:         <code class="filename">/usr/pkg</code>. Should this not conform to your tastes,
1.75      rillig   2160:         set the <code class="varname">LOCALBASE</code>
                   2161:         variable in your environment, and it will use that value as the root of
1.76      rillig   2162:         your packages tree. So, to use <code class="filename">/usr/local</code>, set
1.75      rillig   2163:         <code class="varname">LOCALBASE=/usr/local</code> in your environment.  Please note
                   2164:         that you should use a directory which is
                   2165:         dedicated to packages and not shared with other programs (i.e., do not try
                   2166:         and use <code class="varname">LOCALBASE=/usr</code>).  Also, you should not try to
1.76      rillig   2167:         add any of your own files or directories (such as <code class="filename">src/</code>,
                   2168:         <code class="filename">obj/</code>, or <code class="filename">pkgsrc/</code>) below the
1.75      rillig   2169:         <code class="varname">LOCALBASE</code> tree.  This is to prevent possible conflicts
                   2170:         between programs and other files installed by the package system and
                   2171:         whatever else may have been installed there.</p>
1.76      rillig   2172: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to alter some
1.75      rillig   2173:         configuration options at build time.  Have a look at
1.76      rillig   2174:         <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to
1.75      rillig   2175:         get an overview of what will be set there by default.  Environment
                   2176:         variables such as <code class="varname">LOCALBASE</code>
1.76      rillig   2177:         can be set in <code class="filename">/etc/mk.conf</code> to
1.75      rillig   2178:         save having to remember to set them each time you want to use pkgsrc.</p>
                   2179: <p>Occasionally, people want to &#8220;<span class="quote">look under the covers</span>&#8221; to see
                   2180:         what is going on when a package is building or being installed. This may be
                   2181:         for debugging purposes, or out of simple curiosity. A number of utility
                   2182:         values have been added to help with this.</p>
                   2183: <div class="orderedlist"><ol type="1">
                   2184: <li>
                   2185: <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>,
                   2186:             then a huge amount of information will be displayed. For example,</p>
                   2187: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
                   2188: <p>will show all the commands that are invoked, up to and including the
                   2189:             &#8220;<span class="quote">patch</span>&#8221; stage.</p>
                   2190: </li>
                   2191: <li>
                   2192: <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
                   2193:             the <code class="varname">VARNAME</code> definition should be used, in conjunction
                   2194:             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
                   2195:             <code class="varname">LOCALBASE</code>:</p>
                   2196: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
                   2197: /usr/pkg
                   2198: <code class="prompt">%</code>
                   2199:           </pre>
                   2200: </li>
                   2201: </ol></div>
                   2202: <p>If you want to install a binary package that you've either
                   2203:         created yourself (see next section), that you put into pkgsrc/packages manually or
                   2204:         that is located on a remote FTP server, you can use the "bin-install"
                   2205:         target. This target will install a binary package - if available - via
                   2206:         <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>.
                   2207:         The list of remote
                   2208:         FTP sites searched is kept in the variable
                   2209:         <code class="varname">BINPKG_SITES</code>, which defaults to
                   2210:         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
                   2211:         into <code class="varname">BIN_INSTALL_FLAGS</code>.
1.76      rillig   2212:         See <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more details.</p>
1.75      rillig   2213: <p>A final word of warning: If you set up a system that has a non-standard
                   2214:         setting for <code class="varname">LOCALBASE</code>, be sure to set that
1.86    ! schwarz  2215:         before any packages are installed, as you cannot use several directories
1.75      rillig   2216:         for the same purpose. Doing so will result in pkgsrc not being able to
                   2217:         properly detect your installed packages, and fail miserably. Note also that
                   2218:         precompiled binary packages are usually built with the default
                   2219:         <code class="varname">LOCALBASE</code> of
1.76      rillig   2220:         <code class="filename">/usr/pkg</code>, and that you should <span class="emphasis"><em>not</em></span>
1.75      rillig   2221:         install any if you use a non-standard <code class="varname">LOCALBASE</code>.</p>
                   2222: </div>
                   2223: <div class="sect2" lang="en">
                   2224: <div class="titlepage"><div><div><h3 class="title">
                   2225: <a name="selecting-the-compiler"></a>4.2.4. Selecting the compiler</h3></div></div></div>
                   2226: <p>By default, pkgsrc will use GCC to build packages.  This may be
                   2227:         overridden by setting the following variables in /etc/mk.conf:
                   2228:         </p>
                   2229: <div class="variablelist"><dl>
                   2230: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
                   2231: <dd>
                   2232: <p> This is a list of values specifying the chain of
                   2233:               compilers to invoke when building packages.  Valid values
                   2234:               are: </p>
                   2235: <div class="itemizedlist"><ul type="disc">
                   2236: <li><p><code class="varname">distcc</code>:
                   2237:                 distributed C/C++ (chainable)</p></li>
                   2238: <li><p><code class="varname">ccache</code>:
                   2239:                 compiler cache (chainable)</p></li>
                   2240: <li><p><code class="varname">gcc</code>:
                   2241:                 GNU C/C++ Compiler</p></li>
                   2242: <li><p><code class="varname">mipspro</code>:
                   2243:                 Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
                   2244: <li><p><code class="varname">mipspro</code>:
                   2245:                 Silicon Graphics, Inc. MIPSpro (o32)</p></li>
                   2246: <li><p><code class="varname">sunpro</code>:
                   2247:                 Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
                   2248: </ul></div>
                   2249: <p> The default is
                   2250:               &#8220;<span class="quote"><code class="varname">gcc</code></span>&#8221;.  You can use
                   2251:               <code class="varname">ccache</code> and/or
                   2252:               <code class="varname">distcc</code> with an appropriate
                   2253:               <code class="varname">PKGSRC_COMPILER</code> setting,
                   2254:               e.g. &#8220;<span class="quote"><code class="varname">ccache gcc</code></span>&#8221;.  This
                   2255:               variable should always be
                   2256:               terminated with a value for a real compiler.  </p>
                   2257: </dd>
                   2258: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
                   2259: <dd><p> This specifies the minimum version of GCC to use
                   2260:               when building packages.  If the system GCC doesn't
                   2261:               satisfy this requirement, then pkgsrc will build and
                   2262:               install one of the GCC packages to use instead. </p></dd>
                   2263: </dl></div>
                   2264: </div>
                   2265: </div>
                   2266: </div>
                   2267: <div class="chapter" lang="en">
                   2268: <div class="titlepage"><div><div><h2 class="title">
                   2269: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
                   2270: <div class="toc">
                   2271: <p><b>Table of Contents</b></p>
                   2272: <dl>
                   2273: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                   2274: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78      rillig   2275: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
                   2276: <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>
                   2277: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
                   2278: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75      rillig   2279: </dl>
                   2280: </div>
                   2281: <div class="sect1" lang="en">
                   2282: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2283: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
                   2284: <p>In this section, you can find some variables that apply to all
1.82      rillig   2285:     pkgsrc packages.  The preferred method of setting these variables is
                   2286:     by setting them in <code class="filename">/etc/mk.conf</code>. A complete
                   2287:     list of the variables that can be configured by the user is
                   2288:     available in <code class="filename">mk/defaults/mk.conf</code>, together with
                   2289:     some comments that describe the variable's intent.</p>
1.75      rillig   2290: <div class="itemizedlist"><ul type="disc">
                   2291: <li><p><code class="varname">LOCALBASE</code>: Where
                   2292:            packages will be installed. The default is
1.76      rillig   2293:            <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75      rillig   2294:            with different <code class="varname">LOCALBASE</code>s!</p></li>
                   2295: <li><p><code class="varname">CROSSBASE</code>: Where
                   2296:            &#8220;<span class="quote">cross</span>&#8221; category packages will be
                   2297:            installed. The default is
1.76      rillig   2298:            <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75      rillig   2299: <li><p><code class="varname">X11BASE</code>: Where
                   2300:            X11 is installed on the system. The default is
1.76      rillig   2301:            <code class="filename">/usr/X11R6</code>.</p></li>
1.75      rillig   2302: <li><p><code class="varname">DISTDIR</code>: Where to store the
                   2303:            downloaded copies of the original source distributions used
                   2304:            for building pkgsrc packages. The default is
1.76      rillig   2305:            <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75      rillig   2306: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
                   2307:            If set, override the packages'
                   2308:            <code class="varname">MASTER_SITES</code> with this value.</p></li>
                   2309: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
                   2310:            Backup location(s) for distribution files and patch files
                   2311:            if not found locally or in
1.76      rillig   2312:            <code class="filename">${MASTER_SITES}</code> or
                   2313:            <code class="filename">${PATCH_SITES}</code> respectively.
1.75      rillig   2314:            The defaults are
1.76      rillig   2315:            <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75      rillig   2316:            and
1.76      rillig   2317:            <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75      rillig   2318: <li><p><code class="varname">BINPKG_SITES</code>:
                   2319:            List of sites carrying binary pkgs.</p></li>
1.82      rillig   2320: <li><p><code class="varname">ACCEPTABLE_LICENSES</code>:
                   2321:            List of acceptable licenses. Whenever you try to build a package
                   2322:            whose license is not in this list, you will get an error message
                   2323:            that includes instructions on how to change this variable.</p></li>
1.75      rillig   2324: </ul></div>
                   2325: </div>
                   2326: <div class="sect1" lang="en">
                   2327: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2328: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
                   2329: <p>XXX
                   2330:       </p>
                   2331: <div class="itemizedlist"><ul type="disc">
                   2332: <li><p><code class="varname">PACKAGES</code>: The top level
                   2333:            directory for the binary packages. The default is
1.76      rillig   2334:            <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75      rillig   2335: <li><p><code class="varname">WRKOBJDIR</code>:
                   2336:            The top level directory where, if defined, the separate
                   2337:            working directories will get created, and symbolically
1.76      rillig   2338:            linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75      rillig   2339:            This is useful for building packages on several
1.76      rillig   2340:            architectures, then <code class="filename">${PKGSRCDIR}</code>
                   2341:            can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75      rillig   2342:            is local to every architecture. (It should be noted that
                   2343:            <code class="varname">PKGSRCDIR</code> should not be set by the user
1.85      jmmv     2344:            &mdash; it is an internal definition which refers to the
1.75      rillig   2345:            root of the pkgsrc tree. It is possible to have many
                   2346:            pkgsrc tree instances.)</p></li>
                   2347: <li><p><code class="varname">LOCALPATCHES</code>:
                   2348:            Directory for local patches that aren't part of pkgsrc.
1.77      rillig   2349:            See <a href="#components.patches" title="9.3. patches/*">Section 9.3, &#8220;patches/*&#8221;</a> for more
1.75      rillig   2350:            information. <em class="replaceable"><code>rel</code></em> and
                   2351:            <em class="replaceable"><code>arch</code></em> are replaced with OS
                   2352:            release (&#8220;<span class="quote">2.0</span>&#8221;, etc.) and architecture
                   2353:            (&#8220;<span class="quote">mipsel</span>&#8221;, etc.).</p></li>
                   2354: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76      rillig   2355:            the <code class="filename">mk.conf</code> file used by a package's
1.75      rillig   2356:            BSD-style Makefile. If this is not set,
                   2357:            <code class="varname">MAKECONF</code> is set to
1.76      rillig   2358:            <code class="filename">/dev/null</code> to avoid picking up
                   2359:            settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.82      rillig   2360: <li><p><code class="varname">DEPENDS_TARGET</code>:
                   2361:            By default, dependencies are only installed, and no binary
                   2362:            package is created for them. You can set this variable to
                   2363:            <code class="literal">package</code> to automatically create binary
                   2364:            packages after installing dependencies.</p></li>
1.75      rillig   2365: </ul></div>
                   2366: <p>
                   2367:     </p>
                   2368: </div>
                   2369: <div class="sect1" lang="en">
                   2370: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78      rillig   2371: <a name="conf.compiler"></a>5.3. Selecting and configuring the compiler</h2></div></div></div>
                   2372: <div class="sect2" lang="en">
                   2373: <div class="titlepage"><div><div><h3 class="title">
                   2374: <a name="conf.cflags"></a>5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
                   2375: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
                   2376:        please make sure to use the <code class="literal">+=</code> operator
                   2377:        instead of the <code class="literal">=</code> operator:</p>
                   2378: <pre class="programlisting">
                   2379:     CFLAGS+=        -your -flags
                   2380: </pre>
                   2381: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
                   2382:        &#8220;<span class="quote">+</span>&#8221;) may lead to problems with packages that need
                   2383:        to add their own flags.  Also, you may want to take a look at
                   2384:        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
                   2385:        you're interested in optimization for the current CPU.</p>
                   2386: </div>
                   2387: </div>
                   2388: <div class="sect1" lang="en">
                   2389: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2390: <a name="developer-advanced-settings"></a>5.4. Developer/advanced settings</h2></div></div></div>
1.75      rillig   2391: <p>XXX
                   2392:       </p>
                   2393: <div class="itemizedlist"><ul type="disc">
                   2394: <li>
                   2395: <p><code class="varname">PKG_DEVELOPER</code>:
                   2396:            Run some sanity checks that package developers want:
                   2397:            </p>
                   2398: <div class="itemizedlist"><ul type="circle">
                   2399: <li><p>make sure patches apply with zero fuzz</p></li>
                   2400: <li><p>run check-shlibs to see that all binaries will
                   2401:                find their shared libs.</p></li>
                   2402: </ul></div>
                   2403: <p>
                   2404:          </p>
                   2405: </li>
                   2406: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>:
                   2407:            The level of debugging output which is displayed whilst
                   2408:            making and installing the package.
                   2409:            The default value for this is 0, which will not display
                   2410:            the commands as they are executed (normal, default, quiet
                   2411:            operation); the value 1 will display all shell commands
                   2412:            before their invocation, and the value 2 will display both
                   2413:            the shell commands before their invocation, and their
                   2414:            actual execution progress with <span><strong class="command">set -x</strong></span>
                   2415:            will be displayed.</p></li>
                   2416: </ul></div>
                   2417: <p>
                   2418:     </p>
                   2419: </div>
                   2420: <div class="sect1" lang="en">
                   2421: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78      rillig   2422: <a name="selecting-build-options"></a>5.5. Selecting Build Options</h2></div></div></div>
1.75      rillig   2423: <p>Some packages have build time options, usually to select between
                   2424:       different dependencies, enable optional support for big dependencies
                   2425:       or enable experimental features.</p>
                   2426: <p>To see which options, if any, a package supports, and which
                   2427:       options are mutually exclusive, run <span><strong class="command">make show-options</strong></span>,
                   2428:       for example:</p>
                   2429: <pre class="programlisting">
                   2430:     The following options are supported by this package:
                   2431:         ssl      Enable SSL support.
                   2432:     Exactly one of the following gecko options is required:
                   2433:         firefox  Use firefox as gecko rendering engine.
                   2434:         mozilla  Use mozilla as gecko rendering engine.
                   2435:     At most one of the following database options may be selected:
                   2436:         mysql    Enable support for MySQL database.
                   2437:         pgsql    Enable support for PostgreSQL database.
1.1       grant    2438: 
1.75      rillig   2439:     These options are enabled by default: firefox
                   2440:     These options are currently enabled: mozilla ssl
1.1       grant    2441: </pre>
1.75      rillig   2442: <p>The following variables can be defined in
1.76      rillig   2443:       <code class="filename">/etc/mk.conf</code> to select which options to enable
1.75      rillig   2444:       for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which can be
                   2445:       used to select or disable options for all packages that support them,
                   2446:       and <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
                   2447:       which can be used to select or disable options specifically for
                   2448:       package <em class="replaceable"><code>pkgbase</code></em>.  Options listed in these
                   2449:       variables are selected, options preceded by &#8220;<span class="quote">-</span>&#8221; are
                   2450:       disabled. A few examples:</p>
                   2451: <pre class="screen">
                   2452: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
                   2453: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   2454: PKG_OPTIONS.kdebase=    debug -sasl
                   2455: PKG_OPTIONS.apache=     suexec </pre>
                   2456: <p>The following settings are consulted in the order given, and the
                   2457:       last setting that selects or disables an option is used:</p>
                   2458: <div class="orderedlist"><ol type="1">
                   2459: <li><p>the default options as suggested by the package
                   2460:          maintainer</p></li>
                   2461: <li><p>the options implied by the settings of legacy
                   2462:          variables (see below)</p></li>
                   2463: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
                   2464: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
                   2465: </ol></div>
                   2466: <p>For groups of mutually exclusive options, the last option
                   2467:       selected is used, all others are automatically disabled.  If an option
                   2468:       of the group is explicitly disabled, the previously selected option,
                   2469:       if any, is used.  It is an error if no option from a required group of
                   2470:       options is selected, and building the package will fail.</p>
                   2471: <p>Before the options framework was introduced, build options were
                   2472:       selected by setting a variable (often named
                   2473:       <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
1.76      rillig   2474:       <code class="filename">/etc/mk.conf</code> for each option.  To ease transition
1.75      rillig   2475:       to the options framework for the user, these legacy variables are
                   2476:       converted to the appropriate options setting
                   2477:       (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
                   2478:       automatically.  A warning is issued to prompt the user to
1.76      rillig   2479:       update <code class="filename">/etc/mk.conf</code> to use the options framework
1.75      rillig   2480:       directly.  Support for the legacy variables will be removed
                   2481:       eventually.</p>
                   2482: </div>
                   2483: </div>
                   2484: <div class="chapter" lang="en">
                   2485: <div class="titlepage"><div><div><h2 class="title">
                   2486: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
                   2487: <div class="toc">
                   2488: <p><b>Table of Contents</b></p>
                   2489: <dl>
                   2490: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                   2491: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                   2492: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                   2493: <dd><dl>
                   2494: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                   2495: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                   2496: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                   2497: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                   2498: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                   2499: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                   2500: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                   2501: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                   2502: </dl></dd>
                   2503: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                   2504: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                   2505: </dl>
                   2506: </div>
                   2507: <div class="sect1" lang="en">
                   2508: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2509: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
                   2510: <p>
                   2511:       Once you have built and installed a package, you can create a
                   2512:       <span class="emphasis"><em>binary package</em></span> which can be installed on
                   2513:       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
                   2514:       the same package on a group of hosts and wasting CPU time. It
                   2515:       also provides a simple means for others to install your package,
                   2516:       should you distribute it.
                   2517:     </p>
                   2518: <p>
                   2519:       To create a binary package, change into the appropriate
                   2520:       directory in pkgsrc, and run <span><strong class="command">make
                   2521:       package</strong></span>:
                   2522:     </p>
                   2523: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
                   2524: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
                   2525: <p>
                   2526:       This will build and install your package (if not already done),
                   2527:       and then build a binary package from what was installed. You can
                   2528:       then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
                   2529:       it. Binary packages are created by default in
1.76      rillig   2530:       <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
1.75      rillig   2531:       gzipped tar file. See <a href="#logs.package" title="B.2. Packaging figlet">Section B.2, &#8220;Packaging figlet&#8221;</a> for a
1.76      rillig   2532:       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>
1.75      rillig   2533: <p>
1.77      rillig   2534:       See <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a> for information on how to submit
1.75      rillig   2535:       such a binary package.</p>
                   2536: </div>
                   2537: <div class="sect1" lang="en">
                   2538: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2539: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.77      rillig   2540: <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   2541: </div>
                   2542: <div class="sect1" lang="en">
                   2543: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2544: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
                   2545: <p>If you want to get a full set of precompiled binary
                   2546:       packages, this section describes how to get them. Beware that
                   2547:       the bulk build will remove all currently installed packages from
                   2548:       your system!</p>
                   2549: <p>Having an FTP server configured either on the
                   2550:       machine doing the bulk builds or on a nearby NFS server can help
                   2551:       to make the packages available to other machines that can then
                   2552:       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
                   2553:       more information. If you use a remote NFS server's storage, be
                   2554:       sure to not actually compile on NFS storage, as this slows
                   2555:       things down a lot.</p>
                   2556: <div class="sect2" lang="en">
                   2557: <div class="titlepage"><div><div><h3 class="title">
                   2558: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
                   2559: <div class="sect3" lang="en">
                   2560: <div class="titlepage"><div><div><h4 class="title">
1.76      rillig   2561: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
                   2562: <p>The <code class="filename">build.conf</code> file is the main
1.75      rillig   2563:         configuration file for bulk builds. You can configure how your
                   2564:         copy of pkgsrc is kept up to date, how the distfiles are
                   2565:         downloaded, how the packages are built and how the report is
                   2566:         generated. You can find an annotated example file in
1.76      rillig   2567:         <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
                   2568:         it, copy <code class="filename">build.conf-example</code> to
                   2569:         <code class="filename">build.conf</code> and edit it, following the
1.75      rillig   2570:         comments in that file.</p>
                   2571: </div>
                   2572: <div class="sect3" lang="en">
                   2573: <div class="titlepage"><div><div><h4 class="title">
                   2574: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
                   2575: <p>You may want to set variables in
1.76      rillig   2576:          <code class="filename">/etc/mk.conf</code>.
                   2577:          Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
1.75      rillig   2578:          details of the default settings. You will want to ensure that
                   2579:          <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
                   2580:          As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
                   2581:          accepts <span class="emphasis"><em>all</em></span> licenses.</p>
                   2582: <pre class="programlisting">
                   2583:     PACKAGES?=      ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
                   2584:     WRKOBJDIR?=     /usr/tmp/pkgsrc   # build here instead of in pkgsrc
                   2585:     BSDSRCDIR=      /usr/src
                   2586:     BSDXSRCDIR=     /usr/xsrc         # for x11/xservers
                   2587:     OBJHOSTNAME?=   yes               # use work.`hostname`
                   2588:     FAILOVER_FETCH= yes               # insist on the correct checksum
                   2589:     PKG_DEVELOPER?= yes
                   2590:     _ACCEPTABLE=    yes
1.1       grant    2591: </pre>
1.75      rillig   2592: <p>Some options that are especially useful for bulk builds
                   2593:        can be found at the top lines of the file
1.76      rillig   2594:        <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75      rillig   2595:        options of these are briefly described here.</p>
                   2596: <div class="itemizedlist"><ul type="disc">
                   2597: <li><p>If you are on a slow machine, you may want to
                   2598:        set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
                   2599:        &#8220;<span class="quote">no</span>&#8221;.</p></li>
                   2600: <li><p>If you are doing bulk builds from a read-only
                   2601:        copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
                   2602:        to the directory where all log files are created. Otherwise the
                   2603:        log files are created in the pkgsrc directory.</p></li>
                   2604: <li><p>Another important variable is
                   2605:        <code class="varname">BULK_PREREQ</code>, which is a list of packages that
                   2606:        should be always available while building other
                   2607:        packages.</p></li>
                   2608: </ul></div>
                   2609: <p>Some other options are scattered in the pkgsrc
                   2610:        infrastructure:</p>
                   2611: <div class="itemizedlist"><ul type="disc">
                   2612: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
                   2613:        should be set to <code class="literal">yes</code>. The purpose of the bulk
                   2614:        builds is creating binary packages, no matter if they are
                   2615:        vulnerable or not. When uploading the packages to a public
                   2616:        server, the vulnerable packages will be put into a directory of
                   2617:        their own. Leaving this variable unset would prevent the bulk
                   2618:        build system from even trying to build them, so possible
                   2619:        building errors would not show up.</p></li>
                   2620: <li><p><code class="varname">CHECK_FILES</code>
1.76      rillig   2621:        (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75      rillig   2622:        &#8220;<span class="quote">yes</span>&#8221; to check that the installed set of files
1.76      rillig   2623:        matches the <code class="filename">PLIST</code>.</p></li>
1.75      rillig   2624: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.76      rillig   2625:        (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75      rillig   2626:        &#8220;<span class="quote">yes</span>&#8221; to check that the installed
                   2627:        &#8220;<span class="quote">#!</span>&#8221;-scripts will find their
                   2628:        interpreter.</p></li>
                   2629: </ul></div>
                   2630: </div>
                   2631: <div class="sect3" lang="en">
                   2632: <div class="titlepage"><div><div><h4 class="title">
1.76      rillig   2633: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75      rillig   2634: <p>It is possible to configure the bulk build to perform
                   2635:          certain site-specific tasks at the end of the pre-build
                   2636:          stage.  If the file
1.76      rillig   2637:          <code class="filename">pre-build.local</code> exists in
                   2638:          <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
1.75      rillig   2639:          (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
                   2640:          stage.  An example use of
1.76      rillig   2641:          <code class="filename">pre-build.local</code> is to have the line:</p>
1.75      rillig   2642: <pre class="screen">echo "I do not have enough disk space to build this pig." \
                   2643:     &gt; misc/openoffice/$BROKENF</pre>
                   2644: <p>to prevent the system from trying to build a particular package
                   2645:          which requires nearly 3 GB of disk space.</p>
                   2646: </div>
                   2647: </div>
                   2648: <div class="sect2" lang="en">
                   2649: <div class="titlepage"><div><div><h3 class="title">
                   2650: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76      rillig   2651: <p>As <code class="filename">/usr/pkg</code> will be completely
1.75      rillig   2652:        deleted at the start of bulk builds, make sure your login
                   2653:        shell is placed somewhere else. Either drop it into
1.76      rillig   2654:        <code class="filename">/usr/local/bin</code> (and adjust your login
1.75      rillig   2655:        shell in the passwd file), or (re-)install it via
1.76      rillig   2656:        <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
1.75      rillig   2657:        you can login after a reboot (remember that your current
                   2658:        process won't die if the package is removed, you just can't
                   2659:        start any new instances of the shell any more).  Also, if you
                   2660:        use NetBSD earlier than 1.5, or you still want to use the pkgsrc
                   2661:        version of ssh for some reason, be sure to install ssh before
1.76      rillig   2662:        starting it from <code class="filename">rc.local</code>:</p>
1.75      rillig   2663: <pre class="programlisting">
                   2664:     ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
                   2665:     if [ -f /usr/pkg/etc/rc.d/sshd ]; then
                   2666:         /usr/pkg/etc/rc.d/sshd
                   2667:     fi
1.1       grant    2668: </pre>
1.75      rillig   2669: <p>Not doing so will result in you being not able to log in
                   2670:        via ssh after the bulk build is finished or if the machine
                   2671:        gets rebooted or crashes. You have been warned! :)</p>
                   2672: </div>
                   2673: <div class="sect2" lang="en">
                   2674: <div class="titlepage"><div><div><h3 class="title">
                   2675: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
                   2676: <p>Make sure you don't need any of the packages still
                   2677:        installed.
                   2678:       </p>
                   2679: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
                   2680: <h3 class="title">Warning</h3>
                   2681: <p>During the bulk build, <span class="emphasis"><em>all packages will be
                   2682:            removed!</em></span></p>
                   2683: </div>
                   2684: <p>Be sure to remove all other things that might
                   2685:        interfere with builds, like some libs installed in
1.76      rillig   2686:        <code class="filename">/usr/local</code>, etc. then become root and type:</p>
1.75      rillig   2687: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   2688: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong></pre>
                   2689: <p>If for some reason your last build didn't complete (power
                   2690:        failure, system panic, ...), you can continue it by
                   2691:        running:</p>
                   2692: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
                   2693: <p>
                   2694:         At the end of the bulk build, you will get a summary via mail,
                   2695:        and find build logs in the directory specified by
1.76      rillig   2696:        <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
1.75      rillig   2697:        file.
                   2698:       </p>
                   2699: </div>
                   2700: <div class="sect2" lang="en">
                   2701: <div class="titlepage"><div><div><h3 class="title">
                   2702: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
                   2703: <p>The bulk builds consist of three steps:</p>
                   2704: <div class="variablelist"><dl>
                   2705: <dt><span class="term">1. pre-build</span></dt>
                   2706: <dd><p>
                   2707:              The script updates your pkgsrc tree via (anon)cvs, then
                   2708:              cleans out any broken distfiles, and removes all
                   2709:              packages installed.</p></dd>
                   2710: <dt><span class="term">2. the bulk build</span></dt>
                   2711: <dd><p>
                   2712:              This is basically &#8220;<span class="quote">make bulk-package</span>&#8221; with
                   2713:              an optimised order in which packages will be
                   2714:              built. Packages that don't require other packages will
                   2715:              be built first, and packages with many dependencies will
                   2716:              be built later.
                   2717:            </p></dd>
                   2718: <dt><span class="term">3. post-build</span></dt>
                   2719: <dd><p>
                   2720:              Generates a report that's placed in the directory
1.76      rillig   2721:              specified in the <code class="filename">build.conf</code> file
                   2722:              named <code class="filename">broken.html</code>, a short version
1.75      rillig   2723:              of that report will also be mailed to the build's
                   2724:              admin.</p></dd>
                   2725: </dl></div>
                   2726: <p>
                   2727:         During the build, a list of broken packages will be compiled
1.76      rillig   2728:         in <code class="filename">/usr/pkgsrc/.broken</code> (or
                   2729:         <code class="filename">.../.broken.${MACHINE}</code> if
1.75      rillig   2730:         <code class="varname">OBJMACHINE</code> is set),       individual build logs
                   2731:         of broken builds can be found in the package's
                   2732:         directory. These files are used by the bulk-targets to mark
                   2733:         broken builds  to not waste time trying to rebuild them, and
                   2734:         they can be used to debug      these broken package builds
                   2735:         later.
                   2736:       </p>
                   2737: </div>
                   2738: <div class="sect2" lang="en">
                   2739: <div class="titlepage"><div><div><h3 class="title">
                   2740: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
                   2741: <p>Currently, roughly the following requirements are valid for
                   2742:        NetBSD 2.0/i386:</p>
                   2743: <div class="itemizedlist"><ul type="disc">
                   2744: <li><p>
                   2745:            10 GB - distfiles (NFS ok)
                   2746:          </p></li>
                   2747: <li><p>
                   2748:            8 GB - full set of all binaries (NFS ok)
                   2749:          </p></li>
                   2750: <li><p>
                   2751:            5 GB - temp space for compiling (local disk recommended)
                   2752:          </p></li>
                   2753: </ul></div>
                   2754: <p>
                   2755:         Note that all pkgs will be de-installed as soon as they are
                   2756:         turned into a  binary package, and that sources are removed,
                   2757:         so there is no excessively huge        demand to disk
                   2758:         space. Afterwards, if the package is needed again, it will
                   2759:         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
                   2760:         there are no cycles wasted by recompiling.
                   2761:       </p>
                   2762: </div>
                   2763: <div class="sect2" lang="en">
                   2764: <div class="titlepage"><div><div><h3 class="title">
                   2765: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
                   2766: <p>
                   2767:         If you don't want all the packages nuked from a machine
                   2768:         (rendering it useless for anything but pkg compiling), there
                   2769:         is the possibility of doing the package bulk build inside a
                   2770:         chroot environment.
                   2771:       </p>
                   2772: <p>
                   2773:         The first step is to set up a chroot sandbox,
1.76      rillig   2774:        e.g. <code class="filename">/usr/sandbox</code>.  This can be done by
1.75      rillig   2775:        using null mounts, or manually.
                   2776:       </p>
                   2777: <p>
                   2778:         There is a shell script called
1.76      rillig   2779:         <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
1.75      rillig   2780:         up the sandbox environment using null mounts. It will also
1.76      rillig   2781:         create a script called <code class="filename">sandbox</code> in the
1.75      rillig   2782:         root of the sandbox environment, which will allow the null
                   2783:         mounts to be activated using the <span><strong class="command">sandbox
                   2784:         mount</strong></span> command and deactivated using the
                   2785:         <span><strong class="command">sandbox umount</strong></span> command.
                   2786:       </p>
                   2787: <p>
                   2788:         To set up a sandbox environment by hand, after extracting all
                   2789:         the sets from a NetBSD installation or doing a <span><strong class="command">make
                   2790:         distribution DESTDIR=/usr/sandbox</strong></span> in
1.76      rillig   2791:         <code class="filename">/usr/src/etc</code>, be sure the following items
1.75      rillig   2792:         are present and properly configured:
                   2793:       </p>
                   2794: <div class="procedure"><ol type="1">
                   2795: <li>
                   2796: <p>Kernel</p>
                   2797: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
                   2798: </li>
                   2799: <li>
1.76      rillig   2800: <p><code class="filename">/dev/*</code></p>
1.75      rillig   2801: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
                   2802: </li>
                   2803: <li>
1.76      rillig   2804: <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   2805: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
                   2806: </li>
                   2807: <li>
                   2808: <p>Working(!) mail config (hostname, sendmail.cf):</p>
                   2809: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
                   2810: </li>
                   2811: <li>
1.76      rillig   2812: <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   2813: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
                   2814: </li>
                   2815: <li>
1.76      rillig   2816: <p><code class="filename">/usr/src</code> (system sources,
1.85      jmmv     2817:          e.&nbsp;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   2818: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
                   2819: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
                   2820: </li>
                   2821: <li>
1.76      rillig   2822: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75      rillig   2823: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
                   2824: </li>
                   2825: <li>
1.76      rillig   2826: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75      rillig   2827: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
                   2828: </li>
                   2829: <li>
                   2830: <p>Checkout pkgsrc via cvs into
1.76      rillig   2831:            <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
1.75      rillig   2832: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
                   2833: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong></pre>
                   2834: <p>Do not mount/link this to the copy of your pkgsrc tree
                   2835:            you do development in, as this will likely cause problems!
                   2836:            </p>
                   2837: </li>
                   2838: <li><p>Make
1.76      rillig   2839:            <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
                   2840:            <code class="filename">.../distfiles</code> point somewhere
1.75      rillig   2841:            appropriate. NFS- and/or nullfs-mounts may come in handy!
                   2842:            </p></li>
1.76      rillig   2843: <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>
                   2844: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75      rillig   2845: </ol></div>
                   2846: <p>When the chroot sandbox is set up, you can start
                   2847:        the build with the following steps:</p>
                   2848: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
                   2849: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong></pre>
                   2850: <p>
                   2851:         This will just jump inside the sandbox and start building.  At
                   2852:         the end of the build, mail will be sent with the results of
                   2853:         the build. Created binary pkgs will be in
1.76      rillig   2854:         <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
1.75      rillig   2855:         (wherever that points/mounts to/from).</p>
                   2856: </div>
                   2857: <div class="sect2" lang="en">
                   2858: <div class="titlepage"><div><div><h3 class="title">
                   2859: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
                   2860: <p> In addition to building a complete set of all packages in
1.76      rillig   2861:         pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
1.75      rillig   2862:         may be used to build a subset of the packages contained in
                   2863:         pkgsrc.  By setting <code class="varname">SPECIFIC_PKGS</code>
1.76      rillig   2864:         in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75      rillig   2865: <div class="itemizedlist"><ul type="disc">
                   2866: <li><p>SITE_SPECIFIC_PKGS</p></li>
                   2867: <li><p>HOST_SPECIFIC_PKGS</p></li>
                   2868: <li><p>GROUP_SPECIFIC_PKGS</p></li>
                   2869: <li><p>USER_SPECIFIC_PKGS</p></li>
                   2870: </ul></div>
                   2871: <p> will define the set of packages which should be built.
                   2872:         The bulk build code will also include any packages which are
                   2873:         needed as dependencies for the explicitly listed packages.
                   2874:        </p>
                   2875: <p> One use of this is to do a bulk build with
                   2876:         <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
                   2877:         periodically to have a complete set of the binary packages
                   2878:         needed for your site available without the overhead of
                   2879:         building extra packages that are not needed.  </p>
                   2880: </div>
                   2881: <div class="sect2" lang="en">
                   2882: <div class="titlepage"><div><div><h3 class="title">
                   2883: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
                   2884: <p>
                   2885:         This section describes how pkgsrc developers can upload binary
                   2886:         pkgs built by bulk builds to ftp.NetBSD.org.
                   2887:       </p>
                   2888: <p>
                   2889:        If you would like to automatically create checksum files for the
                   2890:        binary packages you intend to upload, remember to set
                   2891:        <code class="varname">MKSUMS=yes</code> in your
1.76      rillig   2892:        <code class="filename">mk/bulk/build.conf</code>.
1.75      rillig   2893:       </p>
                   2894: <p>
                   2895:        If you would like to PGP sign the checksum files (highly
                   2896:        recommended!), remember to set
                   2897:        <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
1.76      rillig   2898:        <code class="filename">mk/bulk/build.conf</code>.  This will prompt you for
1.75      rillig   2899:        your GPG password to sign the files before uploading everything.
                   2900:       </p>
                   2901: <p>
                   2902:         Then, make sure that you have <code class="varname">RSYNC_DST</code>
1.76      rillig   2903:         set properly in your <code class="filename">mk/bulk/build.conf</code>
1.75      rillig   2904:         file, i.e. adjust it to something like one of the following:
                   2905:       </p>
                   2906: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
                   2907: <p>Please use appropriate values for "pkgsrc-200xQy",
                   2908:         "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
                   2909:        is different from your local login, write your login directly
                   2910:        into the variable, e.g. my local account is "feyrer", but for my
                   2911:        login "hubertf", I use:</p>
                   2912: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
                   2913: <p>
1.76      rillig   2914:         A separate <code class="filename">upload</code> directory is used
1.75      rillig   2915:         here to allow "closing" the directory during upload. To do
                   2916:         so, run the following command on ftp.NetBSD.org next:
                   2917:       </p>
                   2918: <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>
                   2919: <p>
1.76      rillig   2920:         Please note that <code class="filename">/pub/NetBSD/packages</code> is
1.75      rillig   2921:         only appropriate for packages for the NetBSD operating
                   2922:         system. Binary packages for other operating systems should go
1.76      rillig   2923:         into <code class="filename">/pub/pkgsrc</code>.
1.75      rillig   2924:       </p>
                   2925: <p>
                   2926:         Before uploading the binary pkgs, ssh authentication needs to
                   2927:         be set up. This example shows how to set up temporary keys
                   2928:         for the root account <span class="emphasis"><em>inside the sandbox</em></span>
                   2929:         (assuming that no keys should be present there usually):
                   2930:       </p>
                   2931: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
                   2932: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
                   2933: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
                   2934: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong> </pre>
                   2935: <p>
1.76      rillig   2936:         Now take the output of <code class="filename">id-dsa.pub</code> and
                   2937:         append it to your <code class="filename">~/.ssh/authorized_keys</code>
1.75      rillig   2938:         file on ftp.NetBSD.org. You can remove the key after the
                   2939:         upload is done!
                   2940:       </p>
                   2941: <p>
                   2942:         Next, test if your ssh connection really works:
                   2943:       </p>
                   2944: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
                   2945: <p>
                   2946:         Use "-l yourNetBSDlogin" here as appropriate!
                   2947:       </p>
                   2948: <p>
                   2949:         Now after all this works, you can exit the sandbox and start
                   2950:         the upload:
                   2951:       </p>
                   2952: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
                   2953: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
                   2954: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong> </pre>
                   2955: <p>
                   2956:         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
                   2957:         <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
                   2958:         upload. The upload script will take care of not uploading
                   2959:         restricted packages and putting vulnerable packages into the
1.76      rillig   2960:         <code class="filename">vulnerable</code> subdirectory.
1.75      rillig   2961:       </p>
                   2962: <p>
                   2963:         After the upload has ended, first thing is to revoke ssh access:
                   2964:       </p>
                   2965: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
                   2966: Gdd:x! </pre>
                   2967: <p>
                   2968:         Use whatever is needed to remove the key you've entered
                   2969:         before! Last, move the uploaded packages out of the
1.76      rillig   2970:         <code class="filename">upload</code> directory to have them accessible
1.75      rillig   2971:         to everyone:
                   2972:       </p>
                   2973: <pre class="screen">nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
                   2974: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
                   2975: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
                   2976: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong> </pre>
                   2977: </div>
                   2978: </div>
                   2979: <div class="sect1" lang="en">
                   2980: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2981: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
                   2982: <p>
                   2983:       After your pkgsrc bulk-build has completed, you may wish to
                   2984:       create a CD-ROM set of the resulting binary packages to assist
                   2985:       in installing packages on other machines.  The
1.76      rillig   2986:       <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
1.75      rillig   2987:       a simple tool for creating the ISO 9660 images.
                   2988:       <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
                   2989:       way that keeps all the dependencies for a given package on the same
                   2990:       CD as that package.
                   2991:     </p>
                   2992: <div class="sect2" lang="en">
                   2993: <div class="titlepage"><div><div><h3 class="title">
                   2994: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
                   2995: <p>
                   2996:         Complete documentation for cdpack is found in the cdpack(1)
                   2997:         man page. The following short example assumes that the binary
                   2998:         packages are left in
1.76      rillig   2999:         <code class="filename">/usr/pkgsrc/packages/All</code> and that
                   3000:         sufficient disk space exists in <code class="filename">/u2</code> to
1.75      rillig   3001:         hold the ISO 9660 images.</p>
                   3002: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
                   3003: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
                   3004: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
                   3005: <p>
                   3006:         If you wish to include a common set of files
1.76      rillig   3007:        (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
1.75      rillig   3008:        etc.) on each CD in the collection, then you need to create a
                   3009:        directory which contains these files. e.g.
                   3010:       </p>
                   3011: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
                   3012: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" &gt; /tmp/common/README</code></strong>
                   3013: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" &gt; /tmp/common/COPYING</code></strong>
                   3014: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
                   3015: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" &gt; /tmp/common/bin/myscript</code></strong>
                   3016: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" &gt;&gt; /tmp/common/bin/myscript</code></strong>
                   3017: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong></pre>
                   3018: <p>Now create the images:</p>
                   3019: <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   3020: <p>Each image will contain <code class="filename">README</code>,
                   3021:        <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
1.75      rillig   3022:        in their root directories.</p>
                   3023: </div>
                   3024: </div>
                   3025: </div>
                   3026: <div class="chapter" lang="en">
                   3027: <div class="titlepage"><div><div><h2 class="title">
                   3028: <a name="faq"></a>Chapter 7. Frequently Asked Questions</h2></div></div></div>
                   3029: <div class="toc">
                   3030: <p><b>Table of Contents</b></p>
                   3031: <dl>
                   3032: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                   3033: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
                   3034: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
                   3035: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
                   3036: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
                   3037: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                   3038: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                   3039: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
                   3040: <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>
                   3041: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
                   3042: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does &#8220;<span class="quote">Don't know how to make
                   3043: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
                   3044: <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>
                   3045: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
                   3046: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
                   3047: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
                   3048: <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   3049: <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   3050: </dl>
                   3051: </div>
                   3052: <p>This section contains hints, tips &amp; tricks on special things in
                   3053: pkgsrc that we didn't find a better place for in the previous chapters, and
                   3054: it contains items for both pkgsrc users and developers.</p>
                   3055: <div class="sect1" lang="en">
                   3056: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3057: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
                   3058: <p>The following mailing lists may be of interest to pkgsrc users:</p>
                   3059: <div class="itemizedlist"><ul type="disc">
1.78      rillig   3060: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
                   3061:          This is a general purpose list for most issues regarding
                   3062:          pkgsrc, regardless of platform, e.g. soliciting user help
                   3063:          for pkgsrc configuration, unexpected build failures, using
                   3064:          particular packages, upgrading pkgsrc installations,
                   3065:          questions regarding the pkgsrc release branches, etc.  General announcements or
                   3066:          proposals for changes that impact the pkgsrc user community,
                   3067:          e.g. major infrastructure changes, new features, package
                   3068:          removals, etc., may also be posted.</p></li>
1.75      rillig   3069: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
                   3070:          A list where the results of pkgsrc bulk builds are sent and
                   3071:          discussed.</p></li>
                   3072: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
                   3073:          This list is for those who are interested in getting a
                   3074:          commit message for every change committed to pkgsrc. It is
                   3075:          also available in digest form, meaning one daily message
                   3076:          containing all commit messages for changes to the package
                   3077:          source tree in that 24 hour period.</p></li>
                   3078: </ul></div>
                   3079: <p>To subscribe, do:</p>
                   3080: <pre class="programlisting">
                   3081:     <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
                   3082: </pre>
                   3083: <p>Archives for all these mailing lists are available from
                   3084: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
                   3085: </div>
                   3086: <div class="sect1" lang="en">
                   3087: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3088: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
                   3089: <p>Pkgviews is tightly integrated with buildlink.  You can find a
                   3090: pkgviews User's guide in
1.76      rillig   3091: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75      rillig   3092: </div>
                   3093: <div class="sect1" lang="en">
                   3094: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3095: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.80      rillig   3096: <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
1.75      rillig   3097: a number of useful utilities for both users and developers of pkgsrc.  This
                   3098: section attempts only to make the reader aware of the utilities and when
                   3099: they might be useful, and not to duplicate the documentation that comes
                   3100: with each package.</p>
                   3101: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76      rillig   3102: <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   3103:       Symlinks for use by buildlink.</p></li></ul></div>
                   3104: <p>OS tool augmentation (automatically installed when needed):</p>
                   3105: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3106: <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   3107:       Calculates various kinds of checksums (including SHA1).</p></li>
1.76      rillig   3108: <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   3109:       Compatibility library for pkgsrc tools.</p></li>
1.76      rillig   3110: <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.75      rillig   3111:       non-BSD systems due to lack of native mtree.
                   3112:   </p></li>
1.76      rillig   3113: <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   3114:       Up-to-date replacement for
1.76      rillig   3115:       <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75      rillig   3116:       systems where pkg_install is not present.</p></li>
                   3117: </ul></div>
                   3118: <p>Utilities used by pkgsrc (not automatically installed):</p>
                   3119: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3120: <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   3121:       Create a binary package from an
                   3122:       already-installed package.  Used by <span><strong class="command">make replace</strong></span> to
                   3123:       save the old package.</p></li>
1.76      rillig   3124: <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   3125:       Adds extra functionality to pkgsrc, allowing it to fetch distfiles
                   3126:       from multiple locations. It currently supports the following
                   3127:       methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76      rillig   3128: <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   3129:       packages someplace else (enabled by default).</p></li>
1.76      rillig   3130: <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   3131:       best compiler flags to optimise code for your current CPU and
                   3132:       compiler.</p></li>
                   3133: </ul></div>
                   3134: <p>Utilities for keeping track of installed packages, being up to date,
                   3135: etc:</p>
                   3136: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3137: <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   3138:       packages whose installed versions do not match the latest pkgsrc
                   3139:       entries.</p></li>
1.76      rillig   3140: <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   3141:       dependency graphs of packages, to aid in choosing a strategy for
                   3142:       updating.</p></li>
1.76      rillig   3143: <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
                   3144:       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>
                   3145: <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   3146:       pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
                   3147:       does various checks on the complete pkgsrc system.</p></li>
1.76      rillig   3148: <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   3149:       packages you have installed.</p></li>
                   3150: </ul></div>
                   3151: <p>Utilities for people maintaining or creating individual packages:</p>
                   3152: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3153: <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   3154:       making and maintaining patches for a package (includes pkgdiff,
                   3155:       pkgvi, mkpatches, etc.).</p></li>
1.76      rillig   3156: <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>,
                   3157:       <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   3158:       converting to pkgsrc.</p></li>
1.76      rillig   3159: <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   3160:       pkgsrc to a Solaris package.</p></li>
                   3161: </ul></div>
                   3162: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
                   3163: utilities)</p>
                   3164: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3165: <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   3166:       packages in a chrooted area.</p></li>
1.76      rillig   3167: <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   3168:       kernel version for chrooted cross builds.</p></li>
                   3169: </ul></div>
                   3170: </div>
                   3171: <div class="sect1" lang="en">
                   3172: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3173: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
                   3174: <p>If you want to use pkgsrc as non-root user, you can set some
                   3175: variables to make pkgsrc work under these conditions.  At the very least,
                   3176: you need to set <code class="varname">UNPRIVILEGED</code> to &#8220;<span class="quote">yes</span>&#8221;; this
                   3177: will turn on unprivileged mode and set multiple related variables to allow
                   3178: installation of packages as non-root.</p>
                   3179: <p>In case the defaults are not enough, you may want to tune some other
                   3180: variables used.  For example, if the automatic user/group detection leads
                   3181: to incorrect values (or not the ones you would like to use), you can change
                   3182: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
                   3183: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
                   3184: <p>As regards bootstrapping, please note that the
                   3185: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
                   3186: given the &#8220;<span class="quote">--ignore-user-check</span>&#8221; flag, as it will choose and
1.76      rillig   3187: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75      rillig   3188: installation targets.  These directories can be overriden by the
                   3189: &#8220;<span class="quote">--prefix</span>&#8221; flag provided by the script, as well as some others
                   3190: that allow finer tuning of the tree layout.</p>
                   3191: </div>
                   3192: <div class="sect1" lang="en">
                   3193: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3194: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
                   3195: <p>By default, resuming transfers in pkgsrc is disabled, but you can
                   3196: enable this feature by adding the option
                   3197: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76      rillig   3198: <code class="filename">/etc/mk.conf</code>.  If, during a fetch step, an incomplete
1.75      rillig   3199: distfile is found, pkgsrc will try to resume it.</p>
                   3200: <p>You can also
                   3201: 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
                   3202: <code class="varname">FETCH_CMD</code> variable.  Don't forget to set
                   3203: <code class="varname">FETCH_RESUME_ARGS</code> and
                   3204: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
                   3205: values.</p>
                   3206: <p>For example, if you want to use
1.76      rillig   3207: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75      rillig   3208: like:</p>
                   3209: <pre class="programlisting">
                   3210:     FETCH_CMD=             wget
                   3211:     FETCH_BEFORE_ARGS=     --passive-ftp
                   3212:     FETCH_RESUME_ARGS=     -c
                   3213:     FETCH_OUTPUT_ARGS=     -O
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="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
                   3219: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76      rillig   3220: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75      rillig   3221: ...), you will have to add the following line into
1.76      rillig   3222: <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3223: <pre class="programlisting">
                   3224:     X11_TYPE=XFree86
1.1       grant    3225: </pre>
1.75      rillig   3226: </div>
                   3227: <div class="sect1" lang="en">
                   3228: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3229: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
                   3230: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76      rillig   3231: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75      rillig   3232: you will have to add the following line into
1.76      rillig   3233: <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3234: <pre class="programlisting">
                   3235:     X11_TYPE=xorg
1.1       grant    3236: </pre>
1.75      rillig   3237: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   3238: <h3 class="title">Note</h3>
                   3239: <p>The DragonFly operating system defaults to using
                   3240: this X.org X11 implementation from pkgsrc.
                   3241: </p>
                   3242: </div>
                   3243: </div>
                   3244: <div class="sect1" lang="en">
                   3245: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3246: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
                   3247: <p>If you are sitting behind a firewall which does not allow direct
                   3248: connections to Internet hosts (i.e. non-NAT), you may specify the
                   3249: relevant proxy hosts.  This is done using an environment variable in the
                   3250: form of a URL, e.g. in Amdahl, the machine
                   3251: &#8220;<span class="quote">orpheus.amdahl.com</span>&#8221; is one of the firewalls, and it uses
                   3252: port 80 as the proxy port number.  So the proxy environment variables
                   3253: are:</p>
                   3254: <pre class="programlisting">
                   3255:     ftp_proxy=ftp://orpheus.amdahl.com:80/
                   3256:     http_proxy=http://orpheus.amdahl.com:80/
1.1       grant    3257: </pre>
1.75      rillig   3258: </div>
                   3259: <div class="sect1" lang="en">
                   3260: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3261: <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>
                   3262: <p>This depends on which utility is used to retrieve distfiles.  From
1.76      rillig   3263: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75      rillig   3264: the first available command from the following list:</p>
                   3265: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3266: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
                   3267: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75      rillig   3268: </ul></div>
                   3269: <p>On a default NetBSD installation, this will be
1.76      rillig   3270: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75      rillig   3271: connections first, and falls back to active connections if the server
                   3272: refuses to do passive.  For the other tools, add the following to your
1.76      rillig   3273: <code class="filename">/etc/mk.conf</code> file:
1.75      rillig   3274: <code class="varname">PASSIVE_FETCH=1</code>.</p>
                   3275: <p>Having that option present will prevent
1.76      rillig   3276: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75      rillig   3277: transfers.</p>
                   3278: </div>
                   3279: <div class="sect1" lang="en">
                   3280: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3281: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
                   3282: <p>You would like to download all the distfiles in a single batch from
                   3283: work or university, where you can't run a <span><strong class="command">make fetch</strong></span>.
                   3284: There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
                   3285: but downloading the entire directory may not be appropriate.</p>
                   3286: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76      rillig   3287: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75      rillig   3288: resulting list to your machine at work/school and use it there.  If you
                   3289: 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
                   3290: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
                   3291: URL:</p>
                   3292: <p>At home:</p>
                   3293: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   3294: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles &gt;/tmp/fetch.sh</code></strong>
                   3295: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
                   3296: <p>At work:</p>
                   3297: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76      rillig   3298: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75      rillig   3299: home.</p>
                   3300: <p>If you have a machine running NetBSD, and you want to get
                   3301: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your machine
                   3302: architecture), you can do so by using the above-mentioned <span><strong class="command">make
                   3303: fetch-list</strong></span> approach, or fetch the distfiles directly by
                   3304: running:</p>
                   3305: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
                   3306: <p>If you even decide to ignore
                   3307: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
                   3308: by running:</p>
                   3309: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
                   3310: </div>
                   3311: <div class="sect1" lang="en">
                   3312: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3313: <a name="tmac.andoc-missing"></a>7.11. What does &#8220;<span class="quote">Don't know how to make
                   3314: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</h2></div></div></div>
1.76      rillig   3315: <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   3316: package, you get the error from make that it doesn't know how to make
1.76      rillig   3317: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75      rillig   3318: you don't have installed the &#8220;<span class="quote">text</span>&#8221; set (nroff, ...) from
                   3319: the NetBSD base distribution on your machine.  It is recommended to do
                   3320: that to format man pages.</p>
1.76      rillig   3321: <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   3322: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76      rillig   3323: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75      rillig   3324: </div>
                   3325: <div class="sect1" lang="en">
                   3326: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3327: <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.76      rillig   3328: <p> You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75      rillig   3329: when you installed your NetBSD machine.  Please get and install it, by
1.76      rillig   3330: extracting it in <code class="filename">/</code>:</p>
1.75      rillig   3331: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
                   3332: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76      rillig   3333: <p><code class="filename">comp.tgz</code> is part of every NetBSD release.  Get
1.75      rillig   3334: the one that corresponds to your release (determine via <span><strong class="command">uname
                   3335: -r</strong></span>).</p>
                   3336: </div>
                   3337: <div class="sect1" lang="en">
                   3338: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3339: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
                   3340: <p>When installing packages as non-root user and using the just-in-time
                   3341: <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
                   3342: password for each required package installed.  To avoid this, the sudo
                   3343: package can be used, which does password caching over a limited time.  To
                   3344: use it, install sudo (either as binary package or from
1.76      rillig   3345: <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
                   3346: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3347: <pre class="programlisting">
                   3348:     .if exists(${LOCALBASE}/bin/sudo)
                   3349:     SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   3350:     .endif
1.1       grant    3351: </pre>
1.75      rillig   3352: </div>
                   3353: <div class="sect1" lang="en">
                   3354: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3355: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
                   3356: <p>As the system administrator, you can choose where configuration files
                   3357: are installed.  The default settings make all these files go into
1.76      rillig   3358: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75      rillig   3359: be suboptimal depending on your expectations (e.g., a read-only,
                   3360: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
                   3361: configuration of the provided packages).</p>
                   3362: <p>In order to change the defaults, you can modify the
                   3363: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76      rillig   3364: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
                   3365: directory; some common examples include <code class="filename">/etc</code> or
                   3366: <code class="filename">/etc/pkg</code>.</p>
1.75      rillig   3367: <p>Furthermore, you can change this value on a per-package basis by
                   3368: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
                   3369: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
                   3370: package you would like to modify, that is, the contents of
                   3371: <code class="varname">PKGBASE</code>.</p>
                   3372: <p>Note that after changing these settings, you must rebuild and
                   3373: reinstall any affected packages.</p>
                   3374: </div>
                   3375: <div class="sect1" lang="en">
                   3376: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3377: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
                   3378: <p>Please be aware that there can often be bugs in third-party software,
                   3379: and some of these bugs can leave a machine vulnerable to exploitation by
                   3380: attackers.  In an effort to lessen the exposure, the NetBSD packages team
                   3381: maintains a database of known-exploits to packages which have at one time
                   3382: been included in pkgsrc.  The database can be downloaded automatically, and
                   3383: a security audit of all packages installed on a system can take place.  To
1.76      rillig   3384: 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   3385: components:</p>
                   3386: <div class="orderedlist"><ol type="1">
                   3387: <li>
                   3388: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
                   3389:     download a list of the security vulnerabilities information.  This list
                   3390:     is kept up to date by the NetBSD security officer and the NetBSD
                   3391:     packages team, and is distributed from the NetBSD ftp server:</p>
                   3392: <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>
                   3393: </li>
                   3394: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
                   3395:     current machine, checking each vulnerability which is known.  If a
                   3396:     vulnerable package is installed, it will be shown by output to stdout,
                   3397:     including a description of the type of vulnerability, and a URL
                   3398:     containing more information.</p></li>
                   3399: </ol></div>
1.76      rillig   3400: <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   3401: package is strongly recommended!  After
                   3402: &#8220;<span class="quote">audit-packages</span>&#8221; is installed, please read
                   3403: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
                   3404: audit-packages</code></strong>.</p>
                   3405: <p>If this package is installed, pkgsrc builds will use it to perform
                   3406: a security check before building any package.  See
                   3407: <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 check.
                   3408: </p>
                   3409: </div>
                   3410: <div class="sect1" lang="en">
                   3411: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3412: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
                   3413: <p>When you add your own preferences to the
                   3414:        <code class="varname">CFLAGS</code> variable in your
1.76      rillig   3415:        <code class="filename">mk.conf</code>, these flags are passed in
                   3416:        environment variables to the <code class="filename">./configure</code>
1.75      rillig   3417:        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
                   3418:        <code class="varname">CFLAGS</code> from the environment variable by
1.76      rillig   3419:        overriding them in the <code class="filename">Makefile</code>s of their
1.75      rillig   3420:        package.</p>
                   3421: <p>Currently there is no solution to this problem. If you
                   3422:        really need the package to use your <code class="varname">CFLAGS</code>
                   3423:        you should run <span><strong class="command">make patch</strong></span> in the package
1.76      rillig   3424:        directory and then inspect any <code class="filename">Makefile</code> and
                   3425:        <code class="filename">Makefile.in</code> for whether they define
1.75      rillig   3426:        <code class="varname">CFLAGS</code> explicitly. Usually you can remove
                   3427:        these lines. But be aware that some &#8220;<span class="quote">smart</span>&#8221;
                   3428:        programmers write so bad code that it only works for the
                   3429:        specific combination of <code class="varname">CFLAGS</code> they have
                   3430:        chosen.</p>
                   3431: </div>
1.80      rillig   3432: <div class="sect1" lang="en">
                   3433: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3434: <a name="ufaq-fail"></a>7.17. A package does not build. What shall I do?</h2></div></div></div>
                   3435: <div class="procedure"><ol type="1">
                   3436: <li><p>Make sure that your copy of pkgsrc is consistent. A
                   3437:        case that occurs often is that people only update pkgsrc in
                   3438:        parts, because of performance reasons. Since pkgsrc is one large
                   3439:        system, not a collection of many small systems, there are
                   3440:        sometimes changes that only work when the whole pkgsrc tree is
                   3441:        updated.</p></li>
                   3442: <li><p>Make sure that you don't have any CVS conflicts.
                   3443:        Search for &#8220;<span class="quote">&lt;&lt;&lt;&lt;&lt;&lt;</span>&#8221; or
                   3444:        &#8220;<span class="quote">&gt;&gt;&gt;&gt;&gt;&gt;</span>&#8221; in all your pkgsrc
                   3445:        files.</p></li>
                   3446: <li><p>Make sure that you don't have old copies of the packages
                   3447:        extracted. Run <span><strong class="command">make clean clean-depends</strong></span> to
                   3448:        verify this.</p></li>
                   3449: <li><p>If the problem still exists, write a mail to the
                   3450:        <code class="literal">pkgsrc-users</code> mailing list.</p></li>
                   3451: </ol></div>
                   3452: </div>
1.75      rillig   3453: </div>
                   3454: </div>
                   3455: <div class="part" lang="en">
                   3456: <div class="titlepage"><div><div><h1 class="title">
                   3457: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77      rillig   3458: <div class="partintro" lang="en">
                   3459: <div></div>
                   3460: <p>This part of the book deals with creating and
                   3461:        modifying packages. It starts with a &#8220;<span class="quote">HOWTO</span>&#8221;-like
                   3462:        guide on creating a new package. The remaining chapters are more
                   3463:        like a reference manual for pkgsrc.</p>
1.75      rillig   3464: <div class="toc">
                   3465: <p><b>Table of Contents</b></p>
                   3466: <dl>
1.77      rillig   3467: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
                   3468: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75      rillig   3469: <dd><dl>
1.77      rillig   3470: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
                   3471: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
                   3472: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
1.85      jmmv     3473: <dd><dl>
                   3474: <dt><span class="sect2"><a href="#components.patches.guidelines">9.3.1. Patching guidelines</a></span></dt>
                   3475: <dt><span class="sect2"><a href="#components.patches.feedback">9.3.2. Feedback to the author</a></span></dt>
                   3476: </dl></dd>
1.77      rillig   3477: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
                   3478: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78      rillig   3479: <dd><dl>
                   3480: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
                   3481: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
                   3482: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
                   3483: </dl></dd>
1.77      rillig   3484: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
                   3485: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
                   3486: </dl></dd>
                   3487: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
                   3488: <dd><dl>
                   3489: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
                   3490: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
                   3491: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
                   3492: <dd><dl>
                   3493: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
                   3494: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
                   3495: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
                   3496: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
                   3497: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
                   3498: </dl></dd>
                   3499: </dl></dd>
                   3500: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
                   3501: <dd><dl>
                   3502: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
                   3503: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
                   3504: <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>
                   3505: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
                   3506: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
                   3507: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
                   3508: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
                   3509: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
                   3510: </dl></dd>
                   3511: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
                   3512: <dd><dl>
                   3513: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
                   3514: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
                   3515: <dd><dl>
                   3516: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
                   3517: <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>
                   3518: </dl></dd>
                   3519: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
                   3520: <dd><dl>
                   3521: <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>
                   3522: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
                   3523: </dl></dd>
                   3524: </dl></dd>
                   3525: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
                   3526: <dd><dl>
                   3527: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
                   3528: <dd><dl>
                   3529: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
                   3530: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
                   3531: </dl></dd>
                   3532: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
                   3533: <dd><dl>
                   3534: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
                   3535: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
                   3536: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
                   3537: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
                   3538: </dl></dd>
                   3539: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
                   3540: <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>
                   3541: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
                   3542: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
                   3543: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
                   3544: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
                   3545: <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>
                   3546: </dl></dd>
                   3547: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
                   3548: <dd><dl>
                   3549: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
                   3550: <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>
                   3551: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
                   3552: </dl></dd>
                   3553: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
                   3554: <dd><dl>
                   3555: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
                   3556: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
                   3557: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
                   3558: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
                   3559: <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   3560: <dd><dl>
                   3561: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
                   3562: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
                   3563: </dl></dd>
1.77      rillig   3564: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
                   3565: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
                   3566: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
                   3567: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
                   3568: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
                   3569: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   3570: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   3571: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
                   3572: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   3573: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
                   3574: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
                   3575: </dl></dd>
                   3576: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
                   3577: <dd><dl>
                   3578: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
                   3579: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
                   3580: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
                   3581: </dl></dd>
                   3582: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
                   3583: <dd><dl>
                   3584: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
                   3585: <dd><dl>
1.78      rillig   3586: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
                   3587: <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>
                   3588: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
                   3589: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
                   3590: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
                   3591: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
                   3592: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
                   3593: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
                   3594: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
                   3595: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
                   3596: <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   3597: <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   3598: </dl></dd>
                   3599: <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>
                   3600: <dd><dl>
                   3601: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
                   3602: <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>
                   3603: </dl></dd>
                   3604: <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>
                   3605: <dd><dl>
                   3606: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
                   3607: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
                   3608: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
                   3609: </dl></dd>
                   3610: <dt><span class="sect1"><a href="#fixes.build">17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   3611: <dd><dl>
1.78      rillig   3612: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
                   3613: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
                   3614: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
                   3615: </dl></dd>
                   3616: <dt><span class="sect1"><a href="#fixes.install">17.5. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   3617: <dd><dl>
                   3618: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
                   3619: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
                   3620: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
                   3621: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
                   3622: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
                   3623: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
                   3624: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
                   3625: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
                   3626: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
                   3627: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
                   3628: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
                   3629: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
                   3630: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
                   3631: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
                   3632: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
                   3633: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
                   3634: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.85      jmmv     3635: <dt><span class="sect2"><a href="#hicolor-theme">17.5.18. Packages installing hicolor theme icons</a></span></dt>
                   3636: <dt><span class="sect2"><a href="#desktop-files">17.5.19. Packages installing desktop files</a></span></dt>
1.77      rillig   3637: </dl></dd>
                   3638: </dl></dd>
                   3639: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
                   3640: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
                   3641: <dd><dl>
                   3642: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
                   3643: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                   3644: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
                   3645: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
                   3646: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
                   3647: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig   3648: </dl></dd>
1.77      rillig   3649: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.85      jmmv     3650: <dt><span class="chapter"><a href="#gnome">21. GNOME packaging and porting</a></span></dt>
                   3651: <dd><dl>
                   3652: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
                   3653: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
                   3654: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
                   3655: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
                   3656: </dl></dd>
1.75      rillig   3657: </dl>
                   3658: </div>
1.77      rillig   3659: </div>
                   3660: <div class="chapter" lang="en">
                   3661: <div class="titlepage"><div><div><h2 class="title">
                   3662: <a name="creating"></a>Chapter 8. Creating a new pkgsrc package from scratch</h2></div></div></div>
                   3663: <p>When you find a package that is not yet in pkgsrc, you
                   3664:        most likely have a URL from where you can download the source
                   3665:        code. Starting with this URL, creating a package involves only a
                   3666:        few steps.</p>
                   3667: <div class="procedure"><ol type="1">
                   3668: <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>
                   3669: <li><p>Then, choose one of the top-level directories as the
                   3670:        category in which you want to place your package. You can also
                   3671:        create a directory of your own (maybe called
                   3672:        <code class="filename">local</code>). In that category directory, create
                   3673:        another directory for your package and change into
                   3674:        it.</p></li>
                   3675: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
                   3676:        will ask you for a URL. Enter the URL of the distribution file
                   3677:        (in most cases a <code class="filename">.tar.gz</code> file) and watch
                   3678:        how the basic ingredients of your package are created
                   3679:        automatically. The distribution file is extracted automatically
                   3680:        to fill in some details in the <code class="filename">Makefile</code>
                   3681:        that would otherwise have to be done manually.</p></li>
                   3682: <li>
                   3683: <p>Examine the extracted files to determine the
                   3684:        dependencies of your package. Ideally, this is mentioned in some
                   3685:        <code class="filename">README</code> file, but things may differ. For
                   3686:        each of these dependencies, look where it exists in pkgsrc, and
                   3687:        if there is a file called <code class="filename">buildlink3.mk</code> in
                   3688:        that directory, add a line to your package
                   3689:        <code class="filename">Makefile</code> which includes that file just
                   3690:        before the last line. If the <code class="filename">buildlink3.mk</code>
                   3691:        file does not exist, add a <code class="varname">DEPENDS</code> line to
                   3692:        the Makefile, which specifies the version of the dependency and
                   3693:        where it can be found in pkgsrc. This line should be placed in
                   3694:        the third paragraph. If the dependency is only needed for
                   3695:        building the package, but not when using it, use
                   3696:        <code class="varname">BUILD_DEPENDS</code> instead of
                   3697:        <code class="varname">DEPENDS</code>. Your package may then look like
                   3698:        this:</p>
                   3699: <pre class="programlisting">
                   3700:     [...]
                   3701: 
                   3702:     BUILD_DEPENDS+= lua&gt;=5.0:../../lang/lua
                   3703:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   3704:     DEPENDS+=       screen&gt;=4.0:../../misc/screen
                   3705: 
                   3706:     [...]
                   3707: 
                   3708:     .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
                   3709:     .include "../../devel/glib2/buildlink3.mk"
                   3710:     .include "../../mk/bsd.pkg.mk"
                   3711: </pre>
                   3712: </li>
                   3713: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
                   3714:        still need to be done to make your package a &#8220;<span class="quote">good</span>&#8221;
                   3715:        one. If you don't know what pkglint's warnings want to tell you,
                   3716:        try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
                   3717:        -e</strong></span>, which outputs additional
                   3718:        explanations.</p></li>
                   3719: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
                   3720:        package. For the various things that can go wrong in this phase,
                   3721:        consult <a href="#fixes" title="Chapter 17. Making your package work">Chapter 17, <i>Making your package work</i></a>.</p></li>
                   3722: <li><p>When the package builds fine, the next step is to
                   3723:        install the package. Run <span><strong class="command">bmake install</strong></span> and
                   3724:        hope that everything works.</p></li>
                   3725: <li><p>Up to now, the file <code class="filename">PLIST</code>,
                   3726:        which contains a list of the files that are installed by the
                   3727:        package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
                   3728:        &gt;PLIST</strong></span> to generate a probably correct list. Check
                   3729:        the file using your preferred text editor to see if the list of
                   3730:        files looks plausible.</p></li>
                   3731: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
                   3732:        generated <code class="filename">PLIST</code> contains garbage or
                   3733:        not.</p></li>
                   3734: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
                   3735:        package has been registered in the database of installed files,
                   3736:        but with an empty list of files. To fix this, run <span><strong class="command">bmake
                   3737:        deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
                   3738:        Now the package is registered with the list of files from
                   3739:        <code class="filename">PLIST</code>.</p></li>
                   3740: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
                   3741:        binary package from the set of installed files.</p></li>
                   3742: </ol></div>
                   3743: </div>
1.75      rillig   3744: <div class="chapter" lang="en">
                   3745: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   3746: <a name="components"></a>Chapter 9. Package components - files, directories and contents</h2></div></div></div>
1.75      rillig   3747: <div class="toc">
                   3748: <p><b>Table of Contents</b></p>
                   3749: <dl>
1.77      rillig   3750: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
                   3751: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
                   3752: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
1.85      jmmv     3753: <dd><dl>
                   3754: <dt><span class="sect2"><a href="#components.patches.guidelines">9.3.1. Patching guidelines</a></span></dt>
                   3755: <dt><span class="sect2"><a href="#components.patches.feedback">9.3.2. Feedback to the author</a></span></dt>
                   3756: </dl></dd>
1.77      rillig   3757: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
                   3758: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78      rillig   3759: <dd><dl>
                   3760: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
                   3761: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
                   3762: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
                   3763: </dl></dd>
1.77      rillig   3764: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
                   3765: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
1.75      rillig   3766: </dl>
                   3767: </div>
                   3768: <p>  Whenever you're preparing a package, there are a number of
                   3769:     files involved which are described in the following
                   3770:     sections. </p>
                   3771: <div class="sect1" lang="en">
                   3772: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   3773: <a name="components.Makefile"></a>9.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75      rillig   3774: <p>Building, installation and creation of a binary package are all
1.76      rillig   3775:       controlled by the package's <code class="filename">Makefile</code>.
                   3776:       The <code class="filename">Makefile</code> describes various things about
1.75      rillig   3777:       a package, for example from where to get it, how to configure,
                   3778:       build, and install it.
                   3779:     </p>
1.76      rillig   3780: <p>A package <code class="filename">Makefile</code> contains several
1.75      rillig   3781:      sections that describe the package.</p>
                   3782: <p>In the first section there are the following variables, which
1.81      rillig   3783:     should appear exactly in the order given here. The ordering and
                   3784:     grouping of variables is mostly historical and has no further
                   3785:     meaning.</p>
1.75      rillig   3786: <div class="itemizedlist"><ul type="disc">
                   3787: <li><p><code class="varname">DISTNAME</code> is the basename of the
                   3788:       distribution file to be downloaded from the package's
                   3789:       website.</p></li>
                   3790: <li><p><code class="varname">PKGNAME</code> is the name of the
                   3791:       package, as used by pkgsrc. You only need to provide it if it
                   3792:       differs from <code class="varname">DISTNAME</code>. Usually it is the directory name together
                   3793:       with the version number. It must match the regular expression
                   3794:       <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
                   3795:       starts with a letter or digit, and contains only letters, digits,
                   3796:       dashes, underscores, dots and plus signs.</p></li>
                   3797: <li>
                   3798: <p><code class="varname">CATEGORIES</code> is a list of categories
                   3799:            which the package fits in. You can choose any of the top-level
                   3800:            directories of pkgsrc for it.</p>
                   3801: <p>Currently the following values are available for
                   3802:          <code class="varname">CATEGORIES</code>. If more than
                   3803:          one is used, they need to be separated by spaces:</p>
                   3804: <pre class="programlisting">
                   3805:     archivers     cross         geography     meta-pkgs     security
                   3806:     audio         databases     graphics      misc          shells
                   3807:     benchmarks    devel         ham           multimedia    sysutils
                   3808:     biology       editors       inputmethod   net           textproc
                   3809:     cad           emulators     lang          news          time
                   3810:     chat          finance       mail          parallel      wm
                   3811:     comms         fonts         math          pkgtools      www
                   3812:     converters    games         mbone         print         x11
1.1       grant    3813: </pre>
1.75      rillig   3814: </li>
1.81      rillig   3815: <li><p><code class="varname">MASTER_SITES</code>,
                   3816:        <code class="varname">DYNAMIC_MASTER_SITES</code>,
                   3817:        <code class="varname">DIST_SUBDIR</code>, <code class="varname">EXTRACT_SUFX</code>
                   3818:        and <code class="varname">DISTFILES</code> are discussed in detail in
                   3819:        <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   3820: </ul></div>
                   3821: <p>The second section contains information about separately
                   3822:       downloaded patches, if any.
                   3823:       </p>
                   3824: <div class="itemizedlist"><ul type="disc">
                   3825: <li><p><code class="varname">PATCHFILES:</code>
                   3826:          Name(s) of additional files that contain distribution patches.
                   3827:          There is no default. pkgsrc will look for them at
                   3828:          <code class="varname">PATCH_SITES</code>.
                   3829:          They will automatically be uncompressed before patching if
1.76      rillig   3830:          the names end with <code class="filename">.gz</code> or
                   3831:          <code class="filename">.Z</code>.</p></li>
1.75      rillig   3832: <li><p><code class="varname">PATCH_SITES</code>:
                   3833:          Primary location(s) for distribution patch files (see
                   3834:          <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
                   3835: </ul></div>
                   3836: <p>
                   3837:     </p>
                   3838: <p>The third section contains the following variables.
                   3839:       </p>
                   3840: <div class="itemizedlist"><ul type="disc">
                   3841: <li><p><code class="varname">MAINTAINER</code> is the email address
                   3842:       of the person who feels responsible for this package, and who is
                   3843:       most likely to look at problems or questions regarding this
                   3844:       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
                   3845:       developers should contact the <code class="varname">MAINTAINER</code> before
                   3846:       making major changes to the package. When packaging a new program,
                   3847:       set <code class="varname">MAINTAINER</code> to yourself. If you really can't
                   3848:       maintain the package for future updates, set it to
                   3849:       <code class="email">&lt;<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>&gt;</code>.</p></li>
                   3850: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
                   3851:       find more information about the package.</p></li>
                   3852: <li><p><code class="varname">COMMENT</code> is a one-line
                   3853:       description of the package (should not include the package
                   3854:       name).</p></li>
                   3855: </ul></div>
                   3856: <p>
                   3857:     </p>
                   3858: <p>Other variables that affect the build:
                   3859:       </p>
                   3860: <div class="itemizedlist"><ul type="disc"><li>
                   3861: <p><code class="varname">WRKSRC</code>: The directory where the
                   3862:          interesting distribution files of the package are found. The
1.76      rillig   3863:          default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
1.75      rillig   3864:          works for most packages.</p>
                   3865: <p>If a package doesn't create a subdirectory for itself
                   3866:          (most GNU software does, for instance), but extracts itself in
                   3867:          the current directory, you should set <code class="varname">WRKSRC=
                   3868:          ${WRKDIR}</code>.</p>
                   3869: <p>If a package doesn't create a subdirectory with the name
                   3870:          of <code class="varname">DISTNAME</code> but some different name, set
                   3871:          <code class="varname">WRKSRC</code> to point to the proper name in
1.76      rillig   3872:          <code class="filename">${WRKDIR}</code>, for example <code class="varname">WRKSRC=
                   3873:          ${WRKDIR}/${DISTNAME}/unix</code>. See <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   3874: <p>The name of the working directory created by pkgsrc is
                   3875:          taken from the <code class="varname">WRKDIR_BASENAME</code> variable. By
1.76      rillig   3876:          default, its value is <code class="filename">work</code>. If you want
1.75      rillig   3877:          to use the same pkgsrc tree for building different kinds of
                   3878:          binary packages, you can change the variable according to your
                   3879:          needs. Two other variables handle common cases of setting
                   3880:          <code class="varname">WRKDIR_BASENAME</code> individually. If
                   3881:          <code class="varname">OBJHOSTNAME</code> is defined in
1.76      rillig   3882:          <code class="filename">/etc/mk.conf</code>, the first component of the
1.75      rillig   3883:          host's name is attached to the directory name. If
                   3884:          <code class="varname">OBJMACHINE</code> is defined, the platform name is
1.76      rillig   3885:          attached, which might look like <code class="filename">work.i386</code>
                   3886:          or <code class="filename">work.sparc</code>.</p>
1.75      rillig   3887: </li></ul></div>
                   3888: <p>
                   3889:     </p>
                   3890: <p>Please pay attention to the following gotchas:</p>
                   3891: <div class="itemizedlist"><ul type="disc">
                   3892: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are installed in
                   3893:           compressed form by the package; see comment in
1.76      rillig   3894:           <code class="filename">bsd.pkg.mk</code>.</p></li>
                   3895: <li><p>Replace <code class="filename">/usr/local</code> with
1.75      rillig   3896:           &#8220;<span class="quote">${PREFIX}</span>&#8221; in all files (see patches, below).</p></li>
                   3897: <li><p>If the package installs any info files, see
1.78      rillig   3898:           <a href="#faq.info-files" title="17.5.7. Packages installing info files">Section 17.5.7, &#8220;Packages installing info files&#8221;</a>.</p></li>
1.75      rillig   3899: </ul></div>
                   3900: </div>
                   3901: <div class="sect1" lang="en">
                   3902: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   3903: <a name="components.distinfo"></a>9.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76      rillig   3904: <p>The <code class="filename">distinfo</code> file contains the message
1.75      rillig   3905:     digest, or checksum, of each distfile needed for the package. This
                   3906:     ensures that the distfiles retrieved from the Internet have not been
                   3907:     corrupted during transfer or altered by a malign force to introduce
                   3908:     a security hole. Due to recent rumor about weaknesses of digest
                   3909:     algorithms, all distfiles are protected using both SHA1 and RMD160
                   3910:     message digests, as well as the file size.</p>
1.76      rillig   3911: <p>The <code class="filename">distinfo</code> file also contains the
1.75      rillig   3912:     checksums for all the patches found in the
1.77      rillig   3913:     <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   3914: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.75      rillig   3915:     <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
                   3916:     command.</p>
                   3917: <p>Some packages have different sets of distfiles depending on
1.76      rillig   3918:     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
                   3919:     <code class="filename">distinfo</code> file and care should be taken when
1.75      rillig   3920:     upgrading such a package to ensure distfile information is not
                   3921:     lost.</p>
                   3922: </div>
                   3923: <div class="sect1" lang="en">
                   3924: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   3925: <a name="components.patches"></a>9.3. patches/*</h2></div></div></div>
1.75      rillig   3926: <p>This directory contains files that are used by the
                   3927:       <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
                   3928:       modify the sources as distributed in the distribution file into a form
                   3929:       that will compile and run perfectly on NetBSD. The files are applied
                   3930:       successively in alphabetic order (as returned by a shell
                   3931:       &#8220;<span class="quote">patches/patch-*</span>&#8221; glob expansion), so
1.76      rillig   3932:       <code class="filename">patch-aa</code> is applied before
                   3933:       <code class="filename">patch-ab</code>, etc.</p>
                   3934: <p>The <code class="filename">patch-*</code> files should be in
1.75      rillig   3935:       <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
                   3936:       problems. (To force patches to apply
                   3937:       with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
                   3938:       Furthermore, do not put changes for more than one file into a single
                   3939:       patch file, as this will make future modifications more difficult.</p>
                   3940: <p>Similar, a file should be patched at most once, not several times by
                   3941:       several different patches. If a file needs several patches, they should
                   3942:       be combined into one file.</p>
                   3943: <p>One important thing to mention is to pay attention that no RCS IDs
                   3944:       get stored in the patch files, as these will cause problems when
                   3945:       later checked into the NetBSD CVS tree. Use the
                   3946:       <span><strong class="command">pkgdiff</strong></span> from the
1.76      rillig   3947:       <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
1.75      rillig   3948:       these problems.</p>
                   3949: <p>For even more automation, we recommend using <span><strong class="command">mkpatches</strong></span> from the same
                   3950:       package to make a whole set of patches. You just have to backup files
1.76      rillig   3951:       before you edit them to <code class="filename">filename.orig</code>, e.g. with
1.75      rillig   3952:       <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by using
                   3953:       <span><strong class="command">pkgvi</strong></span> again from the same package. If you upgrade a package
                   3954:       this way, you can easily compare the new set of patches with the
                   3955:       previously existing one with <span><strong class="command">patchdiff</strong></span>.</p>
                   3956: <p>When you have finished a package, remember to generate the checksums
                   3957:       for the patch files by using the <span><strong class="command">make makepatchsum</strong></span>
1.77      rillig   3958:       command, see <a href="#components.distinfo" title="9.2. distinfo">Section 9.2, &#8220;<code class="filename">distinfo</code>&#8221;</a>.</p>
1.75      rillig   3959: <p>Patch files that are distributed by the author or other
                   3960:       maintainers can be listed in
                   3961:       <code class="varname">$PATCHFILES</code>. </p>
                   3962: <p>If it is desired to store any patches that should not be committed into
                   3963:       pkgsrc, they can be kept outside the pkgsrc tree in the
1.76      rillig   3964:       <code class="filename">$LOCALPATCHES</code>
1.75      rillig   3965:       directory. The directory tree there is expected to have the same
                   3966:       &#8220;<span class="quote">category/package</span>&#8221; structure as pkgsrc, and patches are
                   3967:       expected to be stored inside these dirs (also known as
1.76      rillig   3968:       <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
1.75      rillig   3969:       example, if you want to keep a private patch for
1.76      rillig   3970:       <code class="filename">pkgsrc/graphics/png</code>, keep
                   3971:       it in <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
1.75      rillig   3972:       files in the named directory are expected to be patch files, and
                   3973:       <span class="emphasis"><em>they are applied after pkgsrc patches are applied</em></span>.</p>
1.85      jmmv     3974: <div class="sect2" lang="en">
                   3975: <div class="titlepage"><div><div><h3 class="title">
                   3976: <a name="components.patches.guidelines"></a>9.3.1. Patching guidelines</h3></div></div></div>
                   3977: <p>When fixing a portability issue in the code do not use
                   3978:       preprocessor magic to check for the current operating system nor
                   3979:       platform.  Doing so hurts portability to other platforms because
                   3980:       the OS-specific details are not abstracted appropriately.</p>
                   3981: <p>The general rule to follow is: instead of checking for the
                   3982:       operating system the application is being built on, check for the
                   3983:       specific <span class="emphasis"><em>features</em></span> you need.  For example,
                   3984:       instead of assuming that kqueue is available under NetBSD and
                   3985:       using the <code class="varname">__NetBSD__</code> macro to conditionalize
                   3986:       kqueue support, add a check that detects kqueue itself &mdash;
                   3987:       yes, this generally involves patching the
                   3988:       <span><strong class="command">configure</strong></span> script.  There is absolutely nothing
                   3989:       that prevents some OSes from adopting interfaces from other OSes
                   3990:       (e.g. Linux implementing kqueue), something that the above checks
                   3991:       cannot take into account.</p>
                   3992: <p>Of course, checking for features generally involves more
                   3993:       work on the developer's side, but the resulting changes are
                   3994:       clearner and there are chances they will work on many other
                   3995:       platforms.  Not to mention that there are higher chances of being
                   3996:       later integrated into the mainstream sources.  Remember:
                   3997:       <span class="emphasis"><em>It doesn't work unless it is right!</em></span></p>
                   3998: <p>Some typical examples:</p>
                   3999: <div class="table">
                   4000: <a name="patch-examples"></a><p class="title"><b>Table 9.1. Patching examples</b></p>
                   4001: <div class="table-contents"><table summary="Patching examples" border="1">
                   4002: <colgroup>
                   4003: <col>
                   4004: <col>
                   4005: <col>
                   4006: </colgroup>
                   4007: <thead><tr>
                   4008: <th>Where</th>
                   4009: <th>Incorrect</th>
                   4010: <th>Correct</th>
                   4011: </tr></thead>
                   4012: <tbody>
                   4013: <tr>
                   4014: <td>configure script</td>
                   4015: <td>
                   4016:                <pre class="programlisting">case ${target_os} in
                   4017:       netbsd*) have_kvm=yes ;;
                   4018:       *)       have_kvm=no  ;;
                   4019:   esac</pre>
                   4020:              </td>
                   4021: <td>
                   4022:                <pre class="programlisting">AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)</pre>
                   4023:              </td>
                   4024: </tr>
                   4025: <tr>
                   4026: <td>C source file</td>
                   4027: <td>
                   4028:                <pre class="programlisting">#if defined(__NetBSD__)
                   4029:   #  include &lt;sys/event.h&gt;
                   4030:   #endif</pre>
                   4031:              </td>
                   4032: <td>
                   4033:                <pre class="programlisting">#if defined(HAVE_SYS_EVENT_H)
                   4034:   #  include &lt;sys/event.h&gt;
                   4035:   #endif</pre>
                   4036:              </td>
                   4037: </tr>
                   4038: <tr>
                   4039: <td>C source file</td>
                   4040: <td>
                   4041: <pre class="programlisting">int
                   4042:   monitor_file(...)
                   4043:   {
                   4044:   #if defined(__NetBSD__)
                   4045:       int fd = kqueue();
                   4046:       ...
                   4047:   #else
                   4048:       ...
                   4049:   #endif
                   4050:   }</pre>
                   4051:              </td>
                   4052: <td>
                   4053:                <pre class="programlisting">int
                   4054:   monitor_file(...)
                   4055:   {
                   4056:   #if defined(HAVE_KQUEUE)
                   4057:       int fd = kqueue();
                   4058:       ...
                   4059:   #else
                   4060:       ...
                   4061:   #endif
                   4062:   }</pre>
                   4063:              </td>
                   4064: </tr>
                   4065: </tbody>
                   4066: </table></div>
                   4067: </div>
                   4068: <br class="table-break"><p>For more information, please read the <span class="emphasis"><em>Making
                   4069:       packager-friendly software</em></span> article (<a href="http://www.onlamp.com/pub/a/onlamp/2005/03/31/packaging.html" target="_top">part
                   4070:       1</a>, <a href="http://www.oreillynet.com/pub/a/onlamp/2005/04/28/packaging2.html" target="_top">part
                   4071:       2</a>).  It summarizes multiple details on how to make
                   4072:       software easier to package; all the suggestions in it were
                   4073:       collected from our experience in pkgsrc work, so they are possibly
                   4074:       helpful when creating patches too.</p>
                   4075: </div>
                   4076: <div class="sect2" lang="en">
                   4077: <div class="titlepage"><div><div><h3 class="title">
                   4078: <a name="components.patches.feedback"></a>9.3.2. Feedback to the author</h3></div></div></div>
                   4079: <p>Always, always, <span class="strong"><strong>always</strong></span>
                   4080:       feed back any <span class="emphasis"><em>portability fixes</em></span> or
                   4081:       improvements you do to a package to the mainstream developers.
                   4082:       This is the only way to get their attention on portability issues
                   4083:       and to ensure that future versions can be built out-of-the box on
                   4084:       NetBSD.  Furthermore, any user that gets newer distfiles will get
                   4085:       the fixes straight from the packaged code.</p>
                   4086: <p>This generally involves cleaning up the patches as described
                   4087:       in the following section (because sometimes the patches that are
                   4088:       added to pkgsrc are quick hacks), filling bug reports in the
                   4089:       appropriate trackers for the projects and working with the
                   4090:       mainstream authors to accept your changes.  It is
                   4091:       <span class="emphasis"><em>extremely important</em></span> that you do it so that
                   4092:       the packages in pkgsrc are kept simple and thus further changes
                   4093:       can be done without much hassle.</p>
                   4094: <p>Support the idea of free software!</p>
                   4095: </div>
1.75      rillig   4096: </div>
                   4097: <div class="sect1" lang="en">
                   4098: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4099: <a name="other-mandatory-files"></a>9.4. Other mandatory files</h2></div></div></div>
1.75      rillig   4100: <div class="variablelist"><dl>
1.76      rillig   4101: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75      rillig   4102: <dd><p>A multi-line description of the piece of software.  This should include
                   4103:             any credits where they are due.  Please bear in mind that others do not
                   4104:             share your sense of humour (or spelling idiosyncrasies), and that others
                   4105:             will read everything that you write here.</p></dd>
1.76      rillig   4106: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.75      rillig   4107: <dd><p>
                   4108:             This file governs the files that are installed on your system: all the
                   4109:             binaries, manual pages, etc. There are other directives which may be
                   4110:             entered in this file, to control the creation and deletion of
                   4111:             directories, and the location of inserted files.
1.77      rillig   4112:             See <a href="#plist" title="Chapter 11. PLIST issues">Chapter 11, <i>PLIST issues</i></a> for more information. </p></dd>
1.75      rillig   4113: </dl></div>
                   4114: </div>
                   4115: <div class="sect1" lang="en">
                   4116: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4117: <a name="components.optional"></a>9.5. Optional files</h2></div></div></div>
1.78      rillig   4118: <div class="sect2" lang="en">
                   4119: <div class="titlepage"><div><div><h3 class="title">
                   4120: <a name="components.optional.bin"></a>9.5.1. Files affecting the binary package</h3></div></div></div>
1.75      rillig   4121: <div class="variablelist"><dl>
1.76      rillig   4122: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75      rillig   4123: <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>.
                   4124:             First time after package
                   4125:             extraction and before files are moved in place, the second time after
                   4126:             the files to install are moved in place. This can be used to do any
                   4127:             custom procedures not possible with @exec commands in
1.76      rillig   4128:             <code class="filename">PLIST</code>. See
1.75      rillig   4129:             <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 <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   4130: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75      rillig   4131: <dd><p>This script is executed before and after any files are removed.  It is
                   4132:             this script's responsibility to clean up any additional messy details
                   4133:             around the package's installation, since all pkg_delete knows is how to
                   4134:             delete the files created in the original distribution.
                   4135:             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>
                   4136:             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   4137: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75      rillig   4138: <dd>
                   4139: <p>This file is displayed after installation of the package.
                   4140:             Useful for things like legal notices on almost-free
                   4141:             software and hints for updating config files after
                   4142:             installing modules for apache, PHP etc.
                   4143:             Please note that you can modify variables in it easily by using
                   4144:             <code class="varname">MESSAGE_SUBST</code> in the package's
1.76      rillig   4145:             <code class="filename">Makefile</code>:</p>
1.75      rillig   4146: <pre class="programlisting">
                   4147:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
1.1       grant    4148: </pre>
1.75      rillig   4149: <p>replaces "${SOMEVAR}" with &#8220;<span class="quote">somevalue</span>&#8221; in
1.76      rillig   4150:             <code class="filename">MESSAGE</code>.</p>
1.75      rillig   4151: </dd>
1.78      rillig   4152: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
                   4153: <dd><p>FIXME: There is no documentation on the
                   4154:        alternatives framework.</p></dd>
                   4155: </dl></div>
                   4156: </div>
                   4157: <div class="sect2" lang="en">
                   4158: <div class="titlepage"><div><div><h3 class="title">
                   4159: <a name="components.optional.build"></a>9.5.2. Files affecting the build process</h3></div></div></div>
                   4160: <div class="variablelist"><dl>
                   4161: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
                   4162: <dd><p>This file contains arbitrary things that could
                   4163:        also go into a <code class="filename">Makefile</code>, but its purpose is
                   4164:        to be used by more than one package. This file should only be
                   4165:        used when the packages that will use the file are known in
                   4166:        advance. For other purposes it is often better to write a
                   4167:        <code class="filename">*.mk</code> file and give it a good name that
                   4168:        describes what it does.</p></dd>
                   4169: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
                   4170: <dd><p>This file contains the dependency information
                   4171:        for the buildlink3 framework (see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p></dd>
                   4172: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
                   4173: <dd><p>This file contains workarounds for compiler bugs
                   4174:        and similar things. It is included automatically by the pkgsrc
                   4175:        infrastructure, so you don't need an extra
                   4176:        <code class="literal">.include</code> line for
                   4177:        it.</p></dd>
                   4178: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
                   4179: <dd><p>This file contains the code for the
                   4180:        package-specific options (see <a href="#options" title="Chapter 14. Options handling">Chapter 14, <i>Options handling</i></a>) that can be
                   4181:        selected by the user. If a package has only one or two options,
                   4182:        it is equally acceptable to put the code directly into the
                   4183:        <code class="filename">Makefile</code>.</p></dd>
                   4184: </dl></div>
                   4185: </div>
                   4186: <div class="sect2" lang="en">
                   4187: <div class="titlepage"><div><div><h3 class="title">
                   4188: <a name="components.optional.none"></a>9.5.3. Files affecting nothing at all</h3></div></div></div>
                   4189: <div class="variablelist"><dl>
                   4190: <dt><span class="term"><code class="filename">README*</code></span></dt>
                   4191: <dd><p>These files do not take place in the creation of
                   4192:        a package and thus are purely informative to the package
                   4193:        developer.</p></dd>
                   4194: <dt><span class="term"><code class="filename">TODO</code></span></dt>
                   4195: <dd><p>This file contains things that need to be done
                   4196:        to make the package even
                   4197:        better.</p></dd>
1.75      rillig   4198: </dl></div>
                   4199: </div>
1.78      rillig   4200: </div>
1.75      rillig   4201: <div class="sect1" lang="en">
                   4202: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4203: <a name="work-dir"></a>9.6. <code class="filename">work*</code></h2></div></div></div>
1.75      rillig   4204: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
                   4205:       unpacked into the directory denoted by
                   4206:       <code class="varname">WRKDIR</code>. It can be removed by running
                   4207:       <span><strong class="command">make clean</strong></span>. Besides the sources, this
                   4208:       directory is also used to keep various timestamp files.
                   4209:       The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
1.76      rillig   4210:       The default is <code class="filename">${.CURDIR}/work</code>
                   4211:       or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
1.75      rillig   4212:       if <code class="varname">OBJMACHINE</code> is set.</p>
                   4213: </div>
                   4214: <div class="sect1" lang="en">
                   4215: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4216: <a name="files-dir"></a>9.7. <code class="filename">files/*</code></h2></div></div></div>
1.75      rillig   4217: <p>If you have any files that you wish to be placed in the package prior
                   4218:       to configuration or building, you could place these files here and use
                   4219:       a &#8220;<span class="quote">${CP}</span>&#8221; command in the
                   4220:       &#8220;<span class="quote">pre-configure</span>&#8221; target to achieve
                   4221:       this. Alternatively, you could simply diff the file against
1.76      rillig   4222:       <code class="filename">/dev/null</code> and use the patch mechanism to manage
1.75      rillig   4223:       the creation of this file.</p>
                   4224: </div>
                   4225: </div>
                   4226: <div class="chapter" lang="en">
                   4227: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   4228: <a name="makefile"></a>Chapter 10. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75      rillig   4229: <div class="toc">
                   4230: <p><b>Table of Contents</b></p>
                   4231: <dl>
1.77      rillig   4232: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
                   4233: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
                   4234: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
                   4235: <dd><dl>
                   4236: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
                   4237: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
                   4238: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
                   4239: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
                   4240: <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   4241: </dl></dd>
                   4242: </dl>
                   4243: </div>
1.76      rillig   4244: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75      rillig   4245:   each of which forms a well-defined part of the pkgsrc system. Using
                   4246:   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
                   4247:   like pkgsrc requires some discipline to keep the code correct and
                   4248:   understandable.</p>
1.76      rillig   4249: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75      rillig   4250:   programming are variables (which are actually macros) and shell
                   4251:   commands. Among these shell commands may even be more complex ones
                   4252:   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
                   4253:   as intended it is necessary to quote all variables correctly when they
                   4254:   are used.</p>
                   4255: <p>This chapter describes some patterns, that appear quite often in
1.76      rillig   4256:   <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75      rillig   4257:   with them.</p>
                   4258: <div class="sect1" lang="en">
                   4259: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4260: <a name="makefile.variables"></a>10.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76      rillig   4261: <p><code class="filename">Makefile</code> variables contain strings that
1.75      rillig   4262:     can be processed using the five operators ``='', ``+='', ``?='',
                   4263:     ``:='', 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
                   4264:     page.</p>
                   4265: <p>When a variable's value is parsed from a
1.76      rillig   4266:     <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75      rillig   4267:     backslash character ``\'' are handled specially. If a backslash is
                   4268:     followed by a newline, any whitespace immediately in front of the
                   4269:     backslash, the backslash, the newline, and any whitespace
                   4270:     immediately behind the newline are replaced with a single space. A
                   4271:     backslash character and an immediately following hash character are
                   4272:     replaced with a single hash character. Otherwise, the backslash is
                   4273:     passed as is. In a variable assignment, any hash character that is
                   4274:     not preceded by a backslash starts a comment that continues upto the
                   4275:     end of the logical line.</p>
                   4276: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
                   4277:     the only way to create a variable consisting of a single backslash
                   4278:     is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
                   4279: <p>So far for defining variables. The other thing you can do with
                   4280:     variables is evaluating them. A variable is evaluated when it is
                   4281:     part of the right side of the ``:='' or the ``!='' operator, or
                   4282:     directly before executing a shell command which the variable is part
                   4283:     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
                   4284:     is, variables are not evaluated until there's no other way. The
                   4285:     ``modifiers'' mentioned in the man page also evaluate the
                   4286:     variable.</p>
                   4287: <p>Some of the modifiers split the string into words and then
                   4288:     operate on the words, others operate on the string as a whole. When
                   4289:     a string is split into words, it is split as you would expect
                   4290:     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.85      jmmv     4291: <p>No rule without exception&mdash;the <span><strong class="command">.for</strong></span>
1.75      rillig   4292:     loop does not follow the shell quoting rules but splits at sequences
                   4293:     of whitespace.</p>
                   4294: <p>There are several types of variables that should be handled
                   4295:     differently. Strings and two types of lists.</p>
                   4296: <div class="itemizedlist"><ul type="disc">
                   4297: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
                   4298:       characters. Nevertheless, you should restrict yourself to only
                   4299:       using printable characters. Examples are
                   4300:       <code class="varname">PREFIX</code> and
                   4301:       <code class="varname">COMMENT</code>.</p></li>
                   4302: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
                   4303:       are never exported to any shell command. Their elements are
                   4304:       separated by whitespace. Therefore, the elements themselves cannot
                   4305:       have embedded whitespace. Any other characters are allowed.
                   4306:       Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
                   4307:       Examples are <code class="varname">DEPENDS</code> and
                   4308:       <code class="varname">BUILD_DEPENDS</code>.</p></li>
                   4309: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
                   4310:       may be exported to a shell command. Their elements can contain any
                   4311:       characters, including whitespace. That's why they cannot be used
                   4312:       in <span><strong class="command">.for</strong></span> loops. Examples are
                   4313:       <code class="varname">DISTFILES</code> and
                   4314:       <code class="varname">MASTER_SITES</code>.</p></li>
                   4315: </ul></div>
                   4316: <div class="sect2" lang="en">
                   4317: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4318: <a name="makefile.variables.names"></a>10.1.1. Naming conventions</h3></div></div></div>
1.75      rillig   4319: <div class="itemizedlist"><ul type="disc">
                   4320: <li><p>All variable names starting with an underscore
                   4321:        are reserved for use by the pkgsrc infrastructure. They shall
                   4322:        not be used by package
1.76      rillig   4323:        <code class="filename">Makefile</code>s.</p></li>
1.75      rillig   4324: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
                   4325:        lowercase variable names for the iteration
                   4326:        variables.</p></li>
                   4327: <li><p>All list variables should have a ``plural''
                   4328:        name, e.g. <code class="varname">PKG_OPTIONS</code> or
                   4329:        <code class="varname">DISTFILES</code>.</p></li>
                   4330: </ul></div>
                   4331: </div>
                   4332: </div>
                   4333: <div class="sect1" lang="en">
                   4334: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4335: <a name="makefile.code"></a>10.2. Code snippets</h2></div></div></div>
1.75      rillig   4336: <p>This section presents you with some code snippets you should
                   4337:     use in your own code. If you don't find anything appropriate here,
                   4338:     you should test your code and add it here.</p>
                   4339: <div class="sect2" lang="en">
                   4340: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4341: <a name="adding-to-list"></a>10.2.1. Adding things to a list</h3></div></div></div>
1.75      rillig   4342: <pre class="programlisting">
                   4343:     STRING=                 foo * bar `date`
                   4344:     INT_LIST=               # empty
                   4345:     ANOTHER_INT_LIST=       apache-[0-9]*:../../www/apache
                   4346:     EXT_LIST=               # empty
                   4347:     ANOTHER_EXT_LIST=       a=b c=d
1.1       grant    4348: 
1.75      rillig   4349:     INT_LIST+=              ${STRING}               # 1
                   4350:     INT_LIST+=              ${ANOTHER_INT_LIST}     # 2
                   4351:     EXT_LIST+=              ${STRING:Q}             # 3
                   4352:     EXT_LIST+=              ${ANOTHER_EXT_LIST}     # 4
1.1       grant    4353: </pre>
1.75      rillig   4354: <p>When you add a string to an external list (example 3), it
                   4355:       must be quoted. In all other cases, you must not add a quoting
                   4356:       level. You must not merge internal and external lists, unless you
                   4357:       are sure that all entries are correctly interpreted in both
                   4358:       lists.</p>
                   4359: </div>
                   4360: <div class="sect2" lang="en">
                   4361: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4362: <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   4363: <pre class="programlisting">
                   4364:     EXT_LIST=       # empty
                   4365:     .for i in ${INT_LIST}
                   4366:     EXT_LIST+=      ${i:Q}""
                   4367:     .endfor
1.1       grant    4368: </pre>
1.75      rillig   4369: <p>This code converts the internal list
                   4370:       <code class="varname">INT_LIST</code> into the external list
                   4371:       <code class="varname">EXT_LIST</code>. As the elements of an internal list
                   4372:       are unquoted they must be quoted here. The reason for appending
                   4373:       <code class="varname">""</code> is explained below.</p>
                   4374: </div>
                   4375: <div class="sect2" lang="en">
                   4376: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4377: <a name="passing-variable-to-shell"></a>10.2.3. Passing variables to a shell command</h3></div></div></div>
1.79      rillig   4378: <p>Sometimes you may want to print an arbitrary string. There
                   4379:        are many ways to get it wrong and only few that can handle every
                   4380:        nastiness.</p>
1.75      rillig   4381: <pre class="programlisting">
                   4382:     STRING=         foo bar &lt;    &gt; * `date` $$HOME ' "
                   4383:     EXT_LIST=       string=${STRING:Q} x=second\ item
1.1       grant    4384: 
1.75      rillig   4385:     all:
                   4386:             echo ${STRING}                  # 1
                   4387:             echo "${STRING}"                # 2
                   4388:             echo "${STRING:Q}"              # 3
                   4389:             echo ${STRING:Q}                # 4
                   4390:             echo x${STRING:Q} | sed 1s,.,,  # 5
1.79      rillig   4391:             printf "%s\\n" ${STRING:Q}""    # 6
1.75      rillig   4392:             env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1       grant    4393: </pre>
1.75      rillig   4394: <p>Example 1 leads to a syntax error in the shell, as the
                   4395:       characters are just copied.</p>
                   4396: <p>Example 2 leads to a syntax error too, and if you leave out
                   4397:       the last " character from <code class="varname">${STRING}</code>,
                   4398:       <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
                   4399:       variable would be evaluated, too.</p>
                   4400: <p>Example 3 outputs each space character preceded by a
                   4401:       backslash (or not), depending on the implementation of the
                   4402:       <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>
                   4403: <p>Example 4 handles correctly every string that does not start
                   4404:       with a dash. In that case, the result depends on the
                   4405:       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
                   4406:       guarantee that your input does not start with a dash, this form is
                   4407:       appropriate.</p>
                   4408: <p>Example 5 handles even the case of a leading dash
                   4409:       correctly.</p>
1.79      rillig   4410: <p>Example 6 also works with every string and is the
                   4411:       light-weight solution, since it does not involve a pipe, which has
                   4412:       its own problems.</p>
1.75      rillig   4413: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
                   4414:       because the quoting has already been done when adding elements to
                   4415:       the list.</p>
                   4416: <p>As internal lists shall not be passed to the shell, there is
                   4417:       no example for it.</p>
                   4418: </div>
                   4419: <div class="sect2" lang="en">
                   4420: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4421: <a name="quoting-guideline"></a>10.2.4. Quoting guideline</h3></div></div></div>
1.75      rillig   4422: <p>There are many possible sources of wrongly quoted variables.
                   4423:       This section lists some of the commonly known ones.</p>
                   4424: <div class="itemizedlist"><ul type="disc">
                   4425: <li>
                   4426: <p>Whenever you use the value of a list, think
                   4427:        about what happens to leading or trailing whitespace. If the
                   4428:        list is a well-formed shell expression, you can apply the
                   4429:        <code class="varname">:M*</code> modifier to strip leading and trailing
                   4430:        whitespace from each word. The <code class="varname">:M</code> operator
                   4431:        first splits its argument according to the rules of the shell,
                   4432:        and then creates a new list consisting of all words that match
                   4433:        the shell glob expression <code class="varname">*</code>, that is: all.
                   4434:        One class of situations where this is needed is when adding a
                   4435:        variable like <code class="varname">CPPFLAGS</code> to
                   4436:        <code class="varname">CONFIGURE_ARGS</code>. If the configure script
                   4437:        invokes other configure scripts, it strips the leading and
                   4438:        trailing whitespace from the variable and then passes it to the
                   4439:        other configure scripts. But these configure scripts expect the
                   4440:        (child) <code class="varname">CPPFLAGS</code> variable to be the same as
                   4441:        the parent <code class="varname">CPPFLAGS</code>. That's why we better
                   4442:        pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
                   4443:        here is how we do it:</p>
                   4444: <pre class="programlisting">
                   4445:     CPPFLAGS=               # empty
                   4446:     CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX:Q}\"
                   4447:     CPPFLAGS+=              ${MY_CPPFLAGS}
1.1       grant    4448: 
1.75      rillig   4449:     CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
1.1       grant    4450: 
1.75      rillig   4451:     all:
                   4452:             echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   4453:             echo x${CONFIGURE_ARGS}x        # properly trimmed
1.1       grant    4454: </pre>
1.75      rillig   4455: </li>
                   4456: <li><p>The example above contains one bug: The
                   4457:        <code class="varname">${PREFIX}</code> is a properly quoted shell
                   4458:        expression, but there is the C compiler after it, which also
                   4459:        expects a properly quoted string (this time in C syntax). The
                   4460:        version above is therefore only correct if
                   4461:        <code class="varname">${PREFIX}</code> does not have embedded backslashes
                   4462:        or double quotes. If you want to allow these, you have to add
                   4463:        another layer of quoting to each variable that is used as a C
                   4464:        string literal. You cannot use the <code class="varname">:Q</code>
                   4465:        operator for it, as this operator only works for the
                   4466:        shell.</p></li>
                   4467: <li>
                   4468: <p>Whenever a variable can be empty, the
                   4469:        <code class="varname">:Q</code> operator can have surprising results. Here
                   4470:        are two completely different cases which can be solved with the
                   4471:        same trick.</p>
                   4472: <pre class="programlisting">
                   4473:     EMPTY=                  # empty
                   4474:     empty_test:
                   4475:             for i in a ${EMPTY:Q} c; do \
                   4476:                     echo "$$i"; \
                   4477:             done
1.1       grant    4478: 
1.75      rillig   4479:     for_test:
                   4480:     .for i in a:\ a:\test.txt
                   4481:             echo ${i:Q}
                   4482:             echo "foo"
                   4483:     .endfor
1.1       grant    4484: </pre>
1.75      rillig   4485: <p>The first example will only print two of the three lines
                   4486:        we might have expected. This is because
                   4487:        <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
                   4488:        the shell cannot see. The workaround is to write
                   4489:        <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
                   4490:        as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
                   4491:        -f ${FNAME:Q}</code> (both of these are wrong).</p>
                   4492: <p>The second example will only print three lines instead of
                   4493:        four. The first line looks like <code class="varname">a:\ echo foo</code>.
                   4494:        This is because the backslash of the value
                   4495:        <code class="varname">a:\</code> is interpreted as a line-continuation by
                   4496:        <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
                   4497:        <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
                   4498:        <code class="varname">${i:Q}""</code>.</p>
                   4499: </li>
                   4500: </ul></div>
                   4501: </div>
                   4502: <div class="sect2" lang="en">
                   4503: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4504: <a name="bsd-make-bug-workaround"></a>10.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75      rillig   4505: <p>The pkgsrc bmake program does not handle the following
                   4506:       assignment correctly. In case <code class="varname">_othervar_</code>
                   4507:       contains a ``-'' character, one of the closing braces is included
                   4508:       in <code class="varname">${VAR}</code> after this code executes.</p>
                   4509: <pre class="programlisting">
                   4510:     VAR:=   ${VAR:N${_othervar_:C/-//}}
1.1       grant    4511: </pre>
1.75      rillig   4512: <p>For a more complex code snippet and a workaround, see the
1.76      rillig   4513:       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   4514:       <code class="varname">bug1</code>.</p>
                   4515: </div>
                   4516: </div>
                   4517: </div>
                   4518: <div class="chapter" lang="en">
                   4519: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   4520: <a name="plist"></a>Chapter 11. PLIST issues</h2></div></div></div>
1.75      rillig   4521: <div class="toc">
                   4522: <p><b>Table of Contents</b></p>
                   4523: <dl>
1.77      rillig   4524: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
                   4525: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
                   4526: <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>
                   4527: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
                   4528: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
                   4529: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
                   4530: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
                   4531: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
1.75      rillig   4532: </dl>
                   4533: </div>
1.76      rillig   4534: <p> The <code class="filename">PLIST</code> file contains a package's
1.75      rillig   4535:     &#8220;<span class="quote">packing list</span>&#8221;, i.e. a list of files that belong to
1.76      rillig   4536:     the package (relative to the <code class="filename">${PREFIX}</code>
1.75      rillig   4537:     directory it's been installed in) plus some additional statements
                   4538:     - 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.
                   4539:     This chapter addresses some issues that need attention when
1.76      rillig   4540:     dealing with the <code class="filename">PLIST</code> file (or files, see
1.75      rillig   4541:     below!).</p>
                   4542: <div class="sect1" lang="en">
                   4543: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4544: <a name="rcs-id"></a>11.1. RCS ID</h2></div></div></div>
1.75      rillig   4545: <p>
                   4546:       Be sure to add a RCS ID line as the first thing in any
1.76      rillig   4547:       <code class="filename">PLIST</code> file you write:
1.75      rillig   4548:     </p>
                   4549: <pre class="programlisting">
                   4550:     @comment $NetBSD$
1.55      rillig   4551: </pre>
1.75      rillig   4552: </div>
                   4553: <div class="sect1" lang="en">
                   4554: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4555: <a name="automatic-plist-generation"></a>11.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75      rillig   4556: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
                   4557:       to output a PLIST that matches any new files since the package
1.77      rillig   4558:       was extracted.  See <a href="#build.helpful-targets" title="15.16. Other helpful targets">Section 15.16, &#8220;Other helpful targets&#8221;</a> for
1.75      rillig   4559:       more information on this target.</p>
                   4560: </div>
                   4561: <div class="sect1" lang="en">
                   4562: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4563: <a name="print-PLIST"></a>11.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></h2></div></div></div>
1.75      rillig   4564: <p> If you have used any of the *-dirs packages, as explained in
1.77      rillig   4565:       <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
1.75      rillig   4566:       <span><strong class="command">make print-PLIST</strong></span> outputs a set of
                   4567:       <code class="varname">@comment</code>s instead of real
                   4568:       <code class="varname">@dirrm</code> lines.  You can also do this for
                   4569:       specific directories and files, so that the results of that
                   4570:       command are very close to reality. This helps <span class="emphasis"><em>a
                   4571:       lot</em></span> during the update of packages. </p>
                   4572: <p> The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
                   4573:       of AWK patterns and actions that are used to filter the output of
                   4574:       print-PLIST.  You can <span class="emphasis"><em>append</em></span> any chunk of AWK
                   4575:       scripting you like to it, but be careful with quoting. </p>
                   4576: <p> For example, to get all files inside the
1.76      rillig   4577:       <code class="filename">libdata/foo</code> directory removed from the
1.75      rillig   4578:       resulting PLIST:</p>
                   4579: <pre class="programlisting">
                   4580:     PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
1.55      rillig   4581: </pre>
1.75      rillig   4582: <p> And to get all the <code class="varname">@dirrm</code> lines referring
                   4583:       to a specific (shared) directory converted to
                   4584:       <code class="varname">@comment</code>s: </p>
                   4585: <pre class="programlisting">
                   4586:     PRINT_PLIST_AWK+=       /^@dirrm share\/specific/ { print "@comment " $$0; next; }
1.51      rillig   4587: </pre>
1.75      rillig   4588: </div>
                   4589: <div class="sect1" lang="en">
                   4590: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4591: <a name="plist.misc"></a>11.4. Variable substitution in PLIST</h2></div></div></div>
1.75      rillig   4592: <p>
                   4593:       A number of variables are substituted automatically in PLISTs
                   4594:       when a package is installed on a system. This includes the
                   4595:       following variables: </p>
                   4596: <div class="variablelist"><dl>
                   4597: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
                   4598: <dd>
                   4599: <p>Some packages like emacs and perl embed information
                   4600:             about which architecture they were built on into the
                   4601:             pathnames where they install their files. To handle this
                   4602:             case, PLIST will be preprocessed before actually used, and
                   4603:             the symbol
                   4604:             &#8220;<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>&#8221; will be
                   4605:             replaced by what <span><strong class="command">uname -p</strong></span> gives. The
                   4606:             same is done if the string
                   4607:             <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
                   4608:             PLIST somewhere - use this on packages that have GNU
                   4609:             autoconf-created configure scripts.</p>
                   4610: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   4611: <h3 class="title">Legacy note</h3>
                   4612: <p>There used to be a symbol
                   4613:               &#8220;<span class="quote"><code class="varname">$ARCH</code></span>&#8221; that
                   4614:               was replaced by the output of <span><strong class="command">uname
                   4615:               -m</strong></span>, but that's no longer supported and has
                   4616:               been removed.</p>
                   4617: </div>
                   4618: </dd>
                   4619: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
                   4620: <dd>
                   4621: <p>Some packages want to embed the OS name and version
                   4622:             into some paths.  To do this, use these variables in the
1.76      rillig   4623:             <code class="filename">PLIST</code>:
1.75      rillig   4624:           </p>
                   4625: <div class="itemizedlist"><ul type="disc">
                   4626: <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>
                   4627: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. &#8220;<span class="quote">solaris</span>&#8221;)</p></li>
                   4628: <li><p><code class="varname">${OS_VERSION}</code> - &#8220;<span class="quote"><span><strong class="command">uname -r</strong></span></span>&#8221;</p></li>
                   4629: </ul></div>
                   4630: </dd>
                   4631: </dl></div>
                   4632: <p> For a complete list of values which are replaced by
1.76      rillig   4633:       default, please look in <code class="filename">bsd.pkg.mk</code> (and
1.75      rillig   4634:       search for <span class="emphasis"><em>PLIST_SUBST</em></span>). </p>
                   4635: <p> If you want to change other variables not listed above, you
                   4636:       can add variables and their expansions to this variable in the
1.77      rillig   4637:       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   4638: <pre class="programlisting">
                   4639:     PLIST_SUBST+=   SOMEVAR="somevalue"
1.1       grant    4640: </pre>
1.75      rillig   4641: <p>This replaces all occurrences of &#8220;<span class="quote">${SOMEVAR}</span>&#8221;
                   4642:       in the PLIST with &#8220;<span class="quote">somevalue</span>&#8221;.  </p>
                   4643: </div>
                   4644: <div class="sect1" lang="en">
                   4645: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4646: <a name="manpage-compression"></a>11.5. Man page compression</h2></div></div></div>
1.75      rillig   4647: <p>Man pages should be installed in compressed form if
1.76      rillig   4648:       <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
1.75      rillig   4649:       and uncompressed otherwise. To handle this in the
1.76      rillig   4650:       <code class="filename">PLIST</code> file, the suffix &#8220;<span class="quote">.gz</span>&#8221; is
1.75      rillig   4651:       appended/removed automatically for man pages according to
                   4652:       <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
                   4653:       or not, see above for details. This modification of the
1.76      rillig   4654:       <code class="filename">PLIST</code> file is done on a copy of it, not
                   4655:       <code class="filename">PLIST</code> itself.</p>
1.75      rillig   4656: </div>
                   4657: <div class="sect1" lang="en">
                   4658: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4659: <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   4660: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.75      rillig   4661:       in generating the binary package, set the variable
                   4662:       <code class="varname">PLIST_SRC</code> to the names of that file(s).
                   4663:       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 order of things is
                   4664:       important.</p>
                   4665: </div>
                   4666: <div class="sect1" lang="en">
                   4667: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4668: <a name="platform-specific-plist"></a>11.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75      rillig   4669: <p>Some packages decide to install a different set of files based on
                   4670:       the operating system being used. These differences can be
                   4671:       automatically handled by using the following files:</p>
                   4672: <div class="itemizedlist"><ul type="disc">
1.76      rillig   4673: <li><p><code class="filename">PLIST.common</code></p></li>
                   4674: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
                   4675: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
                   4676: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
                   4677: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75      rillig   4678: </ul></div>
                   4679: </div>
                   4680: <div class="sect1" lang="en">
                   4681: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4682: <a name="faq.common-dirs"></a>11.8. Sharing directories between packages</h2></div></div></div>
1.75      rillig   4683: <p> A &#8220;<span class="quote">shared directory</span>&#8221; is a directory where
                   4684:       multiple (and unrelated) packages install files.  These
                   4685:       directories are problematic because you have to add special tricks
                   4686:       in the PLIST to conditionally remove them, or have some
                   4687:       centralized package handle them. </p>
                   4688: <p> Within pkgsrc, you'll find both approaches.  If a directory
                   4689:       is shared by a few unrelated packages, it's often not worth to add
                   4690:       an extra package to remove it.  Therefore, one simply does:
                   4691:       </p>
                   4692: <pre class="programlisting">
                   4693:     @unexec ${RMDIR} %D/path/to/shared/directory 2&gt;/dev/null || ${TRUE}
1.1       grant    4694: </pre>
1.75      rillig   4695: <p> in the PLISTs of all affected packages, instead of the
                   4696:       regular "@dirrm" line. </p>
                   4697: <p> However, if the directory is shared across many packages, two
                   4698:       different solutions are available: </p>
                   4699: <div class="orderedlist"><ol type="1">
                   4700: <li><p> If the packages have a common dependency, the directory
                   4701:           can be removed in that.  For example, see
1.76      rillig   4702:           <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/textproc/scrollkeeper/README.html" target="_top"><code class="filename">textproc/scrollkeeper</code></a>, which
1.75      rillig   4703:          removes the shared directory
1.76      rillig   4704:          <code class="filename">share/omf</code>. </p></li>
1.75      rillig   4705: <li><p> If the packages using the directory are not related at
                   4706:           all (they have no common dependencies), a *-dirs package is
                   4707:           used. </p></li>
                   4708: </ol></div>
                   4709: <p> From now on, we'll discuss the second solution.  To get an
                   4710:       idea of the *-dirs packages available, issue: </p>
                   4711: <pre class="programlisting">
                   4712:     <code class="prompt">%</code> cd .../pkgsrc
                   4713:     <code class="prompt">%</code> ls -d */*-dirs
1.1       grant    4714: </pre>
1.75      rillig   4715: <p> Their use from other packages is very simple.  The
                   4716:       <code class="varname">USE_DIRS</code> variable takes a list of package names
                   4717:       (without the &#8220;<span class="quote">-dirs</span>&#8221; part) together with the required
                   4718:       version number (always pick the latest one when writing new
                   4719:       packages). </p>
                   4720: <p> For example, if a package installs files under
1.76      rillig   4721:       <code class="filename">share/applications</code>, it should have the
1.75      rillig   4722:       following line in it:
                   4723:       </p>
                   4724: <pre class="programlisting">
                   4725:     USE_DIRS+=      xdg-1.1
1.1       grant    4726: </pre>
1.75      rillig   4727: <p> After regenerating the PLIST using <span><strong class="command">make
                   4728:       print-PLIST</strong></span>, you should get the right (commented out)
                   4729:       lines. </p>
                   4730: <p> Note that even if your package is using
1.76      rillig   4731:       <code class="filename">$X11BASE</code>, it must not depend on the
1.75      rillig   4732:       *-x11-dirs packages.  Just specify the name without that part and
1.76      rillig   4733:       pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
1.75      rillig   4734:       care of it. </p>
                   4735: </div>
                   4736: </div>
                   4737: <div class="chapter" lang="en">
                   4738: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   4739: <a name="buildlink"></a>Chapter 12. Buildlink methodology</h2></div></div></div>
1.75      rillig   4740: <div class="toc">
                   4741: <p><b>Table of Contents</b></p>
                   4742: <dl>
1.77      rillig   4743: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
                   4744: <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   4745: <dd><dl>
1.77      rillig   4746: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
                   4747: <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   4748: </dl></dd>
1.77      rillig   4749: <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   4750: <dd><dl>
1.77      rillig   4751: <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>
                   4752: <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   4753: </dl></dd>
                   4754: </dl>
                   4755: </div>
                   4756: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
                   4757:     are seen by a package's configure and build processes.  This is implemented
                   4758:     in a two step process:</p>
                   4759: <div class="orderedlist"><ol type="1">
                   4760: <li><p>Symlink headers and libraries for dependencies into
                   4761:        <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
                   4762:        of <code class="varname">WRKDIR</code>.</p></li>
                   4763: <li><p>Create wrapper scripts that are used in place of the normal compiler
                   4764:        tools that translate <code class="option">-I${LOCALBASE}/include</code> and
                   4765:        <code class="option">-L${LOCALBASE}/lib</code> into references to
                   4766:        <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
                   4767:         native compiler on some operating systems look like GCC, so that
                   4768:         packages that expect GCC won't require modifications to build with
                   4769:         those native compilers.</p></li>
                   4770: </ol></div>
                   4771: <p>This normalizes the environment in which a package is built so that the
                   4772:     package may be built consistently despite what other software may be
                   4773:     installed. Please note that the normal system header and library paths,
1.76      rillig   4774:     e.g. <code class="filename">/usr/include</code>,
                   4775:     <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
1.75      rillig   4776:     designed to insulate the package build from non-system-supplied
                   4777:     software. </p>
                   4778: <div class="sect1" lang="en">
                   4779: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4780: <a name="converting-to-buildlink3"></a>12.1. Converting packages to use buildlink3</h2></div></div></div>
1.75      rillig   4781: <p>The process of converting packages to use the buildlink3
                   4782:       framework (&#8220;<span class="quote">bl3ifying</span>&#8221;) is fairly straightforward.
                   4783:       The things to keep in mind are:</p>
                   4784: <div class="orderedlist"><ol type="1">
                   4785: <li><p> Ensure that the build always calls the wrapper scripts
                   4786:           instead of the actual toolchain.  Some packages are tricky,
                   4787:           and the only way to know for sure is the check
1.76      rillig   4788:           <code class="filename">${WRKDIR}/.work.log</code> to see if the
1.75      rillig   4789:           wrappers are being invoked. </p></li>
                   4790: <li><p> Don't override <code class="varname">PREFIX</code> from within
                   4791:           the package Makefile, e.g. Java VMs, standalone shells,
                   4792:           etc., because the code to symlink files into
1.76      rillig   4793:           <code class="filename">${BUILDLINK_DIR}</code> looks for files
1.75      rillig   4794:           relative to &#8220;<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>&#8221;.
                   4795:          </p></li>
                   4796: <li><p> Remember that <span class="emphasis"><em>only</em></span> the
1.76      rillig   4797:           <code class="filename">buildlink3.mk</code> files that you list in a
1.75      rillig   4798:           package's Makefile are added as dependencies for that package.
                   4799:          </p></li>
                   4800: </ol></div>
                   4801: <p> If a dependency on a particular package is required for its libraries and
                   4802:       headers, then we replace: </p>
                   4803: <pre class="programlisting">
                   4804:     DEPENDS+=   foo&gt;=1.1.0:../../category/foo
1.1       grant    4805: </pre>
1.75      rillig   4806: <p>with</p>
                   4807: <pre class="programlisting">
                   4808:     .include "../../category/foo/buildlink3.mk"
1.1       grant    4809: </pre>
1.75      rillig   4810: <p>The buildlink3.mk files usually define the required dependencies.
                   4811:     If you need a newer version of the dependency when using buildlink3.mk
                   4812:     files, then you can define it in your Makefile; for example:
                   4813:     </p>
                   4814: <pre class="programlisting">
                   4815:     BUILDLINK_API_DEPENDS.foo+=   foo&gt;=1.1.0
                   4816:     .include "../../category/foo/buildlink3.mk"
1.1       grant    4817: </pre>
1.76      rillig   4818: <p>There are several <code class="filename">buildlink3.mk</code>
                   4819:       files in <code class="filename">pkgsrc/mk</code>
1.75      rillig   4820:       that handle special package issues:</p>
                   4821: <div class="itemizedlist"><ul type="disc">
1.76      rillig   4822: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.75      rillig   4823:           the native or a pkgsrc Berkeley DB implementation based on
                   4824:           the values of <code class="varname">BDB_ACCEPTED</code> and
                   4825:           <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76      rillig   4826: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.75      rillig   4827:           comes with neither Curses nor NCurses, this will take care
1.76      rillig   4828:          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>
                   4829: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.75      rillig   4830:           of <code class="varname">KRB5_ACCEPTED</code> to choose between
                   4831:          adding a dependency on Heimdal or MIT-krb5 for packages that
                   4832:           require a Kerberos 5 implementation.</p></li>
1.76      rillig   4833: <li><p><code class="filename">motif.buildlink3.mk</code> checks
1.75      rillig   4834:          for a system-provided
1.76      rillig   4835:          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
                   4836:          <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>
                   4837: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.75      rillig   4838:          variables that may be used by packages that use the
                   4839:          Open Sound System (OSS) API.</p></li>
1.76      rillig   4840: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.75      rillig   4841:         either Postgres 7.3 or 7.4, whichever is found installed. See
                   4842:         the file for more information. </p></li>
1.76      rillig   4843: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.75      rillig   4844:          <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
1.76      rillig   4845:          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>
                   4846: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.75      rillig   4847:          <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
                   4848:          library.</p></li>
                   4849: </ul></div>
1.76      rillig   4850: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.75      rillig   4851:       files provide a more complete
                   4852:       description of how to use them properly.</p>
                   4853: </div>
                   4854: <div class="sect1" lang="en">
                   4855: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4856: <a name="creating-buildlink3.mk"></a>12.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.76      rillig   4857: <p> A package's <code class="filename">buildlink3.mk</code> file is
1.75      rillig   4858:       included by Makefiles to indicate the need to compile and link
                   4859:       against header files and libraries provided by the package.  A
1.76      rillig   4860:       <code class="filename">buildlink3.mk</code> file should always provide
1.75      rillig   4861:       enough information to add the correct type of dependency
                   4862:       relationship and include any other
1.76      rillig   4863:       <code class="filename">buildlink3.mk</code> files that it needs to find
1.75      rillig   4864:       headers and libraries that it needs in turn.</p>
1.76      rillig   4865: <p> To generate an initial <code class="filename">buildlink3.mk</code>
                   4866:       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>
1.75      rillig   4867:       package is highly recommended.  For most packages, the following
                   4868:       command will generate a good starting point for
1.76      rillig   4869:       <code class="filename">buildlink3.mk</code> files:</p>
1.75      rillig   4870: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>pkgdir</code></em>
                   4871: <code class="prompt">%</code> createbuildlink &gt;buildlink3.mk</code></strong></pre>
                   4872: <div class="sect2" lang="en">
                   4873: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4874: <a name="anatomy-of-bl3"></a>12.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75      rillig   4875: <p>The following real-life example
1.76      rillig   4876:         <code class="filename">buildlink3.mk</code> is taken
                   4877:         from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75      rillig   4878: <pre class="programlisting">
                   4879:     # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1       grant    4880: 
1.75      rillig   4881:     BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH}+
                   4882:     TIFF_BUILDLINK3_MK:=    ${TIFF_BUILDLINK3_MK}+
1.1       grant    4883: 
1.75      rillig   4884:     .if !empty(BUILDLINK_DEPTH:M+)
                   4885:     BUILDLINK_DEPENDS+=     tiff
                   4886:     .endif
1.1       grant    4887: 
1.75      rillig   4888:     BUILDLINK_PACKAGES:=    ${BUILDLINK_PACKAGES:Ntiff}
                   4889:     BUILDLINK_PACKAGES+=    tiff
1.1       grant    4890: 
1.75      rillig   4891:     .if !empty(TIFF_BUILDLINK3_MK:M+)
                   4892:     BUILDLINK_API_DEPENDS.tiff+=        tiff&gt;=3.6.1
                   4893:     BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
                   4894:     .endif  # TIFF_BUILDLINK3_MK
1.1       grant    4895: 
1.75      rillig   4896:     .include "../../devel/zlib/buildlink3.mk"
                   4897:     .include "../../graphics/jpeg/buildlink3.mk"
1.1       grant    4898: 
1.75      rillig   4899:     BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH:S/+$//}
1.1       grant    4900: </pre>
1.75      rillig   4901: <p> The header and footer manipulate
                   4902:         <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
1.76      rillig   4903:         <code class="filename">buildlink3.mk</code> files and is used to track
1.75      rillig   4904:         at what depth we are including
1.76      rillig   4905:         <code class="filename">buildlink3.mk</code> files.</p>
1.75      rillig   4906: <p> The first section controls if the dependency on
                   4907:         <em class="replaceable"><code>pkg</code></em> is added.
                   4908:         <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
                   4909:         packages for which dependencies are added by
                   4910:         buildlink3.</p>
                   4911: <p> The second section advises pkgsrc that the
1.76      rillig   4912:         <code class="filename">buildlink3.mk</code> file for
1.75      rillig   4913:         <em class="replaceable"><code>pkg</code></em> has been included at some point.
                   4914:         <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
1.76      rillig   4915:         packages for which <code class="filename">buildlink3.mk</code> files
1.75      rillig   4916:         have been included.  It must <span class="emphasis"><em>always</em></span> be
1.76      rillig   4917:         appended to within a <code class="filename">buildlink3.mk</code>
1.75      rillig   4918:         file. </p>
                   4919: <p> The third section is protected from multiple inclusion
                   4920:         and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
                   4921:         added.  Several important variables are set in the section:
                   4922:         </p>
                   4923: <div class="itemizedlist"><ul type="disc">
                   4924: <li><p> <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4925:            is the actual dependency recorded in the installed
                   4926:             package; this should always be set using
                   4927:            <span><strong class="command">+=</strong></span> to ensure that
                   4928:             we're appending to any pre-existing list of values.  This
                   4929:             variable should be set to the first version of the
                   4930:             package that had an API change.
                   4931:            </p></li>
                   4932: <li><p> <code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
                   4933:            is the location of the <em class="replaceable"><code>pkg</code></em>
                   4934:            pkgsrc directory.</p></li>
                   4935: <li><p>
                   4936:            <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
                   4937:            (not shown above) controls whether we use
                   4938:            <code class="varname">BUILD_DEPENDS</code> or
                   4939:            <code class="varname">DEPENDS</code> to add the dependency on
                   4940:            <em class="replaceable"><code>pkg</code></em>.
                   4941:            The build dependency is selected by setting
                   4942:            <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
                   4943:            to &#8220;<span class="quote">build</span>&#8221;.  By default, the
                   4944:            full dependency is used.
                   4945:            </p></li>
                   4946: <li><p>
                   4947:            <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
                   4948:            and
                   4949:            <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
                   4950:            (not shown above) are lists of subdirectories of
1.76      rillig   4951:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4952:            to add to the header and library search paths.  These
                   4953:            default to &#8220;<span class="quote">include</span>&#8221; and &#8220;<span class="quote">lib</span>&#8221;
                   4954:            respectively. </p></li>
                   4955: <li><p>
                   4956:            <code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
                   4957:            (not shown above) is the list of preprocessor flags to add
                   4958:            to <code class="varname">CPPFLAGS</code>, which are passed on to the
                   4959:            configure and build phases.  The &#8220;<span class="quote">-I</span>&#8221; option
                   4960:            should be avoided and instead be handled using
                   4961:            <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
                   4962:            above.</p></li>
                   4963: </ul></div>
                   4964: <p> The following variables are all optionally defined within
                   4965:        this second section (protected against multiple inclusion) and
                   4966:        control which package files are symlinked into
1.76      rillig   4967:        <code class="filename">${BUILDLINK_DIR}</code> and how their names are
1.75      rillig   4968:        transformed during the symlinking: </p>
                   4969: <div class="itemizedlist"><ul type="disc">
                   4970: <li><p>
                   4971:            <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
                   4972:            (not shown above) is a shell glob pattern relative to
1.76      rillig   4973:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4974:            to be symlinked into
1.76      rillig   4975:            <code class="filename">${BUILDLINK_DIR}</code>,
                   4976:            e.g. <code class="filename">include/*.h</code>. </p></li>
1.75      rillig   4977: <li><p>
                   4978:            <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
1.76      rillig   4981:              <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
1.75      rillig   4982:              The resulting files are to be symlinked
1.76      rillig   4983:              into <code class="filename">${BUILDLINK_DIR}</code>.  By default,
                   4984:              this takes the <code class="filename">+CONTENTS</code> of a
1.75      rillig   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>.
                   4987:            </p></li>
                   4988: <li><p>
                   4989:            <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
                   4990:            (not shown above) is a filter command that filters
1.76      rillig   4991:            <code class="filename">+CONTENTS</code> input into a list of files
1.75      rillig   4992:            relative to
1.76      rillig   4993:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4994:            on stdout.  By default for overwrite packages,
                   4995:            <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76      rillig   4996:            outputs the contents of the <code class="filename">include</code>
                   4997:            and <code class="filename">lib</code> directories in the package
                   4998:            <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75      rillig   4999:            it outputs any libtool archives in
1.76      rillig   5000:            <code class="filename">lib</code> directories.
1.75      rillig   5001:            </p></li>
                   5002: <li><p>
                   5003:            <code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
                   5004:            (not shown above) is a list of sed arguments used to
                   5005:            transform the name of the source filename into a
                   5006:            destination filename, e.g. <span><strong class="command">-e
                   5007:            "s|/curses.h|/ncurses.h|g"</strong></span>.
                   5008:            </p></li>
                   5009: </ul></div>
                   5010: <p> The last section includes any
1.76      rillig   5011:            <code class="filename">buildlink3.mk</code> needed for
1.75      rillig   5012:            <em class="replaceable"><code>pkg</code></em>'s library dependencies.
1.76      rillig   5013:            Including these <code class="filename">buildlink3.mk</code> files
1.75      rillig   5014:            means that the headers and libraries for these
                   5015:            dependencies are also symlinked into
1.76      rillig   5016:            <code class="filename">${BUILDLINK_DIR}</code>
1.75      rillig   5017:            whenever the <em class="replaceable"><code>pkg</code></em>
1.76      rillig   5018:            <code class="filename">buildlink3.mk</code>
1.75      rillig   5019:            file is included.
                   5020:            </p>
                   5021: </div>
                   5022: <div class="sect2" lang="en">
                   5023: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5024: <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.75      rillig   5025: <p>
                   5026:         The situation that requires increasing the dependency listed in
                   5027:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5028:        after a package update is when the API or interface to the
                   5029:        header files change.</p>
                   5030: <p> In this case,
                   5031:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5032:        should be adjusted to require at least the new package
                   5033:        version.  In some cases, the packages that depend on this new
                   5034:        version may need their <code class="varname">PKGREVISION</code>s
1.76      rillig   5035:        increased and, if they have <code class="filename">buildlink3.mk</code>
1.75      rillig   5036:        files, their
                   5037:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5038:        adjusted, too.  This is needed so pkgsrc will require the
                   5039:        correct package dependency and not settle for an older one
                   5040:        when building the source.</p>
                   5041: <p>
                   5042:        <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5043:        should be increased when the binary interface or sonames
                   5044:        (major number of the library version) of any installed
                   5045:        shared libraries change.  This is needed so that binary
                   5046:        packages made using it will require the correct package
                   5047:        dependency and not settle for an older one which will not
                   5048:        contain the necessary shared libraries. </p>
                   5049: <p>
1.78      rillig   5050:        See <a href="#dependencies" title="17.1.6. Handling dependencies">Section 17.1.6, &#8220;Handling dependencies&#8221;</a> for
1.75      rillig   5051:        more information about dependencies on other packages,
                   5052:        including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
                   5053:        <code class="varname">ABI_DEPENDS</code> definitions. </p>
                   5054: <p> Please take careful consideration before adjusting
                   5055:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5056:        or
                   5057:        <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5058:        as we don't want to cause unneeded package deletions and
                   5059:        rebuilds.  In many cases, new versions of packages work just
                   5060:        fine with older dependencies.</p>
                   5061: <p>
                   5062:        Also it is not needed to set
                   5063:        <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   5064:        when it is identical to
                   5065:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.       </p>
                   5066: </div>
                   5067: </div>
                   5068: <div class="sect1" lang="en">
                   5069: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5070: <a name="writing-builtin.mk"></a>12.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.75      rillig   5071: <p>
                   5072:       Some packages in pkgsrc install headers and libraries that
                   5073:       coincide with headers and libraries present in the base system.
1.76      rillig   5074:       Aside from a <code class="filename">buildlink3.mk</code> file, these
                   5075:       packages should also include a <code class="filename">builtin.mk</code>
1.75      rillig   5076:       file that includes the necessary checks to decide whether using
                   5077:       the built-in software or the pkgsrc software is
                   5078:       appropriate. </p>
                   5079: <p> The only requirements of a builtin.mk file for
                   5080:       <em class="replaceable"><code>pkg</code></em> are:
                   5081:       </p>
                   5082: <div class="orderedlist"><ol type="1">
                   5083: <li><p> It should set
                   5084:           <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5085:           to either &#8220;<span class="quote">yes</span>&#8221; or &#8220;<span class="quote">no</span>&#8221;
                   5086:           after it is included.
                   5087:        </p></li>
                   5088: <li><p> It should <span class="emphasis"><em>not</em></span> override any
                   5089:           <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5090:           which is already set before the
1.76      rillig   5091:           <code class="filename">builtin.mk</code> file is included.
1.75      rillig   5092:        </p></li>
                   5093: <li><p> It should be written to allow multiple inclusion.  This
                   5094:           is <span class="emphasis"><em>very</em></span> important and takes careful
1.76      rillig   5095:           attention to <code class="filename">Makefile</code> coding.
1.75      rillig   5096:        </p></li>
                   5097: </ol></div>
                   5098: <div class="sect2" lang="en">
                   5099: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5100: <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   5101: <p>The following is the recommended template for builtin.mk
                   5102:         files: </p>
                   5103: <pre class="programlisting">
                   5104:     .if !defined(IS_BUILTIN.foo)
                   5105:     #
                   5106:     # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   5107:     # genuinely exists in the system or not.
                   5108:     #
                   5109:     IS_BUILTIN.foo?=        no
1.1       grant    5110: 
1.75      rillig   5111:     # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   5112:     # version can be determined.
                   5113:     #
                   5114:     .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   5115:     BUILTIN_PKG.foo?=       foo-1.0
                   5116:     .  endif
                   5117:     .endif  # IS_BUILTIN.foo
1.1       grant    5118: 
1.75      rillig   5119:     .if !defined(USE_BUILTIN.foo)
                   5120:     USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   5121:     .  if defined(BUILTIN_PKG.foo)
                   5122:     .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   5123:     .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   5124:     USE_BUILTIN.foo!=                                                       \
                   5125:           if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then     \
                   5126:                   ${ECHO} "yes";                                            \
                   5127:           else                                                              \
                   5128:                   ${ECHO} "no";                                             \
                   5129:           fi
                   5130:     .      endif
                   5131:     .    endfor
                   5132:     .  endif
                   5133:     .endif  # USE_BUILTIN.foo
1.1       grant    5134: 
1.75      rillig   5135:     CHECK_BUILTIN.foo?=     no
                   5136:     .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   5137:     #
                   5138:     # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   5139:     # "yes" or "no".
                   5140:     #
                   5141:     .endif  # CHECK_BUILTIN.foo
1.1       grant    5142: </pre>
1.75      rillig   5143: <p> The first section sets
                   5144:         <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5145:         depending on if <em class="replaceable"><code>pkg</code></em> really exists
                   5146:         in the base system.  This should not be a base system software
                   5147:         with similar functionality to <em class="replaceable"><code>pkg</code></em>;
                   5148:         it should only be &#8220;<span class="quote">yes</span>&#8221; if the actual package is
                   5149:         included as part of the base system.  This variable is only
1.76      rillig   5150:         used internally within the <code class="filename">builtin.mk</code>
1.75      rillig   5151:         file. </p>
                   5152: <p> The second section sets
                   5153:         <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
                   5154:         to the version of <em class="replaceable"><code>pkg</code></em> in the base
                   5155:         system if it exists (if
                   5156:         <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5157:         is &#8220;<span class="quote">yes</span>&#8221;).  This variable is only used internally
1.76      rillig   5158:         within the <code class="filename">builtin.mk</code> file. </p>
1.75      rillig   5159: <p> The third section sets
                   5160:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5161:         and is <span class="emphasis"><em>required</em></span> in all
1.76      rillig   5162:         <code class="filename">builtin.mk</code> files.  The code in this
1.75      rillig   5163:         section must make the determination whether the built-in
                   5164:         software is adequate to satisfy the dependencies listed in
                   5165:         <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
                   5166:         This is typically done by comparing
                   5167:         <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
                   5168:         against each of the dependencies in
                   5169:         <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
                   5170:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5171:         <span class="emphasis"><em>must</em></span> be set to the correct value by the
1.76      rillig   5172:         end of the <code class="filename">builtin.mk</code> file.  Note that
1.75      rillig   5173:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5174:         may be &#8220;<span class="quote">yes</span>&#8221; even if
                   5175:         <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5176:         is &#8220;<span class="quote">no</span>&#8221; because we may make the determination
                   5177:         that the built-in version of the software is similar enough to
                   5178:         be used as a replacement. </p>
                   5179: <p> The last section is guarded by
                   5180:         <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
                   5181:         and includes code that uses the value of
                   5182:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5183:         set in the previous section.  This typically includes, e.g.,
                   5184:         adding additional dependency restrictions and listing
                   5185:         additional files to symlink into
1.76      rillig   5186:         <code class="filename">${BUILDLINK_DIR}</code> (via
1.75      rillig   5187:         <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).
                   5188:         </p>
                   5189: </div>
                   5190: <div class="sect2" lang="en">
                   5191: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5192: <a name="native-or-pkgsrc-preference"></a>12.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.75      rillig   5193: <p>
                   5194:         When building packages, it's possible to choose whether to set
                   5195:         a global preference for using either the built-in (native)
                   5196:         version or the pkgsrc version of software to satisfy a
                   5197:         dependency.  This is controlled by setting
                   5198:         <code class="varname">PREFER_PKGSRC</code> and
                   5199:         <code class="varname">PREFER_NATIVE</code>.  These variables take values
                   5200:         of either &#8220;<span class="quote">yes</span>&#8221;, &#8220;<span class="quote">no</span>&#8221;, or a list of
                   5201:         packages.  <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
                   5202:         use the pkgsrc versions of software, while
                   5203:         <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
                   5204:         built-in versions.  Preferences are determined by the most
                   5205:         specific instance of the package in either
                   5206:         <code class="varname">PREFER_PKGSRC</code> or
                   5207:         <code class="varname">PREFER_NATIVE</code>.  If a package is specified
                   5208:         in neither or in both variables, then
                   5209:         <code class="varname">PREFER_PKGSRC</code> has precedence over
                   5210:         <code class="varname">PREFER_NATIVE</code>.  For example, to require
                   5211:         using pkgsrc versions of software for all but the most basic
                   5212:         bits on a NetBSD system, you can set: </p>
                   5213: <pre class="programlisting">
                   5214:     PREFER_PKGSRC=  yes
                   5215:     PREFER_NATIVE=  getopt skey tcp_wrappers
1.1       grant    5216: </pre>
1.75      rillig   5217: <p> A package <span class="emphasis"><em>must</em></span> have a
1.76      rillig   5218:         <code class="filename">builtin.mk</code>
1.75      rillig   5219:         file to be listed in <code class="varname">PREFER_NATIVE</code>,
                   5220:         otherwise it is simply ignored in that list.
                   5221:        </p>
                   5222: </div>
                   5223: </div>
                   5224: </div>
                   5225: <div class="chapter" lang="en">
                   5226: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   5227: <a name="pkginstall"></a>Chapter 13. The pkginstall framework</h2></div></div></div>
1.75      rillig   5228: <div class="toc">
                   5229: <p><b>Table of Contents</b></p>
                   5230: <dl>
1.77      rillig   5231: <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   5232: <dd><dl>
1.77      rillig   5233: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
                   5234: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
1.75      rillig   5235: </dl></dd>
1.77      rillig   5236: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
1.75      rillig   5237: <dd><dl>
1.77      rillig   5238: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
                   5239: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
                   5240: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
                   5241: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
                   5242: </dl></dd>
                   5243: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
                   5244: <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>
                   5245: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
                   5246: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
                   5247: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
                   5248: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
                   5249: <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   5250: </dl>
                   5251: </div>
                   5252: <p>This chapter describes the framework known as
                   5253: <code class="literal">pkginstall</code>, whose key features are:</p>
                   5254: <div class="itemizedlist"><ul type="disc">
                   5255: <li><p>Generic installation and manipulation of directories and files
                   5256:     outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
                   5257: <li><p>Automatic handling of configuration files during installation,
                   5258:     provided that packages are correctly designed.</p></li>
                   5259: <li><p>Generation and installation of system startup scripts.</p></li>
                   5260: <li><p>Registration of system users and groups.</p></li>
                   5261: <li><p>Registration of system shells.</p></li>
                   5262: <li><p>Automatic updating of fonts databases.</p></li>
                   5263: </ul></div>
                   5264: <p>The following sections inspect each of the above points in detail.</p>
                   5265: <p>You may be thinking that many of the things described here could be
                   5266: easily done with simple code in the package's post-installation target
                   5267: (<code class="literal">post-install</code>).  <span class="emphasis"><em>This is incorrect</em></span>,
                   5268: as the code in them is only executed when building from source.  Machines
                   5269: using binary packages could not benefit from it at all (as the code itself
                   5270: could be unavailable).  Therefore, the only way to achieve any of the items
                   5271: described above is by means of the installation scripts, which are
                   5272: automatically generated by pkginstall.</p>
                   5273: <div class="sect1" lang="en">
                   5274: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5275: <a name="files-and-dirs-outside-prefix"></a>13.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76      rillig   5276: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75      rillig   5277: of files and directories that belong to a package.  The names used in it
1.76      rillig   5278: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75      rillig   5279: which means that it cannot register files outside this directory (absolute
                   5280: path names are not allowed).  Despite this restriction, some packages need
                   5281: to install files outside this location; e.g., under
1.76      rillig   5282: <code class="filename">${VARBASE}</code> or
                   5283: <code class="filename">${PKG_SYSCONFDIR}</code>.</p>
1.75      rillig   5284: <p>The only way to achieve this is to create such files during
                   5285: installation time by using the installation scripts.  These scripts can run
                   5286: arbitrary commands, so they have the potential to create and manage files
                   5287: anywhere in the file system.  Here is where pkginstall comes into play: it
                   5288: provides generic scripts to abstract the manipulation of such files and
                   5289: directories based on variables set in the package's
1.76      rillig   5290: <code class="filename">Makefile</code>.  The rest of this section describes these
1.75      rillig   5291: variables.</p>
                   5292: <div class="sect2" lang="en">
                   5293: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5294: <a name="dirs-outside-prefix"></a>13.1.1. Directory manipulation</h3></div></div></div>
1.75      rillig   5295: <p>The following variables can be set to request the creation of
                   5296: directories anywhere in the file system:</p>
                   5297: <div class="itemizedlist"><ul type="disc">
                   5298: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
                   5299:     contain a list of directories that should be created and should attempt
                   5300:     to be destroyed by the installation scripts.  The difference between
                   5301:     the two is that the latter prompts the administrator to remove any
                   5302:     directories that may be left after deinstallation (because they were
                   5303:     not empty), while the former does not.</p></li>
                   5304: <li>
                   5305: <p><code class="varname">MAKE_DIRS_PERMS</code> and
                   5306:     <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
                   5307:     which directories should be created and should attempt to be destroyed
                   5308:     by the installation scripts.  Each tuple holds the following values,
                   5309:     separated by spaces: the directory name, its owner, its group and its
                   5310:     numerical mode.  For example:</p>
                   5311: <pre class="programlisting">
                   5312:     MAKE_DIRS_PERMS+=         ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1       grant    5313: </pre>
1.75      rillig   5314: <p>The difference between the two is exactly the same as their
                   5315:     non-<code class="varname">PERMS</code> counterparts.</p>
                   5316: </li>
                   5317: </ul></div>
                   5318: </div>
                   5319: <div class="sect2" lang="en">
                   5320: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5321: <a name="files-outside-prefix"></a>13.1.2. File manipulation</h3></div></div></div>
1.75      rillig   5322: <p>Creating non-empty files outside the installation prefix is tricky
1.76      rillig   5323: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75      rillig   5324: To overcome this problem, the only solution is to extract the file in the
                   5325: known place (i.e., inside the installation prefix) and copy it to the
                   5326: appropriate location during installation (done by the installation scripts
                   5327: generated by pkginstall).  We will call the former the <span class="emphasis"><em>master
                   5328: file</em></span> in the following paragraphs, which describe the variables
                   5329: that can be used to automatically and consistently handle files outside the
                   5330: installation prefix:</p>
                   5331: <div class="itemizedlist"><ul type="disc">
                   5332: <li>
                   5333: <p><code class="varname">CONF_FILES</code> and
                   5334:     <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
                   5335:     During installation time, the master file is copied to the target one
                   5336:     if and only if the latter does not exist.  Upon deinstallation, the
                   5337:     target file is removed provided that it was not modified by the
                   5338:     installation.</p>
                   5339: <p>The difference between the two is that the latter prompts the
                   5340:     administrator to remove any files that may be left after
                   5341:     deinstallation (because they were not empty), while the former does
                   5342:     not.</p>
                   5343: </li>
                   5344: <li>
                   5345: <p><code class="varname">CONF_FILES_PERMS</code> and
                   5346:     <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
                   5347:     files as well as their target locations.  For each of them, it also
                   5348:     specifies their owner, their group and their numeric permissions, in
                   5349:     this order.  For example:</p>
                   5350: <pre class="programlisting">
                   5351:     SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1       grant    5352: </pre>
1.75      rillig   5353: <p>The difference between the two is exactly the same as their
                   5354:     non-<code class="varname">PERMS</code> counterparts.</p>
                   5355: </li>
                   5356: </ul></div>
                   5357: </div>
                   5358: </div>
                   5359: <div class="sect1" lang="en">
                   5360: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5361: <a name="conf-files"></a>13.2. Configuration files</h2></div></div></div>
1.75      rillig   5362: <p>Configuration files are special in the sense that they are installed
                   5363: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
                   5364: need special treatment during installation (most of which is automated by
                   5365: pkginstall).  The main concept you must bear in mind is that files marked
                   5366: as configuration files are automatically copied to the right place (somewhere
                   5367: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
                   5368: and only if</em></span> they didn't exist before.  Similarly, they will not
                   5369: be removed if they have local modifications.  This ensures that
                   5370: administrators never lose any custom changes they may have made.</p>
                   5371: <div class="sect2" lang="en">
                   5372: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5373: <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   5374: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
                   5375: specifies where configuration files shall be installed.  Its contents are
                   5376: set based upon the following variables:</p>
                   5377: <div class="itemizedlist"><ul type="disc">
                   5378: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76      rillig   5379:     directory.  Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75      rillig   5380:     be overridden by the user to point to his preferred location (e.g.,
1.76      rillig   5381:     <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75      rillig   5382:     Packages must not use it directly.</p></li>
                   5383: <li>
                   5384: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
                   5385:     <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
                   5386:     for the package being built shall be installed.  The definition of this
                   5387:     variable only makes sense in the package's
1.76      rillig   5388:     <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75      rillig   5389: <p>As an example, consider the Apache package,
1.76      rillig   5390:     <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   5391:     configuration files under the
1.76      rillig   5392:     <code class="filename">httpd/</code> subdirectory of
1.75      rillig   5393:     <code class="varname">PKG_SYSCONFBASE</code>.  This should be set in the package
                   5394:     Makefile.</p>
                   5395: </li>
                   5396: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
                   5397:     variable that holds this package's configuration directory (if
                   5398:     different from <code class="varname">PKG_SYSCONFBASE</code>).  It defaults to
                   5399:     <code class="varname">PKGBASE</code>'s value, and is always prefixed with
                   5400:     <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
                   5401: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
                   5402:     directory where the configuration files for the package identified by
                   5403:     <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
                   5404: </ul></div>
                   5405: <p>Based on the above variables, pkginstall determines the value of
                   5406: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
                   5407: variable that can be used within a package to refer to its configuration
                   5408: directory.  The algorithm used to set its value is basically the
                   5409: following:</p>
                   5410: <div class="orderedlist"><ol type="1">
                   5411: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
                   5412:     its value is used.</p></li>
                   5413: <li><p>If the previous variable is not defined but
                   5414:     <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76      rillig   5415:     <code class="filename">Makefile</code>, the resulting value is
                   5416:     <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75      rillig   5417: <li><p>Otherwise, it is set to
1.76      rillig   5418:     <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75      rillig   5419: </ol></div>
1.76      rillig   5420: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.77      rillig   5421: 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   5422: </div>
                   5423: <div class="sect2" lang="en">
                   5424: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5425: <a name="conf-files-configure"></a>13.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75      rillig   5426: <p>Given that pkgsrc (and users!) expect configuration files to be in a
                   5427: known place, you need to teach each package where it shall install its
                   5428: files.  In some cases you will have to patch the package Makefiles to
                   5429: achieve it.  If you are lucky, though, it may be as easy as passing an
                   5430: extra flag to the configuration script; this is the case of GNU Autoconf-
                   5431: generated files:</p>
                   5432: <pre class="programlisting">
                   5433:     CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1       grant    5434: </pre>
1.75      rillig   5435: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
                   5436: for</em></span> its configuration files, not where they will be originally
                   5437: installed (although the difference is never explicit,
                   5438: unfortunately).</p>
                   5439: </div>
                   5440: <div class="sect2" lang="en">
                   5441: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5442: <a name="conf-files-patching"></a>13.2.3. Patching installations</h3></div></div></div>
1.75      rillig   5443: <p>As said before, pkginstall automatically handles configuration files.
                   5444: This means that <span class="strong"><strong>the packages themselves must not
1.76      rillig   5445: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75      rillig   5446: directly</strong></span>.  Bad news is that many software installation scripts
                   5447: will, out of the box, mess with the contents of that directory.  So what is
                   5448: the correct procedure to fix this issue?</p>
                   5449: <p>You must teach the package (usually by manually patching it) to
                   5450: install any configuration files under the examples hierarchy,
1.76      rillig   5451: <code class="filename">share/examples/${PKGBASE}/</code>.  This way, the
                   5452: <code class="filename">PLIST</code> registers them and the administrator always
1.75      rillig   5453: has the original copies available.</p>
                   5454: <p>Once the required configuration files are in place (i.e., under the
                   5455: examples hierarchy), the pkginstall framework can use them as master copies
                   5456: during the package installation to update what is in
1.76      rillig   5457: <code class="filename">${PKG_SYSCONFDIR}</code>.  To achieve this, the variables
1.75      rillig   5458: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.77      rillig   5459: 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   5460: about their syntax and their purpose.  Here is an example, taken from the
1.76      rillig   5461: <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   5462: <pre class="programlisting">
                   5463:     EGDIR=        ${PREFIX}/share/doc/mutt/samples
                   5464:     CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1       grant    5465: </pre>
1.75      rillig   5466: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
                   5467: package and has no meaning outside it.</p>
                   5468: </div>
                   5469: <div class="sect2" lang="en">
                   5470: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5471: <a name="conf-files-disable"></a>13.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75      rillig   5472: <p>The automatic copying of config files can be toggled by setting the
                   5473: environment variable <code class="varname">PKG_CONFIG</code> prior to package
                   5474: installation.</p>
                   5475: </div>
                   5476: </div>
                   5477: <div class="sect1" lang="en">
                   5478: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5479: <a name="rcd-scripts"></a>13.3. System startup scripts</h2></div></div></div>
1.75      rillig   5480: <p>System startup scripts are special files because they must be
                   5481: installed in a place known by the underlying OS, usually outside the
1.77      rillig   5482: 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   5483: can be used.  However, pkginstall provides a special mechanism to handle
                   5484: these files.</p>
                   5485: <p>In order to provide system startup scripts, the package has
                   5486: to:</p>
                   5487: <div class="orderedlist"><ol type="1">
1.76      rillig   5488: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75      rillig   5489:     the <code class="literal">.sh</code> suffix appended.  Considering the
1.76      rillig   5490:     <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
                   5491:     <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75      rillig   5492: <li>
                   5493: <p>Tell pkginstall to handle it, appending the name of the script,
                   5494:     without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
                   5495:     Continuing the previous example:</p>
                   5496: <pre class="programlisting">
                   5497:     RCD_SCRIPTS+=   cupsd
1.1       grant    5498: </pre>
1.75      rillig   5499: </li>
                   5500: </ol></div>
                   5501: <p>Once this is done, pkginstall will do the following steps for each
                   5502: script in an automated fashion:</p>
                   5503: <div class="orderedlist"><ol type="1">
                   5504: <li><p>Process the file found in the files directory applying all the
1.76      rillig   5505:     substitutions described in the <code class="filename">FILES_SUBST</code>
1.75      rillig   5506:     variable.</p></li>
                   5507: <li><p>Copy the script from the files directory to the examples
1.76      rillig   5508:     hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>.  Note
1.75      rillig   5509:     that this master file must be explicitly registered in the
1.76      rillig   5510:     <code class="filename">PLIST</code>.</p></li>
1.75      rillig   5511: <li><p>Add code to the installation scripts to copy the startup script
                   5512:     from the examples hierarchy into the system-wide startup scripts
                   5513:     directory.</p></li>
                   5514: </ol></div>
                   5515: <div class="sect2" lang="en">
                   5516: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5517: <a name="rcd-scripts-disable"></a>13.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75      rillig   5518: <p>The automatic copying of config files can be toggled by setting the
                   5519: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
                   5520: installation.  Note that the scripts will be always copied inside the
1.76      rillig   5521: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75      rillig   5522: matter what the value of this variable is.</p>
                   5523: </div>
                   5524: </div>
                   5525: <div class="sect1" lang="en">
                   5526: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5527: <a name="users-and-groups"></a>13.4. System users and groups</h2></div></div></div>
1.75      rillig   5528: <p>If a package needs to create special users and/or groups during
                   5529: installation, it can do so by using the pkginstall framework.</p>
                   5530: <p>Users can be created by adding entries to the
                   5531: <code class="varname">PKG_USERS</code> variable.  Each entry has the following
                   5532: syntax:</p>
                   5533: <pre class="programlisting">
                   5534:     user:group
1.1       grant    5535: </pre>
1.75      rillig   5536: <p>Further specification of user details may be done by setting per-user
                   5537: variables.
                   5538: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the numeric
                   5539: UID for the user.
                   5540: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the user's
                   5541: description or comment.
                   5542: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the user's
1.76      rillig   5543: home directory, and defaults to <code class="filename">/nonexistent</code> if not
1.75      rillig   5544: specified.
                   5545: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the user's
1.76      rillig   5546: shell, and defaults to <code class="filename">/sbinno/login</code> if not specified.
1.75      rillig   5547: </p>
                   5548: <p>Similarly, groups can be created by adding entries to the
                   5549: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
                   5550: <pre class="programlisting">
                   5551:     group
1.1       grant    5552: </pre>
1.75      rillig   5553: <p>The numeric GID of the group may be set by defining 
                   5554: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
                   5555: <p>If a package needs to create the users and groups at an earlier
                   5556: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
                   5557: either <code class="literal">configure</code> or <code class="literal">build</code> to
                   5558: indicate the phase before which the users and groups are created.  In
                   5559: this case, the numeric UIDs and GIDs of the created users and groups
                   5560: are automatically hardcoded into the final installation scripts.</p>
                   5561: </div>
                   5562: <div class="sect1" lang="en">
                   5563: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5564: <a name="shells"></a>13.5. System shells</h2></div></div></div>
1.75      rillig   5565: <p>Packages that install system shells should register them in the shell
1.76      rillig   5566: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75      rillig   5567: administrator.  This must be done from the installation scripts to keep
                   5568: binary packages working on any system.  pkginstall provides an easy way to
                   5569: accomplish this task.</p>
                   5570: <p>When a package provides a shell interpreter, it has to set the
                   5571: <code class="varname">PKG_SHELL</code> variable to its absolute file name.  This will
                   5572: add some hooks to the installation scripts to handle it.  Consider the
1.76      rillig   5573: 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   5574: <pre class="programlisting">
                   5575:     PKG_SHELL=      ${PREFIX}/bin/zsh
1.1       grant    5576: </pre>
1.75      rillig   5577: <div class="sect2" lang="en">
                   5578: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5579: <a name="shells-disable"></a>13.5.1. Disabling shell registration</h3></div></div></div>
1.75      rillig   5580: <p>The automatic registration of shell interpreters can be disabled by
1.76      rillig   5581: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75      rillig   5582: environment variable to <code class="literal">NO</code>.</p>
                   5583: </div>
                   5584: </div>
                   5585: <div class="sect1" lang="en">
                   5586: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5587: <a name="fonts"></a>13.6. Fonts</h2></div></div></div>
1.75      rillig   5588: <p>Packages that install X11 fonts should update the database files
                   5589: that index the fonts within each fonts directory.  This can easily be
                   5590: accomplished within the pkginstall framework.</p>
                   5591: <p>When a package installs X11 fonts, it must list the directories in
                   5592: which fonts are installed in the
                   5593: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
                   5594: where <em class="replaceable"><code>type</code></em> can be one of &#8220;<span class="quote">ttf</span>&#8221;,
                   5595: &#8220;<span class="quote">type1</span>&#8221; or &#8220;<span class="quote">x11</span>&#8221;.  This will add hooks to the
                   5596: installation scripts to run the appropriate commands to update the fonts
                   5597: database files within each of those directories.  For convenience, if the
                   5598: directory path is relative, it is taken to be relative to the package's
1.76      rillig   5599: 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   5600: <pre class="programlisting">
                   5601:     FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1       grant    5602: </pre>
1.75      rillig   5603: <div class="sect2" lang="en">
                   5604: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5605: <a name="fonts-disable"></a>13.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75      rillig   5606: <p>The automatic update of fonts databases can be disabled by
1.76      rillig   5607: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75      rillig   5608: environment variable to <code class="literal">NO</code>.</p>
                   5609: </div>
                   5610: </div>
                   5611: </div>
                   5612: <div class="chapter" lang="en">
                   5613: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   5614: <a name="options"></a>Chapter 14. Options handling</h2></div></div></div>
1.75      rillig   5615: <div class="toc">
                   5616: <p><b>Table of Contents</b></p>
                   5617: <dl>
1.77      rillig   5618: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
                   5619: <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>
                   5620: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
1.75      rillig   5621: </dl>
                   5622: </div>
                   5623: <p>Many packages have the ability to be built to support different
1.76      rillig   5624: sets of features.  <code class="filename">bsd.options.mk</code> is a framework
1.75      rillig   5625: in pkgsrc that provides generic handling of those options that
                   5626: determine different ways in which the packages can be built.  It's
                   5627: possible for the user to specify exactly which sets of options will be
                   5628: built into a package or to allow a set of global default options
                   5629: apply.</p>
                   5630: <div class="sect1" lang="en">
                   5631: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5632: <a name="global-default-options"></a>14.1. Global default options</h2></div></div></div>
1.75      rillig   5633: <p>Global default options are listed in
                   5634: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
                   5635: that should be built into every package if that option is supported.
1.76      rillig   5636: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75      rillig   5637: </div>
                   5638: <div class="sect1" lang="en">
                   5639: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5640: <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   5641: <p>The following example shows how
1.76      rillig   5642: <code class="filename">bsd.options.mk</code> should be used
1.75      rillig   5643: by the hypothetical ``wibble'' package, either in the package
1.76      rillig   5644: <code class="filename">Makefile</code>, or in a file,
                   5645: e.g. <code class="filename">options.mk</code>, that is included by the
                   5646: main package <code class="filename">Makefile</code>.</p>
1.75      rillig   5647: <pre class="programlisting">
                   5648:     PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   5649:     PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   5650:     PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   5651:     PKG_OPTIONS_GROUP.database=     mysql pgsql
                   5652:     PKG_SUGGESTED_OPTIONS=          wibble-foo
                   5653:     PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   5654:     PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
1.1       grant    5655: 
1.75      rillig   5656:     .include "../../mk/bsd.prefs.mk"
1.69      rillig   5657: 
1.75      rillig   5658:     # this package was previously named wibble2
                   5659:     .if defined(PKG_OPTIONS.wibble2)
                   5660:     PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   5661:     PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78      rillig   5662:             "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75      rillig   5663:     .endif
1.69      rillig   5664: 
1.75      rillig   5665:     .include "../../mk/bsd.options.mk"
1.69      rillig   5666: 
1.75      rillig   5667:     # Package-specific option-handling
1.69      rillig   5668: 
1.75      rillig   5669:     ###
                   5670:     ### FOO support
                   5671:     ###
                   5672:     .if !empty(PKG_OPTIONS:Mwibble-foo)
                   5673:     CONFIGURE_ARGS+=    --enable-foo
                   5674:     .endif
1.69      rillig   5675: 
1.75      rillig   5676:     ###
                   5677:     ### LDAP support
                   5678:     ###
                   5679:     .if !empty(PKG_OPTIONS:Mldap)
1.77      rillig   5680:     .  include "../../databases/openldap-client/buildlink3.mk"
                   5681:     CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75      rillig   5682:     .endif
1.69      rillig   5683: 
1.75      rillig   5684:     ###
                   5685:     ### database support
                   5686:     ###
                   5687:     .if !empty(PKG_OPTIONS:Mmysql)
                   5688:     .  include "../../mk/mysql.buildlink3.mk"
                   5689:     .endif
                   5690:     .if !empty(PKG_OPTIONS:Mpgsql)
                   5691:     .  include "../../mk/pgsql.buildlink3.mk"
                   5692:     .endif
                   5693: </pre>
                   5694: <p>The first section contains the information about which build
                   5695: options are supported by the package, and any default options settings
                   5696: if needed.</p>
                   5697: <div class="orderedlist"><ol type="1">
                   5698: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
                   5699: <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
                   5700: options.  It should be set to
1.78      rillig   5701: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
                   5702: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
                   5703: at the point where the options are processed.</p></li>
1.75      rillig   5704: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
                   5705: build options supported by the package.</p></li>
                   5706: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
                   5707: list of names of groups of mutually exclusive options.  The options in
                   5708: each group are listed in
                   5709: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
                   5710: The most specific setting of any option from the group takes
                   5711: precedence over all other options in the group.  Options from the
                   5712: groups will be automatically added to
                   5713: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
                   5714: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
                   5715: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
                   5716: packages will fail if no option from the group is
                   5717: selected.</p></li>
                   5718: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
                   5719: of names of sets of options.  At least one option from each set must
                   5720: be selected.  The options in each set are listed in
                   5721: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
                   5722: Options from the sets will be automatically added to
                   5723: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.  Building the package will
                   5724: fail if no option from the set is selected.</p></li>
                   5725: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
                   5726: build options which are enabled by default.</p></li>
                   5727: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
                   5728: of
                   5729: &#8220;<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>&#8221;
1.76      rillig   5730: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75      rillig   5731: their option counterparts.  Pairs should be added with
                   5732: &#8220;<span class="quote">+=</span>&#8221; to keep the listing of global legacy variables.  A
                   5733: warning will be issued if the user uses a legacy
                   5734: variable.</p></li>
                   5735: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
                   5736: of
                   5737: &#8220;<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>&#8221;
                   5738: pairs that map options that have been renamed to their new
                   5739: counterparts.  Pairs should be added with &#8220;<span class="quote">+=</span>&#8221; to keep
                   5740: the listing of global legacy options.  A warning will be issued if
                   5741: the user uses a legacy option.</p></li>
                   5742: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
                   5743: options implied by deprecated variables used.  This can be used for
                   5744: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
                   5745: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
                   5746: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
                   5747: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
                   5748: a list of warnings about deprecated variables or options used, and
                   5749: what to use instead.</p></li>
                   5750: </ol></div>
                   5751: <p>A package should never modify
                   5752: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
                   5753: <code class="varname">PKG_OPTIONS_VAR</code>.  These are strictly user-settable.
                   5754: To suggest a default set of options, use
                   5755: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
                   5756: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76      rillig   5757: including <code class="filename">bsd.options.mk</code>.  If none of
1.75      rillig   5758: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
                   5759: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
                   5760: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
                   5761: happen with platform-specific options if none of them is supported on
                   5762: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
                   5763: empty list and the package is otherwise treated as not using the
                   5764: options framework.</p>
1.76      rillig   5765: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75      rillig   5766: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
                   5767: build options, properly filtered to remove unsupported and duplicate
                   5768: options.</p>
                   5769: <p>The remaining sections contain the logic that is specific to
                   5770: each option.  The correct way to check for an option is to check
                   5771: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
                   5772: <pre class="programlisting">
                   5773:     .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
                   5774: </pre>
                   5775: </div>
                   5776: <div class="sect1" lang="en">
                   5777: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5778: <a name="option-names"></a>14.3. Option Names</h2></div></div></div>
1.75      rillig   5779: <p>Options that enable similar features in different packages (like
                   5780: optional support for a library) should use a common name in all
                   5781: packages that support it (like the name of the library).  If another
                   5782: package already has an option with the same meaning, use the same
                   5783: name.</p>
                   5784: <p>Options that enable features specific to one package, where it's
                   5785: unlikely that another (unrelated) package has the same (or a similar)
                   5786: optional feature, should use a name prefixed with
                   5787: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
                   5788: <p>If a group of related packages share an optional feature
                   5789: specific to that group, prefix it with the name of the
                   5790: &#8220;<span class="quote">main</span>&#8221; package
                   5791: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
                   5792: <p>For new options, add a line to
1.76      rillig   5793: <code class="filename">mk/defaults/options.description</code>.  Lines have two
1.75      rillig   5794: fields, separated by tab.  The first field is the option name, the
                   5795: second its description.  The description should be a whole sentence
                   5796: (starting with an uppercase letter and ending with a period) that
                   5797: describes what enabling the option does.  E. g. &#8220;<span class="quote">Enable ispell
                   5798: support.</span>&#8221; The file is sorted by option names.</p>
                   5799: </div>
                   5800: </div>
                   5801: <div class="chapter" lang="en">
                   5802: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   5803: <a name="build"></a>Chapter 15. The build process</h2></div></div></div>
1.75      rillig   5804: <div class="toc">
                   5805: <p><b>Table of Contents</b></p>
                   5806: <dl>
1.77      rillig   5807: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
                   5808: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
                   5809: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
                   5810: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
                   5811: <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   5812: <dd><dl>
                   5813: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
                   5814: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
                   5815: </dl></dd>
1.77      rillig   5816: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
                   5817: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
                   5818: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
                   5819: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
                   5820: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
                   5821: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   5822: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   5823: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
                   5824: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   5825: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
                   5826: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
1.75      rillig   5827: </dl>
                   5828: </div>
                   5829: <div class="sect1" lang="en">
                   5830: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5831: <a name="build.intro"></a>15.1. Introduction</h2></div></div></div>
1.75      rillig   5832: <p>This chapter gives a detailed description on how a package is
                   5833: built. Building a package is separated into different
                   5834: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
                   5835: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
                   5836: described in the following sections. Each phase is splitted into
                   5837: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
                   5838: containing phase, prefixed by one of <code class="varname">pre-</code>,
                   5839: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
                   5840: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
                   5841: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
                   5842: <p>The basic steps for building a program are always the same.  First
                   5843: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
                   5844: the local system and then extracted. After any pkgsrc-specific patches
                   5845: to compile properly are applied, the software can be configured, then
                   5846: built (usually by compiling), and finally the generated binaries, etc.
                   5847: can be put into place on the system.</p>
                   5848: </div>
                   5849: <div class="sect1" lang="en">
                   5850: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5851: <a name="build.prefix"></a>15.2. Program location</h2></div></div></div>
1.75      rillig   5852: <p>Before outlining the process performed by the NetBSD package system in
                   5853:       the next section, here's a brief discussion on where programs are
                   5854:       installed, and which variables influence this.</p>
                   5855: <p>The automatic variable <code class="varname">PREFIX</code> indicates
                   5856:       where all files of the final program shall be installed. It is
                   5857:       usually set to <code class="varname">LOCALBASE</code>
1.76      rillig   5858:       (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.75      rillig   5859:       for pkgs in the &#8220;<span class="quote">cross</span>&#8221; category.  The value of
                   5860:       <code class="varname">PREFIX</code> needs to be put
                   5861:       into the various places in the program's source where paths to
1.77      rillig   5862:       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   5863: <p>When choosing which of these variables to use,
                   5864:       follow the following rules:</p>
                   5865: <div class="itemizedlist"><ul type="disc">
                   5866: <li><p><code class="varname">PREFIX</code> always points to the location where the current
                   5867:          pkg will be installed.  When referring to a pkg's own installation path,
                   5868:          use &#8220;<span class="quote">${PREFIX}</span>&#8221;.</p></li>
                   5869: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs are installed.
                   5870:          If you need to construct a -I or -L argument to the compiler to find
                   5871:          includes and libraries installed by another non-X11 pkg, use
1.78      rillig   5872:          &#8220;<span class="quote">${LOCALBASE}</span>&#8221;. The name
                   5873:          <code class="varname">LOCALBASE</code> stems from FreeBSD, which
                   5874:          installed all packages in <code class="filename">/usr/local</code>. As
                   5875:          pkgsrc leaves <code class="filename">/usr/local</code> for the system
                   5876:          administrator, this variable is a misnomer.</p></li>
1.75      rillig   5877: <li><p><code class="varname">X11BASE</code> is where the actual X11 distribution (from
                   5878:          xsrc, etc.) is installed. When looking for
                   5879:          <span class="emphasis"><em>standard</em></span> X11 includes (not
                   5880:          those installed by a pkg), use &#8220;<span class="quote">${X11BASE}</span>&#8221;.</p></li>
                   5881: <li>
                   5882: <p>X11-based packages are special in that they may be installed in
                   5883:          either <code class="varname">X11BASE</code> or <code class="varname">LOCALBASE</code>.</p>
                   5884: <p>Usually, X11 packages should be installed under
                   5885:          <code class="varname">LOCALBASE</code> whenever possible.  Note that you will
1.76      rillig   5886:          need to include <code class="filename">../../mk/x11.buildlink3.mk</code>
1.75      rillig   5887:          in them to request the
                   5888:          presence of X11 and to get the right compilation flags.</p>
                   5889: <p>Even though, there are some packages that cannot be installed
                   5890:          under <code class="varname">LOCALBASE</code>: those that come with app-defaults
                   5891:          files. These packages are special and they must be placed under
                   5892:          <code class="varname">X11BASE</code>. To accomplish this, set either
                   5893:          <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
                   5894:          your package.</p>
                   5895: <p>Some notes: If you need
                   5896:          to find includes or libraries installed by a pkg that has
                   5897:          <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
1.76      rillig   5898:          its pkg <code class="filename">Makefile</code>, you need to look in
                   5899:          <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
                   5900:          <code class="filename">${LOCALBASE}</code>. To force installation of
1.75      rillig   5901:          all X11 packages in <code class="varname">LOCALBASE</code>, the
1.76      rillig   5902:          <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a> package
1.75      rillig   5903:          is enabled by default.</p>
                   5904: </li>
                   5905: <li><p><code class="varname">X11PREFIX</code> should be used to refer to the installed
                   5906:          location of an X11 package. <code class="varname">X11PREFIX</code> will be set to
                   5907:          <code class="varname">X11BASE</code> if xpkgwedge is not installed,
                   5908:          and to <code class="varname">LOCALBASE</code> if xpkgwedge is installed.</p></li>
                   5909: <li>
                   5910: <p>If xpkgwedge is installed, it is possible to have some packages installed
                   5911:          in <code class="varname">X11BASE</code> and some in <code class="varname">LOCALBASE</code>.
                   5912:          To determine the prefix of an installed package, the
                   5913:          <code class="varname">EVAL_PREFIX</code> definition can be used. It takes pairs in the
                   5914:          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
                   5915:          <code class="varname">DIRNAME</code> will be set to the prefix of the installed
                   5916:          package &lt;package&gt;, or &#8220;<span class="quote">${X11PREFIX}</span>&#8221; if the package is
                   5917:          not installed.</p>
                   5918: <p>This is best illustrated by example.</p>
                   5919: <p>The following lines are taken from
1.76      rillig   5920:          <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75      rillig   5921: <pre class="programlisting">
                   5922:     EVAL_PREFIX+=           GTKDIR=gtk+
                   5923:     CONFIGURE_ARGS+=        --with-guile-prefix=${LOCALBASE:Q}
                   5924:     CONFIGURE_ARGS+=        --with-gtk-prefix=${GTKDIR:Q}
                   5925:     CONFIGURE_ARGS+=        --enable-multibyte
                   5926: </pre>
                   5927: <p>Specific defaults can be defined for the packages evaluated using
                   5928:          <code class="varname">EVAL_PREFIX</code>, by using a definition of the form:</p>
                   5929: <pre class="programlisting">
                   5930:     GTKDIR_DEFAULT= ${LOCALBASE}
                   5931: </pre>
                   5932: <p>where <code class="varname">GTKDIR</code> corresponds
                   5933:          to the first definition in
                   5934:          the <code class="varname">EVAL_PREFIX</code> pair.</p>
                   5935: </li>
1.76      rillig   5936: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.75      rillig   5937:           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
1.76      rillig   5938:           manual pages go into <code class="filename">${PREFIX}/man</code>, not
                   5939:           <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75      rillig   5940: </ul></div>
                   5941: </div>
                   5942: <div class="sect1" lang="en">
                   5943: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5944: <a name="build.builddirs"></a>15.3. Directories used during the build process</h2></div></div></div>
1.75      rillig   5945: <p>When building a package, a number of directories is used to store
                   5946: source files, temporary files, pkgsrc-internal files, and so on. These
                   5947: directories are explained here.</p>
                   5948: <p>Some of the directory variables contain relative pathnames. There
                   5949: are two common base directories for these relative directories:
                   5950: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
                   5951: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
                   5952: inside the package itself.</p>
                   5953: <div class="variablelist"><dl>
                   5954: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
                   5955: <dd><p>This is an absolute pathname that points to the pkgsrc
                   5956: root directory. Generally, you don't need
                   5957: it.</p></dd>
                   5958: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
                   5959: <dd><p>This is a pathname relative to
                   5960: <code class="varname">PKGSRCDIR</code> that points to the current
                   5961: package.</p></dd>
                   5962: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
                   5963: <dd><p>This is an absolute pathname pointing to the directory
                   5964: where all work takes place. The distfiles are extraced to this
                   5965: directory. It also contains temporary directories and log files used by
                   5966: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
                   5967: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
                   5968: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
                   5969: <dd><p>This is an absolute pathname pointing to the directory
                   5970: where the distfiles are extracted. It is usually a direct subdirectory
                   5971: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
                   5972: that isn't hidden. This variable may be changed by a package
1.76      rillig   5973: <code class="filename">Makefile</code>.</p></dd>
1.75      rillig   5974: </dl></div>
                   5975: </div>
                   5976: <div class="sect1" lang="en">
                   5977: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5978: <a name="build.running"></a>15.4. Running a phase</h2></div></div></div>
1.75      rillig   5979: <p>You can run a particular phase by typing <span><strong class="command">make
                   5980: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
                   5981: phase. This will automatically run all phases that are required for this
                   5982: phase. The default phase is <code class="varname">build</code>, that is, when you
                   5983: run <span><strong class="command">make</strong></span> without parameters in a package directory,
                   5984: the package will be built, but not installed.</p>
                   5985: </div>
                   5986: <div class="sect1" lang="en">
                   5987: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5988: <a name="build.fetch"></a>15.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.81      rillig   5989: <p>The first step in building a package is to fetch the
                   5990:        distribution files (distfiles) from the sites that are providing
                   5991:        them. This is the task of the <span class="emphasis"><em>fetch</em></span>
                   5992:        phase.</p>
                   5993: <div class="sect2" lang="en">
                   5994: <div class="titlepage"><div><div><h3 class="title">
                   5995: <a name="build.fetch.what"></a>15.5.1. What to fetch and where to get it from</h3></div></div></div>
                   5996: <p>In simple cases, <code class="varname">MASTER_SITES</code> defines
                   5997:        all URLs from where the distfile, whose name is derived from the
                   5998:        <code class="varname">DISTNAME</code> variable, is fetched. The more
                   5999:        complicated cases are described below.</p>
                   6000: <p>The variable <code class="varname">DISTFILES</code> specifies the
                   6001:        list of distfiles that have to be fetched. Its value defaults to
                   6002:        <code class="literal">${DISTNAME}${EXTRACT_SUFX}</code>, so that most
                   6003:        packages don't need to define it at all.
                   6004:        <code class="varname">EXTRACT_SUFX</code> is <code class="literal">.tar.gz</code> by
                   6005:        default, but can be changed freely. Note that if your package
                   6006:        requires additional distfiles to the default one, you cannot
                   6007:        just append the additional filenames using the
                   6008:        <code class="literal">+=</code> operator, but you have write for
                   6009:        example:</p>
                   6010: <pre class="programlisting">
                   6011:     DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   6012: </pre>
                   6013: <p>Each of the distfiles is fetched from a list of sites,
                   6014:        usually <code class="varname">MASTER_SITES</code>. If the package has
                   6015:        multiple <code class="varname">DISTFILES</code> or multiple
                   6016:        <code class="varname">PATCHFILES</code> from different sites, you can set
                   6017:        <code class="varname">SITES.<em class="replaceable"><code>distfile</code></em></code> to
                   6018:        the list of URLs where the file
                   6019:        <code class="filename"><em class="replaceable"><code>distfile</code></em></code>
                   6020:        (including the suffix) can be found.</p>
                   6021: <pre class="programlisting">
                   6022:     DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   6023:     DISTFILES+=     foo-file.tar.gz
                   6024:     SITES.foo-file.tar.gz= \
                   6025:             http://www.somewhere.com/somehow/ \
                   6026:             http://www.somewhereelse.com/mirror/somehow/
                   6027: </pre>
                   6028: <p>When actually fetching the distfiles, each item from
                   6029:        <code class="varname">MASTER_SITES</code> or <code class="varname">SITES.*</code>
                   6030:        gets the name of each distfile appended to it, without an
                   6031:        intermediate slash. Therefore, all site values have to end with
                   6032:        a slash or other separator character. This allows for example to
                   6033:        set <code class="varname">MASTER_SITES</code> to a URL of a CGI script
                   6034:        that gets the name of the distfile as a parameter. In this case,
                   6035:        the definition would look like:</p>
                   6036: <pre class="programlisting">
                   6037:     MASTER_SITES=   http://www.example.com/download.cgi?file=
                   6038: </pre>
                   6039: <p>There are some predefined values for
                   6040:        <code class="varname">MASTER_SITES</code>, which can be used in packages.
                   6041:        The names of the variables should speak for themselves.</p>
                   6042: <pre class="programlisting">
                   6043:     ${MASTER_SITE_APACHE}
                   6044:     ${MASTER_SITE_BACKUP}
                   6045:     ${MASTER_SITE_CYGWIN}
                   6046:     ${MASTER_SITE_DEBIAN}
                   6047:     ${MASTER_SITE_FREEBSD}
                   6048:     ${MASTER_SITE_FREEBSD_LOCAL}
                   6049:     ${MASTER_SITE_GNOME}
                   6050:     ${MASTER_SITE_GNU}
                   6051:     ${MASTER_SITE_GNUSTEP}
                   6052:     ${MASTER_SITE_IFARCHIVE}
                   6053:     ${MASTER_SITE_KDE}
                   6054:     ${MASTER_SITE_MOZILLA}
                   6055:     ${MASTER_SITE_MYSQL}
                   6056:     ${MASTER_SITE_OPENOFFICE}
                   6057:     ${MASTER_SITE_PERL_CPAN}
                   6058:     ${MASTER_SITE_PGSQL}
                   6059:     ${MASTER_SITE_R_CRAN}
                   6060:     ${MASTER_SITE_SOURCEFORGE}
                   6061:     ${MASTER_SITE_SOURCEFORGE_JP}
                   6062:     ${MASTER_SITE_SUNSITE}
                   6063:     ${MASTER_SITE_SUSE}
                   6064:     ${MASTER_SITE_TEX_CTAN}
                   6065:     ${MASTER_SITE_XCONTRIB}
                   6066:     ${MASTER_SITE_XEMACS}
                   6067: </pre>
                   6068: <p>If you choose one of these predefined sites, you may want
                   6069:        to specify a subdirectory of that site. Since these macros may
                   6070:        expand to more than one actual site, you
                   6071:        <span class="emphasis"><em>must</em></span> use the following construct to specify
                   6072:        a subdirectory:</p>
                   6073: <pre class="programlisting">
                   6074:     MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   6075:     MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
                   6076: </pre>
                   6077: <p>Note the trailing slash after the subdirectory
                   6078:        name.</p>
                   6079: </div>
                   6080: <div class="sect2" lang="en">
                   6081: <div class="titlepage"><div><div><h3 class="title">
                   6082: <a name="build.fetch.how"></a>15.5.2. How are the files fetched?</h3></div></div></div>
                   6083: <p>The <span class="emphasis"><em>fetch</em></span> phase makes sure that all
                   6084:        the distfiles exist in a local directory
                   6085:        (<code class="varname">DISTDIR</code>), which can be set by the pkgsrc
                   6086:        user). If the files do not exist, they are fetched using
                   6087:        commands of the form
                   6088: 
                   6089: </p>
1.75      rillig   6090: <pre class="programlisting">
                   6091:     ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
                   6092: </pre>
1.81      rillig   6093: <p>
                   6094: 
                   6095:        where <code class="literal">${site}</code> varies through several
                   6096:        possibilities in turn: first,
                   6097:        <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the sites
                   6098:        specified in either <code class="varname">SITES.file</code> if defined,
                   6099:        else <code class="varname">MASTER_SITES</code> or
                   6100:        <code class="varname">PATCH_SITES</code>, as applies, then finally the
                   6101:        value of <code class="varname">MASTER_SITE_BACKUP</code>. The order of all
                   6102:        except the first can be optionally sorted by the user, via
                   6103:        setting either <code class="varname">MASTER_SORT_AWK</code> or
                   6104:        <code class="varname">MASTER_SORT_REGEX</code>.</p>
                   6105: </div>
1.75      rillig   6106: </div>
                   6107: <div class="sect1" lang="en">
                   6108: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6109: <a name="build.checksum"></a>15.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.75      rillig   6110: <p>After the distfile(s) are fetched, their checksum is generated and
                   6111:            compared with the checksums stored in the distinfo file. If the
                   6112:            checksums don't match, the build is aborted. This is to ensure the same
                   6113:            distfile is used for building, and that the distfile wasn't changed,
                   6114:            e.g. by some malign force, deliberately changed distfiles on the master
                   6115:            distribution site or network lossage.</p>
                   6116: </div>
                   6117: <div class="sect1" lang="en">
                   6118: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6119: <a name="build.extract"></a>15.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75      rillig   6120: <p>When the distfiles are present on the local system, they
                   6121:        need to be extracted, as they usually come in the form of some
                   6122:        compressed archive format.</p>
                   6123: <p>By default, all <code class="varname">DISTFILES</code> are
                   6124:        extracted. If you only need some of them, you can set the
                   6125:        <code class="varname">EXTRACT_ONLY</code> variable to the list of those
                   6126:        files.</p>
                   6127: <p>Extracting the files is usually done by a little program,
1.76      rillig   6128:        <code class="filename">mk/scripts/extract</code>, which already knows how
1.75      rillig   6129:        to extract various archive formats, so most likely you will not
                   6130:        need to change anything here. But if you need, the following
                   6131:        variables may help you:</p>
                   6132: <div class="variablelist"><dl>
                   6133: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
                   6134: <dd><p>Use these variables to override the default
                   6135:        options for an extract command, which are defined in
1.76      rillig   6136:        <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75      rillig   6137: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
                   6138: <dd><p>This variable can be set to
                   6139:        <code class="literal">pax</code>, <code class="literal">tar</code> or an absolute
                   6140:        pathname pointing to the command with which tar archives should
                   6141:        be extracted.</p></dd>
                   6142: </dl></div>
1.76      rillig   6143: <p>If the <code class="filename">extract</code> program doesn't serve
1.75      rillig   6144:        your needs, you can also override the
                   6145:        <code class="varname">EXTRACT_CMD</code> variable, which holds the command
                   6146:        used for extracting the files. This command is executed in the
1.76      rillig   6147:        <code class="filename">${WRKSRC}</code> directory. During execution of
1.75      rillig   6148:        this command, the shell variable <code class="varname">extract_file</code>
                   6149:        holds the absolute pathname of the file that is going to be
                   6150:        extracted.</p>
                   6151: <p>And if that still does not suffice, you can override the
                   6152:        <code class="varname">do-extract</code> target in the package
                   6153:        Makefile.</p>
                   6154: </div>
                   6155: <div class="sect1" lang="en">
                   6156: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6157: <a name="build.patch"></a>15.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75      rillig   6158: <p>After extraction, all the patches named by the
                   6159:            <code class="varname">PATCHFILES</code>, those present in the patches
                   6160:            subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
1.76      rillig   6161:            <code class="filename">/usr/local/patches/graphics/png</code>) are applied.
                   6162:            Patchfiles ending in <code class="filename">.Z</code> or
                   6163:            <code class="filename">.gz</code> are uncompressed before they are applied,
                   6164:            files ending in <code class="filename">.orig</code> or
                   6165:            <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   6166:            can be handed in <code class="varname">PATCH_DIST_ARGS</code>.
1.77      rillig   6167:            See <a href="#components.patches" title="9.3. patches/*">Section 9.3, &#8220;patches/*&#8221;</a> for more details.</p>
1.75      rillig   6168: <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
                   6169:            patches apply with some lines of fuzz. Please fix (regen) the patches
                   6170:            so that they apply cleanly. The rationale behind this is that
                   6171:            patches that don't apply cleanly may end up being applied in the wrong
                   6172:            place, and cause severe harm there.</p>
                   6173: </div>
                   6174: <div class="sect1" lang="en">
                   6175: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6176: <a name="build.tools"></a>15.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.75      rillig   6177: <p>This is covered in
1.77      rillig   6178: <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   6179: </p>
                   6180: </div>
                   6181: <div class="sect1" lang="en">
                   6182: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6183: <a name="build.wrapper"></a>15.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75      rillig   6184: <p>This phase creates wrapper programs for the compilers and
                   6185:        linkers. The following variables can be used to tweak the
                   6186:        wrappers.</p>
                   6187: <div class="variablelist"><dl>
                   6188: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
                   6189: <dd><p>The command used to print progress
                   6190:                messages. Does nothing by default. Set to
                   6191:                <code class="literal">${ECHO}</code> to see the progress
                   6192:                messages.</p></dd>
                   6193: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
                   6194: <dd><p>This variable can be set to
                   6195:                <code class="literal">yes</code> (default) or
                   6196:                <code class="literal">no</code>, depending on whether you want
                   6197:                additional information in the wrapper log
                   6198:                file.</p></dd>
                   6199: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
                   6200: <dd><p>This variable can be set to
                   6201:                <code class="literal">yes</code> or <code class="literal">no</code>,
                   6202:                depending on whether the wrapper should use its cache,
                   6203:                which will improve the speed. The default value is
                   6204:                <code class="literal">yes</code>, but is forced to
                   6205:                <code class="literal">no</code> if the platform does not support
                   6206:                it.</p></dd>
                   6207: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
                   6208: <dd><p>A list of reordering commands. A
                   6209:                reordering command has the form
                   6210:                <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
                   6211:                It ensures that that
                   6212:                <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code>
                   6213:                occurs before
                   6214:                <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
                   6215:                </p></dd>
                   6216: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
                   6217: <dd><p>A list of transformation commands. [TODO:
                   6218:                investigate further]</p></dd>
                   6219: </dl></div>
                   6220: </div>
                   6221: <div class="sect1" lang="en">
                   6222: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6223: <a name="build.configure"></a>15.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75      rillig   6224: <p>Most pieces of software need information on the header files,
                   6225: system calls, and library routines which are available on the platform
                   6226: they run on. The process of determining this information is known as
                   6227: configuration, and is usually automated. In most cases, a script is
                   6228: supplied with the distfiles, and its invocation results in generation of
                   6229: header files, Makefiles, etc.</p>
                   6230: <p>If the package contains a configure script, this can be invoked by
                   6231: setting <code class="varname">HAS_CONFIGURE</code> to &#8220;<span class="quote">yes</span>&#8221;. If the
                   6232: configure script is a GNU autoconf script, you should set
                   6233: <code class="varname">GNU_CONFIGURE</code> to &#8220;<span class="quote">yes</span>&#8221; instead. What
                   6234: happens in the <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
                   6235: <pre class="programlisting">
                   6236:     .for d in ${CONFIGURE_DIRS}
                   6237:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${CONFIGURE_ENV} \
                   6238:                 ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
                   6239:     .endfor
                   6240: </pre>
                   6241: <p><code class="varname">CONFIGURE_DIRS</code> (default: &#8220;<span class="quote">.</span>&#8221;) is a
                   6242: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
                   6243: these directories, the configure script is run with the environment
                   6244: <code class="varname">CONFIGURE_ENV</code> and arguments
                   6245: <code class="varname">CONFIGURE_ARGS</code>. The variables
                   6246: <code class="varname">CONFIGURE_ENV</code>, <code class="varname">CONFIGURE_SCRIPT</code>
                   6247: (default: &#8220;<span class="quote">./configure</span>&#8221;) and
                   6248: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
                   6249: package.</p>
1.76      rillig   6250: <p>If the program uses an <code class="filename">Imakefile</code> for
1.75      rillig   6251: configuration, the appropriate steps can be invoked by setting
                   6252: <code class="varname">USE_IMAKE</code> to &#8220;<span class="quote">yes</span>&#8221;. (If you only want
                   6253: the package installed in <code class="varname">${X11PREFIX}</code> but xmkmf not
                   6254: being run, set <code class="varname">USE_X11BASE</code> instead.)</p>
                   6255: </div>
                   6256: <div class="sect1" lang="en">
                   6257: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6258: <a name="build.build"></a>15.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.75      rillig   6259: <p>For building a package, a rough equivalent of the following code
                   6260: is executed.</p>
                   6261: <pre class="programlisting">
                   6262:     .for d in ${BUILD_DIRS}
                   6263:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${MAKE_ENV} \
                   6264:                 ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
                   6265:                     -f ${MAKEFILE} ${BUILD_TARGET}
                   6266:     .endfor
                   6267: </pre>
                   6268: <p><code class="varname">BUILD_DIRS</code> (default: &#8220;<span class="quote">.</span>&#8221;) is a
                   6269: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
                   6270: these directories, <code class="varname">MAKE_PROGRAM</code> is run with the
                   6271: environment <code class="varname">MAKE_ENV</code> and arguments
                   6272: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
                   6273: <code class="varname">MAKE_ENV</code>, <code class="varname">BUILD_MAKE_FLAGS</code>,
                   6274: <code class="varname">MAKEFILE</code> and <code class="varname">BUILD_TARGET</code> may all
                   6275: be changed by the package.</p>
                   6276: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
                   6277: &#8220;<span class="quote">gmake</span>&#8221; if <code class="varname">USE_TOOLS</code> contains
                   6278: &#8220;<span class="quote">gmake</span>&#8221;, &#8220;<span class="quote">make</span>&#8221; otherwise. The default value
                   6279: of <code class="varname">MAKEFILE</code> is &#8220;<span class="quote">Makefile</span>&#8221;, and
                   6280: <code class="varname">BUILD_TARGET</code> defaults to &#8220;<span class="quote">all</span>&#8221;.</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.test"></a>15.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75      rillig   6285: <p>[TODO]</p>
                   6286: </div>
                   6287: <div class="sect1" lang="en">
                   6288: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6289: <a name="build.install"></a>15.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75      rillig   6290: <p>Once the build stage has completed, the final step is to
                   6291:        install the software in public directories, so users can access
                   6292:        the programs and files.</p>
                   6293: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
                   6294:        equivalent of the following code is executed. Additionally,
                   6295:        before and after this code, much magic is performed to do
                   6296:        consistency checks, registering the package, and so on.</p>
                   6297: <pre class="programlisting">
                   6298:     .for d in ${INSTALL_DIRS}
                   6299:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${MAKE_ENV} \
                   6300:                 ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
                   6301:                     -f ${MAKEFILE} ${BUILD_TARGET}
                   6302:     .endfor
                   6303: </pre>
                   6304: <p>The variable's meanings are analogous to the ones in the
                   6305:        <span class="emphasis"><em>build</em></span> phase.
                   6306:        <code class="varname">INSTALL_DIRS</code> defaults to
                   6307:        <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
                   6308:        is &#8220;<span class="quote">install</span>&#8221; by default, plus
                   6309:        &#8220;<span class="quote">install.man</span>&#8221; if <code class="varname">USE_IMAKE</code> is
                   6310:        defined.</p>
                   6311: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
                   6312:        variables are useful. They are all variations of the
                   6313:        <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
                   6314:        permissions preset. <code class="varname">INSTALL</code> is the plain
                   6315:        install command. The specialized variants, together with their
                   6316:        intended use, are:</p>
                   6317: <div class="variablelist"><dl>
                   6318: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
                   6319: <dd><p>directories that contain binaries</p></dd>
                   6320: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
                   6321: <dd><p>directories that contain scripts</p></dd>
                   6322: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
                   6323: <dd><p>directories that contain shared and static libraries</p></dd>
                   6324: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
                   6325: <dd><p>directories that contain data files</p></dd>
                   6326: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
                   6327: <dd><p>directories that contain man pages</p></dd>
                   6328: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
                   6329: <dd><p>binaries that can be stripped from debugging symbols</p></dd>
                   6330: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
                   6331: <dd><p>binaries that cannot be stripped</p></dd>
                   6332: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
                   6333: <dd><p>game binaries</p></dd>
                   6334: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
                   6335: <dd><p>shared and static libraries</p></dd>
                   6336: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
                   6337: <dd><p>data files</p></dd>
                   6338: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
                   6339: <dd><p>data files for games</p></dd>
                   6340: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
                   6341: <dd><p>man pages</p></dd>
                   6342: </dl></div>
                   6343: <p>Some other variables are:</p>
                   6344: <div class="variablelist"><dl>
                   6345: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
                   6346: <dd><p>A list of directories relative to
                   6347:                <code class="varname">PREFIX</code> that are created by pkgsrc at
1.78      rillig   6348:                the beginning of the <span class="emphasis"><em>install</em></span> phase.
                   6349:                If this variable is set,
1.75      rillig   6350:                <code class="varname">NO_MTREE</code>=&#8220;<span class="quote">yes</span>&#8221; is
                   6351:                assumed, which means that the package claims to create
                   6352:                all needed directories itself before installing files to
                   6353:                it. Therefore this variable should only be set in
1.76      rillig   6354:                <code class="filename">Makefile</code>s that are under control of
1.78      rillig   6355:                the package's author. The directories are created with
                   6356:                the correct ownership, depending on their
                   6357:                name.</p></dd>
1.75      rillig   6358: </dl></div>
                   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.package"></a>15.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.75      rillig   6363: <p>[TODO]</p>
                   6364: </div>
                   6365: <div class="sect1" lang="en">
                   6366: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6367: <a name="build.helpful-targets"></a>15.16. Other helpful targets</h2></div></div></div>
1.75      rillig   6368: <div class="variablelist"><dl>
                   6369: <dt><span class="term">pre/post-*</span></dt>
                   6370: <dd><p>For any of the main targets described in the previous section, two
                   6371:            auxiliary targets exist with &#8220;<span class="quote">pre-</span>&#8221; and
                   6372:            &#8220;<span class="quote">post-</span>&#8221; used as a prefix
                   6373:            for the main target's name.  These targets are invoked before and
                   6374:            after the main target is called, allowing extra configuration or
                   6375:            installation steps be performed from a package's Makefile, for
                   6376:            example, which a program's configure script
                   6377:            or install target omitted.</p></dd>
                   6378: <dt><span class="term">do-*</span></dt>
                   6379: <dd><p>Should one of the main targets do the wrong thing, and should there
                   6380:            be no variable to fix this, you can redefine it with the do-*
                   6381:            target.  (Note that redefining the target itself instead of the
                   6382:            do-* target is a bad idea, as the pre-* and post-* targets won't be
                   6383:            called anymore, etc.) You will not usually need to do this.</p></dd>
                   6384: <dt><span class="term">reinstall</span></dt>
                   6385: <dd><p>If you did a <span><strong class="command">make install</strong></span> and you noticed some file
                   6386:            was not installed properly, you can repeat the installation with this
                   6387:            target, which will ignore the &#8220;<span class="quote">already installed</span>&#8221; flag.</p></dd>
                   6388: <dt><span class="term">deinstall</span></dt>
                   6389: <dd>
                   6390: <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,
                   6391:            effectively de-installing the package. The following variables can
                   6392:            be used to tune the behaviour:</p>
                   6393: <div class="variablelist"><dl>
                   6394: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
                   6395: <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>
                   6396: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
                   6397: <dd><p>Remove all packages that require (depend on) the given package.
                   6398:                  This can be used to remove any packages that may have been pulled in
                   6399:                  by a given package, e.g. if <span><strong class="command">make deinstall
                   6400:                    DEINSTALLDEPENDS=1</strong></span> is done in
1.76      rillig   6401:                  <code class="filename">pkgsrc/x11/kde</code>, this is likely to remove whole
1.75      rillig   6402:                  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>
                   6403: </dl></div>
                   6404: </dd>
                   6405: <dt><span class="term">update</span></dt>
                   6406: <dd>
                   6407: <p>This target causes the current package to be updated to the latest
                   6408:            version.  The package and all depending packages first get de-installed,
                   6409:            then current versions of the corresponding packages get compiled and
                   6410:            installed.  This is similar to manually noting which packages are
                   6411:            currently installed, then performing a series of <span><strong class="command">make
                   6412:              deinstall</strong></span> and <span><strong class="command">make install</strong></span> (or whatever
                   6413:            <code class="varname">UPDATE_TARGET</code> is set to) for these packages.</p>
                   6414: <p>You can use the &#8220;<span class="quote">update</span>&#8221; target to resume package
                   6415:            updating in case a previous <span><strong class="command">make update</strong></span> was interrupted
                   6416:            for some reason.  However, in this case, make sure you don't call
                   6417:            <span><strong class="command">make clean</strong></span> or otherwise remove the list of dependent
                   6418:            packages in <code class="varname">WRKDIR</code>.  Otherwise, you lose the
                   6419:            ability to automatically update the current package along with the
                   6420:            dependent packages you have installed.</p>
                   6421: <p>Resuming an interrupted <span><strong class="command">make update</strong></span> will only work as
                   6422:            long as the package tree remains unchanged.  If the source code for
                   6423:            one of the packages to be updated has been changed, resuming
                   6424:            <span><strong class="command">make update</strong></span> will most certainly fail!</p>
                   6425: <p>The following variables can be used either on the command line or in
1.76      rillig   6426:            <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75      rillig   6427:            <span><strong class="command">make update</strong></span>:</p>
                   6428: <div class="variablelist"><dl>
                   6429: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
                   6430: <dd><p>Install target to recursively use for the updated package and the
                   6431:                  dependent packages.  Defaults to <code class="varname">DEPENDS_TARGET</code> if set,
                   6432:                  &#8220;<span class="quote">install</span>&#8221; otherwise for <span><strong class="command">make update</strong></span>.
                   6433:                  e.g. <span><strong class="command">make update UPDATE_TARGET=package</strong></span></p></dd>
                   6434: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
                   6435: <dd><p>Don't clean up after updating.  Useful if you want to leave the
                   6436:                  work sources of the updated packages around for inspection or
                   6437:                  other purposes.  Be sure you eventually clean up the source
                   6438:                  tree (see the &#8220;<span class="quote">clean-update</span>&#8221; target below) or you may
                   6439:                  run into troubles with old source code still lying around on your
                   6440:                  next <span><strong class="command">make</strong></span> or <span><strong class="command">make update</strong></span>.</p></dd>
                   6441: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
                   6442: <dd><p>Deinstall each package before installing (making
                   6443:                  <code class="varname">DEPENDS_TARGET</code>). This may be necessary if the
                   6444:                  &#8220;<span class="quote">clean-update</span>&#8221; target (see below) was called after
                   6445:                  interrupting a running <span><strong class="command">make update</strong></span>.</p></dd>
                   6446: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
                   6447: <dd><p>Allows you to disable recursion and hardcode the target for
                   6448:                  packages.  The default is &#8220;<span class="quote">update</span>&#8221; for the update target,
                   6449:                  facilitating a recursive update of prerequisite packages.
                   6450:                  Only set <code class="varname">DEPENDS_TARGET</code> if you want to disable
                   6451:                  recursive updates. Use <code class="varname">UPDATE_TARGET</code> instead to just
                   6452:                  set a specific target for each package to be installed during
                   6453:                  <span><strong class="command">make update</strong></span> (see above).</p></dd>
                   6454: </dl></div>
                   6455: </dd>
                   6456: <dt><span class="term">clean-update</span></dt>
                   6457: <dd>
                   6458: <p>Clean the source tree for all packages that would get updated if
                   6459:            <span><strong class="command">make update</strong></span> was called from the current directory.
                   6460:            This target should not be used if the current package (or any of its
                   6461:            depending packages) have already been de-installed (e.g., after calling
                   6462:            <span><strong class="command">make update</strong></span>) or you may lose some packages you intended
                   6463:            to update. As a rule of thumb: only use this target
                   6464:            <span class="emphasis"><em>before</em></span> the first time you run
                   6465:            <span><strong class="command">make update</strong></span> and only if you have a dirty package tree
                   6466:            (e.g., if you used <code class="varname">NOCLEAN</code>).</p>
                   6467: <p>If you are unsure about whether your tree is clean, you can either
                   6468:            perform a <span><strong class="command">make clean</strong></span> at the top of the tree, or use
                   6469:            the following sequence of commands from the directory of the package
                   6470:            you want to update (<span class="emphasis"><em>before</em></span> running
                   6471:            <span><strong class="command">make update</strong></span> for the first time, otherwise you lose
                   6472:            all the packages you wanted to update!):</p>
                   6473: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
                   6474: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
                   6475: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong></pre>
                   6476: <p>The following variables can be used either on the command line or in
1.76      rillig   6477:            <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75      rillig   6478:            <span><strong class="command">make clean-update</strong></span>:</p>
                   6479: <div class="variablelist"><dl>
                   6480: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
                   6481: <dd><p>After <span><strong class="command">make clean</strong></span>, do not reconstruct the list of
                   6482:                  directories to update for this package.  Only use this if <span><strong class="command">make
                   6483:                    update</strong></span> successfully installed all packages you wanted to
                   6484:                  update.  Normally, this is done automatically on <span><strong class="command">make
                   6485:                    update</strong></span>, but may have been suppressed by the
                   6486:                  <code class="varname">NOCLEAN</code> variable (see above).</p></dd>
                   6487: </dl></div>
                   6488: </dd>
                   6489: <dt><span class="term">info</span></dt>
                   6490: <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
                   6491:            package. You can use this to check which version of a package is
                   6492:            installed.</p></dd>
                   6493: <dt><span class="term">readme</span></dt>
1.76      rillig   6494: <dd><p>This target generates a <code class="filename">README.html</code> file, which
1.75      rillig   6495:            can be viewed using a browser such as
1.83      wiz      6496:            <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   6497:            <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   6498:            The generated files contain references to any
                   6499:            packages which are in the <code class="varname">PACKAGES</code> directory on
                   6500:            the local host. The generated files can be made to refer to URLs based on
                   6501:            <code class="varname">FTP_PKG_URL_HOST</code> and
                   6502:            <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I wanted to generate
1.76      rillig   6503:            <code class="filename">README.html</code> files which pointed to binary packages
1.75      rillig   6504:            on the local machine, in the directory
1.76      rillig   6505:            <code class="filename">/usr/packages</code>, set
1.75      rillig   6506:            <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
                   6507:            <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
                   6508:            <code class="varname">${PACKAGES}</code> directory and its subdirectories will be
                   6509:            searched for all the binary packages.</p></dd>
                   6510: <dt><span class="term">readme-all</span></dt>
1.76      rillig   6511: <dd><p>Use this target to create a file <code class="filename">README-all.html</code>
1.75      rillig   6512:            which contains a list of all packages currently available in the NetBSD
                   6513:            Packages Collection, together with the category they belong to and a
                   6514:            short description. This file is compiled from the
1.76      rillig   6515:            <code class="filename">pkgsrc/*/README.html</code> files, so be sure to run
1.75      rillig   6516:            this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make readme</strong></span>.</p></dd>
                   6517: <dt><span class="term">cdrom-readme</span></dt>
                   6518: <dd><p>This is very much the same as the &#8220;<span class="quote">readme</span>&#8221; target (see
                   6519:            above), but is to be used when generating a pkgsrc tree to be written
                   6520:            to a CD-ROM.  This target also produces
1.76      rillig   6521:            <code class="filename">README.html</code> files, and can be made to refer
1.75      rillig   6522:            to URLs based on <code class="varname">CDROM_PKG_URL_HOST</code> and
                   6523:            <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
                   6524: <dt><span class="term">show-distfiles</span></dt>
                   6525: <dd><p>This target shows which distfiles and patchfiles are needed to build
                   6526:            the package. (<code class="varname">DISTFILES</code> and
1.76      rillig   6527:            <code class="varname">PATCHFILES</code>, but not <code class="filename">patches/*</code>)</p></dd>
1.75      rillig   6528: <dt><span class="term">show-downlevel</span></dt>
                   6529: <dd><p>This target shows nothing if the package is not installed. If a version
                   6530:            of this package is installed, but is not the version provided in this
                   6531:            version of pkgsrc, then a warning message is displayed. This target can
                   6532:            be used to show which of your installed packages are downlevel, and so
                   6533:            the old versions can be deleted, and the current ones added.</p></dd>
                   6534: <dt><span class="term">show-pkgsrc-dir</span></dt>
                   6535: <dd><p>This target shows the directory in the pkgsrc hierarchy from which the
                   6536:            package can be built and installed. This may not be the same directory
                   6537:            as the one from which the package was installed. This target is intended
                   6538:            to be used by people who may wish to upgrade many packages on a single
                   6539:            host, and can be invoked from the top-level pkgsrc Makefile by using the
                   6540:            &#8220;<span class="quote">show-host-specific-pkgs</span>&#8221; target.</p></dd>
                   6541: <dt><span class="term">show-installed-depends</span></dt>
                   6542: <dd><p>This target shows which installed packages match the current package's
                   6543:            <code class="varname">DEPENDS</code>. Useful if out of date dependencies are
                   6544:            causing build problems.</p></dd>
                   6545: <dt><span class="term">check-shlibs</span></dt>
                   6546: <dd><p>After a package is installed, check all its binaries and (on ELF
                   6547:            platforms) shared libraries to see if they find the shared libs they need.
                   6548:            Run by default if <code class="varname">PKG_DEVELOPER</code> is set in
1.76      rillig   6549:            <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75      rillig   6550: <dt><span class="term">print-PLIST</span></dt>
                   6551: <dd>
                   6552: <p>After a &#8220;<span class="quote">make install</span>&#8221; from a new or
                   6553:            upgraded pkg, this prints out an attempt to generate a new
1.76      rillig   6554:            <code class="filename">PLIST</code> from a <span><strong class="command">find -newer
1.75      rillig   6555:            work/.extract_done</strong></span>.  An attempt is made to care
                   6556:            for shared libs etc., but it is
                   6557:            <span class="emphasis"><em>strongly</em></span> recommended to review the
                   6558:            result before putting it into
1.76      rillig   6559:            <code class="filename">PLIST</code>. On upgrades, it's useful to
1.75      rillig   6560:            diff the output of this command against an already
1.76      rillig   6561:            existing <code class="filename">PLIST</code> file.</p>
1.75      rillig   6562: <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
                   6563:            methods that don't update file access times, be sure to
                   6564:            add these files manually to your
1.76      rillig   6565:            <code class="filename">PLIST</code>, as the &#8220;<span class="quote">find
1.75      rillig   6566:            -newer</span>&#8221; command used by this target won't catch
                   6567:            them!</p>
1.77      rillig   6568: <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
1.75      rillig   6569:            information on this target.</p>
                   6570: </dd>
                   6571: <dt><span class="term">bulk-package</span></dt>
                   6572: <dd>
                   6573: <p>Used to do bulk builds. If an appropriate binary package already exists,
                   6574:            no action is taken. If not, this target will compile, install and
                   6575:            package it (and its depends, if <code class="varname">PKG_DEPENDS</code> is
                   6576:            set properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, &#8220;Configuration&#8221;</a>).
                   6577:            After creating the binary
                   6578:            package, the sources, the just-installed package and its required
                   6579:            packages are removed, preserving free disk space.</p>
                   6580: <p><span class="emphasis"><em>Beware that this target may deinstall all
                   6581:            packages installed on a system!</em></span></p>
                   6582: </dd>
                   6583: <dt><span class="term">bulk-install</span></dt>
                   6584: <dd>
                   6585: <p>Used during bulk-installs to install required packages. If an
                   6586:            up-to-date binary package is available, it will be installed via
                   6587:            <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,
                   6588:            but the installed binary won't be removed. </p>
                   6589: <p> A binary package is considered &#8220;<span class="quote">up-to-date</span>&#8221; to be
                   6590:            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>
                   6591: <div class="itemizedlist"><ul type="disc">
1.76      rillig   6592: <li><p>None of the package's files (<code class="filename">Makefile</code>,
1.75      rillig   6593:                ...) were modified since it was built.</p></li>
                   6594: <li><p>None of the package's required (binary) packages were
                   6595:                modified since it was built.</p></li>
                   6596: </ul></div>
                   6597: <p><span class="emphasis"><em>Beware that this target may deinstall all
                   6598:            packages installed on a system!</em></span></p>
                   6599: </dd>
                   6600: </dl></div>
                   6601: </div>
                   6602: </div>
                   6603: <div class="chapter" lang="en">
                   6604: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   6605: <a name="tools"></a>Chapter 16. Tools needed for building or running</h2></div></div></div>
1.75      rillig   6606: <div class="toc">
                   6607: <p><b>Table of Contents</b></p>
                   6608: <dl>
1.77      rillig   6609: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
                   6610: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
                   6611: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
1.75      rillig   6612: </dl>
                   6613: </div>
                   6614: <p>
                   6615: The <code class="varname">USE_TOOLS</code> definition is used both internally
                   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
                   6621: package will not be used.
                   6622: </p>
                   6623: <p>
                   6624: When building a package, the replacement tools are
                   6625: made available in a directory (as symlinks or wrapper scripts)
                   6626: that is early in the executable search path. Just like the buildlink
                   6627: system, this helps with consistent builds.
                   6628: </p>
                   6629: <p>
                   6630: A tool may be needed to help build a specific package. For example,
                   6631: perl, GNU make (gmake) or yacc may be needed.
                   6632: </p>
                   6633: <p>
                   6634: Also a tool may be needed, for example, because the native system's supplied
                   6635: tool may be inefficient for building a package with pkgsrc.
                   6636: For example, a package may need GNU awk, bison (instead of
                   6637: yacc) or a better sed.
                   6638: </p>
                   6639: <p>
                   6640: The tools used by a package can be listed by running
                   6641: <span><strong class="command">make show-tools</strong></span>.
                   6642: </p>
                   6643: <div class="sect1" lang="en">
                   6644: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6645: <a name="pkgsrc-tools"></a>16.1. Tools for pkgsrc builds</h2></div></div></div>
1.75      rillig   6646: <p>
                   6647: The default set of tools used by pkgsrc is defined in
1.76      rillig   6648: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75      rillig   6649: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
                   6650: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
                   6651: These can be seen by running:
                   6652: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.
                   6653: </p>
                   6654: <p>
                   6655: If a package needs a specific program to build
                   6656: then the <code class="varname">USE_TOOLS</code> variable can be used
                   6657: to define the tools needed.
                   6658: </p>
                   6659: </div>
                   6660: <div class="sect1" lang="en">
                   6661: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6662: <a name="package-tools"></a>16.2. Tools needed by packages</h2></div></div></div>
1.75      rillig   6663: <p>
                   6664: In the following examples, the :pkgsrc means to use the pkgsrc version
                   6665: and not the native version for a build dependency.
                   6666: And the :run means that it is used for a
                   6667: run-time dependencies also (and becomes a DEPENDS).
                   6668: The default is a build dependency which can be set with
                   6669: :build. (So in this example, it is the same as gmake:build
                   6670: and pkg-config:build.)
                   6671: </p>
                   6672: <pre class="programlisting">
                   6673: USE_TOOLS+=     mktemp:pkgsrc
                   6674: USE_TOOLS+=     gmake perl:run pkg-config
                   6675: </pre>
                   6676: <p>
                   6677: When using the tools framework, a
                   6678: <code class="varname">TOOLS_PATH.foo</code> variable is defined
                   6679: which contains the full path to the appropriate tool. For example,
                   6680: <code class="varname">TOOLS_PATH.bash</code> could be &#8220;<span class="quote">/bin/bash</span>&#8221;
                   6681: on Linux systems.
                   6682: </p>
                   6683: <p>
                   6684: If you always need a pkgsrc version of the
                   6685: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
                   6686: 
                   6687: </p>
                   6688: </div>
                   6689: <div class="sect1" lang="en">
                   6690: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6691: <a name="platform-tools"></a>16.3. Tools provided by platforms</h2></div></div></div>
1.75      rillig   6692: <p>
                   6693: When improving or porting pkgsrc to a new platform, have a look
                   6694: at (or create) the corresponding platform specific make file fragment under
1.76      rillig   6695: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75      rillig   6696: the name of the common tools. For example:</p>
                   6697: <pre class="programlisting">
                   6698: .if exists(/usr/bin/bzcat)
                   6699: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   6700: .elif exists(/usr/bin/bzip2)
                   6701: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   6702: .endif
1.69      rillig   6703: 
1.75      rillig   6704: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   6705: </pre>
                   6706: </div>
                   6707: </div>
                   6708: <div class="chapter" lang="en">
                   6709: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   6710: <a name="fixes"></a>Chapter 17. Making your package work</h2></div></div></div>
1.75      rillig   6711: <div class="toc">
                   6712: <p><b>Table of Contents</b></p>
                   6713: <dl>
1.77      rillig   6714: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
1.75      rillig   6715: <dd><dl>
1.78      rillig   6716: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
                   6717: <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>
                   6718: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
                   6719: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
                   6720: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
                   6721: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
                   6722: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
                   6723: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
                   6724: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
                   6725: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
                   6726: <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   6727: <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   6728: </dl></dd>
                   6729: <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>
                   6730: <dd><dl>
                   6731: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
                   6732: <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>
                   6733: </dl></dd>
                   6734: <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>
                   6735: <dd><dl>
                   6736: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
                   6737: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
                   6738: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
                   6739: </dl></dd>
                   6740: <dt><span class="sect1"><a href="#fixes.build">17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   6741: <dd><dl>
1.78      rillig   6742: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
                   6743: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
                   6744: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
                   6745: </dl></dd>
                   6746: <dt><span class="sect1"><a href="#fixes.install">17.5. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   6747: <dd><dl>
                   6748: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
                   6749: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
                   6750: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
                   6751: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
                   6752: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
                   6753: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
                   6754: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
                   6755: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
                   6756: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
                   6757: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
                   6758: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
                   6759: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
                   6760: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
                   6761: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
                   6762: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
                   6763: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
                   6764: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.85      jmmv     6765: <dt><span class="sect2"><a href="#hicolor-theme">17.5.18. Packages installing hicolor theme icons</a></span></dt>
                   6766: <dt><span class="sect2"><a href="#desktop-files">17.5.19. Packages installing desktop files</a></span></dt>
1.75      rillig   6767: </dl></dd>
                   6768: </dl>
                   6769: </div>
                   6770: <div class="sect1" lang="en">
                   6771: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6772: <a name="general-operation"></a>17.1. General operation</h2></div></div></div>
1.75      rillig   6773: <div class="sect2" lang="en">
                   6774: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6775: <a name="portability-of-packages"></a>17.1.1. Portability of packages</h3></div></div></div>
                   6776: <p>One appealing feature of pkgsrc is that it runs on many
                   6777:        different platforms. As a result, it is important to ensure,
                   6778:        where possible, that packages in pkgsrc are portable. This
                   6779:        chapter mentions some particular details you should pay
                   6780:        attention to while working on pkgsrc.</p>
                   6781: </div>
                   6782: <div class="sect2" lang="en">
                   6783: <div class="titlepage"><div><div><h3 class="title">
                   6784: <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>
                   6785: <p>The pkgsrc user can configure pkgsrc by overriding several
                   6786:        variables in the file pointed to by <code class="varname">MAKECONF</code>,
                   6787:        which is <code class="filename">/etc/mk.conf</code> by default. When you
                   6788:        want to use those variables in the preprocessor directives of
                   6789:        <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
                   6790:        <code class="literal">.for</code>), you need to include the file
                   6791:        <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
                   6792:        loads the user preferences.</p>
                   6793: <p>But note that some variables may not be completely defined
                   6794:        after <code class="filename">../../mk/bsd.prefs.mk</code> has been
                   6795:        included, as they may contain references to variables that are
                   6796:        not yet defined. In shell commands this is no problem, since
                   6797:        variables are actually macros, which are only expanded when they
                   6798:        are used. But in the preprocessor directives mentioned above and
                   6799:        in dependency lines (of the form <code class="literal">target:
                   6800:        dependencies</code>) the variables are expanded at load
                   6801:        time.</p>
                   6802: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   6803: <h3 class="title">Note</h3>
                   6804: <p>Currently there is no exhaustive list of all
                   6805:        variables that tells you whether they can be used at load time
                   6806:        or only at run time, but it is in preparation.</p>
                   6807: </div>
                   6808: </div>
                   6809: <div class="sect2" lang="en">
                   6810: <div class="titlepage"><div><div><h3 class="title">
                   6811: <a name="user-interaction"></a>17.1.3. User interaction</h3></div></div></div>
                   6812: <p>Occasionally, packages require interaction from the user, and this can be
                   6813:         in a number of ways:</p>
                   6814: <div class="itemizedlist"><ul type="disc">
1.79      rillig   6815: <li><p>When fetching the distfiles, some packages require user
                   6816:          interaction such as entering username/password or accepting a
                   6817:          license on a web page.</p></li>
1.78      rillig   6818: <li><p>When extracting the distfiles, some packages may ask for passwords.</p></li>
                   6819: <li><p>help to configure the package before it is built</p></li>
                   6820: <li><p>help during the build process</p></li>
                   6821: <li><p>help during the installation of a package</p></li>
                   6822: </ul></div>
                   6823: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is provided to notify
                   6824:         the pkgsrc mechanism of an interactive stage which will be needed, and
                   6825:         this should be set in the package's <code class="filename">Makefile</code>, e.g.:</p>
1.75      rillig   6826: <pre class="programlisting">
1.78      rillig   6827:     INTERACTIVE_STAGE=      build
1.75      rillig   6828: </pre>
1.78      rillig   6829: <p>Multiple interactive stages can be specified:</p>
1.75      rillig   6830: <pre class="programlisting">
1.78      rillig   6831:     INTERACTIVE_STAGE=      configure install
1.75      rillig   6832: </pre>
                   6833: </div>
                   6834: <div class="sect2" lang="en">
                   6835: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6836: <a name="handling-licenses"></a>17.1.4. Handling licenses</h3></div></div></div>
                   6837: <p>A package may be covered by a license which the user has
                   6838:         or has not agreed to accept.  For these cases, pkgsrc contains
                   6839:         a mechanism to note that a package is covered by a particular
                   6840:         license, and the package cannot be built unless the user has
                   6841:         accepted the license.  (Installation of binary packages are
                   6842:         not currently subject to this mechanism.)  Packages with
                   6843:         licenses that are either Open Source according to the Open
                   6844:         Source Initiative or Free according to the Free Software
                   6845:         Foundation will not be marked with a license tag.  Packages
                   6846:         with licenses that have not been determined to meet either
                   6847:         definition will be marked with a license tag referring to the
                   6848:         license.  This will prevent building unless pkgsrc is informed
                   6849:         that the license is acceptable, and enables displaying the
                   6850:         license.</p>
                   6851: <p>The license tag mechanism is intended to address
                   6852:        copyright-related issues surrounding building, installing and
                   6853:        using a package, and not to address redistribution issues (see
                   6854:        <code class="varname">RESTRICTED</code> and
                   6855:        <code class="varname">NO_SRC_ON_FTP</code>, etc.).  However, the above
                   6856:        definition of licenses for which tags are not needed implies
                   6857:        that packages with redistribution restrictions should have
                   6858:        tags.</p>
                   6859: <p>
                   6860:         Denoting that a package is covered by a particular license is
                   6861:         done by placing the license in
                   6862:         <code class="filename">pkgsrc/licenses</code> and setting the
                   6863:         <code class="varname">LICENSE</code> variable to a string identifying
                   6864:         the license, e.g. in
                   6865:        <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>: </p>
                   6866: <pre class="programlisting">
                   6867:     LICENSE=        xv-license
                   6868: </pre>
                   6869: <p>
                   6870:        When trying to build, the user will get a notice that the
                   6871:         package is covered by a license which has not been
                   6872:         accepted:</p>
                   6873: <pre class="programlisting">
                   6874:     <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
                   6875:     ===&gt; xv-3.10anb9 has an unacceptable license: xv-license.
                   6876:     ===&gt;     To view the license, enter "/usr/bin/make show-license".
                   6877:     ===&gt;     To indicate acceptance, add this line to your /etc/mk.conf:
                   6878:     ===&gt;     ACCEPTABLE_LICENSES+=xv-license
                   6879:     *** Error code 1
                   6880: </pre>
                   6881: <p>The license can be viewed with <span><strong class="command">make
                   6882:           show-license</strong></span>, and if it is considered appropriate,
                   6883:           the line printed above can be added to
                   6884:           <code class="filename">/etc/mk.conf</code> to indicate acceptance of
                   6885:           the particular license:</p>
                   6886: <pre class="programlisting">
                   6887:     ACCEPTABLE_LICENSES+=xv-license
                   6888: </pre>
                   6889: <p>When adding a package with a new license, the license
                   6890:           text should be added to <code class="filename">pkgsrc/licenses</code>
                   6891:           for displaying. A list of known licenses can be seen in this
                   6892:           directory as well as by looking at the list of (commented
                   6893:           out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
                   6894:           settings in
                   6895:           <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
                   6896: <p>The use of <code class="varname">LICENSE=shareware</code>,
                   6897:          <code class="varname">LICENSE=no-commercial-use</code>, and similar
                   6898:          language is deprecated because it does not crisply refer to
                   6899:          a particular license text.  Another problem with such usage
                   6900:          is that it does not enable a user to denote acceptance of
                   6901:          the license for a single package without accepting the same
                   6902:          license text for another package.  In particular, this can
                   6903:          be inappropriate when e.g. one accepts a particular license to
                   6904:          indicate to pkgsrc that a fee has been paid.</p>
1.75      rillig   6905: </div>
                   6906: <div class="sect2" lang="en">
                   6907: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6908: <a name="restricted-packages"></a>17.1.5. Restricted packages</h3></div></div></div>
1.75      rillig   6909: <p>Some licenses restrict how software may be re-distributed.
                   6910:         In order to satisfy these restrictions, the package system
                   6911:         defines five make variables that can be set to note these
                   6912:         restrictions:</p>
                   6913: <div class="itemizedlist"><ul type="disc">
                   6914: <li>
                   6915: <p><code class="varname">RESTRICTED</code></p>
                   6916: <p>This variable should be set whenever a restriction
                   6917:             exists (regardless of its kind).  Set this variable to a
                   6918:             string containing the reason for the restriction.</p>
                   6919: </li>
                   6920: <li>
                   6921: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
                   6922: <p>Binaries may not be placed on CD-ROM.  Set this
                   6923:             variable to <code class="varname">${RESTRICTED}</code> whenever a
                   6924:             binary package may not be included on a CD-ROM.</p>
                   6925: </li>
                   6926: <li>
                   6927: <p><code class="varname">NO_BIN_ON_FTP</code></p>
                   6928: <p>Binaries may not be placed on an FTP server.  Set
                   6929:             this variable to <code class="varname">${RESTRICTED}</code>
                   6930:             whenever a binary package may not not be made available
                   6931:             on the Internet.</p>
                   6932: </li>
                   6933: <li>
                   6934: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
                   6935: <p>Distfiles may not be placed on CD-ROM.  Set this
                   6936:             variable to <code class="varname">${RESTRICTED}</code> if
                   6937:             re-distribution of the source code or other distfile(s) is
                   6938:             not allowed on CD-ROMs.</p>
                   6939: </li>
                   6940: <li>
                   6941: <p><code class="varname">NO_SRC_ON_FTP</code></p>
                   6942: <p>Distfiles may not be placed on FTP.  Set this variable
                   6943:             to <code class="varname">${RESTRICTED}</code> if re-distribution of
                   6944:             the source code or other distfile(s) via the Internet is not
                   6945:             allowed.</p>
                   6946: </li>
                   6947: </ul></div>
                   6948: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
                   6949:         <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
                   6950:         generic make variables to denote restrictions is deprecated,
                   6951:         because they unconditionally prevent users from generating
                   6952:         binary packages!</p>
                   6953: </div>
                   6954: <div class="sect2" lang="en">
                   6955: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6956: <a name="dependencies"></a>17.1.6. Handling dependencies</h3></div></div></div>
1.75      rillig   6957: <p>Your package may depend on some other package being present
                   6958:         - and there are various ways of expressing this
                   6959:         dependency. pkgsrc supports the <code class="varname">BUILD_DEPENDS</code>
                   6960:         and <code class="varname">DEPENDS</code> definitions, the
                   6961:         <code class="varname">USE_TOOLS</code> definition, as well as
1.76      rillig   6962:         dependencies via <code class="filename">buildlink3.mk</code>, which is
1.75      rillig   6963:         the preferred way to handle dependencies, and which uses the
1.77      rillig   6964:         variables named above. See <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a> for more
1.75      rillig   6965:         information.</p>
                   6966: <p>The basic difference between the two variables is as
                   6967:         follows: The <code class="varname">DEPENDS</code> definition registers
                   6968:         that pre-requisite in the binary package so it will be pulled in
                   6969:         when the binary package is later installed, whilst the
                   6970:         <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
                   6971:         dependency that is only needed for building the package.
                   6972: </p>
                   6973: <p>This means that if you only need a package present whilst
                   6974:         you are building, it should be noted as a
                   6975:         <code class="varname">BUILD_DEPENDS</code>.</p>
                   6976: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
                   6977:         <code class="varname">DEPENDS</code> definition is:</p>
                   6978: <pre class="programlisting">
                   6979:     &lt;pre-req-package-name&gt;:../../&lt;category&gt;/&lt;pre-req-package&gt;
                   6980: </pre>
                   6981: <p>Please note that the &#8220;<span class="quote">pre-req-package-name</span>&#8221;
                   6982:         may include any of the wildcard version numbers recognized by
                   6983:         <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>
                   6984: <div class="orderedlist"><ol type="1">
                   6985: <li>
                   6986: <p>If your package needs another package's binaries or
                   6987:             libraries to build or run, and if that package has a
1.76      rillig   6988:             <code class="filename">buildlink3.mk</code> file available, use it:
1.75      rillig   6989: </p>
                   6990: <pre class="programlisting">
                   6991:     .include "../../graphics/jpeg/buildlink3.mk"
                   6992: </pre>
                   6993: </li>
                   6994: <li>
                   6995: <p>If your package needs to use another package to build
1.76      rillig   6996:             itself and there is no <code class="filename">buildlink3.mk</code>
1.75      rillig   6997:             file available, use the <code class="varname">BUILD_DEPENDS</code>
                   6998:             definition:</p>
                   6999: <pre class="programlisting">
                   7000:     BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
                   7001: </pre>
                   7002: </li>
                   7003: <li>
                   7004: <p>If your package needs a library with which to link and
1.76      rillig   7005:        again there is no <code class="filename">buildlink3.mk</code> file
1.75      rillig   7006:         available, this is specified using the
                   7007:         <code class="varname">DEPENDS</code> definition. For example:</p>
                   7008: <pre class="programlisting">
                   7009:     DEPENDS+=       xpm-3.4j:../../graphics/xpm
                   7010: </pre>
                   7011: <p>You can also use wildcards in package dependences:</p>
                   7012: <pre class="programlisting">
                   7013:     DEPENDS+=       xpm-[0-9]*:../../graphics/xpm
                   7014: </pre>
                   7015: <p>Note that such wildcard dependencies are retained when
                   7016:             creating binary packages.  The dependency is checked when
                   7017:             installing the binary package and any package which matches
                   7018:             the pattern will be used.  Wildcard dependencies should be
                   7019:             used with care.</p>
                   7020: <p>The &#8220;<span class="quote">-[0-9]*</span>&#8221; should be used instead of
                   7021:             &#8220;<span class="quote">-*</span>&#8221; to avoid potentially ambiguous matches
                   7022:             such as &#8220;<span class="quote">tk-postgresql</span>&#8221; matching a
                   7023:             &#8220;<span class="quote">tk-*</span>&#8221; <code class="varname">DEPENDS</code>.</p>
                   7024: <p>Wildcards can also be used to specify that a package
                   7025:             will only  build against a certain minimum version of a
                   7026:             pre-requisite:</p>
                   7027: <pre class="programlisting">
                   7028:     DEPENDS+=       tiff&gt;=3.5.4:../../graphics/tiff
                   7029: </pre>
                   7030: <p>This means that the package will build against version
                   7031:             3.5.4 of the tiff library or newer.  Such a dependency may
                   7032:             be warranted if, for example, the API of the library has
                   7033:             changed with version 3.5.4 and a package would not compile
                   7034:             against an earlier version of tiff.</p>
                   7035: <p>Please note that such dependencies should only be
                   7036:             updated if a package requires  a newer pre-requisite, but
                   7037:             not to denote recommendations such as 
                   7038:             ABI changes that do not prevent a package from building
                   7039:             correctly.  Such recommendations can be expressed using
                   7040:             <code class="varname">ABI_DEPENDS</code>:</p>
                   7041: <pre class="programlisting">
                   7042:     ABI_DEPENDS+=   tiff&gt;=3.6.1:../../graphics/tiff
                   7043: </pre>
                   7044: <p>In addition to the above <code class="varname">DEPENDS</code>
                   7045:             line, this denotes that while a package will build against
                   7046:             tiff&gt;=3.5.4, at least version 3.6.1 is recommended.
                   7047:             <code class="varname">ABI_DEPENDS</code> entries will be turned into
                   7048:             dependencies unless explicitly ignored (in which case a
                   7049:             warning will be printed).</p>
                   7050: <p>To ignore these ABI dependency recommendations and just
                   7051:             use the required <code class="varname">DEPENDS</code>, set
                   7052:             <code class="varname">USE_ABI_DEPENDS=NO</code>.   This may make
                   7053:             it easier and faster to update packages built using pkgsrc,
                   7054:             since older compatible dependencies can continue to be
                   7055:             used. This is useful for people who watch their rebuilds
                   7056:             very carefully; it is not very good as a general-purpose
                   7057:             hammer.  If you use it, you need to be mindful of possible
                   7058:             ABI changes, including those from the underlying OS.
                   7059: </p>
                   7060: <p>Packages that are built with recommendations ignored
                   7061:             may not be uploaded to ftp.NetBSD.org by developers and
                   7062:             should not be used across different systems that may have
                   7063:             different versions of binary packages installed.</p>
                   7064: <p>For security fixes, please update the package
1.78      rillig   7065:             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
1.75      rillig   7066:             information.</p>
                   7067: </li>
                   7068: <li>
                   7069: <p>If your package needs some executable to be able to run
                   7070:             correctly and if there's no
1.76      rillig   7071:             <code class="filename">buildlink3.mk</code> file, this is specified
1.75      rillig   7072:             using the <code class="varname">DEPENDS</code> variable. The
1.76      rillig   7073:             <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
1.75      rillig   7074:            be able to execute the latex binary from the teTeX package
                   7075:            when it runs, and that is specified:</p>
                   7076: <pre class="programlisting">
                   7077:     DEPENDS+=        teTeX-[0-9]*:../../print/teTeX
                   7078: </pre>
                   7079: <p>The comment about wildcard dependencies from previous
                   7080:             paragraph  applies here, too.</p>
                   7081: </li>
                   7082: </ol></div>
                   7083: <p>If your package needs files from another package to build,
                   7084:        add the relevant distribution files to
                   7085:        <code class="varname">DISTFILES</code>, so they will be extracted
1.76      rillig   7086:        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.
1.75      rillig   7087:        (It relies on the jpeg sources being present in source form
                   7088:        during the build.)</p>
                   7089: <p>Please also note the <code class="varname">BUILD_USES_MSGFMT</code>
                   7090:         and <code class="varname">BUILD_USES_GETTEXT_M4</code> definitions, which
                   7091:         are provided as convenience definitions.  The former works out
                   7092:         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,
1.76      rillig   7093:         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.
1.75      rillig   7094:        The latter adds a build dependency on either an installed
                   7095:        version of an older gettext package, or if it isn't, installs the
1.76      rillig   7096:         <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   7097: </div>
                   7098: <div class="sect2" lang="en">
                   7099: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7100: <a name="conflicts"></a>17.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75      rillig   7101: <p>Your package may conflict with other packages a user might
                   7102:         already have installed on his system, e.g. if your package
                   7103:         installs the same set of files like another package in our
                   7104:         pkgsrc tree.</p>
                   7105: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
                   7106:         space-separated list of packages (including version string) your
                   7107:         package conflicts with.</p>
1.76      rillig   7108: <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>
                   7109:         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>
1.75      rillig   7110:         install the same shared library, thus you set in
1.76      rillig   7111:         <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
1.75      rillig   7112: <pre class="programlisting">
                   7113:     CONFLICTS=      Xaw-Xpm-[0-9]*
                   7114: </pre>
1.76      rillig   7115: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:
1.75      rillig   7116: </p>
                   7117: <pre class="programlisting">
                   7118:     CONFLICTS=      Xaw3d-[0-9]*
                   7119: </pre>
                   7120: <p>Packages will automatically conflict with other packages
                   7121:         with the name prefix  and a different version
                   7122:         string. &#8220;<span class="quote">Xaw3d-1.5</span>&#8221; e.g. will automatically
                   7123:         conflict  with the older version &#8220;<span class="quote">Xaw3d-1.3</span>&#8221;.
                   7124: </p>
                   7125: </div>
                   7126: <div class="sect2" lang="en">
                   7127: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7128: <a name="not-building-packages"></a>17.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75      rillig   7129: <p>There are several reasons why a package might be
                   7130:         instructed to not build under certain circumstances. If the
                   7131:         package builds and runs on most platforms, the exceptions
                   7132:         should be noted with <code class="varname">NOT_FOR_PLATFORM</code>.  If
                   7133:         the package builds and runs on a small handful of platforms,
                   7134:         set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
                   7135:        Both <code class="varname">ONLY_FOR_PLATFORM</code> and
                   7136:         <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
                   7137:         (OS-version-platform) that can use glob-style
                   7138:         wildcards.</p>
                   7139: <p>If the package should be skipped (for example, because it
                   7140:         provides functionality already provided by the system), set
                   7141:         <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.
                   7142:         If the package should fail because some preconditions are not
                   7143:         met, set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
                   7144:         message.</p>
                   7145: </div>
                   7146: <div class="sect2" lang="en">
                   7147: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7148: <a name="undeletable-packages"></a>17.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75      rillig   7149: <p>To ensure that a package may not be deleted, once it has been
                   7150:         installed, the <code class="varname">PKG_PRESERVE</code> definition should
                   7151:         be set in the package Makefile. This will be carried into any
                   7152:         binary package that is made from this pkgsrc entry. A
                   7153:         &#8220;<span class="quote">preserved</span>&#8221; package will
                   7154:         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
                   7155:         &#8220;<span class="quote">-f</span>&#8221; option is used.</p>
                   7156: </div>
                   7157: <div class="sect2" lang="en">
                   7158: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7159: <a name="security-handling"></a>17.1.10. Handling packages with security problems</h3></div></div></div>
1.75      rillig   7160: <p>When a vulnerability is found, this should be noted in
1.76      rillig   7161:         <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
1.75      rillig   7162:         and after committing that file, use <span><strong class="command">make upload</strong></span>
                   7163:        in the same directory to update the file on ftp.NetBSD.org.</p>
                   7164: <p>After fixing the vulnerability by a patch, its
                   7165:        <code class="varname">PKGREVISION</code> should be increased (this
                   7166:        is of course not necessary if the problem is fixed by using
                   7167:        a newer release of the software).</p>
                   7168: <p>Also, if the fix should be applied to the stable pkgsrc
                   7169:         branch, be sure to submit a pullup request!</p>
                   7170: <p>Binary packages already on ftp.NetBSD.org will be handled
                   7171:        semi-automatically by a weekly cron job.</p>
                   7172: </div>
                   7173: <div class="sect2" lang="en">
                   7174: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7175: <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   7176: <p>When making fixes to an existing package it can be useful
                   7177:         to change the version number in <code class="varname">PKGNAME</code>. To
                   7178:         avoid conflicting with future versions by the original author, a
                   7179:         &#8220;<span class="quote">nb1</span>&#8221;, &#8220;<span class="quote">nb2</span>&#8221;, ... suffix can be used
                   7180:         on package versions by setting <code class="varname">PKGREVISION=1</code>
                   7181:         (2, ...). The &#8220;<span class="quote">nb</span>&#8221; is treated like a
                   7182:         &#8220;<span class="quote">.</span>&#8221; by the pkg tools. e.g.</p>
                   7183: <pre class="programlisting">
                   7184:     DISTNAME=       foo-17.42
                   7185:     PKGREVISION=    9
                   7186: </pre>
                   7187: <p>will result in a <code class="varname">PKGNAME</code> of
                   7188:         &#8220;<span class="quote">foo-17.42nb9</span>&#8221;.</p>
                   7189: <p>When a new release of the package is released, the
                   7190:         <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
                   7191:         minor release of the above package, things should be like:</p>
                   7192: <pre class="programlisting">
                   7193:     DISTNAME=       foo-17.43
                   7194: </pre>
1.78      rillig   7195: <p>PKGREVISION should be incremented for any non-trivial change in the
                   7196:     resulting binary package.  Without a PKGREVISION bump, someone with
                   7197:     the previous version installed has no way of knowing that their
                   7198:     package is out of date.  Thus, changes without increasing PKGREVISION
                   7199:     are essentially labeled "this is so trivial that no reasonable person
                   7200:     would want to upgrade", and this is the rough test for when increasing
                   7201:     PKGREVISION is appropriate.  Examples of changes that do not merit
                   7202:     increasing PKGREVISION are:</p>
                   7203: <pre class="programlisting">
                   7204: Changing HOMEPAGE, MAINTAINER, or comments in Makefile.
                   7205: Changing build variables if the resulting binary package is the same.
                   7206: Changing DESCR.
                   7207: Adding PKG_OPTIONS if the default options don't change.
                   7208: </pre>
                   7209: <p>Examples of changes that do merit an increase to PKGREVISION
                   7210:     include:</p>
                   7211: <pre class="programlisting">
                   7212: Security fixes
                   7213: Changes or additions to a patch file
                   7214: Changes to the PLIST
1.75      rillig   7215: </pre>
1.78      rillig   7216: <p>PKGREVISION must also be incremented when dependencies have ABI
                   7217:     changes.</p>
1.75      rillig   7218: </div>
1.79      rillig   7219: <div class="sect2" lang="en">
                   7220: <div class="titlepage"><div><div><h3 class="title">
                   7221: <a name="fixes.subst"></a>17.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
                   7222: <p>When you want to replace the same text in multiple files
                   7223:        or when the replacement text varies, patches alone cannot help.
                   7224:        This is where the SUBST framework comes in. It provides an
                   7225:        easy-to-use interface for replacing text in files.
                   7226:        Example:</p>
                   7227: <pre class="programlisting">
                   7228:     SUBST_CLASSES+=                 fix-paths
                   7229:     SUBST_STAGE.fix-paths=          pre-configure
                   7230:     SUBST_MESSAGE.fix-paths=        Fixing absolute paths.
                   7231:     SUBST_FILES.fix-paths=          src/*.c
                   7232:     SUBST_FILES.fix-paths+=         scripts/*.sh
                   7233:     SUBST_SED.fix-paths=            -e 's,"/usr/local,"${PREFIX},g'
                   7234:     SUBST_SED.fix-paths+=           -e 's,"/var/log,"${VARBASE}/log,g'
                   7235: </pre>
                   7236: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
                   7237:        that are used to identify the different SUBST blocks that are
                   7238:        defined. The SUBST framework is heavily used by pkgsrc, so it is
                   7239:        important to always use the <code class="literal">+=</code> operator with
                   7240:        this variable. Otherwise some substitutions may be
                   7241:        skipped.</p>
                   7242: <p>The remaining variables of each SUBST block are
                   7243:        parameterized with the identifier from the first line
                   7244:        (<code class="literal">fix-paths</code> in this case.) They can be seen as
                   7245:        parameters to a function call.</p>
                   7246: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
                   7247:        which the replacement will take place. All combinations of
                   7248:        <code class="literal">pre-</code>, <code class="literal">do-</code> and
                   7249:        <code class="literal">post-</code> together with a phase name are
                   7250:        possible, though only few are actually used. Most commonly used
                   7251:        are <code class="literal">post-patch</code> and
                   7252:        <code class="literal">pre-configure</code>. Of these two,
                   7253:        <code class="literal">pre-configure</code> should be preferred because
                   7254:        then it is possible to run <span><strong class="command">bmake patch</strong></span> and
                   7255:        have the state after applying the patches but before making any
                   7256:        other changes. This is especially useful when you are debugging
                   7257:        a package in order to create new patches for it. Similarly,
                   7258:        <code class="literal">post-build</code> is preferred over
                   7259:        <code class="literal">pre-install</code>, because the install phase should
                   7260:        generally be kept as simple as possible. When you use
                   7261:        <code class="literal">post-build</code>, you have the same files in the
                   7262:        working directory that will be installed later, so you can check
                   7263:        if the substitution has succeeded.</p>
                   7264: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
                   7265:        that is printed just before the substitution is done.</p>
                   7266: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
                   7267:        globbing patterns that specifies the files in which the
                   7268:        substitution will take place. The patterns are interpreted
                   7269:        relatively to the <code class="varname">WRKSRC</code> directory.</p>
                   7270: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
                   7271:        <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
                   7272:        command should be prefixed with <code class="literal">-e</code>, so that
                   7273:        all SUBST blocks look uniform.</p>
                   7274: <p>There are some more variables, but they are so seldomly
                   7275:        used that they are only documented in the
1.80      rillig   7276:        <code class="filename">mk/subst.mk</code> file.</p>
1.79      rillig   7277: </div>
1.75      rillig   7278: </div>
                   7279: <div class="sect1" lang="en">
                   7280: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   7281: <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   7282: <div class="sect2" lang="en">
                   7283: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7284: <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   7285: <p>If you need to download from a dynamic URL you can set
                   7286:         <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
1.76      rillig   7287:         fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
1.75      rillig   7288:         with the name of each file to download as an argument, expecting
                   7289:         it to output the URL of the directory from which to download
1.76      rillig   7290:         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
1.79      rillig   7291:        example of this usage.</p>
1.75      rillig   7292: <p>If the download can't be automated, because the user must
                   7293:        submit personal information to apply for a password, or must pay
                   7294:        for the source, or whatever, you can set
                   7295:        <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
                   7296:        displayed to the user before aborting the build. Example:</p>
                   7297: <pre class="programlisting">
                   7298:     FETCH_MESSAGE=  "Please download the files"
                   7299:     FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   7300:     FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   7301: </pre>
                   7302: </div>
                   7303: <div class="sect2" lang="en">
                   7304: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7305: <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   7306: <p>Sometimes authors of a software package make some
                   7307:         modifications after the software was released, and they put up a
                   7308:         new distfile without changing the package's version number. If a
                   7309:         package is already in pkgsrc at that time, the checksum will
                   7310:         no longer match. The contents of the new distfile should be
                   7311:        compared against the old one before changing anything, to make
                   7312:        sure the distfile was really updated on purpose, and that
                   7313:         no trojan horse or so crept in.
                   7314:        Then, the correct way to work around this is to
                   7315:        set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
                   7316:        usually based on <code class="varname">PKGNAME_NOREV</code>. In case this
                   7317:        happens more often, <code class="varname">PKGNAME</code> can be used (thus
1.76      rillig   7318:        including the <code class="filename">nbX</code> suffix) or a date stamp
1.75      rillig   7319:        can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
1.76      rillig   7320:        Do not forget regenerating the <code class="filename">distinfo</code> file
1.75      rillig   7321:        after that, since it contains the <code class="varname">DIST_SUBDIR</code>
                   7322:        path in the filenames.
                   7323:         Furthermore, a mail to the package's authors seems appropriate
                   7324:        telling them that changing distfiles after releases without
                   7325:        changing the file names is not good practice.</p>
                   7326: </div>
                   7327: </div>
                   7328: <div class="sect1" lang="en">
                   7329: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   7330: <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   7331: <div class="sect2" lang="en">
                   7332: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7333: <a name="fixes.libtool"></a>17.3.1. Shared libraries - libtool</h3></div></div></div>
1.75      rillig   7334: <p>pkgsrc supports many different machines, with different
                   7335:         object formats like a.out and ELF, and varying abilities to do
                   7336:         shared library and dynamic loading at all. To accompany this,
                   7337:         varying commands and options have to be passed to the
                   7338:         compiler, linker, etc. to get the Right Thing, which can be
                   7339:         pretty annoying especially if you don't have all the machines
                   7340:         at your hand to test things.  The
1.76      rillig   7341:        <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/libtool/README.html" target="_top"><code class="filename">devel/libtool</code></a> pkg
1.75      rillig   7342:         can help here, as it just &#8220;<span class="quote">knows</span>&#8221; how to build
                   7343:         both static and dynamic libraries from a set of source files,
                   7344:         thus being platform-independent.</p>
                   7345: <p>Here's how to use libtool in a pkg in seven simple
                   7346:         steps:</p>
                   7347: <div class="orderedlist"><ol type="1">
                   7348: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
                   7349:             Makefile.</p></li>
                   7350: <li><p>For library objects, use &#8220;<span class="quote">${LIBTOOL} --mode=compile
                   7351:             ${CC}</span>&#8221; in place of &#8220;<span class="quote">${CC}</span>&#8221;. You could even
                   7352:             add it to the definition of <code class="varname">CC</code>, if only
                   7353:             libraries are being built in a given Makefile. This one command
                   7354:             will build both PIC and non-PIC library objects, so you need not
                   7355:             have separate shared and non-shared library rules.</p></li>
                   7356: <li>
                   7357: <p>For the linking of the library, remove any
                   7358:             &#8220;<span class="quote">ar</span>&#8221;, &#8220;<span class="quote">ranlib</span>&#8221;, and &#8220;<span class="quote">ld
                   7359:             -Bshareable</span>&#8221; commands, and instead use:</p>
                   7360: <pre class="programlisting">
                   7361:     ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
                   7362:         -rpath ${PREFIX}/lib -version-info major:minor
                   7363: </pre>
                   7364: <p>Note that the library is changed to have a
1.76      rillig   7365:             <code class="filename">.la</code> extension, and the objects are
                   7366:             changed to have a <code class="filename">.lo</code>
1.75      rillig   7367:             extension. Change <code class="varname">OBJS</code> as
                   7368:             necessary. This automatically creates all of the
1.76      rillig   7369:             <code class="filename">.a</code>,
                   7370:             <code class="filename">.so.major.minor</code>, and ELF symlinks (if
1.75      rillig   7371:             necessary) in the build directory. Be sure to include
                   7372:             &#8220;<span class="quote">-version-info</span>&#8221;, especially when major and
                   7373:             minor are zero, as libtool will otherwise strip off the
                   7374:             shared library version.</p>
                   7375: <p>From the libtool manual:</p>
                   7376: <pre class="programlisting">
                   7377:     So, libtool library versions are described by three integers:
1.69      rillig   7378: 
1.75      rillig   7379:     CURRENT
                   7380:         The most recent interface number that this library implements.
1.69      rillig   7381: 
1.75      rillig   7382:     REVISION
                   7383:         The implementation number of the CURRENT interface.
1.69      rillig   7384: 
1.75      rillig   7385:     AGE
                   7386:         The difference between the newest and oldest interfaces that
                   7387:         this library implements.  In other words, the library implements
                   7388:         all the interface numbers in the range from number `CURRENT -
                   7389:         AGE' to `CURRENT'.
1.1       grant    7390: 
1.75      rillig   7391:     If two libraries have identical CURRENT and AGE numbers, then the
                   7392:     dynamic linker chooses the library with the greater REVISION number.
                   7393: </pre>
                   7394: <p>The &#8220;<span class="quote">-release</span>&#8221; option will produce
                   7395:             different results for a.out and ELF (excluding symlinks)
                   7396:             in only one case. An ELF library of the form
                   7397:             &#8220;<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;
                   7398:             will have a symlink of
                   7399:             &#8220;<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;
                   7400:             on an a.out platform. This is handled
                   7401:             automatically.</p>
                   7402: <p>The &#8220;<span class="quote">-rpath argument</span>&#8221; is the install
                   7403:             directory of the library being built.</p>
1.76      rillig   7404: <p>In the <code class="filename">PLIST</code>, include only the
                   7405:             <code class="filename">.la</code> file, the other files will be
1.75      rillig   7406:            added automatically.</p>
                   7407: </li>
                   7408: <li>
1.76      rillig   7409: <p>When linking shared object (<code class="filename">.so</code>)
1.75      rillig   7410:             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
                   7411:             shared libraries, use &#8220;<span class="quote">-module
                   7412:             -avoid-version</span>&#8221; to prevent them getting version
                   7413:             tacked on.</p>
1.76      rillig   7414: <p>The <code class="filename">PLIST</code> file gets the
                   7415:             <code class="filename">foo.so</code> entry.</p>
1.75      rillig   7416: </li>
                   7417: <li>
                   7418: <p>When linking programs that depend on these libraries
                   7419:             <span class="emphasis"><em>before</em></span> they are installed, preface
                   7420:             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}
                   7421:             --mode=link</span>&#8221;, and it will find the correct
                   7422:             libraries (static or shared), but please be aware that
                   7423:             libtool will not allow you to specify a relative path in
                   7424:             -L (such as &#8220;<span class="quote">-L../somelib</span>&#8221;), because it
                   7425:             expects you to change that argument to be the
1.76      rillig   7426:             <code class="filename">.la</code> file. e.g.</p>
1.75      rillig   7427: <pre class="programlisting">
                   7428:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   7429: </pre>
                   7430: <p>should be changed to:</p>
                   7431: <pre class="programlisting">
                   7432:     ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
                   7433: </pre>
                   7434: <p>and it will do the right thing with the libraries.</p>
                   7435: </li>
                   7436: <li>
                   7437: <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>
                   7438:             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}
                   7439:             --mode=install</span>&#8221;, and change the library name to
1.76      rillig   7440:             <code class="filename">.la</code>. e.g.</p>
1.75      rillig   7441: <pre class="programlisting">
                   7442:     ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
                   7443: </pre>
1.76      rillig   7444: <p>This will install the static <code class="filename">.a</code>,
1.75      rillig   7445:             shared library, any needed symlinks, and run
                   7446:             <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>
                   7447: </li>
1.76      rillig   7448: <li><p>In your <code class="filename">PLIST</code>, include only
                   7449:             the <code class="filename">.la</code>
1.75      rillig   7450:             file (this is a change from previous behaviour).</p></li>
                   7451: </ol></div>
                   7452: </div>
                   7453: <div class="sect2" lang="en">
                   7454: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7455: <a name="using-libtool"></a>17.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75      rillig   7456: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
                   7457:         package Makefile. This will override the package's own libtool
                   7458:         in most cases.  For older libtool using packages,  libtool is
                   7459:         made by ltconfig script during the do-configure step; you can
                   7460:         check the libtool script location by doing <span><strong class="command">make
                   7461:         configure; find work*/ -name libtool</strong></span>.</p>
                   7462: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
                   7463:         scripts, relative to <code class="varname">WRKSRC</code>, to override.  By
                   7464:         default, it is set to &#8220;<span class="quote">libtool */libtool
                   7465:         */*/libtool</span>&#8221;.  If this does not match the location of the
                   7466:         package's libtool script(s), set it as appropriate.</p>
1.76      rillig   7467: <p>If you do not need <code class="filename">*.a</code> static
1.75      rillig   7468:         libraries built and installed, then use
                   7469:         <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
                   7470: <p>If your package makes use of the platform-independent library
                   7471:         for loading dynamic shared objects, that comes with libtool
                   7472:         (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
                   7473: <p>Some packages use libtool incorrectly so that the package may not work or
                   7474:         build in some circumstances. Some of the more common errors are:</p>
                   7475: <div class="itemizedlist"><ul type="disc">
                   7476: <li>
                   7477: <p>The inclusion of a shared object (-module) as a dependent library in an
                   7478:             executable or library. This in itself isn't a problem if one of two things
                   7479:             has been done:</p>
                   7480: <div class="orderedlist"><ol type="1">
                   7481: <li><p>The shared object is named correctly, i.e.
1.76      rillig   7482:                 <code class="filename">libfoo.la</code>, not
                   7483:                 <code class="filename">foo.la</code></p></li>
1.75      rillig   7484: <li><p>The -dlopen option is used when linking an executable.</p></li>
                   7485: </ol></div>
                   7486: </li>
                   7487: <li><p>The use of libltdl without the correct calls to initialisation routines.
                   7488:             The function lt_dlinit() should be called and the macro
                   7489:             <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
                   7490:             executables.</p></li>
                   7491: </ul></div>
                   7492: </div>
                   7493: <div class="sect2" lang="en">
                   7494: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7495: <a name="autoconf-automake"></a>17.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75      rillig   7496: <p>If a package needs GNU autoconf or automake to be executed
                   7497:         to regenerate the configure script and Makefile.in makefile
                   7498:         templates, then they should be executed in a pre-configure
                   7499:         target.</p>
                   7500: <p>For packages that need only autoconf:</p>
                   7501: <pre class="programlisting">
                   7502:     AUTOCONF_REQD=  2.50            # if default version is not good enough
                   7503:     USE_TOOLS+=     autoconf        # use "autoconf213" for autoconf-2.13
                   7504:     ...
1.1       grant    7505: 
1.75      rillig   7506:     pre-configure:
                   7507:             cd ${WRKSRC}; autoconf
1.1       grant    7508: 
1.75      rillig   7509:     ...
                   7510: </pre>
                   7511: <p>and for packages that need automake and autoconf:</p>
                   7512: <pre class="programlisting">
                   7513:     AUTOMAKE_REQD=  1.7.1           # if default version is not good enough
                   7514:     USE_TOOLS+=     automake        # use "automake14" for automake-1.4
                   7515:     ...
1.1       grant    7516: 
1.75      rillig   7517:     pre-configure:
                   7518:             cd ${WRKSRC};                          \
                   7519:             aclocal; autoheader;                   \
                   7520:             automake -a --foreign -i; autoconf
1.1       grant    7521: 
1.75      rillig   7522:     ...
                   7523: </pre>
                   7524: <p>Packages which use GNU Automake will almost certainly
                   7525:           require GNU Make.</p>
                   7526: <p>There are times when the configure process makes
                   7527:           additional  changes to the generated files, which then causes
                   7528:           the build  process to try to re-execute the automake sequence.
                   7529:           This is  prevented by touching various files in the configure
                   7530:           stage. If  this causes problems with your package you can set
                   7531:           <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
                   7532:           Makefile.</p>
                   7533: </div>
                   7534: </div>
                   7535: <div class="sect1" lang="en">
                   7536: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   7537: <a name="fixes.build"></a>17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
                   7538: <p>The most common failures when building a package are that
                   7539:        some platforms do not provide certain header files, functions or
                   7540:        libraries, or they provide the functions in a library that the
                   7541:        original package author didn't know. To work around this, you
                   7542:        can rewrite the source code in most cases so that it does not
                   7543:        use the missing functions or provides a replacement function.</p>
                   7544: <div class="sect2" lang="en">
                   7545: <div class="titlepage"><div><div><h3 class="title">
                   7546: <a name="fixes.build.cpp"></a>17.4.1. Compiling C and C++ code conditionally</h3></div></div></div>
                   7547: <p>If a package already comes with a GNU configure script, the
                   7548:        preferred way to fix the build failure is to change the
                   7549:        configure script, not the code. In the other cases, you can
                   7550:        utilize the C preprocessor, which defines certain macros
                   7551:        depending on the operating system and hardware architecture it
                   7552:        compiles for. These macros can be queried using for example
                   7553:        <code class="varname">#if defined(__i386)</code>. Almost every operating
                   7554:        system, hardware architecture and compiler has its own macro.
                   7555:        For example, if the macros <code class="varname">__GNUC__</code>,
                   7556:        <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
                   7557:        are all defined, you know that you are using NetBSD on an i386
                   7558:        compatible CPU, and your compiler is GCC.</p>
                   7559: <p>The list of the following macros for hardware and
                   7560:        operating system depends on the compiler that is used. For
                   7561:        example, if you want to conditionally compile code on Solaris,
                   7562:        don't use <code class="varname">__sun__</code>, as the SunPro compiler
                   7563:        does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75      rillig   7564: <div class="sect3" lang="en">
                   7565: <div class="titlepage"><div><div><h4 class="title">
1.77      rillig   7566: <a name="fixes.build.cpp.os"></a>17.4.1.1. C preprocessor macros to identify the operating system</h4></div></div></div>
1.75      rillig   7567: <p>To distinguish between 4.4 BSD-derived systems and the
                   7568:         rest of the world, you should use the following code.</p>
                   7569: <pre class="programlisting">
                   7570:     #include &lt;sys/param.h&gt;
                   7571:     #if (defined(BSD) &amp;&amp; BSD &gt;= 199306)
                   7572:       /* BSD-specific code goes here */
                   7573:     #else
                   7574:       /* non-BSD-specific code goes here */
                   7575:     #endif
                   7576: </pre>
1.77      rillig   7577: <p>If this distinction is not fine enough, you can also test
                   7578:        for the following macros.</p>
1.75      rillig   7579: <pre class="programlisting">
                   7580:     FreeBSD     __FreeBSD__
                   7581:     DragonFly   __DragonFly__
                   7582:     Interix     __INTERIX
                   7583:     Linux       linux, __linux, __linux__
                   7584:     NetBSD      __NetBSD__
                   7585:     OpenBSD     __OpenBSD__
                   7586:     Solaris     sun, __sun
                   7587: </pre>
                   7588: </div>
                   7589: <div class="sect3" lang="en">
                   7590: <div class="titlepage"><div><div><h4 class="title">
1.77      rillig   7591: <a name="fixes.build.cpp.arch"></a>17.4.1.2. C preprocessor macros to identify the hardware architecture</h4></div></div></div>
1.75      rillig   7592: <pre class="programlisting">
                   7593:     i386        i386, __i386, __i386__
                   7594:     MIPS        __mips
                   7595:     SPARC       sparc, __sparc
                   7596: </pre>
                   7597: </div>
                   7598: <div class="sect3" lang="en">
                   7599: <div class="titlepage"><div><div><h4 class="title">
1.77      rillig   7600: <a name="fixes.build.cpp.compiler"></a>17.4.1.3. C preprocessor macros to identify the compiler</h4></div></div></div>
1.75      rillig   7601: <pre class="programlisting">
                   7602:     GCC         __GNUC__ (major version), __GNUC_MINOR__
                   7603:     SunPro      __SUNPRO_C (0x570 for version 5.7)
1.81      rillig   7604:     SunPro C++  __SUNPRO_CC (0x580 for version 5.8)
1.75      rillig   7605: </pre>
                   7606: </div>
                   7607: </div>
1.78      rillig   7608: <div class="sect2" lang="en">
                   7609: <div class="titlepage"><div><div><h3 class="title">
                   7610: <a name="compiler-bugs"></a>17.4.2. How to handle compiler bugs</h3></div></div></div>
                   7611: <p>Some source files trigger bugs in the compiler, based on
                   7612:         combinations  of compiler version and architecture and almost
                   7613:         always relation to  optimisation being enabled.  Common symptoms
                   7614:         are gcc internal errors  or never finishing compiling a
                   7615:        file.</p>
                   7616: <p>Typically, a workaround involves testing the
                   7617:         <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
                   7618:         optimisation for that combination of file,
                   7619:        <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
                   7620:        in  <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
                   7621:        number of examples.</p>
                   7622: </div>
                   7623: <div class="sect2" lang="en">
                   7624: <div class="titlepage"><div><div><h3 class="title">
                   7625: <a name="undefined-reference"></a>17.4.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</h3></div></div></div>
                   7626: <p>This compiler error often means that a package did not
                   7627:        link to a shared library it needs. The following functions are
                   7628:        known to cause this error message over and over.</p>
                   7629: <div class="informaltable">
                   7630: <a name="undefined-reference-functions"></a><table border="1">
                   7631: <colgroup>
                   7632: <col>
                   7633: <col>
                   7634: <col>
                   7635: </colgroup>
                   7636: <thead><tr>
                   7637: <th>Function</th>
                   7638: <th>Library</th>
                   7639: <th>Affected platforms</th>
                   7640: </tr></thead>
                   7641: <tbody>
                   7642: <tr>
                   7643: <td>accept, bind, connect</td>
                   7644: <td>-lsocket</td>
                   7645: <td>Solaris</td>
                   7646: </tr>
                   7647: <tr>
                   7648: <td>crypt</td>
                   7649: <td>-lcrypt</td>
                   7650: <td>DragonFly, NetBSD</td>
                   7651: </tr>
                   7652: <tr>
                   7653: <td>dlopen, dlsym</td>
                   7654: <td>-ldl</td>
                   7655: <td>Linux</td>
                   7656: </tr>
                   7657: <tr>
                   7658: <td>gethost*</td>
                   7659: <td>-lnsl</td>
                   7660: <td>Solaris</td>
                   7661: </tr>
                   7662: <tr>
                   7663: <td>inet_aton</td>
                   7664: <td>-lresolv</td>
                   7665: <td>Solaris</td>
                   7666: </tr>
                   7667: <tr>
                   7668: <td>nanosleep, sem_*, timer_*</td>
                   7669: <td>-lrt</td>
                   7670: <td>Solaris</td>
                   7671: </tr>
                   7672: <tr>
                   7673: <td>openpty</td>
                   7674: <td>-lutil</td>
                   7675: <td>Linux</td>
                   7676: </tr>
                   7677: </tbody>
                   7678: </table>
                   7679: </div>
                   7680: <p>To fix these linker errors, it is often sufficient to say
                   7681:        <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
                   7682:        -l<em class="replaceable"><code>foo</code></em></code> to the package
                   7683:        <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
                   7684:        bmake</strong></span>.</p>
                   7685: </div>
1.75      rillig   7686: </div>
                   7687: <div class="sect1" lang="en">
                   7688: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78      rillig   7689: <a name="fixes.install"></a>17.5. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75      rillig   7690: <div class="sect2" lang="en">
                   7691: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7692: <a name="install-scripts"></a>17.5.1. Creating needed directories</h3></div></div></div>
                   7693: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
                   7694:        with some operating systems cannot create more than one
                   7695:        directory at a time. As such, you should call
                   7696:        <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
1.75      rillig   7697: <pre class="programlisting">
1.78      rillig   7698:     ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   7699:     ${INSTALL_DATA_DIR} ${PREFIX}/dir2
1.75      rillig   7700: </pre>
1.78      rillig   7701: <p>You can also just append &#8220;<span class="quote"><code class="literal">dir1
                   7702:        dir2</code></span>&#8221; to the
                   7703:        <code class="varname">INSTALLATION_DIRS</code> variable, which will
                   7704:        automatically do the right thing.</p>
1.75      rillig   7705: </div>
                   7706: <div class="sect2" lang="en">
                   7707: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7708: <a name="where-to-install-documentation"></a>17.5.2. Where to install documentation</h3></div></div></div>
1.83      wiz      7709: <p>In general, documentation should be installed into
1.78      rillig   7710:        <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
1.84      wiz      7711:        <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the
                   7712:        latter includes the version number of the package).</p>
                   7713: <p>Many modern packages using GNU autoconf allow to set the
                   7714:        directory where HTML documentation is installed with the
                   7715:        &#8220;<span class="quote">--with-html-dir</span>&#8221; option. Sometimes using this
                   7716:        flag is needed because otherwise the documentation ends up in
                   7717:        <code class="filename">${PREFIX}/share/doc/html</code> or other
                   7718:        places.</p>
1.83      wiz      7719: <p>An exception to the above is that library API
                   7720:        documentation 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
                   7721:        special browsers (devhelp) should be left at their default
                   7722:        location, which is
                   7723:        <code class="filename">${PREFIX}/share/gtk-doc</code>.  Such
                   7724:        documentation can be recognized from files ending in
                   7725:        <code class="filename">.devhelp</code> or
                   7726:        <code class="filename">.devhelp2</code>.  (It is also acceptable to
                   7727:        install such files in
1.84      wiz      7728:        <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
                   7729:        <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code>; the
                   7730:        <code class="filename">.devhelp*</code> file must be directly in that
                   7731:        directory then, no additional
                   7732:        subdirectory level is allowed in this case. This is usually
                   7733:        achieved by using
                   7734:        &#8220;<span class="quote">--with-html-dir=${PREFIX}/share/doc</span>&#8221;.
                   7735:        <code class="filename">${PREFIX}/share/gtk-doc</code> is preferred
                   7736:        though.)</p>
1.75      rillig   7737: </div>
                   7738: <div class="sect2" lang="en">
                   7739: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7740: <a name="installing-score-files"></a>17.5.3. Installing score files</h3></div></div></div>
1.75      rillig   7741: <p>Certain packages, most of them in the games category, install
                   7742:         a score file that allows all users on the system to record their
                   7743:         highscores.  In order for this to work, the binaries need to be
                   7744:         installed setgid and the score files owned by the appropriate
                   7745:         group and/or owner (traditionally the "games" user/group).  The
                   7746:         following variables, documented in more detail in
1.76      rillig   7747:         <code class="filename">mk/defaults/mk.conf</code>, control this
1.75      rillig   7748:         behaviour: <code class="varname">SETGIDGAME</code>,
                   7749:         <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
                   7750:         <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
                   7751: <p>Note that per default, setgid installation of games is
                   7752:         disabled;  setting <code class="varname">SETGIDGAME=YES</code> will set all
                   7753:         the other variables accordingly.</p>
                   7754: <p>A package should therefor never hard code file ownership or
                   7755:         access permissions but rely on <code class="varname">INSTALL_GAME</code> and
                   7756:         <code class="varname">INSTALL_GAME_DATA</code> to set these
                   7757:         correctly.</p>
                   7758: </div>
                   7759: <div class="sect2" lang="en">
                   7760: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7761: <a name="perl-scripts"></a>17.5.4. Packages containing perl scripts</h3></div></div></div>
1.75      rillig   7762: <p>
                   7763:         If your package contains interpreted perl scripts, set
                   7764:         <code class="varname">REPLACE_PERL</code> to ensure that the proper
                   7765:         interpreter path is set. <code class="varname">REPLACE_PERL</code> should
                   7766:         contain a list of scripts, relative to
                   7767:         <code class="varname">WRKSRC</code>, that you want adjusted.</p>
                   7768: </div>
                   7769: <div class="sect2" lang="en">
                   7770: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7771: <a name="hardcoded-paths"></a>17.5.5. Packages with hardcoded paths to other interpreters</h3></div></div></div>
1.75      rillig   7772: <p>
                   7773:         Your package may also contain scripts with hardcoded paths to
                   7774:         other interpreters besides (or as well as) perl.  To correct the
                   7775:         full pathname to the script interpreter, you need to set the
1.76      rillig   7776:         following definitions in your <code class="filename">Makefile</code> (we
1.75      rillig   7777:         shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
                   7778: <pre class="programlisting">
                   7779:     REPLACE_INTERPRETER+=   tcl
                   7780:     REPLACE.tcl.old=        .*/bin/tclsh
                   7781:     REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   7782:     REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   7783:                             # relative to ${WRKSRC}, just as in REPLACE_PERL
                   7784: </pre>
                   7785: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   7786: <h3 class="title">Note</h3>
                   7787: <p>Before March 2006, these variables were called
                   7788:        <code class="varname">_REPLACE.*</code> and
                   7789:        <code class="varname">_REPLACE_FILES.*</code>.</p>
                   7790: </div>
                   7791: </div>
                   7792: <div class="sect2" lang="en">
                   7793: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7794: <a name="perl-modules"></a>17.5.6. Packages installing perl modules</h3></div></div></div>
1.75      rillig   7795: <p>Makefiles of packages providing perl5 modules should include
                   7796:         the Makefile fragment
1.76      rillig   7797:         <code class="filename">../../lang/perl5/module.mk</code>.  It provides a
1.75      rillig   7798:         <span><strong class="command">do-configure</strong></span> target for the standard perl
                   7799:         configuration for such modules as well as various hooks to tune
                   7800:         this configuration.  See comments in this file for
                   7801:         details.</p>
                   7802: <p>Perl5 modules will install into different places depending
                   7803:         on the version of perl used during the build process.  To
                   7804:         address this, pkgsrc will append lines to the
1.76      rillig   7805:         <code class="filename">PLIST</code> corresponding to the files listed in
                   7806:         the installed <code class="filename">.packlist</code> file generated by
1.75      rillig   7807:         most perl5 modules.  This is invoked by defining
                   7808:         <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
                   7809:         paths to packlist files, e.g.:</p>
                   7810: <pre class="programlisting">
                   7811:     PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
                   7812: </pre>
                   7813: <p>The variables <code class="varname">PERL5_SITELIB</code>,
                   7814:         <code class="varname">PERL5_SITEARCH</code>, and
                   7815:         <code class="varname">PERL5_ARCHLIB</code> represent the three locations
                   7816:         in which perl5 modules may be installed, and may be used by
                   7817:         perl5 packages that don't have a packlist.  These three
                   7818:         variables are also substituted for in the
1.76      rillig   7819:         <code class="filename">PLIST</code>.</p>
1.75      rillig   7820: </div>
                   7821: <div class="sect2" lang="en">
                   7822: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7823: <a name="faq.info-files"></a>17.5.7. Packages installing info files</h3></div></div></div>
1.75      rillig   7824: <p>Some packages install info files or use the
                   7825:         &#8220;<span class="quote">makeinfo</span>&#8221;  or &#8220;<span class="quote">install-info</span>&#8221;
                   7826:        commands.  <code class="varname">INFO_FILES</code> should be defined in
1.76      rillig   7827:        the package Makefile so that <code class="filename">INSTALL</code> and
                   7828:         <code class="filename">DEINSTALL</code> scripts will be generated to
1.75      rillig   7829:         handle registration of the info files in the Info directory
                   7830:         file. The &#8220;<span class="quote">install-info</span>&#8221; command used for the info
                   7831:         files registration is either provided by the system, or by a
                   7832:         special purpose package automatically added as dependency if
                   7833:         needed.</p>
                   7834: <p><code class="varname">PKGINFODIR</code> is the directory under
1.76      rillig   7835:        <code class="filename">${PREFIX}</code> where info files are primarily
1.75      rillig   7836:        located. <code class="varname">PKGINFODIR</code> defaults to
                   7837:        &#8220;<span class="quote">info</span>&#8221; and can be overridden by the user.</p>
                   7838: <p>The info files for the package should be listed in the
1.76      rillig   7839:        package <code class="filename">PLIST</code>; however any split info files
1.75      rillig   7840:        need not be listed.</p>
                   7841: <p>A package which needs the &#8220;<span class="quote">makeinfo</span>&#8221; command
                   7842:         at build time must add &#8220;<span class="quote">makeinfo</span>&#8221; to
                   7843:         <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
                   7844:         version of the &#8220;<span class="quote">makeinfo</span>&#8221; command is needed it
                   7845:         should be noted with the <code class="varname">TEXINFO_REQD</code>
1.76      rillig   7846:         variable in the package <code class="filename">Makefile</code>. By
1.75      rillig   7847:         default, a minimum version of 3.12 is required. If the system
                   7848:         does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
                   7849:         does not match the required minimum, a build dependency on the
1.76      rillig   7850:         <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
1.75      rillig   7851:        be added automatically.</p>
                   7852: <p>The build and installation process of the software provided
                   7853:         by the package should not use the
                   7854:         <span><strong class="command">install-info</strong></span> command as the registration of
                   7855:         info files is the task of the package
1.76      rillig   7856:         <code class="filename">INSTALL</code> script, and it must use the
1.75      rillig   7857:         appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
                   7858: <p>To achieve this goal, the pkgsrc infrastructure creates
                   7859:         overriding scripts for the <span><strong class="command">install-info</strong></span> and
                   7860:         <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
                   7861:         in <code class="varname">PATH</code>.</p>
                   7862: <p>The script overriding <span><strong class="command">install-info</strong></span> has
                   7863:         no effect except the logging of a message. The script overriding
                   7864:         <span><strong class="command">makeinfo</strong></span> logs a message and according to the
                   7865:         value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
                   7866:        <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
                   7867: </div>
                   7868: <div class="sect2" lang="en">
                   7869: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7870: <a name="manpages"></a>17.5.8. Packages installing man pages</h3></div></div></div>
1.81      rillig   7871: <p>All packages that install manual pages should install them
                   7872:        into the same directory, so that there is one common place to
                   7873:        look for them. In pkgsrc, this place is
                   7874:        <code class="literal">${PREFIX}/${PKGMANDIR}</code>, and this expression
                   7875:        should be used in packages. The default for
                   7876:        <code class="varname">PKGMANDIR</code> is
                   7877:        &#8220;<span class="quote"><code class="filename">man</code></span>&#8221;. Another often-used
                   7878:        value is &#8220;<span class="quote"><code class="filename">share/man</code></span>&#8221;.</p>
1.75      rillig   7879: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   7880: <h3 class="title">Note</h3>
1.81      rillig   7881: <p>The support for a custom
                   7882:        <code class="varname">PKGMANDIR</code> is far from complete.</p>
1.75      rillig   7883: </div>
1.81      rillig   7884: <p>The <code class="filename">PLIST</code> files can just use
                   7885:        <code class="filename">man/</code> as the top level directory for the man
                   7886:        page file entries, and the pkgsrc framework will convert as
                   7887:        needed. In all other places, the correct
                   7888:        <code class="varname">PKGMANDIR</code> must be used.</p>
1.75      rillig   7889: <p> Packages that are
                   7890:        configured with <code class="varname">GNU_CONFIGURE</code> set as
                   7891:        &#8220;<span class="quote">yes</span>&#8221;, by default will use the
1.76      rillig   7892:        <code class="filename">./configure</code>
1.75      rillig   7893:        --mandir switch to set where the man pages should be installed.
                   7894:        The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
                   7895:        to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.
                   7896:       </p>
                   7897: <p>
                   7898:        Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
                   7899:        use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
                   7900:        to &#8220;<span class="quote">no</span>&#8221;.
1.76      rillig   7901:        Or if the <code class="filename">./configure</code> script uses
1.75      rillig   7902:        a non-standard use of --mandir, you can set
                   7903:        <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.
                   7904:       </p>
1.77      rillig   7905: <p>See <a href="#manpage-compression" title="11.5. Man page compression">Section 11.5, &#8220;Man page compression&#8221;</a> for
1.75      rillig   7906:        information on installation of compressed manual pages.
                   7907:       </p>
                   7908: </div>
                   7909: <div class="sect2" lang="en">
                   7910: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7911: <a name="gconf2-data-files"></a>17.5.9. Packages installing GConf2 data files</h3></div></div></div>
1.75      rillig   7912: <p>
1.76      rillig   7913:         If a package installs <code class="filename">.schemas</code> or
                   7914:         <code class="filename">.entries</code> files, used by GConf2,
1.75      rillig   7915:         you need to take some extra steps to make sure they get registered
                   7916:         in the database:
                   7917: </p>
                   7918: <div class="orderedlist"><ol type="1">
1.76      rillig   7919: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
                   7920:           instead of its <code class="filename">buildlink3.mk</code> file.  This
1.75      rillig   7921:           takes care of rebuilding the GConf2 database at installation and
                   7922:           deinstallation time, and tells the package where to install
                   7923:           GConf2 data files using some standard configure arguments.  It
                   7924:           also disallows any access to the database directly from the
                   7925:           package.</p></li>
                   7926: <li><p>Ensure that the package installs its
1.76      rillig   7927:           <code class="filename">.schemas</code> files under
                   7928:           <code class="filename">${PREFIX}/share/gconf/schemas</code>.  If they get
                   7929:           installed under <code class="filename">${PREFIX}/etc</code>, you will
1.75      rillig   7930:           need to manually patch the package.</p></li>
                   7931: <li><p>Check the PLIST and remove any entries under the etc/gconf
                   7932:           directory, as they will be handled automatically.  See
                   7933:           <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>
                   7934: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.76      rillig   7935:           your <code class="filename">Makefile</code> with a list of all
                   7936:           <code class="filename">.schemas</code> files installed by the package, if
1.75      rillig   7937:           any.  Names must not contain any directories in them.</p></li>
                   7938: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.76      rillig   7939:           your <code class="filename">Makefile</code> with a
                   7940:           list of all <code class="filename">.entries</code> files installed by the
1.75      rillig   7941:           package, if any. Names must not contain any directories in
                   7942:           them.</p></li>
                   7943: </ol></div>
                   7944: </div>
                   7945: <div class="sect2" lang="en">
                   7946: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7947: <a name="scrollkeeper-data-files"></a>17.5.10. Packages installing scrollkeeper data files</h3></div></div></div>
1.75      rillig   7948: <p>
1.76      rillig   7949:         If a package installs <code class="filename">.omf</code> files, used by
1.75      rillig   7950:         scrollkeeper, you need to take some extra steps to make sure they
                   7951:         get registered in the database:
                   7952: </p>
                   7953: <div class="orderedlist"><ol type="1">
                   7954: <li><p>Include
1.76      rillig   7955:             <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
                   7956:             instead of its <code class="filename">buildlink3.mk</code> file.  This
1.75      rillig   7957:             takes care of rebuilding the scrollkeeper database at
                   7958:             installation and deinstallation time, and disallows any access
                   7959:             to it directly from the package.
                   7960: </p></li>
                   7961: <li><p>Check the PLIST and remove any entries under the
1.76      rillig   7962:             <code class="filename">libdata/scrollkeeper</code> directory, as they
1.75      rillig   7963:             will be handled automatically.</p></li>
1.76      rillig   7964: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.75      rillig   7965:             the PLIST.  It will be handled by scrollkeeper.</p></li>
                   7966: </ol></div>
                   7967: </div>
                   7968: <div class="sect2" lang="en">
                   7969: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7970: <a name="x11-fonts"></a>17.5.11. Packages installing X11 fonts</h3></div></div></div>
1.75      rillig   7971: <p>If a package installs font files, you will need to rebuild
                   7972:         the fonts database in the directory where they get installed at
                   7973:         installation and deinstallation time.  This can be automatically
                   7974:         done by using the pkginstall framework.</p>
                   7975: <p>You can list the directories where fonts are installed in the
                   7976:         <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
                   7977:         variables, where <em class="replaceable"><code>type</code></em> can be one of
                   7978:         &#8220;<span class="quote">ttf</span>&#8221;, &#8220;<span class="quote">type1</span>&#8221; or &#8220;<span class="quote">x11</span>&#8221;.
                   7979:         Also make sure that the database file
1.76      rillig   7980:         <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75      rillig   7981: <p>Note that you should not create new directories for fonts;
                   7982:         instead use the standard ones to avoid that the user needs to
                   7983:         manually configure his X server to find them.</p>
                   7984: </div>
                   7985: <div class="sect2" lang="en">
                   7986: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7987: <a name="gtk2-modules"></a>17.5.12. Packages installing GTK2 modules</h3></div></div></div>
1.75      rillig   7988: <p>If a package installs GTK2 immodules or loaders, you need to
                   7989:         take some extra steps to get them registered in the GTK2 database
                   7990:         properly:</p>
                   7991: <div class="orderedlist"><ol type="1">
                   7992: <li><p>Include
1.76      rillig   7993:         <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
                   7994:         <code class="filename">buildlink3.mk</code> file.  This takes care of
1.75      rillig   7995:         rebuilding the database at installation and deinstallation time.
                   7996: </p></li>
                   7997: <li><p>
                   7998:         Set <code class="varname">GTK2_IMMODULES=YES</code> if
                   7999:             your package installs GTK2 immodules.</p></li>
                   8000: <li><p>
                   8001:         Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
                   8002:             GTK2 loaders.</p></li>
                   8003: <li>
                   8004: <p>
                   8005:         Patch the package to not touch any of the GTK2 databases directly.
                   8006:         These are:
                   8007: 
                   8008:         </p>
                   8009: <div class="itemizedlist"><ul type="disc">
1.76      rillig   8010: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
                   8011: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75      rillig   8012: </ul></div>
                   8013: <p>
                   8014: </p>
                   8015: </li>
                   8016: <li><p>
                   8017:         Check the PLIST and remove any entries under the
1.76      rillig   8018:         <code class="filename">libdata/gtk-2.0</code> directory, as they will be
1.75      rillig   8019:         handled automatically.</p></li>
                   8020: </ol></div>
                   8021: </div>
                   8022: <div class="sect2" lang="en">
                   8023: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   8024: <a name="sgml-xml-data"></a>17.5.13. Packages installing SGML or XML data</h3></div></div></div>
1.75      rillig   8025: <p>If a package installs SGML or XML data files that need to be
                   8026:         registered in system-wide catalogs (like DTDs, sub-catalogs,
                   8027:         etc.), you need to take some extra steps:
                   8028: </p>
                   8029: <div class="orderedlist"><ol type="1">
                   8030: <li><p>Include
1.76      rillig   8031:             <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
                   8032:             your <code class="filename">Makefile</code>, which takes care of
1.75      rillig   8033:             registering those files in system-wide catalogs at
                   8034:             installation and deinstallation time.</p></li>
                   8035: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
                   8036:             any SGML catalogs installed by the package.</p></li>
                   8037: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
                   8038:             any XML catalogs installed by the package.</p></li>
                   8039: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
                   8040:             to be added to the SGML catalog.  These come in groups of
                   8041:             three strings; see xmlcatmgr(1) for more information
                   8042:             (specifically, arguments recognized by the 'add' action).
                   8043:             Note that you will normally not use this variable.</p></li>
                   8044: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
                   8045:             to be added to the XML catalog.  These come in groups of three
                   8046:             strings; see xmlcatmgr(1) for more information (specifically,
                   8047:             arguments recognized by the 'add' action).  Note that you will
                   8048:             normally not use this variable.
                   8049: </p></li>
                   8050: </ol></div>
                   8051: </div>
                   8052: <div class="sect2" lang="en">
                   8053: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   8054: <a name="mime-database"></a>17.5.14. Packages installing extensions to the MIME database</h3></div></div></div>
1.75      rillig   8055: <p>If a package provides extensions to the MIME database by
1.76      rillig   8056:         installing <code class="filename">.xml</code> files inside
                   8057:         <code class="filename">${PREFIX}/share/mime/packages</code>, you
1.75      rillig   8058:         need to take some extra steps to ensure that the database is kept
                   8059:         consistent with respect to these new files:
                   8060: </p>
                   8061: <div class="orderedlist"><ol type="1">
                   8062: <li><p>Include
1.76      rillig   8063:             <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
                   8064:             (avoid using the <code class="filename">buildlink3.mk</code> file from
1.75      rillig   8065:             this same directory, which is reserved for inclusion from
1.76      rillig   8066:             other <code class="filename">buildlink3.mk</code> files).  It takes
1.75      rillig   8067:             care of rebuilding the MIME database at installation and
                   8068:             deinstallation time, and disallows any access to it directly
                   8069:             from the package.</p></li>
                   8070: <li><p>Check the PLIST and remove any entries under the
1.76      rillig   8071:             <code class="filename">share/mime</code> directory,
1.75      rillig   8072:             <span class="emphasis"><em>except</em></span> for files saved under
1.76      rillig   8073:             <code class="filename">share/mime/packages</code>.  The former are
1.75      rillig   8074:             handled automatically by
                   8075:             the update-mime-database program, but the latter are
                   8076:             package-dependent and must be removed by the package that
                   8077:             installed them in the first place.</p></li>
1.76      rillig   8078: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.75      rillig   8079:             from the PLIST.  They will be handled by the shared-mime-info
                   8080:             package.</p></li>
                   8081: </ol></div>
                   8082: </div>
                   8083: <div class="sect2" lang="en">
                   8084: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   8085: <a name="intltool"></a>17.5.15. Packages using intltool</h3></div></div></div>
1.75      rillig   8086: <p>If a package uses intltool during its build, include the
1.76      rillig   8087:         <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
1.75      rillig   8088:         which forces it to use the intltool package provided by pkgsrc,
                   8089:         instead of the one bundled with the distribution file.
                   8090: </p>
                   8091: <p>This tracks intltool's build-time dependencies and uses the
                   8092:         latest available version; this way, the package benefits of any
                   8093:         bug fixes that may have appeared since it was released.
                   8094: </p>
                   8095: </div>
                   8096: <div class="sect2" lang="en">
                   8097: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   8098: <a name="startup-scripts"></a>17.5.16. Packages installing startup scripts</h3></div></div></div>
1.75      rillig   8099: <p>If a package contains a rc.d script, it won't be copied into
                   8100:         the startup directory by default, but you can enable it, by adding
                   8101:         the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
1.76      rillig   8102:         <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
                   8103:         into <code class="filename">/etc/rc.d</code> when a package is installed, and
1.75      rillig   8104:         it will automatically remove the scripts when the package is
                   8105:         deinstalled.</p>
                   8106: </div>
                   8107: <div class="sect2" lang="en">
                   8108: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   8109: <a name="tex-packages"></a>17.5.17. Packages installing TeX modules</h3></div></div></div>
1.75      rillig   8110: <p>If a package installs TeX packages into the texmf tree,
1.76      rillig   8111:         the <code class="filename">ls-R</code> database of the tree needs to be
1.75      rillig   8112:         updated.</p>
                   8113: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   8114: <h3 class="title">Note</h3>
                   8115: <p>Except the main TeX packages such as teTeX-texmf,
                   8116:          packages should install files
                   8117:          into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
                   8118:          not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
                   8119: </div>
                   8120: <div class="orderedlist"><ol type="1">
                   8121: <li><p>Include
1.76      rillig   8122:             <code class="filename">../../print/teTeX/module.mk</code> instead
                   8123:             of <code class="filename">../../mk/tex.buildlink3.mk</code>.  This
                   8124:             takes care of rebuilding the <code class="filename">ls-R</code>
1.75      rillig   8125:             database at installation and deinstallation time.</p></li>
                   8126: <li>
                   8127: <p>If your package installs files into a texmf
                   8128:             tree other than the one
                   8129:             at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
                   8130:             set <code class="varname">TEXMFDIRS</code> to the list of all texmf
                   8131:             trees that need database update.</p>
                   8132: <p>If your package also installs font map files that need
                   8133:            to be registered using <span><strong class="command">updmap</strong></span>,
                   8134:            set <code class="varname">TEX_FONTMAPS</code> to the list of all
                   8135:            such font map files.  Then <span><strong class="command">updmap</strong></span> will
                   8136:            be run automatically at installation/deinstallation to
                   8137:            enable/disable font map files for TeX output
                   8138:            drivers.</p>
                   8139: </li>
1.76      rillig   8140: <li><p>Make sure that none of <code class="filename">ls-R</code>
                   8141:             databases are included in <code class="filename">PLIST</code>, as
1.75      rillig   8142:             they will be removed only by the teTeX-bin package.</p></li>
                   8143: </ol></div>
                   8144: </div>
1.85      jmmv     8145: <div class="sect2" lang="en">
                   8146: <div class="titlepage"><div><div><h3 class="title">
                   8147: <a name="hicolor-theme"></a>17.5.18. Packages installing hicolor theme icons</h3></div></div></div>
                   8148: <p>If a package installs images under the
                   8149:       <code class="filename">share/icons/hicolor</code> and/or updates the
                   8150:       <code class="filename">share/icons/hicolor/icon-theme.cache</code> database,
                   8151:       you need to take some extra steps to make sure that the shared
                   8152:       theme directory is handled appropriately and that the cache
                   8153:       database is rebuilt:</p>
                   8154: <div class="orderedlist"><ol type="1">
                   8155: <li><p>Include
                   8156:          <code class="filename">../../graphics/hicolor-icon-theme/buildlink3.mk</code>
                   8157:          instead of its <code class="filename">buildlink3.mk</code> file.</p></li>
                   8158: <li><p>Check the PLIST and remove the entry that refers to the
                   8159:          theme cache.</p></li>
                   8160: <li><p>Ensure that the PLIST does not remove the shared icon
                   8161:          directories from the <code class="filename">share/icons/hicolor</code>
                   8162:          hierarchy because they will be handled automatically.</p></li>
                   8163: </ol></div>
                   8164: <p>The best way to verify that the PLIST is correct with
                   8165:       respect to the last two points is to regenerate it using
                   8166:       <span><strong class="command">make print-PLIST</strong></span>.</p>
                   8167: </div>
                   8168: <div class="sect2" lang="en">
                   8169: <div class="titlepage"><div><div><h3 class="title">
                   8170: <a name="desktop-files"></a>17.5.19. Packages installing desktop files</h3></div></div></div>
                   8171: <p>If a package installs <code class="filename">.desktop</code> files
                   8172:       under <code class="filename">share/applications</code> and these include
                   8173:       MIME information, you need to take extra steps to ensure that they
                   8174:       are registered into the MIME database:</p>
                   8175: <div class="orderedlist"><ol type="1">
                   8176: <li><p>Include
                   8177:          <code class="filename">../../sysutils/desktop-file-utils/desktopdb.mk</code>.</p></li>
                   8178: <li><p>Check the PLIST and remove the entry that refers to the
                   8179:          <code class="filename">share/applications/mimeinfo.cache</code> file.
                   8180:          It will be handled automatically.</p></li>
                   8181: </ol></div>
                   8182: <p>The best way to verify that the PLIST is correct with
                   8183:       respect to the last point is to regenerate it using <span><strong class="command">make
                   8184:       print-PLIST</strong></span>.</p>
1.75      rillig   8185: </div>
                   8186: </div>
                   8187: </div>
                   8188: <div class="chapter" lang="en">
                   8189: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   8190: <a name="debug"></a>Chapter 18. Debugging</h2></div></div></div>
1.75      rillig   8191: <p>To check out all the gotchas when building a package, here are the steps
                   8192:     that I do in order to get a package working. Please note this is basically
                   8193:     the same as what was explained in the previous sections, only with some
                   8194:     debugging aids.</p>
                   8195: <div class="itemizedlist"><ul type="disc">
                   8196: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code>
1.76      rillig   8197:        in <code class="filename">/etc/mk.conf</code></p></li>
1.75      rillig   8198: <li>
1.76      rillig   8199: <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   8200:         create a directory for a new package, change into it, then run
                   8201:         <span><strong class="command">url2pkg</strong></span>:</p>
                   8202: <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>
                   8203: <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>
                   8204: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
                   8205: </li>
1.76      rillig   8206: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
                   8207: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.75      rillig   8208: <li><p>Run <span><strong class="command">make configure</strong></span>
                   8209:       </p></li>
                   8210: <li><p>Add any dependencies glimpsed from documentation and the
                   8211:        configure step to the package's
1.76      rillig   8212:        <code class="filename">Makefile</code>.</p></li>
1.75      rillig   8213: <li>
                   8214: <p>Make the package compile, doing multiple rounds of</p>
                   8215: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
                   8216: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
                   8217: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
                   8218: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
                   8219: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
                   8220: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
                   8221: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
                   8222: <p>Doing as non-root user will ensure that no files are modified that
                   8223:        shouldn't be, especially during the build
                   8224:        phase. <span><strong class="command">mkpatches</strong></span>,
                   8225:        <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
1.76      rillig   8226:        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.75      rillig   8227:        package. </p>
                   8228: </li>
1.76      rillig   8229: <li><p>Look at the <code class="filename">Makefile</code>, fix if necessary;
1.77      rillig   8230:        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   8231: <li>
1.76      rillig   8232: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75      rillig   8233: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
                   8234: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST &gt;PLIST</code></strong>
                   8235: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
                   8236: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
                   8237: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.76      rillig   8238: <p>You usually need to be <code class="username">root</code> to do this.
1.75      rillig   8239:        Look if there are any files left:</p>
                   8240: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
                   8241: <p>If this reveals any files that are missing in
1.76      rillig   8242:        <code class="filename">PLIST</code>, add them.</p>
1.75      rillig   8243: </li>
                   8244: <li>
1.76      rillig   8245: <p>Now that the <code class="filename">PLIST</code> is OK,
1.75      rillig   8246:        install the package again and make a binary package:</p>
                   8247: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
                   8248: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
                   8249: </li>
                   8250: <li>
                   8251: <p>Delete the installed package:</p>
                   8252: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete blub</code></strong></pre>
                   8253: </li>
                   8254: <li>
                   8255: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span> command,
                   8256:        which shouldn't find anything now:</p>
                   8257: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
                   8258: </li>
                   8259: <li>
                   8260: <p>Reinstall the binary package:</p>
                   8261: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../blub.tgz</code></strong></pre>
                   8262: </li>
                   8263: <li><p>Play with it. Make sure everything works.</p></li>
                   8264: <li>
                   8265: <p>Run <span><strong class="command">pkglint</strong></span> from
1.76      rillig   8266:         <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   8267:        and fix the problems it reports:</p>
                   8268: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
                   8269: </li>
                   8270: <li><p>Submit (or commit, if you have cvs access);
1.77      rillig   8271:        see <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a>.</p></li>
1.75      rillig   8272: </ul></div>
                   8273: </div>
                   8274: <div class="chapter" lang="en">
                   8275: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   8276: <a name="submit"></a>Chapter 19. Submitting and Committing</h2></div></div></div>
1.75      rillig   8277: <div class="toc">
                   8278: <p><b>Table of Contents</b></p>
                   8279: <dl>
1.77      rillig   8280: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
                   8281: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                   8282: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
                   8283: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
                   8284: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
                   8285: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig   8286: </dl>
                   8287: </div>
                   8288: <div class="sect1" lang="en">
                   8289: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8290: <a name="submitting-binary-packages"></a>19.1. Submitting binary packages</h2></div></div></div>
1.75      rillig   8291: <p>Our policy is that we accept binaries only from pkgsrc
                   8292:        developers to guarantee that the packages don't contain any
                   8293:        trojan horses etc. This is not to annoy anyone but rather to
                   8294:        protect our users! You're still free to put up your home-made
                   8295:        binary packages and tell the world where to get them. NetBSD
                   8296:        developers doing bulk builds and wanting to upload them please
                   8297:        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>
                   8298: </div>
                   8299: <div class="sect1" lang="en">
                   8300: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8301: <a name="submitting-your-package"></a>19.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75      rillig   8302: <p>First, check that your package is complete, compiles and
1.77      rillig   8303:        runs well; see <a href="#debug" title="Chapter 18. Debugging">Chapter 18, <i>Debugging</i></a> and the rest of this
1.75      rillig   8304:        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   8305:        archive that contains all files that make up the package.
1.75      rillig   8306:        Finally, <span><strong class="command">send-pr</strong></span> with category
                   8307:        &#8220;<span class="quote">pkg</span>&#8221;, a synopsis which includes the package name
                   8308:        and version number, a short description of your package
                   8309:        (contents of the COMMENT variable or DESCR file are OK) and
                   8310:        attach the archive to your PR.</p>
                   8311: <p>If you want to submit several packages, please send a
                   8312:        separate PR for each one, it's easier for us to track things
                   8313:        that way.</p>
                   8314: <p>Alternatively, you can also import new packages into
                   8315:        pkgsrc-wip (&#8220;<span class="quote">pkgsrc work-in-progress</span>&#8221;); see the
                   8316:        homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
                   8317:        for details.</p>
                   8318: </div>
                   8319: <div class="sect1" lang="en">
                   8320: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8321: <a name="general-notes-for-changes"></a>19.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75      rillig   8322: <p>Please note all package additions, updates, moves, and
1.76      rillig   8323:        removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75      rillig   8324:        important to keep this file up to date and conforming to the
                   8325:        existing format, because it will be used by scripts to
                   8326:        automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
                   8327:        sites. Additionally, check the
1.76      rillig   8328:        <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75      rillig   8329:        for the package you updated or removed, in case it was mentioned
                   8330:        there.</p>
                   8331: <p>When the <code class="varname">PKGREVISION</code> of a package is
                   8332:        bumped, the change should appear in
1.76      rillig   8333:        <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75      rillig   8334:        related or otherwise relevant. Mass bumps that result from a
                   8335:        dependency being updated should not be mentioned. In all other
                   8336:        cases it's the developer's decision.</p>
                   8337: <p>There is a make target that helps in creating proper
1.76      rillig   8338:   <code class="filename">CHANGES</code> entries:  <span><strong class="command">make
1.75      rillig   8339:   changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
                   8340:   and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76      rillig   8341:   usage is to first make sure that your <code class="filename">CHANGES</code>
1.75      rillig   8342:   file is up-to-date (to avoid having to resolve conflicts later-on)
                   8343:   and then to <span><strong class="command">cd</strong></span> to the package directory.  For
                   8344:   package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
                   8345:   For new packages, or package moves or removals, set the
                   8346:   <code class="varname">CTYPE</code> variable on the command line to "Added",
                   8347:   "Moved", or "Removed".  You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76      rillig   8348:   in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75      rillig   8349:   not the same as your NetBSD login name. Don't forget to commit
1.76      rillig   8350:   the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75      rillig   8351: </div>
                   8352: <div class="sect1" lang="en">
                   8353: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8354: <a name="committing-importing"></a>19.4. Committing: Importing a package into CVS</h2></div></div></div>
1.75      rillig   8355: <p>
                   8356:   This section is only of interest for pkgsrc developers with write
                   8357:   access to the pkgsrc repository. Please remember that cvs
                   8358:   imports files relative to the current working directory, and that
                   8359:   the pathname that you
                   8360:   give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
                   8361:   to place the files in the repository.  Newly created packages should be
                   8362:   imported with a vendor tag of &#8220;<span class="quote">TNF</span>&#8221; and a release tag of
                   8363:   &#8220;<span class="quote">pkgsrc-base</span>&#8221;, e.g:
                   8364: </p>
                   8365: <pre class="programlisting">
                   8366:     <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
                   8367:     <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
                   8368: </pre>
                   8369: <p>
                   8370:   Remember to move the directory from which you imported out of
                   8371:   the way, or cvs will complain the next time you &#8220;<span class="quote">cvs
                   8372:   update</span>&#8221; your source tree.  Also don't forget to add the new
1.76      rillig   8373:   package to the category's <code class="filename">Makefile</code>.
1.75      rillig   8374: </p>
                   8375: <p>
                   8376:   The commit message of the initial import should include part of the
1.76      rillig   8377:   <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.75      rillig   8378:   what the package is/does.
                   8379: </p>
                   8380: <p>
                   8381:   For new packages, &#8220;<span class="quote">cvs import</span>&#8221; is preferred to &#8220;<span class="quote">cvs
                   8382:   add</span>&#8221; because the former gets everything with a single command,
                   8383:   and provides a consistent tag.
                   8384: </p>
                   8385: </div>
                   8386: <div class="sect1" lang="en">
                   8387: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8388: <a name="updating-package"></a>19.5. Updating a package to a newer version</h2></div></div></div>
1.75      rillig   8389: <p>
                   8390:   Please always put a concise, appropriate and relevant summary of the
                   8391:   changes between old and new versions into the commit log when updating
                   8392:   a package. There are various reasons for this:
                   8393: </p>
                   8394: <div class="itemizedlist"><ul type="disc">
                   8395: <li><p>
                   8396:   A URL is volatile, and can change over time. It may go away completely
                   8397:   or its information may be overwritten by newer information.
                   8398: </p></li>
                   8399: <li><p>
                   8400:   Having the change information between old and new versions in our CVS
                   8401:   repository is very useful for people who use either cvs or anoncvs.
                   8402: </p></li>
                   8403: <li><p>
                   8404:   Having the change information between old and new versions in our CVS
                   8405:   repository is very useful for people who read the pkgsrc-changes mailing
                   8406:   list, so that they can make tactical decisions about when to upgrade
                   8407:   the package.
                   8408: </p></li>
                   8409: </ul></div>
                   8410: <p>
                   8411:   Please also recognize that, just because a new version of a package
                   8412:   has been released, it should not automatically be upgraded in the CVS
                   8413:   repository.  We prefer to be conservative in the packages that are
                   8414:   included in pkgsrc - development or beta packages are not really the
                   8415:   best thing for most places in which pkgsrc is used. Please use your
                   8416:   judgement about what should go into pkgsrc, and bear in mind that
                   8417:   stability is to be preferred above new and possibly untested features.
                   8418: </p>
                   8419: </div>
                   8420: <div class="sect1" lang="en">
                   8421: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8422: <a name="moving-package"></a>19.6. Moving a package in pkgsrc</h2></div></div></div>
1.75      rillig   8423: <div class="orderedlist"><ol type="1">
                   8424: <li><p>Make a copy of the directory somewhere else.</p></li>
                   8425: <li>
                   8426: <p>Remove all CVS dirs.</p>
                   8427: <p>
                   8428:   Alternatively to the first two steps you can also do:
                   8429: </p>
                   8430: <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>
                   8431: <p>
                   8432:   and use that for further work.
                   8433: </p>
                   8434: </li>
                   8435: <li><p>Fix <code class="varname">CATEGORIES</code> and any
                   8436: <code class="varname">DEPENDS</code> paths that just did &#8220;<span class="quote">../package</span>&#8221;
                   8437: instead of &#8220;<span class="quote">../../category/package</span>&#8221;.</p></li>
                   8438: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
                   8439: place.</p></li>
                   8440: <li>
                   8441: <p>Check if any package depends on it:
                   8442: </p>
                   8443: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   8444: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
                   8445: <p>
                   8446: </p>
                   8447: </li>
                   8448: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
                   8449: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76      rillig   8450: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
                   8451: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75      rillig   8452: <li>
                   8453: <p>Commit the changed and removed files:</p>
                   8454: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
                   8455: <p>
                   8456:   (and any packages from step 5, of course).
                   8457: </p>
                   8458: </li>
                   8459: </ol></div>
                   8460: </div>
                   8461: </div>
                   8462: <div class="chapter" lang="en">
                   8463: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   8464: <a name="devfaq"></a>Chapter 20. Frequently Asked Questions</h2></div></div></div>
1.75      rillig   8465: <p>This section contains the answers to questions that may
                   8466:        arise when you are writing a package. If you don't find your
                   8467:        question answered here, first have a look in the other chapters,
                   8468:        and if you still don't have the answer, ask on the
                   8469:        <code class="literal">pkgsrc-users</code> mailing list.</p>
                   8470: <div class="qandaset">
                   8471: <dl>
1.85      jmmv     8472: <dt>20.1. <a href="#id2698635">What is the difference between
1.75      rillig   8473:        MAKEFLAGS, .MAKEFLAGS and
                   8474:        MAKE_FLAGS?</a>
                   8475: </dt>
1.85      jmmv     8476: <dt>20.2. <a href="#id2698672">What is the difference between
1.75      rillig   8477:        MAKE, GMAKE and
                   8478:        MAKE_PROGRAM?</a>
                   8479: </dt>
1.85      jmmv     8480: <dt>20.3. <a href="#id2698710">What is the difference between
1.75      rillig   8481:        CC, PKG_CC and
                   8482:        PKGSRC_COMPILER?</a>
                   8483: </dt>
1.85      jmmv     8484: <dt>20.4. <a href="#id2698747">What is the difference between
1.75      rillig   8485:        BUILDLINK_LDFLAGS,
                   8486:        BUILDLINK_LDADD and
                   8487:        BUILDLINK_LIBS?</a>
                   8488: </dt>
1.85      jmmv     8489: <dt>20.5. <a href="#id2698765">Why does make show-var
1.75      rillig   8490:        VARNAME=BUILDLINK_PREFIX.foo
                   8491:        say it's empty?</a>
                   8492: </dt>
1.85      jmmv     8493: <dt>20.6. <a href="#id2698861">What does
1.78      rillig   8494:        ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
                   8495:        don't understand the := inside
                   8496:        it.</a>
                   8497: </dt>
1.85      jmmv     8498: <dt>20.7. <a href="#id2699004">Which mailing lists are there for package
1.78      rillig   8499:        developers?</a>
                   8500: </dt>
1.85      jmmv     8501: <dt>20.8. <a href="#id2699041">Where is the pkgsrc
1.80      rillig   8502:        documentation?</a>
                   8503: </dt>
1.75      rillig   8504: </dl>
                   8505: <table border="0" summary="Q and A Set">
                   8506: <col align="left" width="1%">
                   8507: <tbody>
                   8508: <tr class="question">
                   8509: <td align="left" valign="top">
1.85      jmmv     8510: <a name="id2698635"></a><a name="id2698636"></a><b>20.1.</b>
1.75      rillig   8511: </td>
                   8512: <td align="left" valign="top"><p>What is the difference between
                   8513:        <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
                   8514:        <code class="varname">MAKE_FLAGS</code>?</p></td>
                   8515: </tr>
                   8516: <tr class="answer">
1.83      wiz      8517: <td align="left" valign="top"></td>
1.75      rillig   8518: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
                   8519:        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
                   8520:        <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
                   8521:        the <code class="varname">MAKE_PROGRAM</code> when building the
                   8522:        package. [FIXME: What is .MAKEFLAGS for?]</p></td>
                   8523: </tr>
                   8524: <tr class="question">
                   8525: <td align="left" valign="top">
1.85      jmmv     8526: <a name="id2698672"></a><a name="id2698673"></a><b>20.2.</b>
1.75      rillig   8527: </td>
                   8528: <td align="left" valign="top"><p>What is the difference between
                   8529:        <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
                   8530:        <code class="varname">MAKE_PROGRAM</code>?</p></td>
                   8531: </tr>
                   8532: <tr class="answer">
1.83      wiz      8533: <td align="left" valign="top"></td>
1.75      rillig   8534: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
                   8535:        <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
                   8536:        infrastructure. <code class="varname">GMAKE</code> is the path to GNU
                   8537:        Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
                   8538:        use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
                   8539:        Make program that is used for building the
                   8540:        package.</p></td>
                   8541: </tr>
                   8542: <tr class="question">
                   8543: <td align="left" valign="top">
1.85      jmmv     8544: <a name="id2698710"></a><a name="id2698711"></a><b>20.3.</b>
1.75      rillig   8545: </td>
                   8546: <td align="left" valign="top"><p>What is the difference between
                   8547:        <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
                   8548:        <code class="varname">PKGSRC_COMPILER</code>?</p></td>
                   8549: </tr>
                   8550: <tr class="answer">
1.83      wiz      8551: <td align="left" valign="top"></td>
1.75      rillig   8552: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
                   8553:        compiler, which can be configured by the pkgsrc user.
                   8554:        <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
                   8555:        <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
                   8556:        path to a compiler, but the type of compiler that should be
1.76      rillig   8557:        used. See <code class="filename">mk/compiler.mk</code> for more
1.75      rillig   8558:        information about the latter variable.</p></td>
                   8559: </tr>
                   8560: <tr class="question">
                   8561: <td align="left" valign="top">
1.85      jmmv     8562: <a name="id2698747"></a><a name="id2698748"></a><b>20.4.</b>
1.75      rillig   8563: </td>
                   8564: <td align="left" valign="top"><p>What is the difference between
                   8565:        <code class="varname">BUILDLINK_LDFLAGS</code>,
                   8566:        <code class="varname">BUILDLINK_LDADD</code> and
                   8567:        <code class="varname">BUILDLINK_LIBS</code>?</p></td>
                   8568: </tr>
                   8569: <tr class="answer">
1.83      wiz      8570: <td align="left" valign="top"></td>
1.75      rillig   8571: <td align="left" valign="top"><p>[FIXME]</p></td>
                   8572: </tr>
                   8573: <tr class="question">
                   8574: <td align="left" valign="top">
1.85      jmmv     8575: <a name="id2698765"></a><a name="id2698766"></a><b>20.5.</b>
1.75      rillig   8576: </td>
                   8577: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
                   8578:        VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
                   8579:        say it's empty?</p></td>
                   8580: </tr>
                   8581: <tr class="answer">
1.83      wiz      8582: <td align="left" valign="top"></td>
1.75      rillig   8583: <td align="left" valign="top"><p>For optimization reasons, some variables are only
                   8584:        available in the &#8220;<span class="quote">wrapper</span>&#8221; phase and later. To
                   8585:        &#8220;<span class="quote">simulate</span>&#8221; the wrapper phase, append
                   8586:        <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
                   8587:        command.</p></td>
                   8588: </tr>
1.78      rillig   8589: <tr class="question">
                   8590: <td align="left" valign="top">
1.85      jmmv     8591: <a name="id2698861"></a><a name="id2698862"></a><b>20.6.</b>
1.78      rillig   8592: </td>
                   8593: <td align="left" valign="top"><p>What does
                   8594:        <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
                   8595:        don't understand the <code class="literal">:=</code> inside
                   8596:        it.</p></td>
                   8597: </tr>
                   8598: <tr class="answer">
1.83      wiz      8599: <td align="left" valign="top"></td>
1.78      rillig   8600: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
                   8601:        assignment operator, like you might expect at first sight.
                   8602:        Instead, it is a degenerate form of
                   8603:        <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
                   8604:        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
                   8605:        may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
                   8606:        case of <code class="varname">MASTER_SITE_*</code>,
                   8607:        <em class="replaceable"><code>old_string</code></em> is the empty string and
                   8608:        <em class="replaceable"><code>new_string</code></em> is
                   8609:        <code class="literal">package/</code>. That's where the
                   8610:        <code class="literal">:</code> and the <code class="literal">=</code> fall
                   8611:        together.</p></td>
                   8612: </tr>
                   8613: <tr class="question">
                   8614: <td align="left" valign="top">
1.85      jmmv     8615: <a name="id2699004"></a><a name="id2699005"></a><b>20.7.</b>
1.78      rillig   8616: </td>
                   8617: <td align="left" valign="top"><p>Which mailing lists are there for package
                   8618:        developers?</p></td>
                   8619: </tr>
                   8620: <tr class="answer">
1.83      wiz      8621: <td align="left" valign="top"></td>
1.78      rillig   8622: <td align="left" valign="top"><div class="variablelist"><dl>
                   8623: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
                   8624: <dd><p>This is a list for technical discussions related
                   8625:        to pkgsrc development, e.g. soliciting feedback for changes to
                   8626:        pkgsrc infrastructure, proposed new features, questions related
                   8627:        to porting pkgsrc to a new platform, advice for maintaining a
                   8628:        package, patches that affect many packages, help requests moved
                   8629:        from pkgsrc-users when an infrastructure bug is found,
                   8630:        etc.</p></dd>
                   8631: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
                   8632: <dd><p>All bug reports in category "pkg" sent with
                   8633:        <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
                   8634:        directly; use one of the other mailing
                   8635:        lists.</p></dd>
                   8636: </dl></div></td>
                   8637: </tr>
1.80      rillig   8638: <tr class="question">
                   8639: <td align="left" valign="top">
1.85      jmmv     8640: <a name="id2699041"></a><a name="id2699042"></a><b>20.8.</b>
1.80      rillig   8641: </td>
                   8642: <td align="left" valign="top"><p>Where is the pkgsrc
                   8643:        documentation?</p></td>
                   8644: </tr>
                   8645: <tr class="answer">
1.83      wiz      8646: <td align="left" valign="top"></td>
1.80      rillig   8647: <td align="left" valign="top">
                   8648: <p>There are many places where you can find
                   8649:        documentation about pkgsrc:</p>
                   8650: <div class="itemizedlist"><ul type="disc">
                   8651: <li><p>The pkgsrc guide (this document) is a collection
                   8652:        of chapters that explain large parts of pkgsrc, but some
                   8653:        chapters tend to be outdated. Which ones they are is hard to
                   8654:        say.</p></li>
                   8655: <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
                   8656:        about certain features, announcements of new parts of the pkgsrc
                   8657:        infrastructure and sometimes even announcements that a certain
                   8658:        feature has been marked as obsolete. The benefit here is that
                   8659:        each message has a date appended to it.</p></li>
                   8660: <li><p>Many of the files in the
                   8661:        <code class="filename">mk/</code> directory start with a comment that
                   8662:        describes the purpose of the file and how it can be used by the
                   8663:        pkgsrc user and package authors.</p></li>
                   8664: <li><p>The CVS log messages are a rich source of
                   8665:        information, but they tend to be highly abbreviated, especially
                   8666:        for actions that occur often. Some contain a detailed
                   8667:        description of what has changed, but they are geared towards the
                   8668:        other pkgsrc developers, not towards an average pkgsrc user.
                   8669:        They also only document <span class="emphasis"><em>changes</em></span>, so if you
                   8670:        don't know what has been before, these messages may not be worth
                   8671:        too much to you.</p></li>
                   8672: <li><p>Some parts of pkgsrc are only &#8220;<span class="quote">implicitly
                   8673:        documented</span>&#8221;, that is the documentation exists only in the
                   8674:        mind of the developer who wrote the code. To get this
                   8675:        information, use the the <span><strong class="command">cvs annotate</strong></span> command
                   8676:        to see who has written it and ask on the
                   8677:        <code class="literal">tech-pkg</code> mailing list, so that others can
                   8678:        find your questions later (see above). To be sure that the
                   8679:        developer in charge reads the mail, you may CC him or
                   8680:        her.</p></li>
                   8681: </ul></div>
                   8682: </td>
                   8683: </tr>
1.75      rillig   8684: </tbody>
                   8685: </table>
                   8686: </div>
                   8687: </div>
1.85      jmmv     8688: <div class="chapter" lang="en">
                   8689: <div class="titlepage"><div><div><h2 class="title">
                   8690: <a name="gnome"></a>Chapter 21. GNOME packaging and porting</h2></div></div></div>
                   8691: <div class="toc">
                   8692: <p><b>Table of Contents</b></p>
                   8693: <dl>
                   8694: <dt><span class="sect1"><a href="#meta-packages">21.1. Meta packages</a></span></dt>
                   8695: <dt><span class="sect1"><a href="#new-package">21.2. Packaging a GNOME application</a></span></dt>
                   8696: <dt><span class="sect1"><a href="#full-update">21.3. Updating GNOME to a newer version</a></span></dt>
                   8697: <dt><span class="sect1"><a href="#patching">21.4. Patching guidelines</a></span></dt>
                   8698: </dl>
                   8699: </div>
                   8700: <p>Quoting <a href="http://www.gnome.org/" target="_top">GNOME's web
                   8701: site</a>:</p>
                   8702: <div class="blockquote"><blockquote class="blockquote"><p>The GNOME project provides two things: The GNOME desktop
                   8703:   environment, an intuitive and attractive desktop for users, and the
                   8704:   GNOME development platform, an extensive framework for building
                   8705:   applications that integrate into the rest of the desktop.</p></blockquote></div>
                   8706: <p>pkgsrc provides a seamless way to automatically build and install
                   8707: a complete GNOME environment <span class="emphasis"><em>under many different
                   8708: platforms</em></span>.  We can say with confidence that pkgsrc is one of
                   8709: the most advanced build and packaging systems for GNOME due to its
                   8710: included technologies buildlink3, the wrappers and tools framework and
                   8711: automatic configuration file management.  Lots of efforts are put into
                   8712: achieving a completely clean deinstallation of installed software
                   8713: components.</p>
                   8714: <p>Given that pkgsrc is <a href="http://www.NetBSD.org/" target="_top">NetBSD</a>'s official packaging system,
                   8715: the above also means that great efforts are put into making GNOME work
                   8716: under this operating system.  Recently, <a href="http://www.dragonflybsd.org/" target="_top">DragonFly BSD</a> also adopted
                   8717: pkgsrc as its preferred packaging system, contributing lots of
                   8718: portability fixes to make GNOME build and install under it.</p>
                   8719: <p>This chapter is aimed at pkgsrc developers and other people
                   8720: interested in helping our GNOME porting and packaging efforts.  It
                   8721: provides instructions on how to manage the existing packages and some
                   8722: important information regarding their internals.</p>
                   8723: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   8724: <h3 class="title">We need your help!</h3>
                   8725: <p>Should you have some spare cycles to devote to NetBSD, pkgsrc
                   8726:   and GNOME and are willing to learn new exciting stuff, please jump
                   8727:   straight to the <a href="http://www.NetBSD.org/contrib/projects.html#gnome" target="_top">pending
                   8728:   work</a> list!  There is still a long way to go to get a
                   8729:   fully-functional GNOME desktop under NetBSD and we need your help to
                   8730:   achieve it!</p>
                   8731: </div>
                   8732: <div class="sect1" lang="en">
                   8733: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8734: <a name="meta-packages"></a>21.1. Meta packages</h2></div></div></div>
                   8735: <p>pkgsrc includes three GNOME-related meta packages:</p>
                   8736: <div class="itemizedlist"><ul type="disc">
                   8737: <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
                   8738:     the core GNOME desktop environment.  It only includes the necessary
                   8739:     bits to get it to boot correctly, although it may lack important
                   8740:     functionality for daily operation.  The idea behind this package is
                   8741:     to let end users build their own configurations on top of this one,
                   8742:     first installing this meta package to achieve a functional setup and
                   8743:     then adding individual applications.</p></li>
                   8744: <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
                   8745:     complete installation of the GNOME platform and desktop as defined
                   8746:     by the GNOME project; this is based on the components distributed in
                   8747:     the <code class="filename">platform/x.y/x.y.z/sources</code> and
                   8748:     <code class="filename">desktop/x.y/x.y.z/sources</code> directories of the
                   8749:     official FTP server.  Developer-only tools found in those
                   8750:     directories are not installed unless required by some other
                   8751:     component to work properly.  Similarly, packages from the bindings
                   8752:     set (<code class="filename">bindings/x.y/x.y.z/sources</code>) are not pulled
                   8753:     in unless required as a dependency for an end-user component.  This
                   8754:     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>
                   8755: <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>:
                   8756:     Installs all the tools required to build a GNOME component when
                   8757:     fetched from the CVS repository.  These are required to let the
                   8758:     <span><strong class="command">autogen.sh</strong></span> scripts work appropriately.</p></li>
                   8759: </ul></div>
                   8760: <p>In all these packages, the <code class="varname">DEPENDS</code> lines are
                   8761: sorted in a way that eases updates: a package may depend on other
                   8762: packages listed before it but not on any listed after it.  It is very
                   8763: important to keep this order to ease updates so... <span class="emphasis"><em>do not
                   8764: change it to alphabetical sorting!</em></span></p>
                   8765: </div>
                   8766: <div class="sect1" lang="en">
                   8767: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8768: <a name="new-package"></a>21.2. Packaging a GNOME application</h2></div></div></div>
                   8769: <p>Almost all GNOME applications are written in C and use a common
                   8770: set of tools as their build system.  Things get different with the new
                   8771: bindings to other languages (such as Python), but the following will
                   8772: give you a general idea on the minimum required tools:</p>
                   8773: <div class="itemizedlist"><ul type="disc">
                   8774: <li>
                   8775: <p>Almost all GNOME applications use the GNU Autotools as their
                   8776:     build system.  As a general rule you will need to tell this to your
                   8777:     package:</p>
                   8778: <pre class="programlisting">GNU_CONFIGURE=yes
                   8779: USE_LIBTOOL=yes
                   8780: USE_TOOLS+=gmake</pre>
                   8781: </li>
                   8782: <li>
                   8783: <p>If the package uses pkg-config to detect dependencies, add this
                   8784:     tool to the list of required utilities:</p>
                   8785: <pre class="programlisting">USE_TOOLS+=pkg-config</pre>
                   8786: <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
                   8787:     the end of the build process to ensure that you did not miss to
                   8788:     specify any dependency in your package and that the version
                   8789:     requirements are all correct.</p>
                   8790: </li>
                   8791: <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
                   8792:     to handle dependencies and to force the package to use the latest
                   8793:     available version.</p></li>
                   8794: <li>
                   8795: <p>If the package uses gtk-doc (a documentation generation
                   8796:     utility), do <span class="emphasis"><em>not</em></span> add a dependency on it.  The
                   8797:     tool is rather big and the distfile should come with pregenerated
                   8798:     documentation anyway; if it does not, it is a bug that you ought to
                   8799:     report.  For such packages you should disable gtk-doc (unless it is
                   8800:     the default) and change the location of installed HTML files:</p>
                   8801: <pre class="programlisting">CONFIGURE_ARGS+=--disable-gtk-doc
                   8802: CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/doc</pre>
                   8803: </li>
                   8804: </ul></div>
                   8805: <p>GNOME uses multiple <span class="emphasis"><em>shared</em></span> directories and
                   8806: files under the installation prefix to maintain databases.  In this
                   8807: context, shared means that those exact same directories and files are
                   8808: used among several different packages, leading to conflicts in the
                   8809: <code class="filename">PLIST</code>.  pkgsrc currently includes functionality to
                   8810: handle the most common cases, so you have to forget about using
                   8811: <code class="literal">@unexec ${RMDIR}</code> lines in your file lists and
                   8812: omitting shared files from them.  If you find yourself doing those,
                   8813: <span class="emphasis"><em>your package is most likely incorrect</em></span>.</p>
                   8814: <p>The following table lists the common situations that result in
                   8815: using shared directories or files.  For each of them, the appropriate
                   8816: solution is given.  After applying the solution be sure to
                   8817: <span class="emphasis"><em>regenerate the package's file list</em></span> with
                   8818: <span><strong class="command">make print-PLIST</strong></span> and ensure it is correct.</p>
                   8819: <div class="table">
                   8820: <a name="plist-handling"></a><p class="title"><b>Table 21.1. PLIST handling for GNOME packages</b></p>
                   8821: <div class="table-contents"><table summary="PLIST handling for GNOME packages" border="1">
                   8822: <colgroup>
                   8823: <col>
                   8824: <col>
                   8825: </colgroup>
                   8826: <thead><tr>
                   8827: <th>If the package...</th>
                   8828: <th>Then...</th>
                   8829: </tr></thead>
                   8830: <tbody>
                   8831: <tr>
                   8832: <td>Installs OMF files under <code class="filename">share/omf</code>.</td>
                   8833: <td>See <a href="#scrollkeeper-data-files" title="17.5.10. Packages installing scrollkeeper data files">Section 17.5.10, &#8220;Packages installing scrollkeeper data files&#8221;</a>.</td>
                   8834: </tr>
                   8835: <tr>
                   8836: <td>Installs icons under the
                   8837:         <code class="filename">share/icons/hicolor</code> hierarchy or updates
                   8838:         <code class="filename">share/icons/hicolor/icon-theme.cache</code>.</td>
                   8839: <td>See <a href="#hicolor-theme" title="17.5.18. Packages installing hicolor theme icons">Section 17.5.18, &#8220;Packages installing hicolor theme icons&#8221;</a>.</td>
                   8840: </tr>
                   8841: <tr>
                   8842: <td>Installs files under
                   8843:         <code class="filename">share/mime/packages</code>.</td>
                   8844: <td>See <a href="#mime-database" title="17.5.14. Packages installing extensions to the MIME database">Section 17.5.14, &#8220;Packages installing extensions to the MIME database&#8221;</a>.</td>
                   8845: </tr>
                   8846: <tr>
                   8847: <td>Installs <code class="filename">.desktop</code> files under
                   8848:         <code class="filename">share/applications</code> and these include MIME
                   8849:         information.</td>
                   8850: <td>See <a href="#desktop-files" title="17.5.19. Packages installing desktop files">Section 17.5.19, &#8220;Packages installing desktop files&#8221;</a>.</td>
                   8851: </tr>
                   8852: </tbody>
                   8853: </table></div>
                   8854: </div>
                   8855: <br class="table-break">
                   8856: </div>
                   8857: <div class="sect1" lang="en">
                   8858: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8859: <a name="full-update"></a>21.3. Updating GNOME to a newer version</h2></div></div></div>
                   8860: <p>When seeing GNOME as a whole, there are two kinds of
                   8861: updates:</p>
                   8862: <div class="variablelist"><dl>
                   8863: <dt><span class="term">Major update</span></dt>
                   8864: <dd>
                   8865: <p>Given that there is still a very long way for GNOME 3 (if it
                   8866:       ever appears), we consider a major update one that goes from a
                   8867:       <code class="literal">2.X</code> version to a <code class="literal">2.Y</code> one,
                   8868:       where <code class="literal">Y</code> is even and greater than
                   8869:       <code class="literal">X</code>.  These are hard to achieve because they
                   8870:       introduce lots of changes in the components' code and almost all
                   8871:       GNOME distfiles are updated to newer versions.  Some of them can
                   8872:       even break API and ABI compatibility with the previous major
                   8873:       version series.  As a result, the update needs to be done all at
                   8874:       once to minimize breakage.</p>
                   8875: <p>A major update typically consists of around 80 package
                   8876:       updates and the addition of some new ones.</p>
                   8877: </dd>
                   8878: <dt><span class="term">Minor update</span></dt>
                   8879: <dd>
                   8880: <p>We consider a minor update one that goes from a
                   8881:       <code class="literal">2.A.X</code> version to a <code class="literal">2.A.Y</code>
                   8882:       one where <code class="literal">Y</code> is greater than
                   8883:       <code class="literal">X</code>.  These are easy to achieve because they do
                   8884:       not update all GNOME components, can be done in an incremental way
                   8885:       and do not break API nor ABI compatibility.</p>
                   8886: <p>A minor update typically consists of around 50 package
                   8887:       updates, although the numbers here may vary a lot.</p>
                   8888: </dd>
                   8889: </dl></div>
                   8890: <p>In order to update the GNOME components in pkgsrc to a new stable
                   8891: release (either major or minor), the following steps should be
                   8892: followed:</p>
                   8893: <div class="orderedlist"><ol type="1">
                   8894: <li>
                   8895: <p>Get a list of all the tarballs that form the new release by
                   8896:     using the following commands.  These will leave the full list of the
                   8897:     components's distfiles into the <code class="filename">list.txt</code>
                   8898:     file:</p>
                   8899: <pre class="screen"><code class="prompt">$ </code><strong class="userinput"><code>echo ls "*.tar.bz2" | \
                   8900:     ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   8901:     awk '{ print $9 }' &gt;list.txt</code></strong>
                   8902: <code class="prompt">$ </code><strong class="userinput"><code>echo ls "*.tar.bz2" | \
                   8903:     ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   8904:     awk '{ print $9 }' &gt;&gt;list.txt</code></strong></pre>
                   8905: </li>
                   8906: <li><p>Open each meta package's <code class="filename">Makefile</code> and
                   8907:     bump their version to the release you are updating them to.  The
                   8908:     three meta packages should be always consistent with versioning.
                   8909:     Obviously remove any <code class="varname">PKGREVISION</code>s that might be
                   8910:     in them.</p></li>
                   8911: <li>
                   8912: <p>For each meta package, update all its
                   8913:     <code class="varname">DEPENDS</code> lines to match the latest versions as
                   8914:     shown by the above commands.  Do <span class="emphasis"><em>not</em></span> list any
                   8915:     newer version (even if found in the FTP) because the meta packages
                   8916:     are supposed to list the exact versions that form a specific GNOME
                   8917:     release.  Exceptions are permitted here if a newer version solves a
                   8918:     serious issue in the overall desktop experience; these typically
                   8919:     come in the form of a revision bump in pkgsrc, not in newer versions
                   8920:     from the developers.</p>
                   8921: <p>Packages not listed in the <code class="filename">list.txt</code> file
                   8922:     should be updated to the latest version available (if found in
                   8923:     pkgsrc).  This is the case, for example, of the dependencies on the
                   8924:     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>
                   8925: </li>
                   8926: <li>
                   8927: <p>Generate a patch from the modified meta packages and extract the
                   8928:     list of "new" lines.  This will provide you an outline on what
                   8929:     packages need to be updated in pkgsrc and in what order:</p>
                   8930: <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>
                   8931: </li>
                   8932: <li><p>For major desktop updates it is recommended to zap all your
                   8933:     installed packages and start over from scratch at this point.</p></li>
                   8934: <li><p>Now comes the longest step by far: iterate over the contents
                   8935:     of <code class="filename">todo.txt</code> and update the packages listed in
                   8936:     it in order.  For major desktop updates none of these should be
                   8937:     commited until the entire set is completed because there are chances
                   8938:     of breaking not-yet-updated packages.</p></li>
                   8939: <li><p>Once the packages are up to date and working, commit them to
                   8940:     the tree one by one with appropriate log messages.  At the end,
                   8941:     commit the three meta package updates and all the corresponding
                   8942:     changes to the <code class="filename">doc/CHANGES-&lt;YEAR&gt;</code> and
                   8943:     <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>
                   8944: </ol></div>
                   8945: </div>
                   8946: <div class="sect1" lang="en">
                   8947: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8948: <a name="patching"></a>21.4. Patching guidelines</h2></div></div></div>
                   8949: <p>GNOME is a very big component in pkgsrc which approaches 100
                   8950: packages.  Please, it is very important that you always, always,
                   8951: <span class="strong"><strong>always</strong></span> feed back any portability
                   8952: 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
                   8953: their attention on portability issues and to ensure that future versions
                   8954: can be built out-of-the box on NetBSD.  The less custom patches in
                   8955: pkgsrc, the easier further updates are.  Those developers in charge of
                   8956: issuing major GNOME updates will be grateful if you do that.</p>
                   8957: <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
                   8958: Bugzilla</a>.  Not all components use these to track bugs, but most
                   8959: of them do.  Do not be short on your reports: always provide detailed
                   8960: explanations of the current failure, how it can be improved to achieve
                   8961: maximum portability and, if at all possible, provide a patch against CVS
                   8962: head.  The more verbose you are, the higher chances of your patch being
                   8963: accepted.</p>
                   8964: <p>Also, please avoid using preprocessor magic to fix portability
                   8965: issues.  While the FreeBSD GNOME people are doing a great job in porting
                   8966: GNOME to their operating system, the official GNOME sources are now
                   8967: plagued by conditionals that check for <code class="varname">__FreeBSD__</code>
                   8968: and similar macros.  This hurts portability.  Please see our patching
                   8969: guidelines (<a href="#components.patches.guidelines" title="9.3.1. Patching guidelines">Section 9.3.1, &#8220;Patching guidelines&#8221;</a>) for more
                   8970: details.</p>
                   8971: </div>
                   8972: </div>
1.75      rillig   8973: </div>
                   8974: <div class="part" lang="en">
                   8975: <div class="titlepage"><div><div><h1 class="title">
                   8976: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
                   8977: <div class="partintro" lang="en">
                   8978: <div></div>
                   8979: <p>This part of the guide deals with everything
                   8980:        from the infrastructure that is behind the interfaces described
                   8981:        in the developer's guide. A casual package maintainer should not
                   8982:        need anything from this part.</p>
                   8983: <div class="toc">
                   8984: <p><b>Table of Contents</b></p>
                   8985: <dl>
1.85      jmmv     8986: <dt><span class="chapter"><a href="#infr.design">22. Design of the pkgsrc infrastructure</a></span></dt>
1.75      rillig   8987: <dd><dl>
1.85      jmmv     8988: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
                   8989: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
                   8990: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.75      rillig   8991: <dd><dl>
1.85      jmmv     8992: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
                   8993: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.75      rillig   8994: </dl></dd>
1.85      jmmv     8995: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
                   8996: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig   8997: <dd><dl>
1.85      jmmv     8998: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
                   8999: <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   9000: </dl></dd>
1.85      jmmv     9001: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.81      rillig   9002: <dd><dl>
1.85      jmmv     9003: <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>
                   9004: <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   9005: </dl></dd>
                   9006: </dl></dd>
1.85      jmmv     9007: <dt><span class="chapter"><a href="#regression">23. Regression tests</a></span></dt>
1.75      rillig   9008: <dd><dl>
1.85      jmmv     9009: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
                   9010: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
                   9011: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75      rillig   9012: <dd><dl>
1.85      jmmv     9013: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
                   9014: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75      rillig   9015: </dl></dd>
                   9016: </dl></dd>
1.85      jmmv     9017: <dt><span class="chapter"><a href="#porting">24. Porting pkgsrc</a></span></dt>
1.75      rillig   9018: <dd><dl>
1.85      jmmv     9019: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
                   9020: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75      rillig   9021: </dl></dd>
                   9022: </dl>
                   9023: </div>
                   9024: </div>
                   9025: <div class="chapter" lang="en">
                   9026: <div class="titlepage"><div><div><h2 class="title">
1.85      jmmv     9027: <a name="infr.design"></a>Chapter 22. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75      rillig   9028: <div class="toc">
                   9029: <p><b>Table of Contents</b></p>
                   9030: <dl>
1.85      jmmv     9031: <dt><span class="sect1"><a href="#infr.vardef">22.1. The meaning of variable definitions</a></span></dt>
                   9032: <dt><span class="sect1"><a href="#infr.vardef.problems">22.2. Avoiding problems before they arise</a></span></dt>
                   9033: <dt><span class="sect1"><a href="#infr.var">22.3. Variable evaluation</a></span></dt>
1.81      rillig   9034: <dd><dl>
1.85      jmmv     9035: <dt><span class="sect2"><a href="#infr.var.load">22.3.1. At load time</a></span></dt>
                   9036: <dt><span class="sect2"><a href="#infr.var.run">22.3.2. At runtime</a></span></dt>
1.81      rillig   9037: </dl></dd>
1.85      jmmv     9038: <dt><span class="sect1"><a href="#infr.varspec">22.4. How can variables be specified?</a></span></dt>
                   9039: <dt><span class="sect1"><a href="#infr.design.intf">22.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig   9040: <dd><dl>
1.85      jmmv     9041: <dt><span class="sect2"><a href="#infr.design.intf.proc">22.5.1. Procedures with parameters</a></span></dt>
                   9042: <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   9043: </dl></dd>
1.85      jmmv     9044: <dt><span class="sect1"><a href="#infr.order">22.6. The order in which files are loaded</a></span></dt>
1.75      rillig   9045: <dd><dl>
1.85      jmmv     9046: <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>
                   9047: <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   9048: </dl></dd>
                   9049: </dl>
                   9050: </div>
                   9051: <p>The pkgsrc infrastructure consists of many small Makefile
                   9052:        fragments. Each such fragment needs a properly specified
                   9053:        interface. This chapter explains how such an interface looks
                   9054:        like.</p>
                   9055: <div class="sect1" lang="en">
                   9056: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9057: <a name="infr.vardef"></a>22.1. The meaning of variable definitions</h2></div></div></div>
1.81      rillig   9058: <p>Whenever a variable is defined in the pkgsrc
                   9059:        infrastructure, the location and the way of definition provide
                   9060:        much information about the intended use of that variable.
                   9061:        Additionally, more documentation may be found in a header
                   9062:        comment or in this pkgsrc guide.</p>
                   9063: <p>A special file is
                   9064:        <code class="filename">mk/defaults/mk.conf</code>, which lists all
                   9065:        variables that are intended to be user-defined. They are either
                   9066:        defined using the <code class="literal">?=</code> operator or they are
                   9067:        left undefined because defining them to anything would
                   9068:        effectively mean &#8220;<span class="quote">yes</span>&#8221;. All these variables may be
                   9069:        overridden by the pkgsrc user in the <code class="varname">MAKECONF</code>
                   9070:        file.</p>
                   9071: <p>Outside this file, the following conventions apply:
                   9072:        Variables that are defined using the <code class="literal">?=</code>
                   9073:        operator may be overridden by a package.</p>
                   9074: <p>Variables that are defined using the <code class="literal">=</code>
                   9075:        operator may be used read-only at run-time.</p>
                   9076: <p>Variables whose name starts with an underscore must not be
                   9077:        accessed outside the pkgsrc infrastructure at all. They may
                   9078:        change without further notice.</p>
                   9079: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   9080: <h3 class="title">Note</h3>
                   9081: <p>These conventions are currently not applied
                   9082:        consistently to the complete pkgsrc
                   9083:        infrastructure.</p>
                   9084: </div>
                   9085: </div>
                   9086: <div class="sect1" lang="en">
                   9087: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9088: <a name="infr.vardef.problems"></a>22.2. Avoiding problems before they arise</h2></div></div></div>
1.81      rillig   9089: <p>All variables that contain lists of things should default
                   9090:        to being empty. Two examples that do not follow this rule are
                   9091:        <code class="varname">USE_LANGUAGES</code> and
                   9092:        <code class="varname">DISTFILES</code>. These variables cannot simply be
                   9093:        modified using the <code class="literal">+=</code> operator in package
                   9094:        <code class="filename">Makefile</code>s (or other files included by
                   9095:        them), since there is no guarantee whether the variable is
                   9096:        already set or not, and what its value is. In the case of
                   9097:        <code class="varname">DISTFILES</code>, the packages &#8220;<span class="quote">know</span>&#8221;
                   9098:        the default value and just define it as in the following
                   9099:        example.</p>
                   9100: <pre class="programlisting">
                   9101:     DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   9102: </pre>
                   9103: <p>Because of the selection of this default value, the same
                   9104:        value appears in many package Makefiles. Similarly for
                   9105:        <code class="varname">USE_LANGUAGES</code>, but in this case the default
                   9106:        value (&#8220;<span class="quote"><code class="literal">c</code></span>&#8221;) is so short that it
                   9107:        doesn't stand out. Nevertheless it is mentioned in many
                   9108:        files.</p>
                   9109: </div>
                   9110: <div class="sect1" lang="en">
                   9111: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9112: <a name="infr.var"></a>22.3. Variable evaluation</h2></div></div></div>
1.75      rillig   9113: <div class="sect2" lang="en">
                   9114: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9115: <a name="infr.var.load"></a>22.3.1. At load time</h3></div></div></div>
1.75      rillig   9116: <p>Variable evaluation takes place either at load time or at
                   9117:        runtime, depending on the context in which they occur. The
                   9118:        contexts where variables are evaluated at load time are:</p>
                   9119: <div class="itemizedlist"><ul type="disc">
                   9120: <li><p>The right hand side of the <code class="literal">:=</code>
                   9121:        and <code class="literal">!=</code> operators,</p></li>
                   9122: <li><p>Make directives like <code class="literal">.if</code> or
                   9123:        <code class="literal">.for</code>,</p></li>
                   9124: <li><p>Dependency lines.</p></li>
                   9125: </ul></div>
                   9126: <p>A special exception are references to the iteration
                   9127:        variables of <code class="literal">.for</code> loops, which are expanded
                   9128:        inline, no matter in which context they appear.</p>
                   9129: <p>As the values of variables may change during load time,
                   9130:        care must be taken not to evaluate them by accident. Typical
                   9131:        examples for variables that should not be evaluated at load time
                   9132:        are <code class="varname">DEPENDS</code> and
                   9133:        <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
                   9134:        clear, here is an example:</p>
                   9135: <pre class="programlisting">
                   9136:     CONFIGURE_ARGS=         # none
                   9137:     CFLAGS=                 -O
                   9138:     CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
1.1       grant    9139: 
1.75      rillig   9140:     CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
1.1       grant    9141: 
1.75      rillig   9142:     CFLAGS+=                -Wall
                   9143:        </pre>
                   9144: <p>This code shows how the use of the <code class="literal">:=</code>
                   9145:        operator can quickly lead to unexpected results. The first
                   9146:        paragraph is fairly common code. The second paragraph evaluates
                   9147:        the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
                   9148:        <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
                   9149:        <code class="literal">-Wall</code> is appended to the
                   9150:        <code class="varname">CFLAGS</code>, but this addition will not appear in
                   9151:        <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
                   9152:        paragraphs from above typically occur in completely unrelated
                   9153:        files.</p>
                   9154: </div>
                   9155: <div class="sect2" lang="en">
                   9156: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9157: <a name="infr.var.run"></a>22.3.2. At runtime</h3></div></div></div>
1.75      rillig   9158: <p>After all the files have been loaded, the values of the
                   9159:        variables cannot be changed anymore. Variables that are used in
                   9160:        the shell commands are expanded at this point.</p>
                   9161: </div>
                   9162: </div>
                   9163: <div class="sect1" lang="en">
                   9164: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9165: <a name="infr.varspec"></a>22.4. How can variables be specified?</h2></div></div></div>
1.78      rillig   9166: <p>There are many ways in which the definition and use of a
                   9167:        variable can be restricted in order to detect bugs and
                   9168:        violations of the (mostly unwritten) policies. See the
                   9169:        <code class="literal">pkglint</code> developer's documentation for further
                   9170:        details.</p>
                   9171: </div>
                   9172: <div class="sect1" lang="en">
                   9173: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9174: <a name="infr.design.intf"></a>22.5. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76      rillig   9175: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75      rillig   9176:        of the following classes. Cases where a file falls into more
                   9177:        than one class should be avoided as it often leads to subtle
                   9178:        bugs.</p>
                   9179: <div class="sect2" lang="en">
                   9180: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9181: <a name="infr.design.intf.proc"></a>22.5.1. Procedures with parameters</h3></div></div></div>
1.75      rillig   9182: <p>In a traditional imperative programming language some of
1.76      rillig   9183:        the <code class="filename">.mk</code> files could be described as
1.85      jmmv     9184:        procedures. They take some input parameters and&mdash;after
                   9185:        inclusion&mdash;provide a result in output parameters. Since all
1.76      rillig   9186:        variables in <code class="filename">Makefile</code>s have global scope
1.75      rillig   9187:        care must be taken not to use parameter names that have already
                   9188:        another meaning. For example, <code class="varname">PKGNAME</code> is a
                   9189:        bad choice for a parameter name.</p>
                   9190: <p>Procedures are completely evaluated at preprocessing time.
                   9191:        That is, when calling a procedure all input parameters must be
                   9192:        completely resolvable. For example,
                   9193:        <code class="varname">CONFIGURE_ARGS</code> should never be an input
                   9194:        parameter since it is very likely that further text will be
                   9195:        added after calling the procedure, which would effectively apply
                   9196:        the procedure to only a part of the variable. Also, references
                   9197:        to other variables wit will be modified after calling the
                   9198:        procedure.</p>
                   9199: <p>A procedure can declare its output parameters either as
                   9200:        suitable for use in preprocessing directives or as only
                   9201:        available at runtime. The latter alternative is for variables
                   9202:        that contain references to other runtime variables.</p>
                   9203: <p>Procedures shall be written such that it is possible to
                   9204:        call the procedure more than once. That is, the file must not
                   9205:        contain multiple-inclusion guards.</p>
                   9206: <p>Examples for procedures are
1.76      rillig   9207:        <code class="filename">mk/bsd.options.mk</code> and
                   9208:        <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75      rillig   9209:        that the parameters are evaluated at load time, they should be
                   9210:        assigned using the <code class="literal">:=</code> operator, which should
                   9211:        be used only for this purpose.</p>
                   9212: </div>
                   9213: <div class="sect2" lang="en">
                   9214: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9215: <a name="infr.design.intf.action"></a>22.5.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75      rillig   9216: <p>Action files take some input parameters and may define
                   9217:        runtime variables. They shall not define loadtime variables.
                   9218:        There are action files that are included implicitly by the
                   9219:        pkgsrc infrastructure, while other must be included
                   9220:        explicitly.</p>
                   9221: <p>An example for action files is
1.76      rillig   9222:        <code class="filename">mk/subst.mk</code>.</p>
1.75      rillig   9223: </div>
                   9224: </div>
1.81      rillig   9225: <div class="sect1" lang="en">
                   9226: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9227: <a name="infr.order"></a>22.6. The order in which files are loaded</h2></div></div></div>
1.81      rillig   9228: <p>Package <code class="filename">Makefile</code>s usually consist of
                   9229:        a set of variable definitions, and include the file
                   9230:        <code class="filename">../../mk/bsd.pkg.mk</code> in the very last line.
                   9231:        Before that, they may also include various other
                   9232:        <code class="filename">*.mk</code> files if they need to query the
                   9233:        availability of certain features like the type of compiler or
                   9234:        the X11 implementation. Due to the heavy use of preprocessor
                   9235:        directives like <code class="literal">.if</code> and
                   9236:        <code class="literal">.for</code>, the order in which the files are loaded
                   9237:        matters.</p>
                   9238: <p>This section describes at which point the various files
                   9239:        are loaded and gives reasons for that order.</p>
                   9240: <div class="sect2" lang="en">
                   9241: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9242: <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   9243: <p>The very first action in <code class="filename">bsd.pkg.mk</code>
                   9244:        is to define some essential variables like
                   9245:        <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code> and
                   9246:        <code class="varname">MACHINE_ARCH</code>.</p>
                   9247: <p>Then, the user settings are loaded from the file specified
                   9248:        in <code class="varname">MAKECONF</code>. If the bmake command from pkgsrc
                   9249:        is used, <code class="varname">MAKECONF</code> defaults to
                   9250:        <code class="filename"><em class="replaceable"><code>${prefix}</code></em>/etc/mk.conf</code>.
                   9251:        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
                   9252:        <code class="filename">/etc/mk.conf</code>. After that, those variables
                   9253:        that have not been overridden by the user are loaded from
                   9254:        <code class="filename">mk/defaults/mk.conf</code>.</p>
                   9255: <p>After the user settings, the system settings and platform
                   9256:        settings are loaded, which may override the user
                   9257:        settings.</p>
                   9258: <p>Then, the tool definitions are loaded. The tool wrappers
                   9259:        are not yet in effect. This only happens when building a
                   9260:        package, so the proper variables must be used instead of the
                   9261:        direct tool names.</p>
                   9262: <p>As the last steps, some essential variables from the
                   9263:        wrapper and the package system flavor are loaded, as well as the
                   9264:        variables that have been cached in earlier phases of a package
                   9265:        build.</p>
                   9266: </div>
                   9267: <div class="sect2" lang="en">
                   9268: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9269: <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   9270: <p>First, <code class="filename">bsd.prefs.mk</code> is loaded.</p>
                   9271: <p>Then, the various <code class="filename">*-vars.mk</code> files are
                   9272:        loaded, which fill default values for those variables that have
                   9273:        not been defined by the the package. These variables may later
                   9274:        be used even in unrelated files.</p>
                   9275: <p>Then, the file <code class="filename">bsd.pkg.error.mk</code>
                   9276:        provides the target <code class="literal">error-check</code> that is added
                   9277:        as a special dependency to all other targets that use
                   9278:        <code class="varname">DELAYED_ERROR_MSG</code> or
                   9279:        <code class="varname">DELAYED_WARNING_MSG</code>.</p>
                   9280: <p>Then, the package-specific hacks from
                   9281:        <code class="filename">hacks.mk</code> are included.</p>
                   9282: <p>Then, various other files follow. Most of them don't have
                   9283:        any dependencies on what they need to have included before or
                   9284:        after them, though some do.</p>
                   9285: <p>The code to check <code class="varname">PKG_FAIL_REASON</code> and
                   9286:        <code class="varname">PKG_SKIP_REASON</code> is then executed, which
                   9287:        restricts the use of these variables to all the files that have
                   9288:        been included before. Appearances in later files will be
                   9289:        silently ignored.</p>
                   9290: <p>Then, the files for the main targets are included, in the
                   9291:        order of later execution, though the actual order should not
                   9292:        matter.</p>
                   9293: <p>At last, some more files are included that don't set any
                   9294:        interesting variables but rather just define make targets to be
                   9295:        executed.</p>
                   9296: </div>
                   9297: </div>
1.75      rillig   9298: </div>
                   9299: <div class="chapter" lang="en">
                   9300: <div class="titlepage"><div><div><h2 class="title">
1.85      jmmv     9301: <a name="regression"></a>Chapter 23. Regression tests</h2></div></div></div>
1.75      rillig   9302: <div class="toc">
                   9303: <p><b>Table of Contents</b></p>
                   9304: <dl>
1.85      jmmv     9305: <dt><span class="sect1"><a href="#regression.descr">23.1. The regression tests framework</a></span></dt>
                   9306: <dt><span class="sect1"><a href="#regression.run">23.2. Running the regression tests</a></span></dt>
                   9307: <dt><span class="sect1"><a href="#regression.new">23.3. Adding a new regression test</a></span></dt>
1.75      rillig   9308: <dd><dl>
1.85      jmmv     9309: <dt><span class="sect2"><a href="#regression.fun.override">23.3.1. Overridable functions</a></span></dt>
                   9310: <dt><span class="sect2"><a href="#regression.fun.helper">23.3.2. Helper functions</a></span></dt>
1.75      rillig   9311: </dl></dd>
                   9312: </dl>
                   9313: </div>
                   9314: <p>The pkgsrc infrastructure consists of a large codebase,
                   9315:        and there are many corners where every little bit of a file is
                   9316:        well thought out, making pkgsrc likely to fail as soon as
                   9317:        anything is changed near those parts. To prevent most changes
                   9318:        from breaking anything, a suite of regression tests should go
                   9319:        along with every important part of the pkgsrc infrastructure.
                   9320:        This chapter describes how regression tests work in pkgsrc and
                   9321:        how you can add new tests.</p>
                   9322: <div class="sect1" lang="en">
                   9323: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9324: <a name="regression.descr"></a>23.1. The regression tests framework</h2></div></div></div>
1.75      rillig   9325: <p></p>
                   9326: </div>
                   9327: <div class="sect1" lang="en">
                   9328: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9329: <a name="regression.run"></a>23.2. Running the regression tests</h2></div></div></div>
1.76      rillig   9330: <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   9331:        provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
                   9332:        can simply run that command, which will run all tests in the
1.76      rillig   9333:        <code class="filename">regress</code> category.</p>
1.75      rillig   9334: </div>
                   9335: <div class="sect1" lang="en">
                   9336: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9337: <a name="regression.new"></a>23.3. Adding a new regression test</h2></div></div></div>
1.76      rillig   9338: <p>Every directory in the <code class="filename">regress</code>
                   9339:        category that contains a file called <code class="filename">spec</code>
1.75      rillig   9340:        is considered a regression test. This file is a shell program
                   9341:        that is included by the <span><strong class="command">pkg_regress</strong></span> command.
                   9342:        The following functions can be overridden to suit your
                   9343:        needs.</p>
                   9344: <div class="sect2" lang="en">
                   9345: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9346: <a name="regression.fun.override"></a>23.3.1. Overridable functions</h3></div></div></div>
1.75      rillig   9347: <p>These functions do not take any parameters. They are all
                   9348:        called in &#8220;<span class="quote">set -e</span>&#8221; mode, so you should be careful
                   9349:        to check the exitcodes of any commands you run in the
                   9350:        test.</p>
                   9351: <div class="variablelist"><dl>
                   9352: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
                   9353: <dd><p>This function prepares the environment for the
                   9354:        test. By default it does nothing.</p></dd>
                   9355: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
                   9356: <dd><p>This function runs the actual test. By default,
                   9357:        it calls <code class="varname">TEST_MAKE</code> with the arguments
                   9358:        <code class="varname">MAKEARGS_TEST</code> and writes its output including
                   9359:        error messages into the file
                   9360:        <code class="varname">TEST_OUTFILE</code>.</p></dd>
                   9361: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
                   9362: <dd><p>This function is run after the test and is
                   9363:        typically used to compare the actual output from the one that is
                   9364:        expected. It can make use of the various helper functions from
                   9365:        the next section.</p></dd>
                   9366: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
                   9367: <dd><p>This function cleans everything up after the
                   9368:        test has been run. By default it does nothing.</p></dd>
                   9369: </dl></div>
                   9370: </div>
                   9371: <div class="sect2" lang="en">
                   9372: <div class="titlepage"><div><div><h3 class="title">
1.85      jmmv     9373: <a name="regression.fun.helper"></a>23.3.2. Helper functions</h3></div></div></div>
1.75      rillig   9374: <div class="variablelist"><dl>
                   9375: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
                   9376: <dd><p>This function compares the exitcode of the
                   9377:        <span><strong class="command">do_test()</strong></span> function with its first parameter.
                   9378:        If they differ, the test will fail.</p></dd>
                   9379: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
                   9380: <dd><p>This function checks for each of its parameters
                   9381:        if the output from <span><strong class="command">do_test()</strong></span> matches the
                   9382:        extended regular expression. If it does not, the test will
                   9383:        fail.</p></dd>
                   9384: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
                   9385: <dd><p>This function checks for each of its parameters
                   9386:        if the output from <span><strong class="command">do_test()</strong></span> does
                   9387:        <span class="emphasis"><em>not</em></span> match the extended regular expression.
                   9388:        If any of the regular expressions matches, the test will
                   9389:        fail.</p></dd>
                   9390: </dl></div>
                   9391: </div>
                   9392: </div>
                   9393: </div>
                   9394: <div class="chapter" lang="en">
                   9395: <div class="titlepage"><div><div><h2 class="title">
1.85      jmmv     9396: <a name="porting"></a>Chapter 24. Porting pkgsrc</h2></div></div></div>
1.75      rillig   9397: <div class="toc">
                   9398: <p><b>Table of Contents</b></p>
                   9399: <dl>
1.85      jmmv     9400: <dt><span class="sect1"><a href="#porting.opsys">24.1. Porting pkgsrc to a new operating system</a></span></dt>
                   9401: <dt><span class="sect1"><a href="#porting.compiler">24.2. Adding support for a new compiler</a></span></dt>
1.75      rillig   9402: </dl>
                   9403: </div>
                   9404: <p>The pkgsrc system has already been ported to many
                   9405:        operating systems, hardware architectures and compilers. This
                   9406:        chapter explains the necessary steps to make pkgsrc even more
                   9407:        portable.</p>
                   9408: <div class="sect1" lang="en">
                   9409: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9410: <a name="porting.opsys"></a>24.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75      rillig   9411: <p>To port pkgsrc to a new operating system (called
                   9412:        <code class="literal">MyOS</code> in this example), you need to touch the
                   9413:        following files:</p>
                   9414: <div class="variablelist"><dl>
1.76      rillig   9415: <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   9416: <dd><p>This file contains some basic definitions, for
                   9417:        example the name of the C
                   9418:        compiler.</p></dd>
1.76      rillig   9419: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75      rillig   9420: <dd><p>Insert code that defines the variables
                   9421:        <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
                   9422:        <code class="varname">LOWER_OS_VERSION</code>,
                   9423:        <code class="varname">LOWER_VENDOR</code>,
                   9424:        <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
                   9425:        <code class="varname">APPEND_ELF</code>, and the other variables that
                   9426:        appear in this file.</p></dd>
1.76      rillig   9427: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75      rillig   9428: <dd><p>This file contains the platform-specific
                   9429:        definitions that are used by pkgsrc. Start by copying one of the
                   9430:        other files and edit it to your
                   9431:        needs.</p></dd>
1.76      rillig   9432: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75      rillig   9433: <dd><p>This file contains a list of directories,
                   9434:        together with their permission bits and ownership. These
                   9435:        directories will be created automatically with every package
                   9436:        that does not explicitly set <code class="varname">NO_MTREE</code>. There
                   9437:        have been some discussions about whether this file is needed at
                   9438:        all, but with no result.</p></dd>
1.76      rillig   9439: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75      rillig   9440: <dd><p>Just copy one of the pre-existing x11.dist files
                   9441:        to your
1.76      rillig   9442:        <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
                   9443: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75      rillig   9444: <dd><p>On some operating systems, the tools that are
                   9445:        provided with the base system are not good enough for pkgsrc.
                   9446:        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
                   9447:        narrow limit on the line length they can process. Therefore
                   9448:        pkgsrc brings its own tools, which can be enabled
                   9449:        here.</p></dd>
1.76      rillig   9450: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75      rillig   9451: <dd><p>This file defines the paths to all the tools
                   9452:        that are needed by one or the other package in pkgsrc, as well
                   9453:        as by pkgsrc itself. Find out where these tools are on your
                   9454:        platform and add them.</p></dd>
                   9455: </dl></div>
                   9456: <p>Now, you should be able to build some basic packages, like
1.76      rillig   9457:        <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   9458: </div>
                   9459: <div class="sect1" lang="en">
                   9460: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.85      jmmv     9461: <a name="porting.compiler"></a>24.2. Adding support for a new compiler</h2></div></div></div>
1.75      rillig   9462: <p>TODO</p>
                   9463: </div>
                   9464: </div>
                   9465: </div>
                   9466: <div class="appendix" lang="en">
                   9467: <div class="titlepage"><div><div><h2 class="title">
                   9468: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
                   9469: <div class="toc">
                   9470: <p><b>Table of Contents</b></p>
                   9471: <dl>
                   9472: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
                   9473: <dd><dl>
                   9474: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
                   9475: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
                   9476: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
                   9477: <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>
                   9478: </dl></dd>
                   9479: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
                   9480: </dl>
                   9481: </div>
                   9482: <p>We checked to find a piece of software that wasn't in the packages
                   9483:     collection, and picked GNU bison. Quite why someone would want to have
                   9484:     <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
                   9485:     present in the tree is beyond us, but it's useful for the purposes of
                   9486:     this exercise.</p>
                   9487: <div class="sect1" lang="en">
                   9488: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9489: <a name="example-files"></a>A.1. files</h2></div></div></div>
                   9490: <div class="sect2" lang="en">
                   9491: <div class="titlepage"><div><div><h3 class="title">
                   9492: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
                   9493: <pre class="programlisting">
1.51      rillig   9494:     # $NetBSD$
                   9495:     #
1.1       grant    9496: 
1.51      rillig   9497:     DISTNAME=       bison-1.25
                   9498:     CATEGORIES=     devel
                   9499:     MASTER_SITES=   ${MASTER_SITE_GNU}
1.1       grant    9500: 
1.51      rillig   9501:     MAINTAINER=     thorpej@NetBSD.org
                   9502:     HOMEPAGE=       http://www.gnu.org/software/bison/bison.html
                   9503:     COMMENT=        GNU yacc clone
1.1       grant    9504: 
1.51      rillig   9505:     GNU_CONFIGURE=  yes
                   9506:     INFO_FILES=     bison.info
1.1       grant    9507: 
1.51      rillig   9508:     .include "../../mk/bsd.pkg.mk"
1.1       grant    9509: </pre>
1.75      rillig   9510: </div>
                   9511: <div class="sect2" lang="en">
                   9512: <div class="titlepage"><div><div><h3 class="title">
                   9513: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
                   9514: <pre class="programlisting">
1.51      rillig   9515:     GNU version of yacc.  Can make re-entrant parsers, and numerous other
1.75      rillig   9516:     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   9517:     of the NetBSD source tree is beyond me.
1.1       grant    9518: </pre>
1.75      rillig   9519: </div>
                   9520: <div class="sect2" lang="en">
                   9521: <div class="titlepage"><div><div><h3 class="title">
                   9522: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
                   9523: <pre class="programlisting">
1.51      rillig   9524:     @comment $NetBSD$
                   9525:     bin/bison
                   9526:     man/man1/bison.1.gz
                   9527:     share/bison.simple
                   9528:     share/bison.hairy
1.1       grant    9529: </pre>
1.75      rillig   9530: </div>
                   9531: <div class="sect2" lang="en">
                   9532: <div class="titlepage"><div><div><h3 class="title">
                   9533: <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>
                   9534: <p>The NetBSD package system comes with
1.76      rillig   9535:         <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   9536:        which helps to check the contents of these
                   9537:        files. After installation it is quite easy to use, just change to the
                   9538:        directory of the package you wish to examine and execute
                   9539:        <span><strong class="command">pkglint</strong></span>:</p>
                   9540: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
                   9541: looks fine.</pre>
                   9542: <p>Depending on the supplied command line arguments (see pkglint(1)),
                   9543:        more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
                   9544:        -Wall</strong></span> for a very thorough check.</p>
                   9545: </div>
                   9546: </div>
                   9547: <div class="sect1" lang="en">
                   9548: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9549: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
                   9550: <p>Create the directory where the package lives,
                   9551:       plus any auxiliary directories:</p>
                   9552: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
                   9553: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
                   9554: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
                   9555: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76      rillig   9556: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.77      rillig   9557:       <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   9558:       then continue with fetching the distfile:</p>
                   9559: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1       grant    9560: &gt;&gt; bison-1.25.tar.gz doesn't seem to exist on this system.
                   9561: &gt;&gt; Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   9562: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   9563: ftp: Error retrieving file: 500 Internal error
                   9564: 
                   9565: &gt;&gt; Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   9566: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   9567: ftp: Error retrieving file: 500 Internal error
                   9568: 
                   9569: &gt;&gt; Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   9570: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75      rillig   9571: Successfully retrieved file.</pre>
                   9572: <p>Generate the checksum of the distfile into
1.76      rillig   9573:       <code class="filename">distinfo</code>:</p>
1.75      rillig   9574: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makesum</code></strong></pre>
                   9575: <p>Now compile:</p>
                   9576: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1       grant    9577: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   9578: ===&gt;  Extracting for bison-1.25
                   9579: ===&gt;  Patching for bison-1.25
                   9580: ===&gt;   Ignoring empty patch directory
                   9581: ===&gt;  Configuring for bison-1.25
                   9582: creating cache ./config.cache
                   9583: checking for gcc... cc
                   9584: checking whether we are using GNU C... yes
                   9585: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   9586: checking how to run the C preprocessor... cc -E
                   9587: checking for minix/config.h... no
                   9588: checking for POSIXized ISC... no
                   9589: checking whether cross-compiling... no
                   9590: checking for ANSI C header files... yes
                   9591: checking for string.h... yes
                   9592: checking for stdlib.h... yes
                   9593: checking for memory.h... yes
                   9594: checking for working const... yes
                   9595: checking for working alloca.h... no
                   9596: checking for alloca... yes
                   9597: checking for strerror... yes
                   9598: updating cache ./config.cache
                   9599: creating ./config.status
                   9600: creating Makefile
                   9601: ===&gt;  Building for bison-1.25
                   9602: 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
                   9603: 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
                   9604: 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
                   9605: 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
                   9606: 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   9607: 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    9608: 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
                   9609: 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
                   9610: 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
                   9611: 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
                   9612: 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
                   9613: 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
                   9614: 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
                   9615: 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
                   9616: 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
                   9617: 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
                   9618: 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
                   9619: 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
                   9620: 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
                   9621: 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
                   9622: 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
                   9623: 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
                   9624: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   9625: rm -f bison.s1
1.75      rillig   9626: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" &lt; ./bison.simple &gt; bison.s1</pre>
                   9627: <p>Everything seems OK, so install the files:</p>
                   9628: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1       grant    9629: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   9630: ===&gt;  Installing for bison-1.25
                   9631: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   9632: rm -f /usr/pkg/bin/bison
                   9633: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   9634: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   9635: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   9636: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   9637: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   9638: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   9639: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75      rillig   9640: ===&gt;  Registering installation for bison-1.25</pre>
                   9641: <p>You can now use bison, and also - if you decide so - remove it with
                   9642:       <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
                   9643:       binary package, do this now:</p>
                   9644: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1       grant    9645: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   9646: ===&gt;  Building package for bison-1.25
                   9647: Creating package bison-1.25.tgz
                   9648: Registering depends:.
1.75      rillig   9649: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
                   9650: <p>Now that you don't need the source and object files
                   9651:       any more, clean up:</p>
                   9652: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
                   9653: ===&gt;  Cleaning for bison-1.25</pre>
                   9654: </div>
                   9655: </div>
                   9656: <div class="appendix" lang="en">
                   9657: <div class="titlepage"><div><div><h2 class="title">
                   9658: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
                   9659: <div class="toc">
                   9660: <p><b>Table of Contents</b></p>
                   9661: <dl>
                   9662: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
                   9663: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
                   9664: </dl>
                   9665: </div>
                   9666: <div class="sect1" lang="en">
                   9667: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9668: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
                   9669: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1       grant    9670: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   9671: =&gt; figlet221.tar.gz doesn't seem to exist on this system.
                   9672: =&gt; Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   9673: =&gt; [172219 bytes]
                   9674: Connected to ftp.plig.net.
                   9675: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   9676: 331 Guest login ok, send your complete e-mail address as password.
                   9677: 230-You are user #5 of 500 simultaneous users allowed.
                   9678: 230-
1.68      rillig   9679: 230-  ___ _             _ _
                   9680: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
1.1       grant    9681: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   9682: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   9683: 230-         |_|   |_|     |___|         |___|
                   9684: 230-
                   9685: 230-** Welcome to ftp.plig.org **
                   9686: 230-
                   9687: 230-Please note that all transfers from this FTP site are logged. If you
                   9688: 230-do not like this, please disconnect now.
                   9689: 230-
                   9690: 230-This arhive is available via
                   9691: 230-
                   9692: 230-HTTP:  http://ftp.plig.org/
                   9693: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   9694: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   9695: 230-
                   9696: 230-Please email comments, bug reports and requests for packages to be
1.68      rillig   9697: 230-mirrored to ftp-admin@plig.org.
1.1       grant    9698: 230-
                   9699: 230-
                   9700: 230 Logged in anonymously.
                   9701: Remote system type is UNIX.
                   9702: Using binary mode to transfer files.
                   9703: 200 Type okay.
                   9704: 250 "/pub" is new cwd.
                   9705: 250-"/pub/figlet" is new cwd.
                   9706: 250-
                   9707: 250-Welcome to the figlet archive at ftp.figlet.org
1.68      rillig   9708: 250-
1.75      rillig   9709: 250-   ftp://ftp.figlet.org/pub/figlet/
1.1       grant    9710: 250-
                   9711: 250-The official FIGlet web page is:
1.75      rillig   9712: 250-   http://www.figlet.org/
1.1       grant    9713: 250-
                   9714: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   9715: 250-contribute a font or something else, you can email us.
1.68      rillig   9716: 250
1.1       grant    9717: 250 "/pub/figlet/program" is new cwd.
                   9718: 250 "/pub/figlet/program/unix" is new cwd.
                   9719: local: figlet221.tar.gz remote: figlet221.tar.gz
                   9720: 502 Unimplemented command.
                   9721: 227 Entering Passive Mode (195,40,6,41,246,104)
                   9722: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   9723: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   9724: 226 Transfer completed.
                   9725: 172219 bytes received in 00:02 (75.99 KB/s)
                   9726: 221 Goodbye.
                   9727: =&gt; Checksum OK for figlet221.tar.gz.
                   9728: ===&gt; Extracting for figlet-2.2.1nb2
                   9729: ===&gt; Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   9730: ===&gt; Patching for figlet-2.2.1nb2
                   9731: ===&gt; Applying pkgsrc patches for figlet-2.2.1nb2
                   9732: ===&gt; Overriding tools for figlet-2.2.1nb2
                   9733: ===&gt; Creating toolchain wrappers for figlet-2.2.1nb2
                   9734: ===&gt; Configuring for figlet-2.2.1nb2
                   9735: ===&gt; Building for figlet-2.2.1nb2
                   9736: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   9737: chmod a+x figlet
                   9738: gcc -O2 -o chkfont chkfont.c
                   9739: =&gt; Unwrapping files-to-be-installed.
1.14      xtraeme  9740: <code class="prompt">#</code>
1.75      rillig   9741: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1       grant    9742: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   9743: ===&gt; Installing for figlet-2.2.1nb2
                   9744: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   9745: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   9746: mkdir -p /usr/pkg/share/figlet
                   9747: cp figlet /usr/pkg/bin
                   9748: cp chkfont /usr/pkg/bin
                   9749: chmod 555 figlist showfigfonts
                   9750: cp figlist /usr/pkg/bin
                   9751: cp showfigfonts /usr/pkg/bin
                   9752: cp fonts/*.flf /usr/pkg/share/figlet
                   9753: cp fonts/*.flc /usr/pkg/share/figlet
                   9754: cp figlet.6 /usr/pkg/man/man6
                   9755: ===&gt; Registering installation for figlet-2.2.1nb2
1.75      rillig   9756: <code class="prompt">#</code></pre>
                   9757: </div>
                   9758: <div class="sect1" lang="en">
                   9759: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9760: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
                   9761: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1       grant    9762: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   9763: ===&gt; Packaging figlet-2.2.1nb2
                   9764: ===&gt; Building binary package for figlet-2.2.1nb2
                   9765: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   9766: Using SrcDir value of /usr/pkg
1.68      rillig   9767: Registering depends:.
1.75      rillig   9768: <code class="prompt">#</code></pre>
                   9769: </div>
                   9770: </div>
                   9771: <div class="appendix" lang="en">
                   9772: <div class="titlepage"><div><div><h2 class="title">
1.76      rillig   9773: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
                   9774: <div class="toc">
                   9775: <p><b>Table of Contents</b></p>
                   9776: <dl>
                   9777: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
                   9778: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
                   9779: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
                   9780: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
                   9781: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
                   9782: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
                   9783: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                   9784: source packages</a></span></dt>
                   9785: </dl>
                   9786: </div>
                   9787: <p>As in other big projects, the directory layout of pkgsrc
                   9788:        is quite complex for newbies. This chapter explains where you
                   9789:        find things on the FTP server. The base directory on
                   9790:        <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>.
                   9791:        This directory contains some subdirectories, which are explained
                   9792:        below.</p>
                   9793: <div class="sect1" lang="en">
                   9794: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9795: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
                   9796: <p>For those who only want to manage binary packages on
                   9797:        systems other than NetBSD, we provide the package management
                   9798:        tools in a separate, small tar file.</p>
                   9799: </div>
                   9800: <div class="sect1" lang="en">
                   9801: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9802: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
                   9803: <p>The directory <code class="filename">distfiles</code> contains lots
                   9804:        of archive files from all pkgsrc packages, which are mirrored
                   9805:        here. The subdirectories are called after their package names
                   9806:        and are used when the distributed files have names that don't
                   9807:        explicitly contain a version number or are otherwise too generic
                   9808:        (for example <code class="filename">release.tar.gz</code>).</p>
                   9809: </div>
                   9810: <div class="sect1" lang="en">
                   9811: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9812: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
                   9813: <p>This directory is currently not in use.</p>
                   9814: </div>
                   9815: <div class="sect1" lang="en">
                   9816: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9817: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
                   9818: <p>This directory contains things that individual pkgsrc
                   9819:        developers find worth publishing.</p>
                   9820: </div>
                   9821: <div class="sect1" lang="en">
                   9822: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9823: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
                   9824: <p>These directories contain binary packages. Those
                   9825:        directories that have a branch name
                   9826:        (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
                   9827:        contain packages from that particular branch. The directory
                   9828:        <code class="filename">packages</code> contains binary packages from
                   9829:        pkgsrc-current. (However, this does not necessarily mean that
                   9830:        the packages are still current anymore.)</p>
                   9831: <p>Below the <code class="filename">packages*</code> directories are
                   9832:        directories that distinguish the packages by operating system
                   9833:        and version, the next directory level specifies the hardware
                   9834:        architecture.</p>
                   9835: <p>In each of the platform-specific directories, there is a
                   9836:        whole binary packages collection. It has a directory called
                   9837:        <code class="filename">All</code> which contains all binary packages.
                   9838:        Besides that, there are various category directories that
                   9839:        contain symbolic links to the real binary packages.</p>
                   9840: </div>
                   9841: <div class="sect1" lang="en">
                   9842: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9843: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
                   9844: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                   9845: source packages</h2></div></div></div>
                   9846: <p>These directories contain the &#8220;<span class="quote">real</span>&#8221; pkgsrc,
                   9847:        that is the files that define how to create binary packages from
                   9848:        source archives.</p>
                   9849: <p>The directory <code class="filename">pkgsrc</code> contains a
                   9850:        snapshot of the CVS repository, which is updated on a regularly
                   9851:        basis. The file <code class="filename">pkgsrc.tar.gz</code> contains the
                   9852:        same as the directory, ready to be downloaded as a whole.</p>
                   9853: <p>In the directories for the quarterly branches, there is an
                   9854:        additional file called
                   9855:        <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
                   9856:        which contains the state of pkgsrc when it was branched.</p>
                   9857: </div>
1.75      rillig   9858: </div>
                   9859: <div class="appendix" lang="en">
                   9860: <div class="titlepage"><div><div><h2 class="title">
                   9861: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
                   9862: <div class="toc">
                   9863: <p><b>Table of Contents</b></p>
                   9864: <dl>
1.79      rillig   9865: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75      rillig   9866: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
                   9867: </dl>
                   9868: </div>
1.79      rillig   9869: <p>This section contains information on editing the pkgsrc
                   9870:        guide itself.</p>
1.75      rillig   9871: <div class="sect1" lang="en">
                   9872: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79      rillig   9873: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
                   9874: <p>The pkgsrc guide's source code is stored in
                   9875:        <code class="filename">pkgsrc/doc/guide/files</code>, and several files
                   9876:        are created from it:</p>
                   9877: <div class="itemizedlist"><ul type="disc">
                   9878: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
                   9879: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
                   9880: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/</a></p></li>
                   9881: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</a>:
                   9882:        The PDF version of the pkgsrc guide.</p></li>
                   9883: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</a>:
                   9884:        PostScript version of the pkgsrc guide.</p></li>
1.75      rillig   9885: </ul></div>
                   9886: </div>
                   9887: <div class="sect1" lang="en">
                   9888: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9889: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
1.79      rillig   9890: <p>The procedure to edit the pkgsrc guide is:</p>
                   9891: <div class="procedure"><ol type="1">
                   9892: <li><p>Make sure you have the packages needed to
1.83      wiz      9893:        regenerate the pkgsrc guide (and other XML-based NetBSD
1.79      rillig   9894:        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
                   9895:        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
                   9896:        PostScript and PDF versions. You will need both packages
                   9897:        installed, to make sure documentation is consistent across all
                   9898:        formats.</p></li>
                   9899: <li><p>Run <span><strong class="command">cd doc/guide</strong></span> to get to the
                   9900:        right directory. All further steps will take place
                   9901:        here.</p></li>
                   9902: <li><p>Edit the XML file(s) in
                   9903:        <code class="filename">files/</code>.</p></li>
                   9904: <li><p>Run <span><strong class="command">bmake</strong></span> to check the pkgsrc
                   9905:        guide for valid XML and to build the final output files. If you
                   9906:        get any errors at this stage, you can just edit the files, as
                   9907:        there are only symbolic links in the working directory, pointing
                   9908:        to the files in <code class="filename">files/</code>.</p></li>
                   9909: <li><p><span><strong class="command">(cd files &amp;&amp; cvs
                   9910:        commit)</strong></span></p></li>
                   9911: <li><p>Run <span><strong class="command">bmake clean &amp;&amp; bmake</strong></span> to
                   9912:        regenerate the output files with the proper RCS
                   9913:        Ids.</p></li>
1.83      wiz      9914: <li><p>Run <span><strong class="command">bmake regenerate</strong></span> to
                   9915:        regenerate the files in both <code class="filename">pkgsrc/doc</code> and
                   9916:        <code class="filename">htdocs</code>.</p></li>
                   9917: <li><p>If you have added, removed or renamed some chapters,
                   9918:        you need to synchronize them using <span><strong class="command">cvs add</strong></span> or
                   9919:        <span><strong class="command">cvs delete</strong></span> in the htdocs
                   9920:        directory.</p></li>
1.79      rillig   9921: </ol></div>
1.75      rillig   9922: </div>
                   9923: </div>
                   9924: </div></body>
1.1       grant    9925: </html>

CVSweb <webmaster@jp.NetBSD.org>