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

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.80      rillig     34: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.21 2006/07/03 23:51:01 rillig Exp $</p></div>
1.76      rillig     35: <div><div class="abstract">
1.75      rillig     36: <p class="title"><b>Abstract</b></p>
                     37: <p>pkgsrc is a centralized package management system for
                     38:        Unix-like operating systems. This guide provides information for
                     39:        users and developers of pkgsrc. It covers installation of binary
                     40:        and source packages, creation of binary and source packages and
                     41:        a high-level overview about the infrastructure.</p>
                     42: </div></div>
                     43: </div>
                     44: <hr>
                     45: </div>
                     46: <div class="toc">
                     47: <p><b>Table of Contents</b></p>
                     48: <dl>
                     49: <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
                     50: <dd><dl>
                     51: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82      rillig     52: <dd><dl>
                     53: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
                     54: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
                     55: </dl></dd>
1.75      rillig     56: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
                     57: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.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>
                    173: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
                    174: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78      rillig    175: <dd><dl>
                    176: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
                    177: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
                    178: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
                    179: </dl></dd>
1.77      rillig    180: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
                    181: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
                    182: </dl></dd>
                    183: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
                    184: <dd><dl>
                    185: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
                    186: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
                    187: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
                    188: <dd><dl>
                    189: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
                    190: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
                    191: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
                    192: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
                    193: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
                    194: </dl></dd>
                    195: </dl></dd>
                    196: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
                    197: <dd><dl>
                    198: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
                    199: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
                    200: <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>
                    201: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
                    202: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
                    203: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
                    204: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
                    205: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
                    206: </dl></dd>
                    207: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
                    208: <dd><dl>
                    209: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
                    210: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
                    211: <dd><dl>
                    212: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
                    213: <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>
                    214: </dl></dd>
                    215: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
                    216: <dd><dl>
                    217: <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>
                    218: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
                    219: </dl></dd>
                    220: </dl></dd>
                    221: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
                    222: <dd><dl>
                    223: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
                    224: <dd><dl>
                    225: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
                    226: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
                    227: </dl></dd>
                    228: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
                    229: <dd><dl>
                    230: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
                    231: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
                    232: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
                    233: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
                    234: </dl></dd>
                    235: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
                    236: <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>
                    237: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
                    238: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
                    239: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
                    240: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
                    241: <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>
                    242: </dl></dd>
                    243: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
                    244: <dd><dl>
                    245: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
                    246: <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>
                    247: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
                    248: </dl></dd>
                    249: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
                    250: <dd><dl>
                    251: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
                    252: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
                    253: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
                    254: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
                    255: <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    256: <dd><dl>
                    257: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
                    258: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
                    259: </dl></dd>
1.77      rillig    260: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
                    261: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
                    262: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
                    263: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
                    264: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
                    265: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                    266: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                    267: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
                    268: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                    269: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
                    270: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
                    271: </dl></dd>
                    272: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
                    273: <dd><dl>
                    274: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
                    275: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
                    276: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
                    277: </dl></dd>
                    278: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
                    279: <dd><dl>
                    280: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
                    281: <dd><dl>
1.78      rillig    282: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
                    283: <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>
                    284: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
                    285: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
                    286: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
                    287: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
                    288: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
                    289: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
                    290: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
                    291: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
                    292: <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    293: <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    294: </dl></dd>
                    295: <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>
                    296: <dd><dl>
                    297: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
                    298: <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>
                    299: </dl></dd>
                    300: <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>
                    301: <dd><dl>
                    302: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
                    303: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
                    304: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
                    305: </dl></dd>
                    306: <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>
                    307: <dd><dl>
1.78      rillig    308: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
                    309: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
                    310: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
                    311: </dl></dd>
                    312: <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>
                    313: <dd><dl>
                    314: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
                    315: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
                    316: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
                    317: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
                    318: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
                    319: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
                    320: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
                    321: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
                    322: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
                    323: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
                    324: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
                    325: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
                    326: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
                    327: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
                    328: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
                    329: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
                    330: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77      rillig    331: </dl></dd>
1.78      rillig    332: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77      rillig    333: </dl></dd>
                    334: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
                    335: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
                    336: <dd><dl>
                    337: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
                    338: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                    339: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
                    340: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
                    341: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
                    342: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig    343: </dl></dd>
1.77      rillig    344: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75      rillig    345: </dl></dd>
                    346: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
                    347: <dd><dl>
1.77      rillig    348: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75      rillig    349: <dd><dl>
1.81      rillig    350: <dt><span class="sect1"><a href="#infr.vardef">21.1. The meaning of variable definitions</a></span></dt>
                    351: <dt><span class="sect1"><a href="#infr.vardef.problems">21.2. Avoiding problems before they arise</a></span></dt>
                    352: <dt><span class="sect1"><a href="#infr.var">21.3. Variable evaluation</a></span></dt>
                    353: <dd><dl>
                    354: <dt><span class="sect2"><a href="#infr.var.load">21.3.1. At load time</a></span></dt>
                    355: <dt><span class="sect2"><a href="#infr.var.run">21.3.2. At runtime</a></span></dt>
                    356: </dl></dd>
                    357: <dt><span class="sect1"><a href="#infr.varspec">21.4. How can variables be specified?</a></span></dt>
                    358: <dt><span class="sect1"><a href="#infr.design.intf">21.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig    359: <dd><dl>
1.81      rillig    360: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.5.1. Procedures with parameters</a></span></dt>
                    361: <dt><span class="sect2"><a href="#infr.design.intf.action">21.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75      rillig    362: </dl></dd>
1.81      rillig    363: <dt><span class="sect1"><a href="#infr.order">21.6. The order in which files are loaded</a></span></dt>
1.75      rillig    364: <dd><dl>
1.81      rillig    365: <dt><span class="sect2"><a href="#infr.order.prefs">21.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
                    366: <dt><span class="sect2"><a href="#infr.order.pkg">21.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75      rillig    367: </dl></dd>
                    368: </dl></dd>
1.77      rillig    369: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75      rillig    370: <dd><dl>
1.77      rillig    371: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
                    372: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
                    373: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75      rillig    374: <dd><dl>
1.77      rillig    375: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
                    376: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75      rillig    377: </dl></dd>
                    378: </dl></dd>
1.80      rillig    379: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75      rillig    380: <dd><dl>
1.80      rillig    381: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
                    382: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75      rillig    383: </dl></dd>
                    384: </dl></dd>
                    385: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
                    386: <dd><dl>
                    387: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
                    388: <dd><dl>
                    389: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
                    390: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
                    391: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
                    392: <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>
                    393: </dl></dd>
                    394: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
                    395: </dl></dd>
                    396: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
                    397: <dd><dl>
                    398: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
                    399: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
                    400: </dl></dd>
1.76      rillig    401: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
                    402: <dd><dl>
                    403: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
                    404: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
                    405: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
                    406: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
                    407: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
                    408: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
                    409: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                    410: source packages</a></span></dt>
                    411: </dl></dd>
1.75      rillig    412: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
                    413: <dd><dl>
1.79      rillig    414: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75      rillig    415: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
                    416: </dl></dd>
                    417: </dl>
                    418: </div>
1.82      rillig    419: <div class="list-of-tables">
                    420: <p><b>List of Tables</b></p>
                    421: <dl>
                    422: <dt>1.1. <a href="#supported-platforms">Platforms supported by pkgsrc</a>
                    423: </dt>
                    424: <dt>3.1. <a href="#binary-kits">Binary kits and available packages</a>
                    425: </dt>
                    426: </dl>
                    427: </div>
1.75      rillig    428: <div class="chapter" lang="en">
                    429: <div class="titlepage"><div><div><h2 class="title">
                    430: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
                    431: <div class="toc">
                    432: <p><b>Table of Contents</b></p>
                    433: <dl>
                    434: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82      rillig    435: <dd><dl>
                    436: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
                    437: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
                    438: </dl></dd>
1.75      rillig    439: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
                    440: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.78      rillig    441: <dd><dl>
                    442: <dt><span class="sect2"><a href="#term.abbrev">1.3.1. Commonly used abbreviations</a></span></dt>
1.82      rillig    443: <dt><span class="sect2"><a href="#term.roles">1.3.2. Roles involved in pkgsrc</a></span></dt>
1.78      rillig    444: </dl></dd>
1.75      rillig    445: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
                    446: </dl>
                    447: </div>
                    448: <div class="sect1" lang="en">
                    449: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    450: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
1.82      rillig    451: <p>There is a lot of software freely available for Unix-based
                    452: systems, which is usually available in form of the source code. Before
                    453: such software can be used, it needs to be configured to the local
                    454: system, compiled and installed, and this is exactly what The NetBSD
                    455: Packages Collection (pkgsrc) does. pkgsrc also has some basic commands
                    456: to handle binary packages, so that not every user has to build the
                    457: packages for himself, which is a time-costly task.</p>
1.75      rillig    458: <p>pkgsrc currently contains several thousand packages,
                    459:       including:</p>
                    460: <div class="itemizedlist"><ul type="disc">
1.76      rillig    461: <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    462:          web server</p></li>
1.83    ! wiz       463: <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    464:          web browser</p></li>
1.76      rillig    465: <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    466:          Desktop Environment</p></li>
1.76      rillig    467: <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    468:          Desktop Environment</p></li>
                    469: </ul></div>
                    470: <p>...just to name a few.</p>
                    471: <p>pkgsrc has built-in support for handling varying dependencies,
                    472:       such as pthreads and X11, and extended features such as IPv6 support on
                    473:       a range of platforms.</p>
1.82      rillig    474: <div class="sect2" lang="en">
                    475: <div class="titlepage"><div><div><h3 class="title">
                    476: <a name="why-pkgsrc"></a>1.1.1. Why pkgsrc?</h3></div></div></div>
                    477: <p>
                    478: pkgsrc provides the following key features:
                    479: </p>
                    480: <div class="itemizedlist"><ul type="disc">
                    481: <li><p>Easy building of software from source as well as the creation
                    482:   and installation of binary packages. The source and latest
                    483:   patches are retrieved from a master or mirror download site, checksum
                    484:   verified, then built on your system. Support for binary-only
                    485:   distributions is available for both native platforms and NetBSD
                    486:   emulated platforms.</p></li>
                    487: <li><p>All packages are installed in a consistent directory tree,
                    488:   including binaries, libraries, man pages and other
                    489:   documentation.</p></li>
                    490: <li><p>Package dependencies, including when performing package updates,
                    491:   are handled automatically. The configuration files of various
                    492:   packages are handled automatically during updates, so local changes
                    493:   are preserved.</p></li>
                    494: <li><p>Like NetBSD, pkgsrc is designed with portability in mind and
                    495:   consists of highly portable code. This allows the greatest speed of
                    496:   development when porting to new a platform. This portability also
                    497:   ensures that pkgsrc is <span class="emphasis"><em>consistent across all
                    498:   platforms</em></span>.</p></li>
                    499: <li><p>The installation prefix, acceptable software licenses,
                    500:   international encryption requirements and build-time options for a
                    501:   large number of packages are all set in a simple, central
                    502:   configuration file.</p></li>
                    503: <li><p>The entire source (not including the distribution files) is
                    504:   freely available under a BSD license, so you may extend and adapt
                    505:   pkgsrc to your needs. Support for local packages and patches is
                    506:   available right out of the box, so you can configure it specifically
                    507:   for your environment.</p></li>
                    508: </ul></div>
                    509: </div>
                    510: <div class="sect2" lang="en">
                    511: <div class="titlepage"><div><div><h3 class="title">
                    512: <a name="intro.platforms"></a>1.1.2. Supported platforms</h3></div></div></div>
                    513: <p>pkgsrc consists of both a source distribution and a binary
                    514: distribution for these operating systems. After retrieving the required
                    515: source or binaries, you can be up and running with pkgsrc in just
                    516: minutes!</p>
1.75      rillig    517: <p>pkgsrc was derived from FreeBSD's ports system, and
                    518:       initially developed for NetBSD only. Since then, pkgsrc has
                    519:       grown a lot, and now supports the following platforms:</p>
1.82      rillig    520: <div class="table">
                    521: <a name="supported-platforms"></a><p class="title"><b>Table 1.1. Platforms supported by pkgsrc</b></p>
1.83    ! wiz       522: <div class="table-contents"><table summary="Platforms supported by pkgsrc" border="1">
1.82      rillig    523: <colgroup>
                    524: <col>
                    525: <col>
                    526: </colgroup>
                    527: <thead><tr>
                    528: <th>Platform</th>
                    529: <th>Date Support Added</th>
                    530: </tr></thead>
                    531: <tbody>
                    532: <tr>
                    533: <td><a href="http://www.NetBSD.org/" target="_top">NetBSD</a></td>
                    534: <td align="center">Aug 1997</td>
                    535: </tr>
                    536: <tr>
                    537: <td><a href="http://wwws.sun.com/software/solaris/" target="_top">Solaris</a></td>
                    538: <td align="center">Mar 1999</td>
                    539: </tr>
                    540: <tr>
                    541: <td><a href="http://www.kernel.org/" target="_top">Linux</a></td>
                    542: <td align="center">Jun 1999</td>
                    543: </tr>
                    544: <tr>
                    545: <td>
                    546:           <a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
                    547:           (<a href="http://developer.apple.com/macosx/" target="_top">Mac OS X</a>)
                    548:         </td>
                    549: <td align="center">Oct 2001</td>
                    550: </tr>
                    551: <tr>
                    552: <td><a href="http://www.freebsd.org/" target="_top">FreeBSD</a></td>
                    553: <td align="center">Nov 2002</td>
                    554: </tr>
                    555: <tr>
                    556: <td><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></td>
                    557: <td align="center">Nov 2002</td>
                    558: </tr>
                    559: <tr>
                    560: <td><a href="http://www.sgi.com/software/irix/" target="_top">IRIX</a></td>
                    561: <td align="center">Dec 2002</td>
                    562: </tr>
                    563: <tr>
                    564: <td>BSD/OS</td>
                    565: <td align="center">Dec 2003</td>
                    566: </tr>
                    567: <tr>
                    568: <td><a href="http://www-1.ibm.com/servers/aix/" target="_top">AIX</a></td>
                    569: <td align="center">Dec 2003</td>
                    570: </tr>
                    571: <tr>
                    572: <td>
                    573:           <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a>
                    574:           (Microsoft Windows Services for Unix)
                    575:         </td>
                    576: <td align="center">Mar 2004</td>
                    577: </tr>
                    578: <tr>
                    579: <td><a href="http://www.dragonflybsd.org/" target="_top">DragonFlyBSD</a></td>
                    580: <td align="center">Oct 2004</td>
                    581: </tr>
                    582: <tr>
                    583: <td><a href="http://www.tru64.org/" target="_top">OSF/1</a></td>
                    584: <td align="center">Nov 2004</td>
                    585: </tr>
                    586: </tbody>
1.83    ! wiz       587: </table></div>
1.82      rillig    588: </div>
1.83    ! wiz       589: <br class="table-break">
1.82      rillig    590: </div>
1.75      rillig    591: </div>
                    592: <div class="sect1" lang="en">
                    593: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    594: <a name="overview"></a>1.2. Overview</h2></div></div></div>
                    595: <p>This document is divided into three parts. The first,
                    596:        <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
                    597:        describes how one can use one of the packages in the Package
                    598:        Collection, either by installing a precompiled binary package,
                    599:        or by building one's own copy using the NetBSD package system. 
                    600:        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
                    601:        package so it can be easily built by other NetBSD users without
                    602:        knowing about the package's building details. The third part,
                    603:        <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
                    604:        is intended for those who want to understand how pkgsrc is
                    605:        implemented.</p>
                    606: <p>This document is available in various formats:
                    607:        <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>
                    608: </div>
                    609: <div class="sect1" lang="en">
                    610: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    611: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
                    612: <p>There has been a lot of talk about &#8220;<span class="quote">ports</span>&#8221;,
                    613:       &#8220;<span class="quote">packages</span>&#8221;, etc. so far. Here is a description of all the
                    614:       terminology used within this document.</p>
                    615: <div class="variablelist"><dl>
                    616: <dt><span class="term">Package</span></dt>
                    617: <dd><p>A set of files and building instructions
                    618:            that describe what's necessary
                    619:            to build a certain piece of software using
                    620:             pkgsrc. Packages are traditionally stored under
1.76      rillig    621:            <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75      rillig    622: <dt><span class="term">The NetBSD package system</span></dt>
                    623: <dd><p>
                    624:            This is the former name of &#8220;<span class="quote">pkgsrc</span>&#8221;.  It is
                    625:            part of the NetBSD operating system and can be bootstrapped to
                    626:            run on non-NetBSD operating systems as well.  It handles
                    627:            building (compiling), installing, and removing of
                    628:            packages.
                    629:            </p></dd>
                    630: <dt><span class="term">Distfile</span></dt>
                    631: <dd><p>This term describes the file or files that are
                    632:            provided by the author of the piece of software to
                    633:            distribute his work. All the changes necessary to build on
                    634:            NetBSD are reflected in the corresponding package. Usually
                    635:            the distfile is in the form of a compressed tar-archive,
                    636:            but other types are possible, too. Distfiles are usually
                    637:            stored below
1.76      rillig    638:            <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75      rillig    639: <dt><span class="term">Port</span></dt>
                    640: <dd><p>This is the term used by FreeBSD and OpenBSD people
                    641:            for what we call a package.
                    642:            In NetBSD terminology, &#8220;<span class="quote">port</span>&#8221; refers to a different
                    643:            architecture.</p></dd>
                    644: <dt><span class="term">Precompiled/binary package</span></dt>
                    645: <dd>
                    646: <p>A set of binaries built with pkgsrc from a distfile
1.76      rillig    647:            and stuffed together in a single <code class="filename">.tgz</code>
1.75      rillig    648:            file so it can be installed on machines of the same
                    649:            machine architecture without the need to
                    650:            recompile. Packages are usually generated in
1.76      rillig    651:            <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75      rillig    652:            an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
                    653: <p>Sometimes, this is referred to by the term &#8220;<span class="quote">package</span>&#8221; too,
                    654:            especially in the context of precompiled packages.</p>
                    655: </dd>
                    656: <dt><span class="term">Program</span></dt>
                    657: <dd><p>The piece of software to be installed which will be constructed from
                    658:            all the files in the distfile by the actions defined in the
                    659:            corresponding package.</p></dd>
                    660: </dl></div>
                    661: <div class="sect2" lang="en">
                    662: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig    663: <a name="term.abbrev"></a>1.3.1. Commonly used abbreviations</h3></div></div></div>
                    664: <div class="variablelist"><dl>
                    665: <dt><span class="term">ICE</span></dt>
                    666: <dd><p>Internal Compiler
                    667:        Error</p></dd>
                    668: </dl></div>
                    669: </div>
                    670: <div class="sect2" lang="en">
                    671: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig    672: <a name="term.roles"></a>1.3.2. Roles involved in pkgsrc</h3></div></div></div>
1.75      rillig    673: <div class="variablelist"><dl>
                    674: <dt><span class="term">pkgsrc users</span></dt>
                    675: <dd>
                    676: <p>The
                    677:        pkgsrc users are people who use the packages provided by pkgsrc.
                    678:        Typically they are system administrators. The people using the
                    679:        software that is inside the packages (maybe called &#8220;<span class="quote">end
                    680:        users</span>&#8221;) are not covered by the pkgsrc guide.</p>
                    681: <p>There are two kinds of pkgsrc users: Some only want to
                    682:        install pre-built binary packages. Others build the pkgsrc
                    683:        packages from source, either for installing them directly or for
                    684:        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
                    685:        documentation.</p>
                    686: </dd>
                    687: <dt><span class="term">package maintainers</span></dt>
                    688: <dd><p>A
                    689:        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>
                    690: <dt><span class="term">infrastructure developers</span></dt>
                    691: <dd><p>These people are involved in all those files
1.76      rillig    692:        that live in the <code class="filename">mk/</code> directory and below.
1.75      rillig    693:        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,
                    694:        too.</p></dd>
                    695: </dl></div>
                    696: </div>
                    697: </div>
                    698: <div class="sect1" lang="en">
                    699: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    700: <a name="typography"></a>1.4. Typography</h2></div></div></div>
                    701: <p>When giving examples for commands, shell prompts are used to
                    702:       show if the command should/can be issued as root, or if
                    703:       &#8220;<span class="quote">normal</span>&#8221; user privileges are sufficient. We use a
                    704:       <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
                    705:       shell prompt, assuming they use the C-shell or tcsh.</p>
                    706: </div>
                    707: </div>
                    708: <div class="part" lang="en">
                    709: <div class="titlepage"><div><div><h1 class="title">
                    710: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
                    711: <div class="toc">
                    712: <p><b>Table of Contents</b></p>
                    713: <dl>
                    714: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
                    715: <dd><dl>
                    716: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                    717: <dd><dl>
                    718: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                    719: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                    720: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                    721: </dl></dd>
                    722: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                    723: <dd><dl>
                    724: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                    725: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                    726: </dl></dd>
                    727: </dl></dd>
                    728: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
                    729: <dd><dl>
1.82      rillig    730: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
                    731: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
                    732: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
                    733: <dd><dl>
                    734: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
                    735: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
                    736: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
                    737: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
                    738: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
                    739: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
                    740: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75      rillig    741: </dl></dd>
                    742: </dl></dd>
                    743: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
                    744: <dd><dl>
                    745: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                    746: <dd><dl>
                    747: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                    748: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82      rillig    749: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
                    750: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
                    751: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
                    752: <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>
                    753: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
                    754: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75      rillig    755: </dl></dd>
                    756: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                    757: <dd><dl>
                    758: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                    759: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                    760: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                    761: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
                    762: </dl></dd>
                    763: </dl></dd>
                    764: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
                    765: <dd><dl>
                    766: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                    767: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78      rillig    768: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
                    769: <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>
                    770: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
                    771: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75      rillig    772: </dl></dd>
                    773: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
                    774: <dd><dl>
                    775: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                    776: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                    777: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                    778: <dd><dl>
                    779: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                    780: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                    781: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                    782: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                    783: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                    784: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                    785: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                    786: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                    787: </dl></dd>
                    788: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                    789: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                    790: </dl></dd>
                    791: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
                    792: <dd><dl>
                    793: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                    794: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
                    795: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
                    796: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
                    797: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
                    798: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                    799: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                    800: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
                    801: <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>
                    802: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
                    803: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does &#8220;<span class="quote">Don't know how to make
                    804: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
                    805: <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>
                    806: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
                    807: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
                    808: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
                    809: <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    810: <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    811: </dl></dd>
                    812: </dl>
                    813: </div>
                    814: <div class="chapter" lang="en">
                    815: <div class="titlepage"><div><div><h2 class="title">
                    816: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
                    817: <div class="toc">
                    818: <p><b>Table of Contents</b></p>
                    819: <dl>
                    820: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                    821: <dd><dl>
                    822: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                    823: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                    824: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                    825: </dl></dd>
                    826: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                    827: <dd><dl>
                    828: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                    829: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                    830: </dl></dd>
                    831: </dl>
                    832: </div>
                    833: <p>The most common location where pkgsrc is installed is
1.76      rillig    834:        <code class="filename">/usr/pkgsrc</code> for the &#8220;<span class="quote">package
                    835:        sources</span>&#8221; and <code class="filename">/usr/pkg</code> for the
1.75      rillig    836:        installed binary packages. You are though free to install the
                    837:        sources and binary packages wherever you want in your
                    838:        filesystem, provided that both paths do not contain white-space
                    839:        or other characters that are interpreted specially by the shell
                    840:        and some other programs. A safe bet is to use only letters,
                    841:        digits, underscores and dashes in the names.</p>
                    842: <div class="sect1" lang="en">
                    843: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    844: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
                    845: <p>Before you download any pkgsrc files, you should decide
                    846:        whether you want the <span class="emphasis"><em>current</em></span> branch or the
                    847:        <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
                    848:        quarterly basis from the current branch and only gets modified
                    849:        for security updates. The names of the stable branches are built
                    850:        from the year and the quarter, for example
                    851:        <code class="literal">2006Q1</code>.</p>
                    852: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
                    853:        want to download pkgsrc. You can get it as a tar file, via SUP,
                    854:        or via CVS. All three ways are described here.</p>
                    855: <div class="sect2" lang="en">
                    856: <div class="titlepage"><div><div><h3 class="title">
                    857: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
                    858: <p>The primary download location for all pkgsrc files is
                    859:        <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
                    860:        number of subdirectories for different purposes, which are
1.76      rillig    861:        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    862: <p>The tar file for the current branch is in the directory
1.76      rillig    863:        <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    864:        It is autogenerated daily.</p>
                    865: <p>The tar file for the stable branch 2006Q1 is in the
1.76      rillig    866:        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    867: <p>After downloading the tar file, change to the directory
                    868:        where you want to have pkgsrc. This is usually
1.76      rillig    869:        <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75      rillig    870:        pkgsrc.tar.gz</strong></span> to extract the files.</p>
                    871: </div>
                    872: <div class="sect2" lang="en">
                    873: <div class="titlepage"><div><div><h3 class="title">
                    874: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
                    875: <p>As an alternative to the tar file, you can get pkgsrc via
                    876:        the Software Update Protocol, SUP. To do so, make sure your
                    877:        supfile has a line
1.1       grant     878: 
1.75      rillig    879: </p>
                    880: <pre class="programlisting">
1.51      rillig    881:     release=pkgsrc
1.1       grant     882: </pre>
1.75      rillig    883: <p>
1.1       grant     884: 
1.75      rillig    885:        in it, see the examples in
1.76      rillig    886:        <code class="filename">/usr/share/examples/supfiles</code>, and that the
                    887:        <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75      rillig    888:        run <span><strong class="command">sup -v
                    889:        <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
                    890: </div>
                    891: <div class="sect2" lang="en">
                    892: <div class="titlepage"><div><div><h3 class="title">
                    893: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
                    894: <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>
                    895:        installed. To do an initial (full) checkout of pkgsrc, you first
                    896:        have to set some environment variables. For the C-Shell,
                    897:        type:</p>
                    898: <pre class="screen">
                    899:     <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
                    900:     <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
                    901: </pre>
                    902: <p>Or, the same for the bourne shell:</p>
                    903: <pre class="screen">
                    904:     <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
                    905:     <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
                    906:     <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
                    907: </pre>
                    908: <p>Then, you change to the directory where you want to have
                    909:        your copy of pkgsrc. In most cases this is
1.76      rillig    910:        <code class="filename">/usr</code>. In that directory you run the
1.75      rillig    911:        checkout command, which is <span><strong class="command">cvs -q checkout -P
                    912:        pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
                    913:        checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
                    914:        branch. This command will create a directory called
1.76      rillig    915:        <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75      rillig    916:        it.</p>
                    917: </div>
                    918: </div>
                    919: <div class="sect1" lang="en">
                    920: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    921: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
                    922: <p>The preferred way to keep pkgsrc up-to-date is via CVS
                    923:        (which also works if you have first installed it via a tar
                    924:        file). It saves bandwidth and hard disk activity, compared to
                    925:        downloading the tar file again.</p>
                    926: <div class="sect2" lang="en">
                    927: <div class="titlepage"><div><div><h3 class="title">
                    928: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
                    929: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
                    930: <h3 class="title">Warning</h3>
1.77      rillig    931: <p>When updating from a tar file, you first need to
                    932:        completely remove the old pkgsrc directory. Otherwise those
                    933:        files that have been removed from pkgsrc in the mean time will
                    934:        not be removed on your local disk, resulting in inconsistencies.
                    935:        When removing the old files, any changes that you have done to
                    936:        the pkgsrc files will be lost after updating. Therefore updating
                    937:        via CVS is strongly recommended.</p>
1.75      rillig    938: </div>
1.82      rillig    939: <p>Note that by default the distfiles and the binary packages
                    940:        are saved in the pkgsrc tree, so don't forget to rescue them
                    941:        before updating. You can also configure pkgsrc to use other than
                    942:        the default directories by setting the
                    943:        <code class="varname">DISTDIR</code> and <code class="varname">PACKAGES</code>
                    944:        variables. See <a href="#configuring" title="Chapter 5. Configuring pkgsrc">Chapter 5, <i>Configuring pkgsrc</i></a> for the details.</p>
1.75      rillig    945: <p>To update pkgsrc from a tar file, download the tar file as
                    946:        explained above. Then, make sure that you have not made any
                    947:        changes to the files in the pkgsrc directory. Remove the pkgsrc
                    948:        directory and extract the new tar file. Done.</p>
                    949: </div>
                    950: <div class="sect2" lang="en">
                    951: <div class="titlepage"><div><div><h3 class="title">
                    952: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
                    953: <p>To update pkgsrc via CVS, make sure the environment
                    954:        variable <code class="varname">CVS_RSH</code> is set as above. Then,
                    955:        change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77      rillig    956:        -dP</strong></span>.</p>
1.75      rillig    957: <div class="sect3" lang="en">
                    958: <div class="titlepage"><div><div><h4 class="title">
                    959: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
                    960: <p>When updating pkgsrc, the CVS program keeps track of the
                    961:        branch you selected. But if you, for whatever reason, want to
                    962:        switch from the stable branch to the current one, you can do it
                    963:        by adding the option &#8220;<span class="quote">-A</span>&#8221; after the
                    964:        &#8220;<span class="quote">update</span>&#8221; keyword. To switch from the current branch
                    965:        back to the stable branch, add the
                    966:        &#8220;<span class="quote">-rpkgsrc-2006Q1</span>&#8221; option.</p>
                    967: </div>
                    968: <div class="sect3" lang="en">
                    969: <div class="titlepage"><div><div><h4 class="title">
                    970: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
                    971: <p>When you update pkgsrc, the CVS program will only touch
                    972:        those files that are registered in the CVS repository. That
                    973:        means that any packages that you created on your own will stay
                    974:        unmodified. If you change files that are managed by CVS, later
                    975:        updates will try to merge your changes with those that have been
                    976:        done by others. See the CVS manual, chapter
                    977:        &#8220;<span class="quote">update</span>&#8221; for details.</p>
                    978: </div>
                    979: </div>
                    980: </div>
                    981: </div>
                    982: <div class="chapter" lang="en">
                    983: <div class="titlepage"><div><div><h2 class="title">
                    984: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
                    985: <div class="toc">
                    986: <p><b>Table of Contents</b></p>
                    987: <dl>
1.82      rillig    988: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
                    989: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
                    990: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
                    991: <dd><dl>
                    992: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
                    993: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
                    994: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
                    995: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
                    996: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
                    997: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
                    998: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75      rillig    999: </dl></dd>
                   1000: </dl>
                   1001: </div>
                   1002: <div class="sect1" lang="en">
                   1003: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82      rillig   1004: <a name="binarydist"></a>3.1. Binary distribution</h2></div></div></div>
                   1005: <p>
                   1006: We provide a bootstrap kit in both source and binary form for other
                   1007: platforms than NetBSD, consisting of the pkg administration tools and other
                   1008: tools required to use pkgsrc and build packages.
                   1009: </p>
                   1010: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1011: <h3 class="title">Note</h3>
                   1012: <p>
                   1013: Older binary snapshots are available in the
                   1014: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/archive/" target="_top">bootstrap-pkgsrc/archive</a>
                   1015: directory on ftp.NetBSD.org.</p>
                   1016: </div>
                   1017: <div class="table">
                   1018: <a name="binary-kits"></a><p class="title"><b>Table 3.1. Binary kits and available packages</b></p>
1.83    ! wiz      1019: <div class="table-contents"><table summary="Binary kits and available packages" border="1">
1.82      rillig   1020: <colgroup>
                   1021: <col>
                   1022: <col>
                   1023: <col>
                   1024: <col>
                   1025: </colgroup>
                   1026: <thead><tr>
                   1027: <th>Platform</th>
                   1028: <th>Latest snapshot</th>
                   1029: <th>Binary kit</th>
                   1030: <th>Binary packages</th>
                   1031: </tr></thead>
                   1032: <tbody>
                   1033: <tr>
                   1034: <td class="osname">Darwin 5.5/powerpc (Mac OS X 10.1.5)</td>
                   1035: <td class="date">20021209</td>
                   1036: <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>
                   1037: <td class="binary-pkgs-url"> </td>
                   1038: </tr>
                   1039: <tr>
                   1040: <td class="osname">Darwin 6.6/powerpc (Mac OS X 10.2.6)</td>
                   1041: <td class="date">20030623</td>
                   1042: <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>
                   1043: <td class="binary-pkgs-url"> </td>
                   1044: </tr>
                   1045: <tr>
                   1046: <td class="osname">Darwin 7.6/powerpc (Mac OS X 10.3.6)</td>
                   1047: <td class="date">20041219</td>
                   1048: <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>
                   1049: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Darwin-7.6/" target="_top">binary packages</a></td>
                   1050: </tr>
                   1051: <tr>
                   1052: <td class="osname">Darwin 7.8/powerpc (Mac OS X 10.3.8)</td>
                   1053: <td class="date">20050320</td>
                   1054: <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>
                   1055: <td class="binary-pkgs-url"> </td>
                   1056: </tr>
                   1057: <tr>
                   1058: <td class="osname">Darwin 8.1/powerpc (Mac OS X 10.4.1)</td>
                   1059: <td class="date">20050625</td>
                   1060: <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>
                   1061: <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>
                   1062: </tr>
                   1063: <tr>
                   1064: <td class="osname">Debian GNU Linux/i386</td>
                   1065: <td class="date">20031023</td>
                   1066: <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>
                   1067: <td class="binary-pkgs-url"> </td>
                   1068: </tr>
                   1069: <tr>
                   1070: <td class="osname">Fedora Core 2 Linux/i386</td>
                   1071: <td class="date">20050618</td>
                   1072: <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>
                   1073: <td class="binary-pkgs-url"> </td>
                   1074: </tr>
                   1075: <tr>
                   1076: <td class="osname">Fedora Core 4 Linux/i386</td>
                   1077: <td class="date">20060105</td>
                   1078: <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>
                   1079: <td class="binary-pkgs-url"> </td>
                   1080: </tr>
                   1081: <tr>
                   1082: <td class="osname">FreeBSD 3.5/i386</td>
                   1083: <td class="date">20030411</td>
                   1084: <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>
                   1085: <td class="binary-pkgs-url"> </td>
                   1086: </tr>
                   1087: <tr>
                   1088: <td class="osname">FreeBSD 4.7/i386</td>
                   1089: <td class="date">20021211</td>
                   1090: <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>
                   1091: <td class="binary-pkgs-url"> </td>
                   1092: </tr>
                   1093: <tr>
                   1094: <td class="osname">FreeBSD 5.0/i386</td>
                   1095: <td class="date">20030411</td>
                   1096: <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>
                   1097: <td class="binary-pkgs-url"> </td>
                   1098: </tr>
                   1099: <tr>
                   1100: <td class="osname">FreeBSD 5.1/i386</td>
                   1101: <td class="date">20030630</td>
                   1102: <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>
                   1103: <td class="binary-pkgs-url"> </td>
                   1104: </tr>
                   1105: <tr>
                   1106: <td class="osname">FreeBSD 5.2.1/i386</td>
                   1107: <td class="date">20040227</td>
                   1108: <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>
                   1109: <td class="binary-pkgs-url"> </td>
                   1110: </tr>
                   1111: <tr>
                   1112: <td class="osname">FreeBSD 5.3/i386</td>
                   1113: <td class="date">20050119</td>
                   1114: <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>
                   1115: <td class="binary-pkgs-url"> </td>
                   1116: </tr>
                   1117: <tr>
                   1118: <td class="osname">Interix 3.5</td>
                   1119: <td class="date">20051010</td>
                   1120: <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>
                   1121: <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>
                   1122: </tr>
                   1123: <tr>
                   1124: <td class="osname">IRIX 6.5 n32-bit ABI</td>
                   1125: <td class="date">20040911</td>
                   1126: <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>
                   1127: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/n32/" target="_top">binary packages</a></td>
                   1128: </tr>
                   1129: <tr>
                   1130: <td class="osname">IRIX 6.5 64-bit ABI</td>
                   1131: <td class="date">20040912</td>
                   1132: <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>
                   1133: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/64/" target="_top">binary packages</a></td>
                   1134: </tr>
                   1135: <tr>
                   1136: <td class="osname">OpenBSD 3.2/i386</td>
                   1137: <td class="date">20030420</td>
                   1138: <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>
                   1139: <td class="binary-pkgs-url"> </td>
                   1140: </tr>
                   1141: <tr>
                   1142: <td class="osname">OpenBSD 3.3/i386</td>
                   1143: <td class="date">20030503</td>
                   1144: <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>
                   1145: <td class="binary-pkgs-url"> </td>
                   1146: </tr>
                   1147: <tr>
                   1148: <td class="osname">OpenBSD 3.5/i386</td>
                   1149: <td class="date">20040507</td>
                   1150: <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>
                   1151: <td class="binary-pkgs-url"> </td>
                   1152: </tr>
                   1153: <tr>
                   1154: <td class="osname">Slackware Linux 8.1/i386</td>
                   1155: <td class="date">20030417</td>
                   1156: <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>
                   1157: <td class="binary-pkgs-url"> </td>
                   1158: </tr>
                   1159: <tr>
                   1160: <td class="osname">Slackware Linux 9/i386</td>
                   1161: <td class="date">20031023</td>
                   1162: <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>
                   1163: <td class="binary-pkgs-url"> </td>
                   1164: </tr>
                   1165: <tr>
                   1166: <td class="osname">Solaris 8/sparc</td>
                   1167: <td class="date">20050220</td>
                   1168: <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>
                   1169: <td class="binary-pkgs-url"> </td>
                   1170: </tr>
                   1171: <tr>
                   1172: <td class="osname">Solaris 8/i386</td>
                   1173: <td class="date">20050220</td>
                   1174: <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>
                   1175: <td class="binary-pkgs-url"> </td>
                   1176: </tr>
                   1177: <tr>
                   1178: <td class="osname">Solaris 9/sparc</td>
                   1179: <td class="date">20041208</td>
                   1180: <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>
                   1181: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/SunOS-5.9/sparc/" target="_top">binary packages</a></td>
                   1182: </tr>
                   1183: <tr>
                   1184: <td class="osname">Solaris 9/i386</td>
                   1185: <td class="date">20030411</td>
                   1186: <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>
                   1187: <td class="binary-pkgs-url"> </td>
                   1188: </tr>
                   1189: </tbody>
1.83    ! wiz      1190: </table></div>
1.82      rillig   1191: </div>
1.83    ! wiz      1192: <br class="table-break"><p>
1.82      rillig   1193: Simply download the binary kit for your platform, and extract it into
                   1194: <code class="filename">/</code> e.g.
                   1195: </p>
                   1196: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
                   1197: <code class="prompt">#</code> <strong class="userinput"><code>gzip -c -d /tmp/bootstrap-pkgsrc-SunOS-5.9-sparc-20031023.tar.gz \
                   1198:   | tar -xpf -</code></strong></pre>
                   1199: <p>
                   1200: Of course, as with any binary distributions, you should verify the
                   1201: checksum against the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/SUM" target="_top">SUM</a>
                   1202: or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/CKSUM" target="_top">CKSUM</a>
                   1203: file and inspect the contents before extracting it.
                   1204: </p>
                   1205: </div>
                   1206: <div class="sect1" lang="en">
                   1207: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1208: <a name="bootstrapping-pkgsrc"></a>3.2. Bootstrapping pkgsrc</h2></div></div></div>
                   1209: <p>Installing the bootstrap kit from source should be as simple as:</p>
1.75      rillig   1210: <pre class="screen">
                   1211: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
                   1212: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
                   1213: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong></pre>
                   1214: <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
                   1215:       pkgsrc before bootstrapping. The given
                   1216:       <span><strong class="command">bootstrap</strong></span> command will use the defaults of
1.76      rillig   1217:       <code class="filename">/usr/pkg</code> for the
1.75      rillig   1218:       <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1.76      rillig   1219:       and <code class="filename">/var/db/pkg</code> for the package database
1.75      rillig   1220:       directory where pkgsrc will do its internal bookkeeping.
                   1221:       However, these can also be set using command-line
                   1222:       arguments.</p>
                   1223: <p>Binary packages for the pkgsrc tools and an initial set of packages is
                   1224:       available for supported platforms. An up-to-date list of these can be
                   1225:       found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
                   1226:       Note that this only works for privileged builds that install
1.76      rillig   1227:       into <code class="filename">/usr/pkg</code>.</p>
1.75      rillig   1228: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1229: <h3 class="title">Note</h3>
                   1230: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
                   1231:        Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
                   1232:        For examples in this guide, use <span><strong class="command">bmake</strong></span>
                   1233:        instead of &#8220;<span class="quote">make</span>&#8221;.</p>
                   1234: </div>
                   1235: </div>
                   1236: <div class="sect1" lang="en">
                   1237: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82      rillig   1238: <a name="platform-specific-notes"></a>3.3. Platform-specific notes</h2></div></div></div>
1.75      rillig   1239: <p>Here are some platform-specific notes you should be aware of.</p>
                   1240: <div class="sect2" lang="en">
                   1241: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1242: <a name="darwin"></a>3.3.1. Darwin (Mac OS X)</h3></div></div></div>
1.75      rillig   1243: <p>Darwin 5.x and 6.x are supported. There are two methods of using
1.82      rillig   1244:        pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.3.1.1. Using a disk image">disk
                   1245:          image</a>, or a <a href="#platform.osx-ufs" title="3.3.1.2. Using a UFS partition">UFS
1.75      rillig   1246:          partition</a>.</p>
                   1247: <p>Before you start, you will need to download and install the Mac OS X Developer
                   1248:        Tools from Apple's Developer Connection.  See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
                   1249:        for details.  Also, make sure you install X11 for Mac OS X and the X11 SDK
                   1250:        from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
                   1251:        if you intend to build packages that use the X11 Window System.</p>
                   1252: <p>If you already have a UFS partition, or have a spare partition
                   1253:        that you can format as UFS, it is recommended to use that instead of
                   1254:        the disk image. It'll be somewhat faster and will mount automatically
                   1255:        at boot time, where you must manually mount a disk image.</p>
                   1256: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1257: <h3 class="title">Note</h3>
                   1258: <p>You cannot use a HFS+ file system for pkgsrc, because pkgsrc currently
                   1259:          requires the file system to be case-sensitive, and HFS+ is not.</p>
                   1260: </div>
                   1261: <div class="sect3" lang="en">
                   1262: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1263: <a name="platform.osx-image"></a>3.3.1.1. Using a disk image</h4></div></div></div>
1.75      rillig   1264: <p>Create the disk image:</p>
                   1265: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
                   1266: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
                   1267: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage mount ~/Documents/NetBSD</code></strong>
                   1268: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
                   1269: <p>That's it!</p>
                   1270: </div>
                   1271: <div class="sect3" lang="en">
                   1272: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1273: <a name="platform.osx-ufs"></a>3.3.1.2. Using a UFS partition</h4></div></div></div>
1.76      rillig   1274: <p>By default, <code class="filename">/usr</code> will be on your root file
1.75      rillig   1275:          system, normally HFS+. It is possible to use the default
1.76      rillig   1276:          <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
                   1277:          by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1.75      rillig   1278:          file system. Obviously, another symlink is required if you want to
                   1279:          place the package database directory outside the
                   1280:          <span class="emphasis"><em>prefix</em></span>. e.g.</p>
                   1281: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
                   1282: <p>If you created your partitions at the time of installing Mac OS X
                   1283:          and formatted the target partition as UFS, it should automatically
1.76      rillig   1284:          mount on <code class="filename">/Volumes/&lt;volume name&gt;</code> when the
1.75      rillig   1285:          machine boots. If you are (re)formatting a partition as UFS, you need
                   1286:          to ensure that the partition map correctly reflects
                   1287:          &#8220;<span class="quote">Apple_UFS</span>&#8221; and not &#8220;<span class="quote">Apple_HFS</span>&#8221;.</p>
                   1288: <p>The problem is that none of the disk tools will let you touch a
                   1289:          disk that is booted from. You can unmount the partition, but even if
                   1290:          you newfs it, the partition type will be incorrect and the
                   1291:          automounter won't mount it. It can be mounted manually, but it won't
                   1292:          appear in Finder.</p>
                   1293: <p>You'll need to boot off of the OS X Installation (User) CD.  When
                   1294:          the Installation program starts, go up to the menu and select Disk
                   1295:          Utility.  Now, you will be able to select the partition you want
                   1296:          to be UFS, and Format it Apple UFS. Quit the Disk Utility, quit the
                   1297:          installer which will reboot your machine. The new UFS file system
                   1298:          will appear in Finder.</p>
                   1299: <p>Be aware that the permissions on the new file system will be writable
                   1300:          by root only.</p>
                   1301: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
                   1302:          Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
                   1303: </div>
                   1304: </div>
                   1305: <div class="sect2" lang="en">
                   1306: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1307: <a name="freebsd"></a>3.3.2. FreeBSD</h3></div></div></div>
1.75      rillig   1308: <p>
                   1309:        FreeBSD 4.7 and 5.0 have been tested and are supported, other versions
                   1310:        may work.</p>
                   1311: <p>Care should be taken so that the tools that this kit installs do not conflict
                   1312:        with the FreeBSD userland tools. There are several steps:</p>
                   1313: <div class="orderedlist"><ol type="1">
                   1314: <li><p>FreeBSD stores its ports pkg database in
1.76      rillig   1315:            <code class="filename">/var/db/pkg</code>. It is therefore
1.75      rillig   1316:            recommended that you choose a different location (e.g.
1.76      rillig   1317:            <code class="filename">/usr/pkgdb</code>) by
1.75      rillig   1318:            using the --pkgdbdir option to the bootstrap script.</p></li>
                   1319: <li>
                   1320: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
                   1321:            good idea to move them out of the way to avoid confusion, e.g.</p>
                   1322: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
                   1323: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
                   1324: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
                   1325: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
                   1326: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
                   1327: </li>
1.76      rillig   1328: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
                   1329:            <code class="filename">/etc/mk.conf.example</code> file
1.75      rillig   1330:            when you use the bootstrap script.</p></li>
                   1331: </ol></div>
                   1332: </div>
                   1333: <div class="sect2" lang="en">
                   1334: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1335: <a name="interix"></a>3.3.3. Interix</h3></div></div></div>
1.75      rillig   1336: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
                   1337:        providing a Unix-like environment with a tighter kernel integration than
                   1338:        available with Cygwin.  It is part of the Windows Services for Unix
                   1339:        package, available for free for any licensed copy of Windows 2000, XP
                   1340:        (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>
                   1341: <p>Services for Unix 3.5, current as of this writing, has been tested.  3.0
                   1342:        or 3.1 may work, but are not officially supported.  (The main difference
                   1343:        in 3.0/3.1 is lack of pthreads.)</p>
                   1344: <div class="sect3" lang="en">
                   1345: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1346: <a name="platform.interix-sfu-install"></a>3.3.3.1. When installing Interix/SFU</h4></div></div></div>
1.75      rillig   1347: <p>At an absolute minimum, the following packages must be installed from
                   1348:          the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
                   1349: <div class="itemizedlist"><ul type="disc">
                   1350: <li><p>Utilities -&gt; Base Utilities</p></li>
                   1351: <li><p>Interix GNU Components -&gt; (all)</p></li>
                   1352: <li><p>Remote Connectivity</p></li>
                   1353: <li><p>Interix SDK</p></li>
                   1354: </ul></div>
                   1355: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
                   1356:          "UNIX Perl".  That is Perl 5.6 without shared module support, installed to
                   1357:          /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
                   1358:          pkgsrc (or from a binary package).</p>
                   1359: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
                   1360:          not need to be installed, but Remote Connectivity itself should be
                   1361:          installed in order to have a working inetd.</p>
                   1362: <p>During installation you may be asked whether to enable setuid
                   1363:          behavior for Interix programs, and whether to make pathnames default to
                   1364:          case-sensitive.  Setuid should be enabled, and case-sensitivity MUST be
                   1365:          enabled.  (Without case-sensitivity, a large number of packages including
                   1366:          perl will not build.)</p>
                   1367: <p>NOTE:  Newer Windows service packs change the way binary execution
                   1368:          works (via the Data Execution Prevention feature).  In order to use
                   1369:          pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
                   1370:          POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
                   1371:          must be installed.  Hotfixes are available from Microsoft through a
                   1372:          support contract; however, a NetBSD developer has made most Interix
                   1373:          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>
                   1374: </div>
                   1375: <div class="sect3" lang="en">
                   1376: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1377: <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   1378: <p>If SFU is already installed and you wish to alter these settings to work
                   1379:          with pkgsrc, note the following things.</p>
                   1380: <div class="itemizedlist"><ul type="disc">
                   1381: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
                   1382:              Windows Services for UNIX, then click Change.  In the installer, choose
                   1383:              Add or Remove, then uncheck Utilities-&gt;UNIX Perl.</p></li>
                   1384: <li>
                   1385: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
                   1386:              change the following registry key:</p>
                   1387: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
                   1388: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
                   1389: </li>
                   1390: <li>
                   1391: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
                   1392:              following registry key:</p>
                   1393: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
                   1394: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
                   1395: </li>
                   1396: </ul></div>
                   1397: </div>
                   1398: <div class="sect3" lang="en">
                   1399: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1400: <a name="platform.interix-notes"></a>3.3.3.3. Important notes for using pkgsrc</h4></div></div></div>
1.75      rillig   1401: <p>The package manager (either the pkgsrc "su" user, or the user
                   1402:          running "pkg_add") must be a member of the local Administrators
                   1403:          group.  Such a user must also be used to run the bootstrap.  This is
                   1404:          slightly relaxed from the normal pkgsrc requirement of "root".</p>
                   1405: <p>The package manager should use a umask of 002.  "make install" will
                   1406:          automatically complain if this is not the case.  This ensures that
                   1407:          directories written in /var/db/pkg are Administrators-group writeable.</p>
                   1408: <p>The popular Interix binary packages from http://www.interopsystems.com/
                   1409:          use an older version of pkgsrc's pkg_* tools.  Ideally, these should
                   1410:          NOT be used in conjunction with pkgsrc.  If you choose to use them at
                   1411:          the same time as the pkgsrc packages, ensure that you use the proper
                   1412:          pkg_* tools for each type of binary package.</p>
                   1413: <p>The TERM setting used for DOS-type console windows (including those
                   1414:          invoked by the csh and ksh startup shortcuts) is "interix".  Most systems
                   1415:          don't have a termcap/terminfo entry for it, but the following .termcap
                   1416:          entry provides adequate emulation in most cases:</p>
                   1417: <pre class="programlisting">
                   1418:     interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
                   1419: </pre>
                   1420: </div>
                   1421: <div class="sect3" lang="en">
                   1422: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1423: <a name="platform.interix-limits"></a>3.3.3.4. Limitations of the Interix platform</h4></div></div></div>
1.75      rillig   1424: <p>Though Interix suffices as a familiar and flexible substitute
                   1425:          for a full Unix-like platform, it has some drawbacks that should
                   1426:          be noted for those desiring to make the most of Interix.</p>
                   1427: <div class="itemizedlist"><ul type="disc">
                   1428: <li>
                   1429: <p><span class="strong"><strong>X11:</strong></span></p>
                   1430: <p>Interix comes with the standard set of X11R6 client libraries,
                   1431:            and can run X11 based applications, but it does
                   1432:            <span class="emphasis"><em>not</em></span> come with an X server.  Some options are
                   1433:            <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
                   1434:            <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
                   1435:            (available in a trimmed version for Interix from Interop Systems as the
                   1436:            <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
                   1437:            and the free X11 server included with
                   1438:            <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
                   1439: <p>Also, StarNet Communications has graciously provided a free
                   1440:            version of their X-Win32 product that accepts connections only
                   1441:            from localhost:
                   1442:            <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
                   1443:            recommended by the maintainer of Interix pkgsrc support.</p>
                   1444: </li>
                   1445: <li>
                   1446: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
                   1447: <p>Because Interix runs in a completely different NT subsystem from
                   1448:            Win32 applications, it does not currently support various X11
                   1449:            protocol extensions for acceleration (such as MIT-SHM or DGA).
                   1450:            Most interactive applications to a local X server will run
                   1451:            reasonably fast, but full motion video and other graphics
                   1452:            intensive applications may require a faster-than-expected CPU.</p>
                   1453: </li>
                   1454: <li>
                   1455: <p><span class="strong"><strong>Audio:</strong></span></p>
                   1456: <p>Interix has no native support for audio output.  For audio
                   1457:            support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
                   1458:            audio system on Interix.  Unlike on most platforms, the
1.76      rillig   1459:            <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   1460:            <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
                   1461:            server component.  To output audio via an Interix host, the
1.76      rillig   1462:            <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   1463:            must also be installed.</p>
                   1464: </li>
                   1465: <li>
                   1466: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
                   1467: <p>Direct device access is not currently supported in Interix, so it
                   1468:            is not currently possible to access CD/DVD drives, USB devices,
                   1469:            or SCSI devices through non-filesystem means.  Among other things,
                   1470:            this makes it impossible to use Interix directly for CD/DVD
                   1471:            burning.</p>
                   1472: </li>
                   1473: <li>
                   1474: <p><span class="strong"><strong>Tape drives:</strong></span></p>
                   1475: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
                   1476:            drives are also not directly accessible in Interix.  However,
                   1477:            support is in work to make tape drive access possible by using
                   1478:            Cygwin as a bridge (similarly to audio bridged via Cygwin's
                   1479:            esound server).</p>
                   1480: </li>
                   1481: </ul></div>
                   1482: </div>
                   1483: <div class="sect3" lang="en">
                   1484: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1485: <a name="platform.interix-knownissues"></a>3.3.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1.75      rillig   1486: <p>It is not necessary, in general, to have a "root" user on the
                   1487:          Windows system; any member of the local Administrators group will
                   1488:          suffice.  However, some packages currently assume that the user
                   1489:          named "root" is the privileged user.  To accommodate these, you
                   1490:          may create such a user; make sure it is in the local group
                   1491:          Administrators (or your language equivalent).</p>
                   1492: <p>"pkg_add" creates directories of mode 0755, not 0775, in
                   1493:          $PKG_DBDIR.  For the time being, install packages as the local
                   1494:          Administrator (or your language equivalent), or run the following
                   1495:          command after installing a package to work around the issue:</p>
                   1496: <pre class="screen">
                   1497: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong></pre>
                   1498: </div>
                   1499: </div>
                   1500: <div class="sect2" lang="en">
                   1501: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1502: <a name="irix"></a>3.3.4. IRIX</h3></div></div></div>
1.75      rillig   1503: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
                   1504:        compiler (cc/c89).  Please set the <code class="varname">CC</code> environment variable
                   1505:        according to your preference.  If you do not have a license for the MIPSpro
                   1506:        compiler suite, you can download a gcc tardist file from <a href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
                   1507: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
                   1508:        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>,
                   1509:        etc.</p>
                   1510: <p>At this point in time, pkgsrc only supports one ABI at a time.  That is, you can not
                   1511:        switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI.  If
                   1512:        you start out using "abi=n32", that's what all your packages will be built
                   1513:        with.</p>
                   1514: <p>Therefore, please make sure that you have no conflicting
                   1515:        <code class="varname">CFLAGS</code> in your environment or the
1.76      rillig   1516:        <code class="filename">/etc/mk.conf</code>.  Particularly, make sure that you do not
1.75      rillig   1517:        try to link n32 object files with lib64 or vice versa.  Check your
1.76      rillig   1518:        <code class="filename">/etc/compiler.defaults</code>!</p>
1.75      rillig   1519: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
                   1520:        please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
                   1521:        as it appears that IRIX linker occasionally runs into issues when trying to
                   1522:        link over a network-mounted file system.</p>
                   1523: <p>The bootstrapping process should set all the right options for programs such
                   1524:        as imake(1), but you may want to set some options depending on your local
1.76      rillig   1525:        setup.  Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1.75      rillig   1526:        course, your compiler's man pages for details.</p>
                   1527: <p>If you are using SGI's MIPSPro compiler, please set
1.1       grant    1528: 
1.75      rillig   1529: </p>
                   1530: <pre class="programlisting">
                   1531:     PKGSRC_COMPILER=        mipspro
                   1532: </pre>
                   1533: <p>
1.1       grant    1534: 
1.76      rillig   1535:         in <code class="filename">/etc/mk.conf</code>.  Otherwise, pkgsrc will assume you
1.75      rillig   1536:         are using gcc and may end up passing invalid flags to the compiler.  Note that
1.76      rillig   1537:         bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1.75      rillig   1538:         default.</p>
                   1539: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
                   1540:         but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
                   1541:         to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1.76      rillig   1542:         <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1.75      rillig   1543:         '--preserve-path' flag.</p>
                   1544: </div>
                   1545: <div class="sect2" lang="en">
                   1546: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1547: <a name="linux"></a>3.3.5. Linux</h3></div></div></div>
1.75      rillig   1548: <p>
                   1549:         Some versions of Linux (for example Debian GNU/Linux) need either
                   1550:         libtermcap or libcurses (libncurses).  Installing the distributions
                   1551:         libncurses-dev package (or equivalent) should fix the problem.</p>
                   1552: <p>
                   1553:         pkgsrc supports both gcc (GNU Compiler Collection) and icc (Intel C++
                   1554:         Compiler). gcc is the default. icc 8.0 and 8.1 on i386 have been tested.
                   1555:       </p>
                   1556: <p>To bootstrap using icc, assuming the default icc installation
                   1557:         directory:</p>
                   1558: <pre class="programlisting">
                   1559:     env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
                   1560:             ac_cv___attribute__=yes ./bootstrap
                   1561: </pre>
                   1562: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1563: <h3 class="title">Note</h3>
                   1564: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
                   1565: </div>
                   1566: <p>icc supports __attribute__, but the GNU configure test uses a nested
                   1567:         function, which icc does not support. #undef'ing __attribute__ has the
                   1568:         unfortunate side-effect of breaking many of the Linux header files, which
                   1569:         cannot be compiled properly without __attribute__. The test must be
                   1570:         overridden so that __attribute__ is assumed supported by the
                   1571:         compiler.</p>
                   1572: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.76      rillig   1573:         in <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   1574: <pre class="programlisting">
                   1575:     PKGSRC_COMPILER=        icc
                   1576: </pre>
                   1577: <p>The default installation directory for icc is
1.76      rillig   1578:         <code class="filename">/opt/intel_cc_80</code>, which
1.75      rillig   1579:         is also the pkgsrc default. If you have installed it into a different
                   1580:         directory, set <code class="varname">ICCBASE</code> in
1.76      rillig   1581:         <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   1582: <pre class="programlisting">
                   1583:     ICCBASE=                /opt/icc
                   1584: </pre>
                   1585: <p>pkgsrc uses the static linking method of the runtime libraries
                   1586:         provided by icc, so binaries can be run on other systems which do not
                   1587:         have the shared libraries installed.</p>
                   1588: <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>
                   1589:         command run when linking a C++ shared library and records it, throwing
                   1590:         away the -Bstatic and -Bdynamic options interspersed between the libraries.
                   1591:         This means that libtool-linked C++ shared libraries will have a
                   1592:         runtime dependency on the icc libraries until this is fixed in libtool.
                   1593:       </p>
                   1594: </div>
                   1595: <div class="sect2" lang="en">
                   1596: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1597: <a name="openbsd"></a>3.3.6. OpenBSD</h3></div></div></div>
1.75      rillig   1598: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
                   1599: <p>Care should be taken so that the tools that this kit installs do not conflict
                   1600:        with the OpenBSD userland tools. There are several steps:</p>
                   1601: <div class="orderedlist"><ol type="1">
                   1602: <li><p>OpenBSD stores its ports pkg database in
1.76      rillig   1603:            <code class="filename">/var/db/pkg</code>. It is therefore
1.75      rillig   1604:            recommended that you choose a different location (e.g.
1.76      rillig   1605:            <code class="filename">/usr/pkgdb</code>) by
1.75      rillig   1606:            using the --pkgdbdir option to the bootstrap script.</p></li>
                   1607: <li>
                   1608: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
                   1609:            good idea to move them out of the way to avoid confusion, e.g.</p>
                   1610: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
                   1611: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
                   1612: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
                   1613: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
                   1614: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
                   1615: </li>
                   1616: <li>
1.76      rillig   1617: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
                   1618:            <code class="filename">/etc/mk.conf.example</code> file
1.75      rillig   1619:            when you use the bootstrap script. OpenBSD's make program uses
1.76      rillig   1620:            <code class="filename">/etc/mk.conf</code>
1.75      rillig   1621:            as well. You can work around this by enclosing all the pkgsrc-specific parts
                   1622:            of the file with:</p>
                   1623: <pre class="programlisting">
                   1624:     .ifdef BSD_PKG_MK
                   1625:     # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
                   1626:     .else
                   1627:     # OpenBSD stuff
1.1       grant    1628:     .endif
                   1629: </pre>
1.75      rillig   1630: </li>
                   1631: </ol></div>
                   1632: </div>
                   1633: <div class="sect2" lang="en">
                   1634: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1635: <a name="solaris"></a>3.3.7. Solaris</h3></div></div></div>
1.75      rillig   1636: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
                   1637:         You will need a working C compiler. Both gcc 2.95.3 and
                   1638:         Sun WorkShop 5 have been tested.</p>
                   1639: <p>The following packages are required on Solaris 8 for the bootstrap
                   1640:        process and to build packages.</p>
                   1641: <div class="itemizedlist"><ul type="disc">
                   1642: <li><p>SUNWsprot</p></li>
                   1643: <li><p>SUNWarc</p></li>
                   1644: <li><p>SUNWbtool</p></li>
                   1645: <li><p>SUNWtoo</p></li>
                   1646: <li><p>SUNWlibm</p></li>
                   1647: </ul></div>
1.78      rillig   1648: <p>Please note that the use of GNU binutils on Solaris is
                   1649:        <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1.75      rillig   1650: <p>Whichever compiler you use, please ensure the compiler tools and
                   1651:          your $prefix are in your <code class="varname">PATH</code>. This includes
1.76      rillig   1652:          <code class="filename">/usr/ccs/{bin,lib}</code>
                   1653:          and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75      rillig   1654: <div class="sect3" lang="en">
                   1655: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1656: <a name="solaris-gcc-note"></a>3.3.7.1. If you are using gcc</h4></div></div></div>
1.75      rillig   1657: <p>It makes life much simpler if you only use the same gcc consistently
                   1658:          for building all packages.</p>
                   1659: <p>It is recommended that an external gcc be used only for bootstrapping,
                   1660:          then either build gcc from
1.76      rillig   1661:          <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   1662:          package, then remove gcc used during bootstrapping.</p>
                   1663: <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>
                   1664: </div>
                   1665: <div class="sect3" lang="en">
                   1666: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1667: <a name="solaris-sun-workshop-note"></a>3.3.7.2. If you are using Sun WorkShop</h4></div></div></div>
1.75      rillig   1668: <p>You will need at least the following packages installed (from WorkShop
                   1669:          5.0)</p>
                   1670: <div class="itemizedlist"><ul type="disc">
                   1671: <li><p>SPROcc
                   1672:                - Sun WorkShop Compiler C 5.0</p></li>
                   1673: <li><p>SPROcpl
                   1674:                - Sun WorkShop Compiler C++ 5.0</p></li>
                   1675: <li><p>SPROild
                   1676:                - Sun WorkShop Incremental Linker</p></li>
                   1677: <li><p>SPROlang
                   1678:                - Sun WorkShop Compilers common components</p></li>
                   1679: </ul></div>
                   1680: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.76      rillig   1681:          optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
1.75      rillig   1682:          e.g.:</p>
                   1683: <pre class="programlisting">
                   1684:     CC=     cc
                   1685:     CXX=    CC
                   1686:     CPP=    /usr/ccs/lib/cpp
1.1       grant    1687: </pre>
1.75      rillig   1688: </div>
                   1689: <div class="sect3" lang="en">
                   1690: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1691: <a name="solaris-sunpro-64"></a>3.3.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1.75      rillig   1692: <p>Building 64-bit binaries is a little trickier. First, you
                   1693:        need to bootstrap pkgsrc in 64-bit mode. One problem here is
                   1694:        that while building one of the programs in the bootstrap kit
1.76      rillig   1695:        (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75      rillig   1696:        variable is not honored, even if it is set in the environment.
                   1697:        To work around this bug, you can create a simple shell script
1.76      rillig   1698:        called <code class="filename">cc64</code> and put it somewhere in the
1.75      rillig   1699:        <code class="varname">PATH</code>:</p>
                   1700: <pre class="programlisting">
                   1701:     #! /bin/sh
                   1702:     exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
1.1       grant    1703: </pre>
1.75      rillig   1704: <p>Then, pass the definition for <code class="varname">CC</code> in the
                   1705:        environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
                   1706: <pre class="programlisting">
                   1707:     <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
                   1708:     <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
                   1709: </pre>
                   1710: <p>After bootstrapping, there are two alternative ways,
                   1711:        depending on whether you want to find bugs in packages or get
                   1712:        your system ready quickly. If you just want a running system,
1.76      rillig   1713:        add the following lines to your <code class="filename">mk.conf</code>
1.75      rillig   1714:        file:</p>
                   1715: <pre class="programlisting">
                   1716:     CC=                     cc64
                   1717:     CXX=                    CC64
                   1718:     PKGSRC_COMPILER=        sunpro
1.1       grant    1719: </pre>
1.75      rillig   1720: <p>This way, all calls to the compiler will be intercepted by
                   1721:        the above wrapper and therefore get the necessary ABI options
                   1722:        automatically. (Don't forget to create the shell script
1.76      rillig   1723:        <code class="filename">CC64</code>, too.)</p>
1.75      rillig   1724: <p>To find packages that ignore the user-specified
                   1725:        <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76      rillig   1726:        the following lines to your <code class="filename">mk.conf</code>
1.75      rillig   1727:        file:</p>
                   1728: <pre class="programlisting">
                   1729:     CC=                     cc
                   1730:     CXX=                    CC
                   1731:     PKGSRC_COMPILER=        sunpro
                   1732:     CFLAGS=                 -xtarget=ultra -xarch=v9
                   1733:     CXXFLAGS=               -xtarget=ultra -xarch=v9
                   1734:     LDFLAGS=                -xtarget=ultra -xarch=v9
1.1       grant    1735: </pre>
1.75      rillig   1736: <p>Packages that don't use the flags provided in the
                   1737:        configuration file will try to build 32-bit binaries and fail
                   1738:        during linking. Detecting this is useful to prevent bugs on
                   1739:        other platforms where the error would not show up but pass
                   1740:        silently.</p>
                   1741: </div>
                   1742: <div class="sect3" lang="en">
                   1743: <div class="titlepage"><div><div><h4 class="title">
1.82      rillig   1744: <a name="plat.sunos.problems"></a>3.3.7.4. Common problems</h4></div></div></div>
1.75      rillig   1745: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.76      rillig   1746:        <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1.75      rillig   1747:        The workaround is to use another shell for the configure
1.76      rillig   1748:        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
                   1749:        to your <code class="filename">mk.conf</code>:</p>
1.75      rillig   1750: <pre class="programlisting">
                   1751:     CONFIG_SHELL=   ${LOCALBASE}/bin/bash
                   1752:     WRAPPER_SHELL=  ${LOCALBASE}/bin/bash
1.1       grant    1753: </pre>
1.76      rillig   1754: <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   1755: </div>
                   1756: </div>
                   1757: </div>
                   1758: </div>
                   1759: <div class="chapter" lang="en">
                   1760: <div class="titlepage"><div><div><h2 class="title">
                   1761: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
                   1762: <div class="toc">
                   1763: <p><b>Table of Contents</b></p>
                   1764: <dl>
                   1765: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                   1766: <dd><dl>
                   1767: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                   1768: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82      rillig   1769: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
                   1770: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
                   1771: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
                   1772: <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>
                   1773: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
                   1774: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75      rillig   1775: </dl></dd>
                   1776: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                   1777: <dd><dl>
                   1778: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                   1779: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                   1780: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                   1781: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
                   1782: </dl></dd>
                   1783: </dl>
                   1784: </div>
                   1785: <p>Basically, there are two ways of using pkgsrc. The first
                   1786:        is to only install the package tools and to use binary packages
                   1787:        that someone else has prepared. This is the &#8220;<span class="quote">pkg</span>&#8221;
                   1788:        in pkgsrc. The second way is to install the &#8220;<span class="quote">src</span>&#8221;
                   1789:        of pkgsrc, too. Then you are able to build your own packages,
                   1790:        and you can still use binary packages from someone else.</p>
                   1791: <div class="sect1" lang="en">
                   1792: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1793: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
                   1794: <p>To use binary packages, you need some tools to manage
                   1795:        them. On NetBSD, these tools are already installed. On all other
                   1796:        operating systems, you need to install them first. For the
                   1797:        following platforms, prebuilt versions of the package tools
                   1798:        are available and can simply be downloaded and unpacked in the
1.76      rillig   1799:        <code class="filename">/</code> directory:</p>
1.75      rillig   1800: <div class="informaltable">
                   1801: <a name="binary-bootstrap-kits"></a><table border="1">
                   1802: <colgroup>
                   1803: <col>
                   1804: <col>
                   1805: </colgroup>
                   1806: <thead><tr>
                   1807: <th>Platform</th>
                   1808: <th>URL</th>
                   1809: </tr></thead>
                   1810: <tbody>
                   1811: <tr>
                   1812: <td>Solaris 9</td>
1.76      rillig   1813: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75      rillig   1814: </tr>
                   1815: <tr>
                   1816: <td>Solaris 10</td>
1.76      rillig   1817: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75      rillig   1818: </tr>
                   1819: </tbody>
                   1820: </table>
                   1821: </div>
1.82      rillig   1822: <p>These pre-built package tools use
1.76      rillig   1823:        <code class="filename">/usr/pkg</code> for the base directory, and
                   1824:        <code class="filename">/var/db/pkg</code> for the database of installed
1.75      rillig   1825:        packages. If you cannot use these directories for whatever
                   1826:        reasons (maybe because you're not root), you have to build the
1.82      rillig   1827:        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   1828: <div class="sect2" lang="en">
                   1829: <div class="titlepage"><div><div><h3 class="title">
                   1830: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
                   1831: <p>To install binary packages, you first need to know from
                   1832:        where to get them. You can get them on CD-ROMs, DVDs, or via FTP
                   1833:        or HTTP.</p>
1.81      rillig   1834: <p>The binary packages can be found at the following
                   1835:        locations.</p>
1.75      rillig   1836: <div class="informaltable">
                   1837: <a name="binary-packages"></a><table border="1">
                   1838: <colgroup>
                   1839: <col>
                   1840: <col>
                   1841: </colgroup>
                   1842: <thead><tr>
                   1843: <th>Platform</th>
                   1844: <th>URL</th>
                   1845: </tr></thead>
                   1846: <tbody>
                   1847: <tr>
1.81      rillig   1848: <td>NetBSD</td>
                   1849: <td><code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/</code></td>
                   1850: </tr>
                   1851: <tr>
1.75      rillig   1852: <td>Solaris 9</td>
1.76      rillig   1853: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75      rillig   1854: </tr>
                   1855: <tr>
                   1856: <td>Solaris 10</td>
1.76      rillig   1857: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75      rillig   1858: </tr>
                   1859: </tbody>
                   1860: </table>
                   1861: </div>
1.81      rillig   1862: <p>Most of these directories contain binary packages for
                   1863:        multiple platforms. Select the appropriate subdirectories,
1.75      rillig   1864:        according to your machine architecture and operating system,
1.76      rillig   1865:        until you find a directory called <code class="filename">All</code>. This
1.75      rillig   1866:        directory contains all the binary packages. Further, there are
                   1867:        subdirectories for categories that contain symbolic links that
                   1868:        point to the actual binary package in
1.76      rillig   1869:        <code class="filename">../All</code>. This directory layout is used for
1.75      rillig   1870:        all package repositories, no matter if they are accessed via
                   1871:        HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
                   1872: </div>
                   1873: <div class="sect2" lang="en">
                   1874: <div class="titlepage"><div><div><h3 class="title">
                   1875: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
                   1876: <p> If you have the files on a CD-ROM or downloaded them to
                   1877:         your hard disk, you can install them with the following command
                   1878:         (be sure to <span><strong class="command">su</strong></span> to root first):</p>
                   1879: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
                   1880: <p> If you have FTP access and you don't want to download the
                   1881:         packages via FTP prior to installation, you can do this
                   1882:         automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:
                   1883:         </p>
1.82      rillig   1884: <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   1885: <p>Note that any prerequisite packages needed to run the
                   1886:         package in question will be installed, too, assuming they are
                   1887:         present where you install from. </p>
                   1888: <p>To save some typing, you can set the
                   1889:         <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
                   1890:        list of paths (including remote URLs); trailing slashes are not allowed.
                   1891:        </p>
1.76      rillig   1892: <p>Additionally to the <code class="filename">All</code> directory
                   1893:         there exists a <code class="filename">vulnerable</code> directory to
1.75      rillig   1894:         which binary packages with known vulnerabilities are
                   1895:         moved, since removing them could cause missing dependencies. To
1.76      rillig   1896:         use these packages, add the <code class="filename">vulnerable</code>
1.75      rillig   1897:         directory to your <code class="varname">PKG_PATH</code>. However, you should run
1.76      rillig   1898:         <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   1899:        especially after installing new packages, and verify that the
                   1900:        vulnerabilities are acceptable for your configuration. An example
                   1901:         <code class="varname">PKG_PATH</code> would be:
1.76      rillig   1902:       <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   1903:         Please note that semicolon (';') is a shell meta-character, so
                   1904:         you'll probably have to quote it.</p>
                   1905: <p>After you've installed packages, be sure to have
1.76      rillig   1906:         <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1.75      rillig   1907:         <code class="varname">PATH</code> so you can actually start the just
                   1908:         installed program. </p>
                   1909: </div>
                   1910: <div class="sect2" lang="en">
                   1911: <div class="titlepage"><div><div><h3 class="title">
1.82      rillig   1912: <a name="using.pkg_delete"></a>4.1.3. Deinstalling packages</h3></div></div></div>
                   1913: <p>To deinstall a package, it does not matter whether it was
                   1914:        installed from source code or from a binary package. The
                   1915:        <span><strong class="command">pkg_delete</strong></span> command does not know it anyway.
                   1916:        To delete a package, you can just run <span><strong class="command">pkg_delete
                   1917:        <em class="replaceable"><code>package-name</code></em></strong></span>. The package
                   1918:        name can be given with or without version number. Wildcards can
                   1919:        also be used to deinstall a set of packages, for example
                   1920:        <code class="literal">*emacs*</code>. Be sure to include them in quotes,
                   1921:        so that the shell does not expand them before
                   1922:        <code class="literal">pkg_delete</code> sees them.</p>
                   1923: <p>The <code class="option">-r</code> option is very powerful: it
                   1924:        removes all the packages that require the package in question
                   1925:        and then removes the package itself. For example:
                   1926: 
                   1927: </p>
                   1928: <pre class="screen">
                   1929:     <code class="prompt">#</code> <strong class="userinput"><code>pkg_delete -r jpeg</code></strong>
                   1930: </pre>
                   1931: <p>
                   1932: 
                   1933:        will remove jpeg and all the packages that used it; this allows
                   1934:        upgrading the jpeg package.</p>
                   1935: </div>
                   1936: <div class="sect2" lang="en">
                   1937: <div class="titlepage"><div><div><h3 class="title">
                   1938: <a name="using.pkg_info"></a>4.1.4. Getting information about installed packages</h3></div></div></div>
                   1939: <p>The <span><strong class="command">pkg_info</strong></span> shows information about
                   1940:        installed packages or binary package files.</p>
                   1941: </div>
                   1942: <div class="sect2" lang="en">
                   1943: <div class="titlepage"><div><div><h3 class="title">
                   1944: <a name="vulnerabilities"></a>4.1.5. Checking for security vulnerabilities in installed packages</h3></div></div></div>
                   1945: <p>
                   1946: The NetBSD Security-Officer and Packages Groups maintain a list of
                   1947: known security vulnerabilities to packages which are (or have been)
                   1948: included in pkgsrc.  The list is available from the NetBSD
                   1949: FTP site at <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities</a>.
                   1950: </p>
                   1951: <p>
                   1952: 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>, 
                   1953: this list can be downloaded
                   1954: automatically, and a security audit of all packages installed on a system
                   1955: can take place.
                   1956: </p>
                   1957: <p>
                   1958: There are two components to 
                   1959: <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
                   1960: component, &#8220;<span class="quote">download-vulnerability-list</span>&#8221;, is for downloading
                   1961: the list of vulnerabilities from the NetBSD FTP site.  The second
                   1962: component, &#8220;<span class="quote">audit-packages</span>&#8221;, checks to see if any of your
                   1963: installed packages are vulnerable.  If a package is vulnerable, you
                   1964: will see output similar to the following:
                   1965: </p>
                   1966: <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
                   1967: http://www.samba.org/samba/whatsnew/macroexploit.html</pre>
                   1968: <p>
                   1969: 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
                   1970: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
                   1971: file daily, and include a package audit in the daily security script.
                   1972: 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>
                   1973: 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>.
                   1974: </p>
                   1975: </div>
                   1976: <div class="sect2" lang="en">
                   1977: <div class="titlepage"><div><div><h3 class="title">
                   1978: <a name="pkg_versions"></a>4.1.6. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
                   1979: <p>
                   1980: 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 
                   1981: <span><strong class="command">lintpkgsrc</strong></span> with the &#8220;<span class="quote">-i</span>&#8221;
                   1982: argument to check if your packages are up-to-date, e.g.
                   1983: </p>
                   1984: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
                   1985: ...
                   1986: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00</pre>
                   1987: <p>You can then use <span><strong class="command">make update</strong></span> to update the
                   1988: package on your system and rebuild any dependencies.
                   1989: </p>
                   1990: </div>
                   1991: <div class="sect2" lang="en">
                   1992: <div class="titlepage"><div><div><h3 class="title">
                   1993: <a name="using.pkg_admin"></a>4.1.7. Other administrative functions</h3></div></div></div>
                   1994: <p>The <span><strong class="command">pkg_admin</strong></span> executes various
                   1995:        administrative functions on the package system.</p>
                   1996: </div>
                   1997: <div class="sect2" lang="en">
                   1998: <div class="titlepage"><div><div><h3 class="title">
                   1999: <a name="a-word-of-warning"></a>4.1.8. A word of warning</h3></div></div></div>
1.75      rillig   2000: <p>Please pay very careful attention to the warnings
                   2001:         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
                   2002:         inherent dangers of installing binary packages which you did
                   2003:         not create yourself, and the security holes that can be
                   2004:         introduced onto your system by indiscriminate adding of such
                   2005:         files.</p>
                   2006: <p>The same warning of course applies to every package you
                   2007:       install from source when you haven't completely read and
                   2008:       understood the source code of the package, the compiler that
                   2009:       is used to build the package and all the other tools that are
                   2010:       involved.</p>
                   2011: </div>
                   2012: </div>
                   2013: <div class="sect1" lang="en">
                   2014: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2015: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1.82      rillig   2016: <p>
                   2017: After obtaining pkgsrc, the <code class="filename">pkgsrc</code> directory
                   2018: now contains a set of packages, organized into categories. You can browse
                   2019: the online index of packages, or run <span><strong class="command">make readme</strong></span>
                   2020: from the <code class="filename">pkgsrc</code> directory to build local
                   2021: <code class="filename">README.html</code> files for all packages, viewable with any web browser such as
                   2022: <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      2023: <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   2024: <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages is
                   2025: <code class="filename">/usr/pkg</code>. If you wish to change this, you should do
                   2026: so by setting <code class="varname">LOCALBASE</code> in
                   2027: <code class="filename">mk.conf</code>. You should not try to use multiple
                   2028: different <code class="varname">LOCALBASE</code> definitions on the same system
                   2029: (inside a chroot is an exception). </p>
                   2030: <p>The rest of this chapter assumes that the package is already in pkgsrc. If it
1.75      rillig   2031:       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
                   2032:       how to create your own packages.</p>
                   2033: <div class="sect2" lang="en">
                   2034: <div class="titlepage"><div><div><h3 class="title">
                   2035: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1.82      rillig   2036: <p>To build packages from source, you need a working C
                   2037:       compiler. On NetBSD, you need to install the
                   2038:       &#8220;<span class="quote">comp</span>&#8221; and the &#8220;<span class="quote">text</span>&#8221; distribution
                   2039:       sets. If you want to build X11-related packages, the
                   2040:       &#8220;<span class="quote">xbase</span>&#8221; and &#8220;<span class="quote">xcomp</span>&#8221; distribution
                   2041:       sets are required, too.</p>
1.75      rillig   2042: </div>
                   2043: <div class="sect2" lang="en">
                   2044: <div class="titlepage"><div><div><h3 class="title">
                   2045: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
                   2046: <p>The first step for building a package is downloading the
                   2047:       distfiles (i.e. the unmodified source). If they have not yet been
                   2048:       downloaded, pkgsrc will fetch them automatically.</p>
1.82      rillig   2049: <p>
                   2050: If you have all files that you need in the
                   2051: <code class="filename">distfiles</code> directory,
                   2052: you don't need to connect. If the distfiles are on CD-ROM, you can
                   2053: mount the CD-ROM on <code class="filename">/cdrom</code> and add:
                   2054: </p>
                   2055: <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
                   2056: <p>
                   2057: to your <code class="filename">mk.conf</code>.
                   2058: </p>
1.75      rillig   2059: <p>You can overwrite some of the major distribution sites to fit to sites
                   2060:         that are close to your own.  Have a look at
1.76      rillig   2061:         <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find some examples
1.83    ! wiz      2062:         &#8212; in particular, look for the <code class="varname">MASTER_SORT</code>,
1.75      rillig   2063:         <code class="varname">MASTER_SORT_REGEX</code> and
                   2064:         <code class="varname">INET_COUNTRY</code> definitions.  This may save some of your
                   2065:         bandwidth and time.</p>
                   2066: <p>You can change these settings either in your shell's environment, or,
                   2067:         if you want to keep the settings, by editing the
1.76      rillig   2068:         <code class="filename">/etc/mk.conf</code> file,
1.75      rillig   2069:         and adding the definitions there.</p>
1.82      rillig   2070: <p>
                   2071: If a package depends on many other packages (such as
                   2072: <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 
                   2073: alternate between periods of
                   2074: downloading source, and compiling. To ensure you have all the source
                   2075: downloaded initially you can run the command:
                   2076: </p>
                   2077: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
                   2078: <p>
                   2079: which will output and run a set of shell commands to fetch the
                   2080: necessary files into the <code class="filename">distfiles</code> directory.  You can
                   2081: also choose to download the files manually.
                   2082: </p>
1.75      rillig   2083: </div>
                   2084: <div class="sect2" lang="en">
                   2085: <div class="titlepage"><div><div><h3 class="title">
                   2086: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1.82      rillig   2087: <p>
                   2088: Once the software has downloaded, any patches will be applied, then it
                   2089: will be compiled for you. This may take some time depending on your
                   2090: computer, and how many other packages the software depends on and their
                   2091: compile time.
                   2092: </p>
1.75      rillig   2093: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   2094: <h3 class="title">Note</h3>
                   2095: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
                   2096:         use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
                   2097:         &#8220;<span class="quote">make</span>&#8221; in the examples in this guide.</p>
                   2098: </div>
                   2099: <p>For example, type </p>
                   2100: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
                   2101: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong></pre>
                   2102: <p>at the shell prompt to build the various components of the
1.82      rillig   2103:         package.</p>
                   2104: <p>The next stage is to actually install the newly compiled
                   2105:        program onto your system. Do this by entering:
                   2106: 
                   2107: </p>
                   2108: <pre class="screen">
                   2109:     <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
                   2110: </pre>
                   2111: <p>
                   2112: 
                   2113:        while you are still in the directory for whatever package you
                   2114:        are installing.</p>
                   2115: <p>Installing the package on your system may require you to
                   2116:        be root.  However, pkgsrc has a
1.75      rillig   2117:         <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
1.82      rillig   2118:         to only become root for the actual installation step.</p>
                   2119: <p>That's it, the software should now be installed and setup for use.
                   2120: You can now enter:
                   2121: 
                   2122: </p>
                   2123: <pre class="screen">
                   2124:     <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
                   2125: </pre>
                   2126: <p>
                   2127: 
                   2128:        to remove the compiled files in the work directory, as you shouldn't need
                   2129:        them any more. If other packages were also added to your system
                   2130:        (dependencies) to allow your program to compile, you can tidy these up
                   2131:        also with the command:</p>
                   2132: <pre class="screen">
                   2133:     <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
                   2134: </pre>
1.75      rillig   2135: <p>Taking the figlet utility as an example, we can install it on our
                   2136:         system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
                   2137: <p>The program is installed under the default root of the packages tree -
1.76      rillig   2138:         <code class="filename">/usr/pkg</code>. Should this not conform to your tastes,
1.75      rillig   2139:         set the <code class="varname">LOCALBASE</code>
                   2140:         variable in your environment, and it will use that value as the root of
1.76      rillig   2141:         your packages tree. So, to use <code class="filename">/usr/local</code>, set
1.75      rillig   2142:         <code class="varname">LOCALBASE=/usr/local</code> in your environment.  Please note
                   2143:         that you should use a directory which is
                   2144:         dedicated to packages and not shared with other programs (i.e., do not try
                   2145:         and use <code class="varname">LOCALBASE=/usr</code>).  Also, you should not try to
1.76      rillig   2146:         add any of your own files or directories (such as <code class="filename">src/</code>,
                   2147:         <code class="filename">obj/</code>, or <code class="filename">pkgsrc/</code>) below the
1.75      rillig   2148:         <code class="varname">LOCALBASE</code> tree.  This is to prevent possible conflicts
                   2149:         between programs and other files installed by the package system and
                   2150:         whatever else may have been installed there.</p>
1.76      rillig   2151: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to alter some
1.75      rillig   2152:         configuration options at build time.  Have a look at
1.76      rillig   2153:         <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to
1.75      rillig   2154:         get an overview of what will be set there by default.  Environment
                   2155:         variables such as <code class="varname">LOCALBASE</code>
1.76      rillig   2156:         can be set in <code class="filename">/etc/mk.conf</code> to
1.75      rillig   2157:         save having to remember to set them each time you want to use pkgsrc.</p>
                   2158: <p>Occasionally, people want to &#8220;<span class="quote">look under the covers</span>&#8221; to see
                   2159:         what is going on when a package is building or being installed. This may be
                   2160:         for debugging purposes, or out of simple curiosity. A number of utility
                   2161:         values have been added to help with this.</p>
                   2162: <div class="orderedlist"><ol type="1">
                   2163: <li>
                   2164: <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>,
                   2165:             then a huge amount of information will be displayed. For example,</p>
                   2166: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
                   2167: <p>will show all the commands that are invoked, up to and including the
                   2168:             &#8220;<span class="quote">patch</span>&#8221; stage.</p>
                   2169: </li>
                   2170: <li>
                   2171: <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
                   2172:             the <code class="varname">VARNAME</code> definition should be used, in conjunction
                   2173:             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
                   2174:             <code class="varname">LOCALBASE</code>:</p>
                   2175: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
                   2176: /usr/pkg
                   2177: <code class="prompt">%</code>
                   2178:           </pre>
                   2179: </li>
                   2180: </ol></div>
                   2181: <p>If you want to install a binary package that you've either
                   2182:         created yourself (see next section), that you put into pkgsrc/packages manually or
                   2183:         that is located on a remote FTP server, you can use the "bin-install"
                   2184:         target. This target will install a binary package - if available - via
                   2185:         <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>.
                   2186:         The list of remote
                   2187:         FTP sites searched is kept in the variable
                   2188:         <code class="varname">BINPKG_SITES</code>, which defaults to
                   2189:         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
                   2190:         into <code class="varname">BIN_INSTALL_FLAGS</code>.
1.76      rillig   2191:         See <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more details.</p>
1.75      rillig   2192: <p>A final word of warning: If you set up a system that has a non-standard
                   2193:         setting for <code class="varname">LOCALBASE</code>, be sure to set that
                   2194:         before any packages are installed, as you can not use several directories
                   2195:         for the same purpose. Doing so will result in pkgsrc not being able to
                   2196:         properly detect your installed packages, and fail miserably. Note also that
                   2197:         precompiled binary packages are usually built with the default
                   2198:         <code class="varname">LOCALBASE</code> of
1.76      rillig   2199:         <code class="filename">/usr/pkg</code>, and that you should <span class="emphasis"><em>not</em></span>
1.75      rillig   2200:         install any if you use a non-standard <code class="varname">LOCALBASE</code>.</p>
                   2201: </div>
                   2202: <div class="sect2" lang="en">
                   2203: <div class="titlepage"><div><div><h3 class="title">
                   2204: <a name="selecting-the-compiler"></a>4.2.4. Selecting the compiler</h3></div></div></div>
                   2205: <p>By default, pkgsrc will use GCC to build packages.  This may be
                   2206:         overridden by setting the following variables in /etc/mk.conf:
                   2207:         </p>
                   2208: <div class="variablelist"><dl>
                   2209: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
                   2210: <dd>
                   2211: <p> This is a list of values specifying the chain of
                   2212:               compilers to invoke when building packages.  Valid values
                   2213:               are: </p>
                   2214: <div class="itemizedlist"><ul type="disc">
                   2215: <li><p><code class="varname">distcc</code>:
                   2216:                 distributed C/C++ (chainable)</p></li>
                   2217: <li><p><code class="varname">ccache</code>:
                   2218:                 compiler cache (chainable)</p></li>
                   2219: <li><p><code class="varname">gcc</code>:
                   2220:                 GNU C/C++ Compiler</p></li>
                   2221: <li><p><code class="varname">mipspro</code>:
                   2222:                 Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
                   2223: <li><p><code class="varname">mipspro</code>:
                   2224:                 Silicon Graphics, Inc. MIPSpro (o32)</p></li>
                   2225: <li><p><code class="varname">sunpro</code>:
                   2226:                 Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
                   2227: </ul></div>
                   2228: <p> The default is
                   2229:               &#8220;<span class="quote"><code class="varname">gcc</code></span>&#8221;.  You can use
                   2230:               <code class="varname">ccache</code> and/or
                   2231:               <code class="varname">distcc</code> with an appropriate
                   2232:               <code class="varname">PKGSRC_COMPILER</code> setting,
                   2233:               e.g. &#8220;<span class="quote"><code class="varname">ccache gcc</code></span>&#8221;.  This
                   2234:               variable should always be
                   2235:               terminated with a value for a real compiler.  </p>
                   2236: </dd>
                   2237: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
                   2238: <dd><p> This specifies the minimum version of GCC to use
                   2239:               when building packages.  If the system GCC doesn't
                   2240:               satisfy this requirement, then pkgsrc will build and
                   2241:               install one of the GCC packages to use instead. </p></dd>
                   2242: </dl></div>
                   2243: </div>
                   2244: </div>
                   2245: </div>
                   2246: <div class="chapter" lang="en">
                   2247: <div class="titlepage"><div><div><h2 class="title">
                   2248: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
                   2249: <div class="toc">
                   2250: <p><b>Table of Contents</b></p>
                   2251: <dl>
                   2252: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                   2253: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78      rillig   2254: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
                   2255: <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>
                   2256: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
                   2257: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75      rillig   2258: </dl>
                   2259: </div>
                   2260: <div class="sect1" lang="en">
                   2261: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2262: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
                   2263: <p>In this section, you can find some variables that apply to all
1.82      rillig   2264:     pkgsrc packages.  The preferred method of setting these variables is
                   2265:     by setting them in <code class="filename">/etc/mk.conf</code>. A complete
                   2266:     list of the variables that can be configured by the user is
                   2267:     available in <code class="filename">mk/defaults/mk.conf</code>, together with
                   2268:     some comments that describe the variable's intent.</p>
1.75      rillig   2269: <div class="itemizedlist"><ul type="disc">
                   2270: <li><p><code class="varname">LOCALBASE</code>: Where
                   2271:            packages will be installed. The default is
1.76      rillig   2272:            <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75      rillig   2273:            with different <code class="varname">LOCALBASE</code>s!</p></li>
                   2274: <li><p><code class="varname">CROSSBASE</code>: Where
                   2275:            &#8220;<span class="quote">cross</span>&#8221; category packages will be
                   2276:            installed. The default is
1.76      rillig   2277:            <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75      rillig   2278: <li><p><code class="varname">X11BASE</code>: Where
                   2279:            X11 is installed on the system. The default is
1.76      rillig   2280:            <code class="filename">/usr/X11R6</code>.</p></li>
1.75      rillig   2281: <li><p><code class="varname">DISTDIR</code>: Where to store the
                   2282:            downloaded copies of the original source distributions used
                   2283:            for building pkgsrc packages. The default is
1.76      rillig   2284:            <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75      rillig   2285: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
                   2286:            If set, override the packages'
                   2287:            <code class="varname">MASTER_SITES</code> with this value.</p></li>
                   2288: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
                   2289:            Backup location(s) for distribution files and patch files
                   2290:            if not found locally or in
1.76      rillig   2291:            <code class="filename">${MASTER_SITES}</code> or
                   2292:            <code class="filename">${PATCH_SITES}</code> respectively.
1.75      rillig   2293:            The defaults are
1.76      rillig   2294:            <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75      rillig   2295:            and
1.76      rillig   2296:            <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75      rillig   2297: <li><p><code class="varname">BINPKG_SITES</code>:
                   2298:            List of sites carrying binary pkgs.</p></li>
1.82      rillig   2299: <li><p><code class="varname">ACCEPTABLE_LICENSES</code>:
                   2300:            List of acceptable licenses. Whenever you try to build a package
                   2301:            whose license is not in this list, you will get an error message
                   2302:            that includes instructions on how to change this variable.</p></li>
1.75      rillig   2303: </ul></div>
                   2304: </div>
                   2305: <div class="sect1" lang="en">
                   2306: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2307: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
                   2308: <p>XXX
                   2309:       </p>
                   2310: <div class="itemizedlist"><ul type="disc">
                   2311: <li><p><code class="varname">PACKAGES</code>: The top level
                   2312:            directory for the binary packages. The default is
1.76      rillig   2313:            <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75      rillig   2314: <li><p><code class="varname">WRKOBJDIR</code>:
                   2315:            The top level directory where, if defined, the separate
                   2316:            working directories will get created, and symbolically
1.76      rillig   2317:            linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75      rillig   2318:            This is useful for building packages on several
1.76      rillig   2319:            architectures, then <code class="filename">${PKGSRCDIR}</code>
                   2320:            can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75      rillig   2321:            is local to every architecture. (It should be noted that
                   2322:            <code class="varname">PKGSRCDIR</code> should not be set by the user
1.83    ! wiz      2323:            &#8212; it is an internal definition which refers to the
1.75      rillig   2324:            root of the pkgsrc tree. It is possible to have many
                   2325:            pkgsrc tree instances.)</p></li>
                   2326: <li><p><code class="varname">LOCALPATCHES</code>:
                   2327:            Directory for local patches that aren't part of pkgsrc.
1.77      rillig   2328:            See <a href="#components.patches" title="9.3. patches/*">Section 9.3, &#8220;patches/*&#8221;</a> for more
1.75      rillig   2329:            information. <em class="replaceable"><code>rel</code></em> and
                   2330:            <em class="replaceable"><code>arch</code></em> are replaced with OS
                   2331:            release (&#8220;<span class="quote">2.0</span>&#8221;, etc.) and architecture
                   2332:            (&#8220;<span class="quote">mipsel</span>&#8221;, etc.).</p></li>
                   2333: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76      rillig   2334:            the <code class="filename">mk.conf</code> file used by a package's
1.75      rillig   2335:            BSD-style Makefile. If this is not set,
                   2336:            <code class="varname">MAKECONF</code> is set to
1.76      rillig   2337:            <code class="filename">/dev/null</code> to avoid picking up
                   2338:            settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.82      rillig   2339: <li><p><code class="varname">DEPENDS_TARGET</code>:
                   2340:            By default, dependencies are only installed, and no binary
                   2341:            package is created for them. You can set this variable to
                   2342:            <code class="literal">package</code> to automatically create binary
                   2343:            packages after installing dependencies.</p></li>
1.75      rillig   2344: </ul></div>
                   2345: <p>
                   2346:     </p>
                   2347: </div>
                   2348: <div class="sect1" lang="en">
                   2349: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78      rillig   2350: <a name="conf.compiler"></a>5.3. Selecting and configuring the compiler</h2></div></div></div>
                   2351: <div class="sect2" lang="en">
                   2352: <div class="titlepage"><div><div><h3 class="title">
                   2353: <a name="conf.cflags"></a>5.3.1. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
                   2354: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
                   2355:        please make sure to use the <code class="literal">+=</code> operator
                   2356:        instead of the <code class="literal">=</code> operator:</p>
                   2357: <pre class="programlisting">
                   2358:     CFLAGS+=        -your -flags
                   2359: </pre>
                   2360: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
                   2361:        &#8220;<span class="quote">+</span>&#8221;) may lead to problems with packages that need
                   2362:        to add their own flags.  Also, you may want to take a look at
                   2363:        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
                   2364:        you're interested in optimization for the current CPU.</p>
                   2365: </div>
                   2366: </div>
                   2367: <div class="sect1" lang="en">
                   2368: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2369: <a name="developer-advanced-settings"></a>5.4. Developer/advanced settings</h2></div></div></div>
1.75      rillig   2370: <p>XXX
                   2371:       </p>
                   2372: <div class="itemizedlist"><ul type="disc">
                   2373: <li>
                   2374: <p><code class="varname">PKG_DEVELOPER</code>:
                   2375:            Run some sanity checks that package developers want:
                   2376:            </p>
                   2377: <div class="itemizedlist"><ul type="circle">
                   2378: <li><p>make sure patches apply with zero fuzz</p></li>
                   2379: <li><p>run check-shlibs to see that all binaries will
                   2380:                find their shared libs.</p></li>
                   2381: </ul></div>
                   2382: <p>
                   2383:          </p>
                   2384: </li>
                   2385: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>:
                   2386:            The level of debugging output which is displayed whilst
                   2387:            making and installing the package.
                   2388:            The default value for this is 0, which will not display
                   2389:            the commands as they are executed (normal, default, quiet
                   2390:            operation); the value 1 will display all shell commands
                   2391:            before their invocation, and the value 2 will display both
                   2392:            the shell commands before their invocation, and their
                   2393:            actual execution progress with <span><strong class="command">set -x</strong></span>
                   2394:            will be displayed.</p></li>
                   2395: </ul></div>
                   2396: <p>
                   2397:     </p>
                   2398: </div>
                   2399: <div class="sect1" lang="en">
                   2400: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78      rillig   2401: <a name="selecting-build-options"></a>5.5. Selecting Build Options</h2></div></div></div>
1.75      rillig   2402: <p>Some packages have build time options, usually to select between
                   2403:       different dependencies, enable optional support for big dependencies
                   2404:       or enable experimental features.</p>
                   2405: <p>To see which options, if any, a package supports, and which
                   2406:       options are mutually exclusive, run <span><strong class="command">make show-options</strong></span>,
                   2407:       for example:</p>
                   2408: <pre class="programlisting">
                   2409:     The following options are supported by this package:
                   2410:         ssl      Enable SSL support.
                   2411:     Exactly one of the following gecko options is required:
                   2412:         firefox  Use firefox as gecko rendering engine.
                   2413:         mozilla  Use mozilla as gecko rendering engine.
                   2414:     At most one of the following database options may be selected:
                   2415:         mysql    Enable support for MySQL database.
                   2416:         pgsql    Enable support for PostgreSQL database.
1.1       grant    2417: 
1.75      rillig   2418:     These options are enabled by default: firefox
                   2419:     These options are currently enabled: mozilla ssl
1.1       grant    2420: </pre>
1.75      rillig   2421: <p>The following variables can be defined in
1.76      rillig   2422:       <code class="filename">/etc/mk.conf</code> to select which options to enable
1.75      rillig   2423:       for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which can be
                   2424:       used to select or disable options for all packages that support them,
                   2425:       and <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
                   2426:       which can be used to select or disable options specifically for
                   2427:       package <em class="replaceable"><code>pkgbase</code></em>.  Options listed in these
                   2428:       variables are selected, options preceded by &#8220;<span class="quote">-</span>&#8221; are
                   2429:       disabled. A few examples:</p>
                   2430: <pre class="screen">
                   2431: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
                   2432: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   2433: PKG_OPTIONS.kdebase=    debug -sasl
                   2434: PKG_OPTIONS.apache=     suexec </pre>
                   2435: <p>The following settings are consulted in the order given, and the
                   2436:       last setting that selects or disables an option is used:</p>
                   2437: <div class="orderedlist"><ol type="1">
                   2438: <li><p>the default options as suggested by the package
                   2439:          maintainer</p></li>
                   2440: <li><p>the options implied by the settings of legacy
                   2441:          variables (see below)</p></li>
                   2442: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
                   2443: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
                   2444: </ol></div>
                   2445: <p>For groups of mutually exclusive options, the last option
                   2446:       selected is used, all others are automatically disabled.  If an option
                   2447:       of the group is explicitly disabled, the previously selected option,
                   2448:       if any, is used.  It is an error if no option from a required group of
                   2449:       options is selected, and building the package will fail.</p>
                   2450: <p>Before the options framework was introduced, build options were
                   2451:       selected by setting a variable (often named
                   2452:       <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
1.76      rillig   2453:       <code class="filename">/etc/mk.conf</code> for each option.  To ease transition
1.75      rillig   2454:       to the options framework for the user, these legacy variables are
                   2455:       converted to the appropriate options setting
                   2456:       (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
                   2457:       automatically.  A warning is issued to prompt the user to
1.76      rillig   2458:       update <code class="filename">/etc/mk.conf</code> to use the options framework
1.75      rillig   2459:       directly.  Support for the legacy variables will be removed
                   2460:       eventually.</p>
                   2461: </div>
                   2462: </div>
                   2463: <div class="chapter" lang="en">
                   2464: <div class="titlepage"><div><div><h2 class="title">
                   2465: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
                   2466: <div class="toc">
                   2467: <p><b>Table of Contents</b></p>
                   2468: <dl>
                   2469: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                   2470: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                   2471: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                   2472: <dd><dl>
                   2473: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                   2474: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                   2475: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                   2476: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                   2477: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                   2478: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                   2479: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                   2480: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                   2481: </dl></dd>
                   2482: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                   2483: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                   2484: </dl>
                   2485: </div>
                   2486: <div class="sect1" lang="en">
                   2487: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2488: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
                   2489: <p>
                   2490:       Once you have built and installed a package, you can create a
                   2491:       <span class="emphasis"><em>binary package</em></span> which can be installed on
                   2492:       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
                   2493:       the same package on a group of hosts and wasting CPU time. It
                   2494:       also provides a simple means for others to install your package,
                   2495:       should you distribute it.
                   2496:     </p>
                   2497: <p>
                   2498:       To create a binary package, change into the appropriate
                   2499:       directory in pkgsrc, and run <span><strong class="command">make
                   2500:       package</strong></span>:
                   2501:     </p>
                   2502: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
                   2503: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
                   2504: <p>
                   2505:       This will build and install your package (if not already done),
                   2506:       and then build a binary package from what was installed. You can
                   2507:       then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
                   2508:       it. Binary packages are created by default in
1.76      rillig   2509:       <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
1.75      rillig   2510:       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   2511:       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   2512: <p>
1.77      rillig   2513:       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   2514:       such a binary package.</p>
                   2515: </div>
                   2516: <div class="sect1" lang="en">
                   2517: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2518: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.77      rillig   2519: <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   2520: </div>
                   2521: <div class="sect1" lang="en">
                   2522: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2523: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
                   2524: <p>If you want to get a full set of precompiled binary
                   2525:       packages, this section describes how to get them. Beware that
                   2526:       the bulk build will remove all currently installed packages from
                   2527:       your system!</p>
                   2528: <p>Having an FTP server configured either on the
                   2529:       machine doing the bulk builds or on a nearby NFS server can help
                   2530:       to make the packages available to other machines that can then
                   2531:       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
                   2532:       more information. If you use a remote NFS server's storage, be
                   2533:       sure to not actually compile on NFS storage, as this slows
                   2534:       things down a lot.</p>
                   2535: <div class="sect2" lang="en">
                   2536: <div class="titlepage"><div><div><h3 class="title">
                   2537: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
                   2538: <div class="sect3" lang="en">
                   2539: <div class="titlepage"><div><div><h4 class="title">
1.76      rillig   2540: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
                   2541: <p>The <code class="filename">build.conf</code> file is the main
1.75      rillig   2542:         configuration file for bulk builds. You can configure how your
                   2543:         copy of pkgsrc is kept up to date, how the distfiles are
                   2544:         downloaded, how the packages are built and how the report is
                   2545:         generated. You can find an annotated example file in
1.76      rillig   2546:         <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
                   2547:         it, copy <code class="filename">build.conf-example</code> to
                   2548:         <code class="filename">build.conf</code> and edit it, following the
1.75      rillig   2549:         comments in that file.</p>
                   2550: </div>
                   2551: <div class="sect3" lang="en">
                   2552: <div class="titlepage"><div><div><h4 class="title">
                   2553: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
                   2554: <p>You may want to set variables in
1.76      rillig   2555:          <code class="filename">/etc/mk.conf</code>.
                   2556:          Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
1.75      rillig   2557:          details of the default settings. You will want to ensure that
                   2558:          <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
                   2559:          As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
                   2560:          accepts <span class="emphasis"><em>all</em></span> licenses.</p>
                   2561: <pre class="programlisting">
                   2562:     PACKAGES?=      ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
                   2563:     WRKOBJDIR?=     /usr/tmp/pkgsrc   # build here instead of in pkgsrc
                   2564:     BSDSRCDIR=      /usr/src
                   2565:     BSDXSRCDIR=     /usr/xsrc         # for x11/xservers
                   2566:     OBJHOSTNAME?=   yes               # use work.`hostname`
                   2567:     FAILOVER_FETCH= yes               # insist on the correct checksum
                   2568:     PKG_DEVELOPER?= yes
                   2569:     _ACCEPTABLE=    yes
1.1       grant    2570: </pre>
1.75      rillig   2571: <p>Some options that are especially useful for bulk builds
                   2572:        can be found at the top lines of the file
1.76      rillig   2573:        <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75      rillig   2574:        options of these are briefly described here.</p>
                   2575: <div class="itemizedlist"><ul type="disc">
                   2576: <li><p>If you are on a slow machine, you may want to
                   2577:        set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
                   2578:        &#8220;<span class="quote">no</span>&#8221;.</p></li>
                   2579: <li><p>If you are doing bulk builds from a read-only
                   2580:        copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
                   2581:        to the directory where all log files are created. Otherwise the
                   2582:        log files are created in the pkgsrc directory.</p></li>
                   2583: <li><p>Another important variable is
                   2584:        <code class="varname">BULK_PREREQ</code>, which is a list of packages that
                   2585:        should be always available while building other
                   2586:        packages.</p></li>
                   2587: </ul></div>
                   2588: <p>Some other options are scattered in the pkgsrc
                   2589:        infrastructure:</p>
                   2590: <div class="itemizedlist"><ul type="disc">
                   2591: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
                   2592:        should be set to <code class="literal">yes</code>. The purpose of the bulk
                   2593:        builds is creating binary packages, no matter if they are
                   2594:        vulnerable or not. When uploading the packages to a public
                   2595:        server, the vulnerable packages will be put into a directory of
                   2596:        their own. Leaving this variable unset would prevent the bulk
                   2597:        build system from even trying to build them, so possible
                   2598:        building errors would not show up.</p></li>
                   2599: <li><p><code class="varname">CHECK_FILES</code>
1.76      rillig   2600:        (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75      rillig   2601:        &#8220;<span class="quote">yes</span>&#8221; to check that the installed set of files
1.76      rillig   2602:        matches the <code class="filename">PLIST</code>.</p></li>
1.75      rillig   2603: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.76      rillig   2604:        (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75      rillig   2605:        &#8220;<span class="quote">yes</span>&#8221; to check that the installed
                   2606:        &#8220;<span class="quote">#!</span>&#8221;-scripts will find their
                   2607:        interpreter.</p></li>
                   2608: </ul></div>
                   2609: </div>
                   2610: <div class="sect3" lang="en">
                   2611: <div class="titlepage"><div><div><h4 class="title">
1.76      rillig   2612: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75      rillig   2613: <p>It is possible to configure the bulk build to perform
                   2614:          certain site-specific tasks at the end of the pre-build
                   2615:          stage.  If the file
1.76      rillig   2616:          <code class="filename">pre-build.local</code> exists in
                   2617:          <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
1.75      rillig   2618:          (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
                   2619:          stage.  An example use of
1.76      rillig   2620:          <code class="filename">pre-build.local</code> is to have the line:</p>
1.75      rillig   2621: <pre class="screen">echo "I do not have enough disk space to build this pig." \
                   2622:     &gt; misc/openoffice/$BROKENF</pre>
                   2623: <p>to prevent the system from trying to build a particular package
                   2624:          which requires nearly 3 GB of disk space.</p>
                   2625: </div>
                   2626: </div>
                   2627: <div class="sect2" lang="en">
                   2628: <div class="titlepage"><div><div><h3 class="title">
                   2629: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76      rillig   2630: <p>As <code class="filename">/usr/pkg</code> will be completely
1.75      rillig   2631:        deleted at the start of bulk builds, make sure your login
                   2632:        shell is placed somewhere else. Either drop it into
1.76      rillig   2633:        <code class="filename">/usr/local/bin</code> (and adjust your login
1.75      rillig   2634:        shell in the passwd file), or (re-)install it via
1.76      rillig   2635:        <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   2636:        you can login after a reboot (remember that your current
                   2637:        process won't die if the package is removed, you just can't
                   2638:        start any new instances of the shell any more).  Also, if you
                   2639:        use NetBSD earlier than 1.5, or you still want to use the pkgsrc
                   2640:        version of ssh for some reason, be sure to install ssh before
1.76      rillig   2641:        starting it from <code class="filename">rc.local</code>:</p>
1.75      rillig   2642: <pre class="programlisting">
                   2643:     ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
                   2644:     if [ -f /usr/pkg/etc/rc.d/sshd ]; then
                   2645:         /usr/pkg/etc/rc.d/sshd
                   2646:     fi
1.1       grant    2647: </pre>
1.75      rillig   2648: <p>Not doing so will result in you being not able to log in
                   2649:        via ssh after the bulk build is finished or if the machine
                   2650:        gets rebooted or crashes. You have been warned! :)</p>
                   2651: </div>
                   2652: <div class="sect2" lang="en">
                   2653: <div class="titlepage"><div><div><h3 class="title">
                   2654: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
                   2655: <p>Make sure you don't need any of the packages still
                   2656:        installed.
                   2657:       </p>
                   2658: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
                   2659: <h3 class="title">Warning</h3>
                   2660: <p>During the bulk build, <span class="emphasis"><em>all packages will be
                   2661:            removed!</em></span></p>
                   2662: </div>
                   2663: <p>Be sure to remove all other things that might
                   2664:        interfere with builds, like some libs installed in
1.76      rillig   2665:        <code class="filename">/usr/local</code>, etc. then become root and type:</p>
1.75      rillig   2666: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   2667: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong></pre>
                   2668: <p>If for some reason your last build didn't complete (power
                   2669:        failure, system panic, ...), you can continue it by
                   2670:        running:</p>
                   2671: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
                   2672: <p>
                   2673:         At the end of the bulk build, you will get a summary via mail,
                   2674:        and find build logs in the directory specified by
1.76      rillig   2675:        <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
1.75      rillig   2676:        file.
                   2677:       </p>
                   2678: </div>
                   2679: <div class="sect2" lang="en">
                   2680: <div class="titlepage"><div><div><h3 class="title">
                   2681: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
                   2682: <p>The bulk builds consist of three steps:</p>
                   2683: <div class="variablelist"><dl>
                   2684: <dt><span class="term">1. pre-build</span></dt>
                   2685: <dd><p>
                   2686:              The script updates your pkgsrc tree via (anon)cvs, then
                   2687:              cleans out any broken distfiles, and removes all
                   2688:              packages installed.</p></dd>
                   2689: <dt><span class="term">2. the bulk build</span></dt>
                   2690: <dd><p>
                   2691:              This is basically &#8220;<span class="quote">make bulk-package</span>&#8221; with
                   2692:              an optimised order in which packages will be
                   2693:              built. Packages that don't require other packages will
                   2694:              be built first, and packages with many dependencies will
                   2695:              be built later.
                   2696:            </p></dd>
                   2697: <dt><span class="term">3. post-build</span></dt>
                   2698: <dd><p>
                   2699:              Generates a report that's placed in the directory
1.76      rillig   2700:              specified in the <code class="filename">build.conf</code> file
                   2701:              named <code class="filename">broken.html</code>, a short version
1.75      rillig   2702:              of that report will also be mailed to the build's
                   2703:              admin.</p></dd>
                   2704: </dl></div>
                   2705: <p>
                   2706:         During the build, a list of broken packages will be compiled
1.76      rillig   2707:         in <code class="filename">/usr/pkgsrc/.broken</code> (or
                   2708:         <code class="filename">.../.broken.${MACHINE}</code> if
1.75      rillig   2709:         <code class="varname">OBJMACHINE</code> is set),       individual build logs
                   2710:         of broken builds can be found in the package's
                   2711:         directory. These files are used by the bulk-targets to mark
                   2712:         broken builds  to not waste time trying to rebuild them, and
                   2713:         they can be used to debug      these broken package builds
                   2714:         later.
                   2715:       </p>
                   2716: </div>
                   2717: <div class="sect2" lang="en">
                   2718: <div class="titlepage"><div><div><h3 class="title">
                   2719: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
                   2720: <p>Currently, roughly the following requirements are valid for
                   2721:        NetBSD 2.0/i386:</p>
                   2722: <div class="itemizedlist"><ul type="disc">
                   2723: <li><p>
                   2724:            10 GB - distfiles (NFS ok)
                   2725:          </p></li>
                   2726: <li><p>
                   2727:            8 GB - full set of all binaries (NFS ok)
                   2728:          </p></li>
                   2729: <li><p>
                   2730:            5 GB - temp space for compiling (local disk recommended)
                   2731:          </p></li>
                   2732: </ul></div>
                   2733: <p>
                   2734:         Note that all pkgs will be de-installed as soon as they are
                   2735:         turned into a  binary package, and that sources are removed,
                   2736:         so there is no excessively huge        demand to disk
                   2737:         space. Afterwards, if the package is needed again, it will
                   2738:         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
                   2739:         there are no cycles wasted by recompiling.
                   2740:       </p>
                   2741: </div>
                   2742: <div class="sect2" lang="en">
                   2743: <div class="titlepage"><div><div><h3 class="title">
                   2744: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
                   2745: <p>
                   2746:         If you don't want all the packages nuked from a machine
                   2747:         (rendering it useless for anything but pkg compiling), there
                   2748:         is the possibility of doing the package bulk build inside a
                   2749:         chroot environment.
                   2750:       </p>
                   2751: <p>
                   2752:         The first step is to set up a chroot sandbox,
1.76      rillig   2753:        e.g. <code class="filename">/usr/sandbox</code>.  This can be done by
1.75      rillig   2754:        using null mounts, or manually.
                   2755:       </p>
                   2756: <p>
                   2757:         There is a shell script called
1.76      rillig   2758:         <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
1.75      rillig   2759:         up the sandbox environment using null mounts. It will also
1.76      rillig   2760:         create a script called <code class="filename">sandbox</code> in the
1.75      rillig   2761:         root of the sandbox environment, which will allow the null
                   2762:         mounts to be activated using the <span><strong class="command">sandbox
                   2763:         mount</strong></span> command and deactivated using the
                   2764:         <span><strong class="command">sandbox umount</strong></span> command.
                   2765:       </p>
                   2766: <p>
                   2767:         To set up a sandbox environment by hand, after extracting all
                   2768:         the sets from a NetBSD installation or doing a <span><strong class="command">make
                   2769:         distribution DESTDIR=/usr/sandbox</strong></span> in
1.76      rillig   2770:         <code class="filename">/usr/src/etc</code>, be sure the following items
1.75      rillig   2771:         are present and properly configured:
                   2772:       </p>
                   2773: <div class="procedure"><ol type="1">
                   2774: <li>
                   2775: <p>Kernel</p>
                   2776: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
                   2777: </li>
                   2778: <li>
1.76      rillig   2779: <p><code class="filename">/dev/*</code></p>
1.75      rillig   2780: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
                   2781: </li>
                   2782: <li>
1.76      rillig   2783: <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   2784: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
                   2785: </li>
                   2786: <li>
                   2787: <p>Working(!) mail config (hostname, sendmail.cf):</p>
                   2788: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
                   2789: </li>
                   2790: <li>
1.76      rillig   2791: <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   2792: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
                   2793: </li>
                   2794: <li>
1.76      rillig   2795: <p><code class="filename">/usr/src</code> (system sources,
1.83    ! wiz      2796:          e. g. for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/sysutils/aperture/README.html" target="_top"><code class="filename">sysutils/aperture</code></a>):</p>
1.75      rillig   2797: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
                   2798: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
                   2799: </li>
                   2800: <li>
1.76      rillig   2801: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75      rillig   2802: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
                   2803: </li>
                   2804: <li>
1.76      rillig   2805: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75      rillig   2806: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
                   2807: </li>
                   2808: <li>
                   2809: <p>Checkout pkgsrc via cvs into
1.76      rillig   2810:            <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
1.75      rillig   2811: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
                   2812: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong></pre>
                   2813: <p>Do not mount/link this to the copy of your pkgsrc tree
                   2814:            you do development in, as this will likely cause problems!
                   2815:            </p>
                   2816: </li>
                   2817: <li><p>Make
1.76      rillig   2818:            <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
                   2819:            <code class="filename">.../distfiles</code> point somewhere
1.75      rillig   2820:            appropriate. NFS- and/or nullfs-mounts may come in handy!
                   2821:            </p></li>
1.76      rillig   2822: <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>
                   2823: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75      rillig   2824: </ol></div>
                   2825: <p>When the chroot sandbox is set up, you can start
                   2826:        the build with the following steps:</p>
                   2827: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
                   2828: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong></pre>
                   2829: <p>
                   2830:         This will just jump inside the sandbox and start building.  At
                   2831:         the end of the build, mail will be sent with the results of
                   2832:         the build. Created binary pkgs will be in
1.76      rillig   2833:         <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
1.75      rillig   2834:         (wherever that points/mounts to/from).</p>
                   2835: </div>
                   2836: <div class="sect2" lang="en">
                   2837: <div class="titlepage"><div><div><h3 class="title">
                   2838: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
                   2839: <p> In addition to building a complete set of all packages in
1.76      rillig   2840:         pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
1.75      rillig   2841:         may be used to build a subset of the packages contained in
                   2842:         pkgsrc.  By setting <code class="varname">SPECIFIC_PKGS</code>
1.76      rillig   2843:         in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75      rillig   2844: <div class="itemizedlist"><ul type="disc">
                   2845: <li><p>SITE_SPECIFIC_PKGS</p></li>
                   2846: <li><p>HOST_SPECIFIC_PKGS</p></li>
                   2847: <li><p>GROUP_SPECIFIC_PKGS</p></li>
                   2848: <li><p>USER_SPECIFIC_PKGS</p></li>
                   2849: </ul></div>
                   2850: <p> will define the set of packages which should be built.
                   2851:         The bulk build code will also include any packages which are
                   2852:         needed as dependencies for the explicitly listed packages.
                   2853:        </p>
                   2854: <p> One use of this is to do a bulk build with
                   2855:         <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
                   2856:         periodically to have a complete set of the binary packages
                   2857:         needed for your site available without the overhead of
                   2858:         building extra packages that are not needed.  </p>
                   2859: </div>
                   2860: <div class="sect2" lang="en">
                   2861: <div class="titlepage"><div><div><h3 class="title">
                   2862: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
                   2863: <p>
                   2864:         This section describes how pkgsrc developers can upload binary
                   2865:         pkgs built by bulk builds to ftp.NetBSD.org.
                   2866:       </p>
                   2867: <p>
                   2868:        If you would like to automatically create checksum files for the
                   2869:        binary packages you intend to upload, remember to set
                   2870:        <code class="varname">MKSUMS=yes</code> in your
1.76      rillig   2871:        <code class="filename">mk/bulk/build.conf</code>.
1.75      rillig   2872:       </p>
                   2873: <p>
                   2874:        If you would like to PGP sign the checksum files (highly
                   2875:        recommended!), remember to set
                   2876:        <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
1.76      rillig   2877:        <code class="filename">mk/bulk/build.conf</code>.  This will prompt you for
1.75      rillig   2878:        your GPG password to sign the files before uploading everything.
                   2879:       </p>
                   2880: <p>
                   2881:         Then, make sure that you have <code class="varname">RSYNC_DST</code>
1.76      rillig   2882:         set properly in your <code class="filename">mk/bulk/build.conf</code>
1.75      rillig   2883:         file, i.e. adjust it to something like one of the following:
                   2884:       </p>
                   2885: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
                   2886: <p>Please use appropriate values for "pkgsrc-200xQy",
                   2887:         "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
                   2888:        is different from your local login, write your login directly
                   2889:        into the variable, e.g. my local account is "feyrer", but for my
                   2890:        login "hubertf", I use:</p>
                   2891: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
                   2892: <p>
1.76      rillig   2893:         A separate <code class="filename">upload</code> directory is used
1.75      rillig   2894:         here to allow "closing" the directory during upload. To do
                   2895:         so, run the following command on ftp.NetBSD.org next:
                   2896:       </p>
                   2897: <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>
                   2898: <p>
1.76      rillig   2899:         Please note that <code class="filename">/pub/NetBSD/packages</code> is
1.75      rillig   2900:         only appropriate for packages for the NetBSD operating
                   2901:         system. Binary packages for other operating systems should go
1.76      rillig   2902:         into <code class="filename">/pub/pkgsrc</code>.
1.75      rillig   2903:       </p>
                   2904: <p>
                   2905:         Before uploading the binary pkgs, ssh authentication needs to
                   2906:         be set up. This example shows how to set up temporary keys
                   2907:         for the root account <span class="emphasis"><em>inside the sandbox</em></span>
                   2908:         (assuming that no keys should be present there usually):
                   2909:       </p>
                   2910: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
                   2911: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
                   2912: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
                   2913: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong> </pre>
                   2914: <p>
1.76      rillig   2915:         Now take the output of <code class="filename">id-dsa.pub</code> and
                   2916:         append it to your <code class="filename">~/.ssh/authorized_keys</code>
1.75      rillig   2917:         file on ftp.NetBSD.org. You can remove the key after the
                   2918:         upload is done!
                   2919:       </p>
                   2920: <p>
                   2921:         Next, test if your ssh connection really works:
                   2922:       </p>
                   2923: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
                   2924: <p>
                   2925:         Use "-l yourNetBSDlogin" here as appropriate!
                   2926:       </p>
                   2927: <p>
                   2928:         Now after all this works, you can exit the sandbox and start
                   2929:         the upload:
                   2930:       </p>
                   2931: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
                   2932: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
                   2933: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong> </pre>
                   2934: <p>
                   2935:         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
                   2936:         <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
                   2937:         upload. The upload script will take care of not uploading
                   2938:         restricted packages and putting vulnerable packages into the
1.76      rillig   2939:         <code class="filename">vulnerable</code> subdirectory.
1.75      rillig   2940:       </p>
                   2941: <p>
                   2942:         After the upload has ended, first thing is to revoke ssh access:
                   2943:       </p>
                   2944: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
                   2945: Gdd:x! </pre>
                   2946: <p>
                   2947:         Use whatever is needed to remove the key you've entered
                   2948:         before! Last, move the uploaded packages out of the
1.76      rillig   2949:         <code class="filename">upload</code> directory to have them accessible
1.75      rillig   2950:         to everyone:
                   2951:       </p>
                   2952: <pre class="screen">nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
                   2953: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
                   2954: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
                   2955: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong> </pre>
                   2956: </div>
                   2957: </div>
                   2958: <div class="sect1" lang="en">
                   2959: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2960: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
                   2961: <p>
                   2962:       After your pkgsrc bulk-build has completed, you may wish to
                   2963:       create a CD-ROM set of the resulting binary packages to assist
                   2964:       in installing packages on other machines.  The
1.76      rillig   2965:       <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   2966:       a simple tool for creating the ISO 9660 images.
                   2967:       <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
                   2968:       way that keeps all the dependencies for a given package on the same
                   2969:       CD as that package.
                   2970:     </p>
                   2971: <div class="sect2" lang="en">
                   2972: <div class="titlepage"><div><div><h3 class="title">
                   2973: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
                   2974: <p>
                   2975:         Complete documentation for cdpack is found in the cdpack(1)
                   2976:         man page. The following short example assumes that the binary
                   2977:         packages are left in
1.76      rillig   2978:         <code class="filename">/usr/pkgsrc/packages/All</code> and that
                   2979:         sufficient disk space exists in <code class="filename">/u2</code> to
1.75      rillig   2980:         hold the ISO 9660 images.</p>
                   2981: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
                   2982: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
                   2983: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
                   2984: <p>
                   2985:         If you wish to include a common set of files
1.76      rillig   2986:        (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
1.75      rillig   2987:        etc.) on each CD in the collection, then you need to create a
                   2988:        directory which contains these files. e.g.
                   2989:       </p>
                   2990: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
                   2991: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" &gt; /tmp/common/README</code></strong>
                   2992: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" &gt; /tmp/common/COPYING</code></strong>
                   2993: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
                   2994: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" &gt; /tmp/common/bin/myscript</code></strong>
                   2995: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" &gt;&gt; /tmp/common/bin/myscript</code></strong>
                   2996: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong></pre>
                   2997: <p>Now create the images:</p>
                   2998: <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   2999: <p>Each image will contain <code class="filename">README</code>,
                   3000:        <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
1.75      rillig   3001:        in their root directories.</p>
                   3002: </div>
                   3003: </div>
                   3004: </div>
                   3005: <div class="chapter" lang="en">
                   3006: <div class="titlepage"><div><div><h2 class="title">
                   3007: <a name="faq"></a>Chapter 7. Frequently Asked Questions</h2></div></div></div>
                   3008: <div class="toc">
                   3009: <p><b>Table of Contents</b></p>
                   3010: <dl>
                   3011: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                   3012: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
                   3013: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
                   3014: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
                   3015: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
                   3016: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                   3017: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                   3018: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
                   3019: <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>
                   3020: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
                   3021: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does &#8220;<span class="quote">Don't know how to make
                   3022: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
                   3023: <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>
                   3024: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
                   3025: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
                   3026: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
                   3027: <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   3028: <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   3029: </dl>
                   3030: </div>
                   3031: <p>This section contains hints, tips &amp; tricks on special things in
                   3032: pkgsrc that we didn't find a better place for in the previous chapters, and
                   3033: it contains items for both pkgsrc users and developers.</p>
                   3034: <div class="sect1" lang="en">
                   3035: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3036: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
                   3037: <p>The following mailing lists may be of interest to pkgsrc users:</p>
                   3038: <div class="itemizedlist"><ul type="disc">
1.78      rillig   3039: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
                   3040:          This is a general purpose list for most issues regarding
                   3041:          pkgsrc, regardless of platform, e.g. soliciting user help
                   3042:          for pkgsrc configuration, unexpected build failures, using
                   3043:          particular packages, upgrading pkgsrc installations,
                   3044:          questions regarding the pkgsrc release branches, etc.  General announcements or
                   3045:          proposals for changes that impact the pkgsrc user community,
                   3046:          e.g. major infrastructure changes, new features, package
                   3047:          removals, etc., may also be posted.</p></li>
1.75      rillig   3048: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
                   3049:          A list where the results of pkgsrc bulk builds are sent and
                   3050:          discussed.</p></li>
                   3051: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
                   3052:          This list is for those who are interested in getting a
                   3053:          commit message for every change committed to pkgsrc. It is
                   3054:          also available in digest form, meaning one daily message
                   3055:          containing all commit messages for changes to the package
                   3056:          source tree in that 24 hour period.</p></li>
                   3057: </ul></div>
                   3058: <p>To subscribe, do:</p>
                   3059: <pre class="programlisting">
                   3060:     <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
                   3061: </pre>
                   3062: <p>Archives for all these mailing lists are available from
                   3063: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
                   3064: </div>
                   3065: <div class="sect1" lang="en">
                   3066: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3067: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
                   3068: <p>Pkgviews is tightly integrated with buildlink.  You can find a
                   3069: pkgviews User's guide in
1.76      rillig   3070: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75      rillig   3071: </div>
                   3072: <div class="sect1" lang="en">
                   3073: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3074: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.80      rillig   3075: <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
1.75      rillig   3076: a number of useful utilities for both users and developers of pkgsrc.  This
                   3077: section attempts only to make the reader aware of the utilities and when
                   3078: they might be useful, and not to duplicate the documentation that comes
                   3079: with each package.</p>
                   3080: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76      rillig   3081: <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   3082:       Symlinks for use by buildlink.</p></li></ul></div>
                   3083: <p>OS tool augmentation (automatically installed when needed):</p>
                   3084: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3085: <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   3086:       Calculates various kinds of checksums (including SHA1).</p></li>
1.76      rillig   3087: <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   3088:       Compatibility library for pkgsrc tools.</p></li>
1.76      rillig   3089: <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   3090:       non-BSD systems due to lack of native mtree.
                   3091:   </p></li>
1.76      rillig   3092: <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   3093:       Up-to-date replacement for
1.76      rillig   3094:       <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75      rillig   3095:       systems where pkg_install is not present.</p></li>
                   3096: </ul></div>
                   3097: <p>Utilities used by pkgsrc (not automatically installed):</p>
                   3098: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3099: <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   3100:       Create a binary package from an
                   3101:       already-installed package.  Used by <span><strong class="command">make replace</strong></span> to
                   3102:       save the old package.</p></li>
1.76      rillig   3103: <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   3104:       Adds extra functionality to pkgsrc, allowing it to fetch distfiles
                   3105:       from multiple locations. It currently supports the following
                   3106:       methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76      rillig   3107: <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   3108:       packages someplace else (enabled by default).</p></li>
1.76      rillig   3109: <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   3110:       best compiler flags to optimise code for your current CPU and
                   3111:       compiler.</p></li>
                   3112: </ul></div>
                   3113: <p>Utilities for keeping track of installed packages, being up to date,
                   3114: etc:</p>
                   3115: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3116: <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   3117:       packages whose installed versions do not match the latest pkgsrc
                   3118:       entries.</p></li>
1.76      rillig   3119: <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   3120:       dependency graphs of packages, to aid in choosing a strategy for
                   3121:       updating.</p></li>
1.76      rillig   3122: <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
                   3123:       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>
                   3124: <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   3125:       pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
                   3126:       does various checks on the complete pkgsrc system.</p></li>
1.76      rillig   3127: <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   3128:       packages you have installed.</p></li>
                   3129: </ul></div>
                   3130: <p>Utilities for people maintaining or creating individual packages:</p>
                   3131: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3132: <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   3133:       making and maintaining patches for a package (includes pkgdiff,
                   3134:       pkgvi, mkpatches, etc.).</p></li>
1.76      rillig   3135: <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>,
                   3136:       <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   3137:       converting to pkgsrc.</p></li>
1.76      rillig   3138: <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   3139:       pkgsrc to a Solaris package.</p></li>
                   3140: </ul></div>
                   3141: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
                   3142: utilities)</p>
                   3143: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3144: <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   3145:       packages in a chrooted area.</p></li>
1.76      rillig   3146: <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   3147:       kernel version for chrooted cross builds.</p></li>
                   3148: </ul></div>
                   3149: </div>
                   3150: <div class="sect1" lang="en">
                   3151: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3152: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
                   3153: <p>If you want to use pkgsrc as non-root user, you can set some
                   3154: variables to make pkgsrc work under these conditions.  At the very least,
                   3155: you need to set <code class="varname">UNPRIVILEGED</code> to &#8220;<span class="quote">yes</span>&#8221;; this
                   3156: will turn on unprivileged mode and set multiple related variables to allow
                   3157: installation of packages as non-root.</p>
                   3158: <p>In case the defaults are not enough, you may want to tune some other
                   3159: variables used.  For example, if the automatic user/group detection leads
                   3160: to incorrect values (or not the ones you would like to use), you can change
                   3161: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
                   3162: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
                   3163: <p>As regards bootstrapping, please note that the
                   3164: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
                   3165: given the &#8220;<span class="quote">--ignore-user-check</span>&#8221; flag, as it will choose and
1.76      rillig   3166: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75      rillig   3167: installation targets.  These directories can be overriden by the
                   3168: &#8220;<span class="quote">--prefix</span>&#8221; flag provided by the script, as well as some others
                   3169: that allow finer tuning of the tree layout.</p>
                   3170: </div>
                   3171: <div class="sect1" lang="en">
                   3172: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3173: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
                   3174: <p>By default, resuming transfers in pkgsrc is disabled, but you can
                   3175: enable this feature by adding the option
                   3176: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76      rillig   3177: <code class="filename">/etc/mk.conf</code>.  If, during a fetch step, an incomplete
1.75      rillig   3178: distfile is found, pkgsrc will try to resume it.</p>
                   3179: <p>You can also
                   3180: 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
                   3181: <code class="varname">FETCH_CMD</code> variable.  Don't forget to set
                   3182: <code class="varname">FETCH_RESUME_ARGS</code> and
                   3183: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
                   3184: values.</p>
                   3185: <p>For example, if you want to use
1.76      rillig   3186: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75      rillig   3187: like:</p>
                   3188: <pre class="programlisting">
                   3189:     FETCH_CMD=             wget
                   3190:     FETCH_BEFORE_ARGS=     --passive-ftp
                   3191:     FETCH_RESUME_ARGS=     -c
                   3192:     FETCH_OUTPUT_ARGS=     -O
1.1       grant    3193: </pre>
1.75      rillig   3194: </div>
                   3195: <div class="sect1" lang="en">
                   3196: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3197: <a name="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
                   3198: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76      rillig   3199: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75      rillig   3200: ...), you will have to add the following line into
1.76      rillig   3201: <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3202: <pre class="programlisting">
                   3203:     X11_TYPE=XFree86
1.1       grant    3204: </pre>
1.75      rillig   3205: </div>
                   3206: <div class="sect1" lang="en">
                   3207: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3208: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
                   3209: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76      rillig   3210: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75      rillig   3211: you will have to add the following line into
1.76      rillig   3212: <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3213: <pre class="programlisting">
                   3214:     X11_TYPE=xorg
1.1       grant    3215: </pre>
1.75      rillig   3216: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   3217: <h3 class="title">Note</h3>
                   3218: <p>The DragonFly operating system defaults to using
                   3219: this X.org X11 implementation from pkgsrc.
                   3220: </p>
                   3221: </div>
                   3222: </div>
                   3223: <div class="sect1" lang="en">
                   3224: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3225: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
                   3226: <p>If you are sitting behind a firewall which does not allow direct
                   3227: connections to Internet hosts (i.e. non-NAT), you may specify the
                   3228: relevant proxy hosts.  This is done using an environment variable in the
                   3229: form of a URL, e.g. in Amdahl, the machine
                   3230: &#8220;<span class="quote">orpheus.amdahl.com</span>&#8221; is one of the firewalls, and it uses
                   3231: port 80 as the proxy port number.  So the proxy environment variables
                   3232: are:</p>
                   3233: <pre class="programlisting">
                   3234:     ftp_proxy=ftp://orpheus.amdahl.com:80/
                   3235:     http_proxy=http://orpheus.amdahl.com:80/
1.1       grant    3236: </pre>
1.75      rillig   3237: </div>
                   3238: <div class="sect1" lang="en">
                   3239: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3240: <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>
                   3241: <p>This depends on which utility is used to retrieve distfiles.  From
1.76      rillig   3242: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75      rillig   3243: the first available command from the following list:</p>
                   3244: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3245: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
                   3246: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75      rillig   3247: </ul></div>
                   3248: <p>On a default NetBSD installation, this will be
1.76      rillig   3249: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75      rillig   3250: connections first, and falls back to active connections if the server
                   3251: refuses to do passive.  For the other tools, add the following to your
1.76      rillig   3252: <code class="filename">/etc/mk.conf</code> file:
1.75      rillig   3253: <code class="varname">PASSIVE_FETCH=1</code>.</p>
                   3254: <p>Having that option present will prevent
1.76      rillig   3255: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75      rillig   3256: transfers.</p>
                   3257: </div>
                   3258: <div class="sect1" lang="en">
                   3259: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3260: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
                   3261: <p>You would like to download all the distfiles in a single batch from
                   3262: work or university, where you can't run a <span><strong class="command">make fetch</strong></span>.
                   3263: There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
                   3264: but downloading the entire directory may not be appropriate.</p>
                   3265: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76      rillig   3266: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75      rillig   3267: resulting list to your machine at work/school and use it there.  If you
                   3268: 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
                   3269: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
                   3270: URL:</p>
                   3271: <p>At home:</p>
                   3272: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   3273: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles &gt;/tmp/fetch.sh</code></strong>
                   3274: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
                   3275: <p>At work:</p>
                   3276: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76      rillig   3277: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75      rillig   3278: home.</p>
                   3279: <p>If you have a machine running NetBSD, and you want to get
                   3280: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your machine
                   3281: architecture), you can do so by using the above-mentioned <span><strong class="command">make
                   3282: fetch-list</strong></span> approach, or fetch the distfiles directly by
                   3283: running:</p>
                   3284: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
                   3285: <p>If you even decide to ignore
                   3286: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
                   3287: by running:</p>
                   3288: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
                   3289: </div>
                   3290: <div class="sect1" lang="en">
                   3291: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3292: <a name="tmac.andoc-missing"></a>7.11. What does &#8220;<span class="quote">Don't know how to make
                   3293: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</h2></div></div></div>
1.76      rillig   3294: <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   3295: package, you get the error from make that it doesn't know how to make
1.76      rillig   3296: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75      rillig   3297: you don't have installed the &#8220;<span class="quote">text</span>&#8221; set (nroff, ...) from
                   3298: the NetBSD base distribution on your machine.  It is recommended to do
                   3299: that to format man pages.</p>
1.76      rillig   3300: <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   3301: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76      rillig   3302: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75      rillig   3303: </div>
                   3304: <div class="sect1" lang="en">
                   3305: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3306: <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   3307: <p> You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75      rillig   3308: when you installed your NetBSD machine.  Please get and install it, by
1.76      rillig   3309: extracting it in <code class="filename">/</code>:</p>
1.75      rillig   3310: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
                   3311: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76      rillig   3312: <p><code class="filename">comp.tgz</code> is part of every NetBSD release.  Get
1.75      rillig   3313: the one that corresponds to your release (determine via <span><strong class="command">uname
                   3314: -r</strong></span>).</p>
                   3315: </div>
                   3316: <div class="sect1" lang="en">
                   3317: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3318: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
                   3319: <p>When installing packages as non-root user and using the just-in-time
                   3320: <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
                   3321: password for each required package installed.  To avoid this, the sudo
                   3322: package can be used, which does password caching over a limited time.  To
                   3323: use it, install sudo (either as binary package or from
1.76      rillig   3324: <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
                   3325: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   3326: <pre class="programlisting">
                   3327:     .if exists(${LOCALBASE}/bin/sudo)
                   3328:     SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   3329:     .endif
1.1       grant    3330: </pre>
1.75      rillig   3331: </div>
                   3332: <div class="sect1" lang="en">
                   3333: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3334: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
                   3335: <p>As the system administrator, you can choose where configuration files
                   3336: are installed.  The default settings make all these files go into
1.76      rillig   3337: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75      rillig   3338: be suboptimal depending on your expectations (e.g., a read-only,
                   3339: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
                   3340: configuration of the provided packages).</p>
                   3341: <p>In order to change the defaults, you can modify the
                   3342: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76      rillig   3343: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
                   3344: directory; some common examples include <code class="filename">/etc</code> or
                   3345: <code class="filename">/etc/pkg</code>.</p>
1.75      rillig   3346: <p>Furthermore, you can change this value on a per-package basis by
                   3347: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
                   3348: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
                   3349: package you would like to modify, that is, the contents of
                   3350: <code class="varname">PKGBASE</code>.</p>
                   3351: <p>Note that after changing these settings, you must rebuild and
                   3352: reinstall any affected packages.</p>
                   3353: </div>
                   3354: <div class="sect1" lang="en">
                   3355: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3356: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
                   3357: <p>Please be aware that there can often be bugs in third-party software,
                   3358: and some of these bugs can leave a machine vulnerable to exploitation by
                   3359: attackers.  In an effort to lessen the exposure, the NetBSD packages team
                   3360: maintains a database of known-exploits to packages which have at one time
                   3361: been included in pkgsrc.  The database can be downloaded automatically, and
                   3362: a security audit of all packages installed on a system can take place.  To
1.76      rillig   3363: 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   3364: components:</p>
                   3365: <div class="orderedlist"><ol type="1">
                   3366: <li>
                   3367: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
                   3368:     download a list of the security vulnerabilities information.  This list
                   3369:     is kept up to date by the NetBSD security officer and the NetBSD
                   3370:     packages team, and is distributed from the NetBSD ftp server:</p>
                   3371: <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>
                   3372: </li>
                   3373: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
                   3374:     current machine, checking each vulnerability which is known.  If a
                   3375:     vulnerable package is installed, it will be shown by output to stdout,
                   3376:     including a description of the type of vulnerability, and a URL
                   3377:     containing more information.</p></li>
                   3378: </ol></div>
1.76      rillig   3379: <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   3380: package is strongly recommended!  After
                   3381: &#8220;<span class="quote">audit-packages</span>&#8221; is installed, please read
                   3382: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
                   3383: audit-packages</code></strong>.</p>
                   3384: <p>If this package is installed, pkgsrc builds will use it to perform
                   3385: a security check before building any package.  See
                   3386: <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.
                   3387: </p>
                   3388: </div>
                   3389: <div class="sect1" lang="en">
                   3390: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3391: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
                   3392: <p>When you add your own preferences to the
                   3393:        <code class="varname">CFLAGS</code> variable in your
1.76      rillig   3394:        <code class="filename">mk.conf</code>, these flags are passed in
                   3395:        environment variables to the <code class="filename">./configure</code>
1.75      rillig   3396:        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
                   3397:        <code class="varname">CFLAGS</code> from the environment variable by
1.76      rillig   3398:        overriding them in the <code class="filename">Makefile</code>s of their
1.75      rillig   3399:        package.</p>
                   3400: <p>Currently there is no solution to this problem. If you
                   3401:        really need the package to use your <code class="varname">CFLAGS</code>
                   3402:        you should run <span><strong class="command">make patch</strong></span> in the package
1.76      rillig   3403:        directory and then inspect any <code class="filename">Makefile</code> and
                   3404:        <code class="filename">Makefile.in</code> for whether they define
1.75      rillig   3405:        <code class="varname">CFLAGS</code> explicitly. Usually you can remove
                   3406:        these lines. But be aware that some &#8220;<span class="quote">smart</span>&#8221;
                   3407:        programmers write so bad code that it only works for the
                   3408:        specific combination of <code class="varname">CFLAGS</code> they have
                   3409:        chosen.</p>
                   3410: </div>
1.80      rillig   3411: <div class="sect1" lang="en">
                   3412: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   3413: <a name="ufaq-fail"></a>7.17. A package does not build. What shall I do?</h2></div></div></div>
                   3414: <div class="procedure"><ol type="1">
                   3415: <li><p>Make sure that your copy of pkgsrc is consistent. A
                   3416:        case that occurs often is that people only update pkgsrc in
                   3417:        parts, because of performance reasons. Since pkgsrc is one large
                   3418:        system, not a collection of many small systems, there are
                   3419:        sometimes changes that only work when the whole pkgsrc tree is
                   3420:        updated.</p></li>
                   3421: <li><p>Make sure that you don't have any CVS conflicts.
                   3422:        Search for &#8220;<span class="quote">&lt;&lt;&lt;&lt;&lt;&lt;</span>&#8221; or
                   3423:        &#8220;<span class="quote">&gt;&gt;&gt;&gt;&gt;&gt;</span>&#8221; in all your pkgsrc
                   3424:        files.</p></li>
                   3425: <li><p>Make sure that you don't have old copies of the packages
                   3426:        extracted. Run <span><strong class="command">make clean clean-depends</strong></span> to
                   3427:        verify this.</p></li>
                   3428: <li><p>If the problem still exists, write a mail to the
                   3429:        <code class="literal">pkgsrc-users</code> mailing list.</p></li>
                   3430: </ol></div>
                   3431: </div>
1.75      rillig   3432: </div>
                   3433: </div>
                   3434: <div class="part" lang="en">
                   3435: <div class="titlepage"><div><div><h1 class="title">
                   3436: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77      rillig   3437: <div class="partintro" lang="en">
                   3438: <div></div>
                   3439: <p>This part of the book deals with creating and
                   3440:        modifying packages. It starts with a &#8220;<span class="quote">HOWTO</span>&#8221;-like
                   3441:        guide on creating a new package. The remaining chapters are more
                   3442:        like a reference manual for pkgsrc.</p>
1.75      rillig   3443: <div class="toc">
                   3444: <p><b>Table of Contents</b></p>
                   3445: <dl>
1.77      rillig   3446: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
                   3447: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75      rillig   3448: <dd><dl>
1.77      rillig   3449: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
                   3450: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
                   3451: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
                   3452: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
                   3453: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78      rillig   3454: <dd><dl>
                   3455: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
                   3456: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
                   3457: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
                   3458: </dl></dd>
1.77      rillig   3459: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
                   3460: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
                   3461: </dl></dd>
                   3462: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
                   3463: <dd><dl>
                   3464: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
                   3465: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
                   3466: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
                   3467: <dd><dl>
                   3468: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
                   3469: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
                   3470: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
                   3471: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
                   3472: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
                   3473: </dl></dd>
                   3474: </dl></dd>
                   3475: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
                   3476: <dd><dl>
                   3477: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
                   3478: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
                   3479: <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>
                   3480: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
                   3481: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
                   3482: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
                   3483: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
                   3484: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
                   3485: </dl></dd>
                   3486: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
                   3487: <dd><dl>
                   3488: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
                   3489: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
                   3490: <dd><dl>
                   3491: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
                   3492: <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>
                   3493: </dl></dd>
                   3494: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
                   3495: <dd><dl>
                   3496: <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>
                   3497: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
                   3498: </dl></dd>
                   3499: </dl></dd>
                   3500: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
                   3501: <dd><dl>
                   3502: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
                   3503: <dd><dl>
                   3504: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
                   3505: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
                   3506: </dl></dd>
                   3507: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
                   3508: <dd><dl>
                   3509: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
                   3510: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
                   3511: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
                   3512: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
                   3513: </dl></dd>
                   3514: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
                   3515: <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>
                   3516: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
                   3517: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
                   3518: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
                   3519: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
                   3520: <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>
                   3521: </dl></dd>
                   3522: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
                   3523: <dd><dl>
                   3524: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
                   3525: <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>
                   3526: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
                   3527: </dl></dd>
                   3528: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
                   3529: <dd><dl>
                   3530: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
                   3531: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
                   3532: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
                   3533: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
                   3534: <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   3535: <dd><dl>
                   3536: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
                   3537: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
                   3538: </dl></dd>
1.77      rillig   3539: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
                   3540: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
                   3541: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
                   3542: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
                   3543: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
                   3544: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   3545: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   3546: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
                   3547: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   3548: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
                   3549: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
                   3550: </dl></dd>
                   3551: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
                   3552: <dd><dl>
                   3553: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
                   3554: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
                   3555: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
                   3556: </dl></dd>
                   3557: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
                   3558: <dd><dl>
                   3559: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
                   3560: <dd><dl>
1.78      rillig   3561: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
                   3562: <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>
                   3563: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
                   3564: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
                   3565: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
                   3566: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
                   3567: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
                   3568: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
                   3569: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
                   3570: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
                   3571: <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   3572: <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   3573: </dl></dd>
                   3574: <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>
                   3575: <dd><dl>
                   3576: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
                   3577: <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>
                   3578: </dl></dd>
                   3579: <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>
                   3580: <dd><dl>
                   3581: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
                   3582: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
                   3583: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
                   3584: </dl></dd>
                   3585: <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>
                   3586: <dd><dl>
1.78      rillig   3587: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
                   3588: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
                   3589: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
                   3590: </dl></dd>
                   3591: <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>
                   3592: <dd><dl>
                   3593: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
                   3594: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
                   3595: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
                   3596: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
                   3597: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
                   3598: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
                   3599: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
                   3600: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
                   3601: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
                   3602: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
                   3603: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
                   3604: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
                   3605: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
                   3606: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
                   3607: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
                   3608: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
                   3609: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.77      rillig   3610: </dl></dd>
1.78      rillig   3611: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.77      rillig   3612: </dl></dd>
                   3613: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
                   3614: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
                   3615: <dd><dl>
                   3616: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
                   3617: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                   3618: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
                   3619: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
                   3620: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
                   3621: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig   3622: </dl></dd>
1.77      rillig   3623: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75      rillig   3624: </dl>
                   3625: </div>
1.77      rillig   3626: </div>
                   3627: <div class="chapter" lang="en">
                   3628: <div class="titlepage"><div><div><h2 class="title">
                   3629: <a name="creating"></a>Chapter 8. Creating a new pkgsrc package from scratch</h2></div></div></div>
                   3630: <p>When you find a package that is not yet in pkgsrc, you
                   3631:        most likely have a URL from where you can download the source
                   3632:        code. Starting with this URL, creating a package involves only a
                   3633:        few steps.</p>
                   3634: <div class="procedure"><ol type="1">
                   3635: <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>
                   3636: <li><p>Then, choose one of the top-level directories as the
                   3637:        category in which you want to place your package. You can also
                   3638:        create a directory of your own (maybe called
                   3639:        <code class="filename">local</code>). In that category directory, create
                   3640:        another directory for your package and change into
                   3641:        it.</p></li>
                   3642: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
                   3643:        will ask you for a URL. Enter the URL of the distribution file
                   3644:        (in most cases a <code class="filename">.tar.gz</code> file) and watch
                   3645:        how the basic ingredients of your package are created
                   3646:        automatically. The distribution file is extracted automatically
                   3647:        to fill in some details in the <code class="filename">Makefile</code>
                   3648:        that would otherwise have to be done manually.</p></li>
                   3649: <li>
                   3650: <p>Examine the extracted files to determine the
                   3651:        dependencies of your package. Ideally, this is mentioned in some
                   3652:        <code class="filename">README</code> file, but things may differ. For
                   3653:        each of these dependencies, look where it exists in pkgsrc, and
                   3654:        if there is a file called <code class="filename">buildlink3.mk</code> in
                   3655:        that directory, add a line to your package
                   3656:        <code class="filename">Makefile</code> which includes that file just
                   3657:        before the last line. If the <code class="filename">buildlink3.mk</code>
                   3658:        file does not exist, add a <code class="varname">DEPENDS</code> line to
                   3659:        the Makefile, which specifies the version of the dependency and
                   3660:        where it can be found in pkgsrc. This line should be placed in
                   3661:        the third paragraph. If the dependency is only needed for
                   3662:        building the package, but not when using it, use
                   3663:        <code class="varname">BUILD_DEPENDS</code> instead of
                   3664:        <code class="varname">DEPENDS</code>. Your package may then look like
                   3665:        this:</p>
                   3666: <pre class="programlisting">
                   3667:     [...]
                   3668: 
                   3669:     BUILD_DEPENDS+= lua&gt;=5.0:../../lang/lua
                   3670:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   3671:     DEPENDS+=       screen&gt;=4.0:../../misc/screen
                   3672: 
                   3673:     [...]
                   3674: 
                   3675:     .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
                   3676:     .include "../../devel/glib2/buildlink3.mk"
                   3677:     .include "../../mk/bsd.pkg.mk"
                   3678: </pre>
                   3679: </li>
                   3680: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
                   3681:        still need to be done to make your package a &#8220;<span class="quote">good</span>&#8221;
                   3682:        one. If you don't know what pkglint's warnings want to tell you,
                   3683:        try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
                   3684:        -e</strong></span>, which outputs additional
                   3685:        explanations.</p></li>
                   3686: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
                   3687:        package. For the various things that can go wrong in this phase,
                   3688:        consult <a href="#fixes" title="Chapter 17. Making your package work">Chapter 17, <i>Making your package work</i></a>.</p></li>
                   3689: <li><p>When the package builds fine, the next step is to
                   3690:        install the package. Run <span><strong class="command">bmake install</strong></span> and
                   3691:        hope that everything works.</p></li>
                   3692: <li><p>Up to now, the file <code class="filename">PLIST</code>,
                   3693:        which contains a list of the files that are installed by the
                   3694:        package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
                   3695:        &gt;PLIST</strong></span> to generate a probably correct list. Check
                   3696:        the file using your preferred text editor to see if the list of
                   3697:        files looks plausible.</p></li>
                   3698: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
                   3699:        generated <code class="filename">PLIST</code> contains garbage or
                   3700:        not.</p></li>
                   3701: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
                   3702:        package has been registered in the database of installed files,
                   3703:        but with an empty list of files. To fix this, run <span><strong class="command">bmake
                   3704:        deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
                   3705:        Now the package is registered with the list of files from
                   3706:        <code class="filename">PLIST</code>.</p></li>
                   3707: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
                   3708:        binary package from the set of installed files.</p></li>
                   3709: </ol></div>
                   3710: </div>
1.75      rillig   3711: <div class="chapter" lang="en">
                   3712: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   3713: <a name="components"></a>Chapter 9. Package components - files, directories and contents</h2></div></div></div>
1.75      rillig   3714: <div class="toc">
                   3715: <p><b>Table of Contents</b></p>
                   3716: <dl>
1.77      rillig   3717: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
                   3718: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
                   3719: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
                   3720: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
                   3721: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
1.78      rillig   3722: <dd><dl>
                   3723: <dt><span class="sect2"><a href="#components.optional.bin">9.5.1. Files affecting the binary package</a></span></dt>
                   3724: <dt><span class="sect2"><a href="#components.optional.build">9.5.2. Files affecting the build process</a></span></dt>
                   3725: <dt><span class="sect2"><a href="#components.optional.none">9.5.3. Files affecting nothing at all</a></span></dt>
                   3726: </dl></dd>
1.77      rillig   3727: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
                   3728: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
1.75      rillig   3729: </dl>
                   3730: </div>
                   3731: <p>  Whenever you're preparing a package, there are a number of
                   3732:     files involved which are described in the following
                   3733:     sections. </p>
                   3734: <div class="sect1" lang="en">
                   3735: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   3736: <a name="components.Makefile"></a>9.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75      rillig   3737: <p>Building, installation and creation of a binary package are all
1.76      rillig   3738:       controlled by the package's <code class="filename">Makefile</code>.
                   3739:       The <code class="filename">Makefile</code> describes various things about
1.75      rillig   3740:       a package, for example from where to get it, how to configure,
                   3741:       build, and install it.
                   3742:     </p>
1.76      rillig   3743: <p>A package <code class="filename">Makefile</code> contains several
1.75      rillig   3744:      sections that describe the package.</p>
                   3745: <p>In the first section there are the following variables, which
1.81      rillig   3746:     should appear exactly in the order given here. The ordering and
                   3747:     grouping of variables is mostly historical and has no further
                   3748:     meaning.</p>
1.75      rillig   3749: <div class="itemizedlist"><ul type="disc">
                   3750: <li><p><code class="varname">DISTNAME</code> is the basename of the
                   3751:       distribution file to be downloaded from the package's
                   3752:       website.</p></li>
                   3753: <li><p><code class="varname">PKGNAME</code> is the name of the
                   3754:       package, as used by pkgsrc. You only need to provide it if it
                   3755:       differs from <code class="varname">DISTNAME</code>. Usually it is the directory name together
                   3756:       with the version number. It must match the regular expression
                   3757:       <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
                   3758:       starts with a letter or digit, and contains only letters, digits,
                   3759:       dashes, underscores, dots and plus signs.</p></li>
                   3760: <li>
                   3761: <p><code class="varname">CATEGORIES</code> is a list of categories
                   3762:            which the package fits in. You can choose any of the top-level
                   3763:            directories of pkgsrc for it.</p>
                   3764: <p>Currently the following values are available for
                   3765:          <code class="varname">CATEGORIES</code>. If more than
                   3766:          one is used, they need to be separated by spaces:</p>
                   3767: <pre class="programlisting">
                   3768:     archivers     cross         geography     meta-pkgs     security
                   3769:     audio         databases     graphics      misc          shells
                   3770:     benchmarks    devel         ham           multimedia    sysutils
                   3771:     biology       editors       inputmethod   net           textproc
                   3772:     cad           emulators     lang          news          time
                   3773:     chat          finance       mail          parallel      wm
                   3774:     comms         fonts         math          pkgtools      www
                   3775:     converters    games         mbone         print         x11
1.1       grant    3776: </pre>
1.75      rillig   3777: </li>
1.81      rillig   3778: <li><p><code class="varname">MASTER_SITES</code>,
                   3779:        <code class="varname">DYNAMIC_MASTER_SITES</code>,
                   3780:        <code class="varname">DIST_SUBDIR</code>, <code class="varname">EXTRACT_SUFX</code>
                   3781:        and <code class="varname">DISTFILES</code> are discussed in detail in
                   3782:        <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   3783: </ul></div>
                   3784: <p>The second section contains information about separately
                   3785:       downloaded patches, if any.
                   3786:       </p>
                   3787: <div class="itemizedlist"><ul type="disc">
                   3788: <li><p><code class="varname">PATCHFILES:</code>
                   3789:          Name(s) of additional files that contain distribution patches.
                   3790:          There is no default. pkgsrc will look for them at
                   3791:          <code class="varname">PATCH_SITES</code>.
                   3792:          They will automatically be uncompressed before patching if
1.76      rillig   3793:          the names end with <code class="filename">.gz</code> or
                   3794:          <code class="filename">.Z</code>.</p></li>
1.75      rillig   3795: <li><p><code class="varname">PATCH_SITES</code>:
                   3796:          Primary location(s) for distribution patch files (see
                   3797:          <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
                   3798: </ul></div>
                   3799: <p>
                   3800:     </p>
                   3801: <p>The third section contains the following variables.
                   3802:       </p>
                   3803: <div class="itemizedlist"><ul type="disc">
                   3804: <li><p><code class="varname">MAINTAINER</code> is the email address
                   3805:       of the person who feels responsible for this package, and who is
                   3806:       most likely to look at problems or questions regarding this
                   3807:       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
                   3808:       developers should contact the <code class="varname">MAINTAINER</code> before
                   3809:       making major changes to the package. When packaging a new program,
                   3810:       set <code class="varname">MAINTAINER</code> to yourself. If you really can't
                   3811:       maintain the package for future updates, set it to
                   3812:       <code class="email">&lt;<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>&gt;</code>.</p></li>
                   3813: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
                   3814:       find more information about the package.</p></li>
                   3815: <li><p><code class="varname">COMMENT</code> is a one-line
                   3816:       description of the package (should not include the package
                   3817:       name).</p></li>
                   3818: </ul></div>
                   3819: <p>
                   3820:     </p>
                   3821: <p>Other variables that affect the build:
                   3822:       </p>
                   3823: <div class="itemizedlist"><ul type="disc"><li>
                   3824: <p><code class="varname">WRKSRC</code>: The directory where the
                   3825:          interesting distribution files of the package are found. The
1.76      rillig   3826:          default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
1.75      rillig   3827:          works for most packages.</p>
                   3828: <p>If a package doesn't create a subdirectory for itself
                   3829:          (most GNU software does, for instance), but extracts itself in
                   3830:          the current directory, you should set <code class="varname">WRKSRC=
                   3831:          ${WRKDIR}</code>.</p>
                   3832: <p>If a package doesn't create a subdirectory with the name
                   3833:          of <code class="varname">DISTNAME</code> but some different name, set
                   3834:          <code class="varname">WRKSRC</code> to point to the proper name in
1.76      rillig   3835:          <code class="filename">${WRKDIR}</code>, for example <code class="varname">WRKSRC=
                   3836:          ${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   3837: <p>The name of the working directory created by pkgsrc is
                   3838:          taken from the <code class="varname">WRKDIR_BASENAME</code> variable. By
1.76      rillig   3839:          default, its value is <code class="filename">work</code>. If you want
1.75      rillig   3840:          to use the same pkgsrc tree for building different kinds of
                   3841:          binary packages, you can change the variable according to your
                   3842:          needs. Two other variables handle common cases of setting
                   3843:          <code class="varname">WRKDIR_BASENAME</code> individually. If
                   3844:          <code class="varname">OBJHOSTNAME</code> is defined in
1.76      rillig   3845:          <code class="filename">/etc/mk.conf</code>, the first component of the
1.75      rillig   3846:          host's name is attached to the directory name. If
                   3847:          <code class="varname">OBJMACHINE</code> is defined, the platform name is
1.76      rillig   3848:          attached, which might look like <code class="filename">work.i386</code>
                   3849:          or <code class="filename">work.sparc</code>.</p>
1.75      rillig   3850: </li></ul></div>
                   3851: <p>
                   3852:     </p>
                   3853: <p>Please pay attention to the following gotchas:</p>
                   3854: <div class="itemizedlist"><ul type="disc">
                   3855: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are installed in
                   3856:           compressed form by the package; see comment in
1.76      rillig   3857:           <code class="filename">bsd.pkg.mk</code>.</p></li>
                   3858: <li><p>Replace <code class="filename">/usr/local</code> with
1.75      rillig   3859:           &#8220;<span class="quote">${PREFIX}</span>&#8221; in all files (see patches, below).</p></li>
                   3860: <li><p>If the package installs any info files, see
1.78      rillig   3861:           <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   3862: </ul></div>
                   3863: </div>
                   3864: <div class="sect1" lang="en">
                   3865: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   3866: <a name="components.distinfo"></a>9.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76      rillig   3867: <p>The <code class="filename">distinfo</code> file contains the message
1.75      rillig   3868:     digest, or checksum, of each distfile needed for the package. This
                   3869:     ensures that the distfiles retrieved from the Internet have not been
                   3870:     corrupted during transfer or altered by a malign force to introduce
                   3871:     a security hole. Due to recent rumor about weaknesses of digest
                   3872:     algorithms, all distfiles are protected using both SHA1 and RMD160
                   3873:     message digests, as well as the file size.</p>
1.76      rillig   3874: <p>The <code class="filename">distinfo</code> file also contains the
1.75      rillig   3875:     checksums for all the patches found in the
1.77      rillig   3876:     <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   3877: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.75      rillig   3878:     <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
                   3879:     command.</p>
                   3880: <p>Some packages have different sets of distfiles depending on
1.76      rillig   3881:     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
                   3882:     <code class="filename">distinfo</code> file and care should be taken when
1.75      rillig   3883:     upgrading such a package to ensure distfile information is not
                   3884:     lost.</p>
                   3885: </div>
                   3886: <div class="sect1" lang="en">
                   3887: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   3888: <a name="components.patches"></a>9.3. patches/*</h2></div></div></div>
1.75      rillig   3889: <p>This directory contains files that are used by the
                   3890:       <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
                   3891:       modify the sources as distributed in the distribution file into a form
                   3892:       that will compile and run perfectly on NetBSD. The files are applied
                   3893:       successively in alphabetic order (as returned by a shell
                   3894:       &#8220;<span class="quote">patches/patch-*</span>&#8221; glob expansion), so
1.76      rillig   3895:       <code class="filename">patch-aa</code> is applied before
                   3896:       <code class="filename">patch-ab</code>, etc.</p>
                   3897: <p>The <code class="filename">patch-*</code> files should be in
1.75      rillig   3898:       <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
                   3899:       problems. (To force patches to apply
                   3900:       with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
                   3901:       Furthermore, do not put changes for more than one file into a single
                   3902:       patch file, as this will make future modifications more difficult.</p>
                   3903: <p>Similar, a file should be patched at most once, not several times by
                   3904:       several different patches. If a file needs several patches, they should
                   3905:       be combined into one file.</p>
                   3906: <p>One important thing to mention is to pay attention that no RCS IDs
                   3907:       get stored in the patch files, as these will cause problems when
                   3908:       later checked into the NetBSD CVS tree. Use the
                   3909:       <span><strong class="command">pkgdiff</strong></span> from the
1.76      rillig   3910:       <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   3911:       these problems.</p>
                   3912: <p>For even more automation, we recommend using <span><strong class="command">mkpatches</strong></span> from the same
                   3913:       package to make a whole set of patches. You just have to backup files
1.76      rillig   3914:       before you edit them to <code class="filename">filename.orig</code>, e.g. with
1.75      rillig   3915:       <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by using
                   3916:       <span><strong class="command">pkgvi</strong></span> again from the same package. If you upgrade a package
                   3917:       this way, you can easily compare the new set of patches with the
                   3918:       previously existing one with <span><strong class="command">patchdiff</strong></span>.</p>
                   3919: <p>When you have finished a package, remember to generate the checksums
                   3920:       for the patch files by using the <span><strong class="command">make makepatchsum</strong></span>
1.77      rillig   3921:       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   3922: <p>When adding a patch that corrects a problem in the distfile (rather
                   3923:       than e.g. enforcing pkgsrc's view of where man pages should go), send
                   3924:       the patch as a bug report to the maintainer.  This benefits
                   3925:       non-pkgsrc users of the package, and usually enables removing
                   3926:       the patch in future version.</p>
                   3927: <p>Patch files that are distributed by the author or other
                   3928:       maintainers can be listed in
                   3929:       <code class="varname">$PATCHFILES</code>. </p>
                   3930: <p>If it is desired to store any patches that should not be committed into
                   3931:       pkgsrc, they can be kept outside the pkgsrc tree in the
1.76      rillig   3932:       <code class="filename">$LOCALPATCHES</code>
1.75      rillig   3933:       directory. The directory tree there is expected to have the same
                   3934:       &#8220;<span class="quote">category/package</span>&#8221; structure as pkgsrc, and patches are
                   3935:       expected to be stored inside these dirs (also known as
1.76      rillig   3936:       <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
1.75      rillig   3937:       example, if you want to keep a private patch for
1.76      rillig   3938:       <code class="filename">pkgsrc/graphics/png</code>, keep
                   3939:       it in <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
1.75      rillig   3940:       files in the named directory are expected to be patch files, and
                   3941:       <span class="emphasis"><em>they are applied after pkgsrc patches are applied</em></span>.</p>
                   3942: </div>
                   3943: <div class="sect1" lang="en">
                   3944: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   3945: <a name="other-mandatory-files"></a>9.4. Other mandatory files</h2></div></div></div>
1.75      rillig   3946: <div class="variablelist"><dl>
1.76      rillig   3947: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75      rillig   3948: <dd><p>A multi-line description of the piece of software.  This should include
                   3949:             any credits where they are due.  Please bear in mind that others do not
                   3950:             share your sense of humour (or spelling idiosyncrasies), and that others
                   3951:             will read everything that you write here.</p></dd>
1.76      rillig   3952: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.75      rillig   3953: <dd><p>
                   3954:             This file governs the files that are installed on your system: all the
                   3955:             binaries, manual pages, etc. There are other directives which may be
                   3956:             entered in this file, to control the creation and deletion of
                   3957:             directories, and the location of inserted files.
1.77      rillig   3958:             See <a href="#plist" title="Chapter 11. PLIST issues">Chapter 11, <i>PLIST issues</i></a> for more information. </p></dd>
1.75      rillig   3959: </dl></div>
                   3960: </div>
                   3961: <div class="sect1" lang="en">
                   3962: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   3963: <a name="components.optional"></a>9.5. Optional files</h2></div></div></div>
1.78      rillig   3964: <div class="sect2" lang="en">
                   3965: <div class="titlepage"><div><div><h3 class="title">
                   3966: <a name="components.optional.bin"></a>9.5.1. Files affecting the binary package</h3></div></div></div>
1.75      rillig   3967: <div class="variablelist"><dl>
1.76      rillig   3968: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75      rillig   3969: <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>.
                   3970:             First time after package
                   3971:             extraction and before files are moved in place, the second time after
                   3972:             the files to install are moved in place. This can be used to do any
                   3973:             custom procedures not possible with @exec commands in
1.76      rillig   3974:             <code class="filename">PLIST</code>. See
1.75      rillig   3975:             <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   3976: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75      rillig   3977: <dd><p>This script is executed before and after any files are removed.  It is
                   3978:             this script's responsibility to clean up any additional messy details
                   3979:             around the package's installation, since all pkg_delete knows is how to
                   3980:             delete the files created in the original distribution.
                   3981:             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>
                   3982:             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   3983: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75      rillig   3984: <dd>
                   3985: <p>This file is displayed after installation of the package.
                   3986:             Useful for things like legal notices on almost-free
                   3987:             software and hints for updating config files after
                   3988:             installing modules for apache, PHP etc.
                   3989:             Please note that you can modify variables in it easily by using
                   3990:             <code class="varname">MESSAGE_SUBST</code> in the package's
1.76      rillig   3991:             <code class="filename">Makefile</code>:</p>
1.75      rillig   3992: <pre class="programlisting">
                   3993:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
1.1       grant    3994: </pre>
1.75      rillig   3995: <p>replaces "${SOMEVAR}" with &#8220;<span class="quote">somevalue</span>&#8221; in
1.76      rillig   3996:             <code class="filename">MESSAGE</code>.</p>
1.75      rillig   3997: </dd>
1.78      rillig   3998: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
                   3999: <dd><p>FIXME: There is no documentation on the
                   4000:        alternatives framework.</p></dd>
                   4001: </dl></div>
                   4002: </div>
                   4003: <div class="sect2" lang="en">
                   4004: <div class="titlepage"><div><div><h3 class="title">
                   4005: <a name="components.optional.build"></a>9.5.2. Files affecting the build process</h3></div></div></div>
                   4006: <div class="variablelist"><dl>
                   4007: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
                   4008: <dd><p>This file contains arbitrary things that could
                   4009:        also go into a <code class="filename">Makefile</code>, but its purpose is
                   4010:        to be used by more than one package. This file should only be
                   4011:        used when the packages that will use the file are known in
                   4012:        advance. For other purposes it is often better to write a
                   4013:        <code class="filename">*.mk</code> file and give it a good name that
                   4014:        describes what it does.</p></dd>
                   4015: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
                   4016: <dd><p>This file contains the dependency information
                   4017:        for the buildlink3 framework (see <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a>).</p></dd>
                   4018: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
                   4019: <dd><p>This file contains workarounds for compiler bugs
                   4020:        and similar things. It is included automatically by the pkgsrc
                   4021:        infrastructure, so you don't need an extra
                   4022:        <code class="literal">.include</code> line for
                   4023:        it.</p></dd>
                   4024: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
                   4025: <dd><p>This file contains the code for the
                   4026:        package-specific options (see <a href="#options" title="Chapter 14. Options handling">Chapter 14, <i>Options handling</i></a>) that can be
                   4027:        selected by the user. If a package has only one or two options,
                   4028:        it is equally acceptable to put the code directly into the
                   4029:        <code class="filename">Makefile</code>.</p></dd>
                   4030: </dl></div>
                   4031: </div>
                   4032: <div class="sect2" lang="en">
                   4033: <div class="titlepage"><div><div><h3 class="title">
                   4034: <a name="components.optional.none"></a>9.5.3. Files affecting nothing at all</h3></div></div></div>
                   4035: <div class="variablelist"><dl>
                   4036: <dt><span class="term"><code class="filename">README*</code></span></dt>
                   4037: <dd><p>These files do not take place in the creation of
                   4038:        a package and thus are purely informative to the package
                   4039:        developer.</p></dd>
                   4040: <dt><span class="term"><code class="filename">TODO</code></span></dt>
                   4041: <dd><p>This file contains things that need to be done
                   4042:        to make the package even
                   4043:        better.</p></dd>
1.75      rillig   4044: </dl></div>
                   4045: </div>
1.78      rillig   4046: </div>
1.75      rillig   4047: <div class="sect1" lang="en">
                   4048: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4049: <a name="work-dir"></a>9.6. <code class="filename">work*</code></h2></div></div></div>
1.75      rillig   4050: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
                   4051:       unpacked into the directory denoted by
                   4052:       <code class="varname">WRKDIR</code>. It can be removed by running
                   4053:       <span><strong class="command">make clean</strong></span>. Besides the sources, this
                   4054:       directory is also used to keep various timestamp files.
                   4055:       The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
1.76      rillig   4056:       The default is <code class="filename">${.CURDIR}/work</code>
                   4057:       or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
1.75      rillig   4058:       if <code class="varname">OBJMACHINE</code> is set.</p>
                   4059: </div>
                   4060: <div class="sect1" lang="en">
                   4061: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4062: <a name="files-dir"></a>9.7. <code class="filename">files/*</code></h2></div></div></div>
1.75      rillig   4063: <p>If you have any files that you wish to be placed in the package prior
                   4064:       to configuration or building, you could place these files here and use
                   4065:       a &#8220;<span class="quote">${CP}</span>&#8221; command in the
                   4066:       &#8220;<span class="quote">pre-configure</span>&#8221; target to achieve
                   4067:       this. Alternatively, you could simply diff the file against
1.76      rillig   4068:       <code class="filename">/dev/null</code> and use the patch mechanism to manage
1.75      rillig   4069:       the creation of this file.</p>
                   4070: </div>
                   4071: </div>
                   4072: <div class="chapter" lang="en">
                   4073: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   4074: <a name="makefile"></a>Chapter 10. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75      rillig   4075: <div class="toc">
                   4076: <p><b>Table of Contents</b></p>
                   4077: <dl>
1.77      rillig   4078: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
                   4079: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
                   4080: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
                   4081: <dd><dl>
                   4082: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
                   4083: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
                   4084: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
                   4085: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
                   4086: <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   4087: </dl></dd>
                   4088: </dl>
                   4089: </div>
1.76      rillig   4090: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75      rillig   4091:   each of which forms a well-defined part of the pkgsrc system. Using
                   4092:   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
                   4093:   like pkgsrc requires some discipline to keep the code correct and
                   4094:   understandable.</p>
1.76      rillig   4095: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75      rillig   4096:   programming are variables (which are actually macros) and shell
                   4097:   commands. Among these shell commands may even be more complex ones
                   4098:   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
                   4099:   as intended it is necessary to quote all variables correctly when they
                   4100:   are used.</p>
                   4101: <p>This chapter describes some patterns, that appear quite often in
1.76      rillig   4102:   <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75      rillig   4103:   with them.</p>
                   4104: <div class="sect1" lang="en">
                   4105: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4106: <a name="makefile.variables"></a>10.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76      rillig   4107: <p><code class="filename">Makefile</code> variables contain strings that
1.75      rillig   4108:     can be processed using the five operators ``='', ``+='', ``?='',
                   4109:     ``:='', 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
                   4110:     page.</p>
                   4111: <p>When a variable's value is parsed from a
1.76      rillig   4112:     <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75      rillig   4113:     backslash character ``\'' are handled specially. If a backslash is
                   4114:     followed by a newline, any whitespace immediately in front of the
                   4115:     backslash, the backslash, the newline, and any whitespace
                   4116:     immediately behind the newline are replaced with a single space. A
                   4117:     backslash character and an immediately following hash character are
                   4118:     replaced with a single hash character. Otherwise, the backslash is
                   4119:     passed as is. In a variable assignment, any hash character that is
                   4120:     not preceded by a backslash starts a comment that continues upto the
                   4121:     end of the logical line.</p>
                   4122: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
                   4123:     the only way to create a variable consisting of a single backslash
                   4124:     is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
                   4125: <p>So far for defining variables. The other thing you can do with
                   4126:     variables is evaluating them. A variable is evaluated when it is
                   4127:     part of the right side of the ``:='' or the ``!='' operator, or
                   4128:     directly before executing a shell command which the variable is part
                   4129:     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
                   4130:     is, variables are not evaluated until there's no other way. The
                   4131:     ``modifiers'' mentioned in the man page also evaluate the
                   4132:     variable.</p>
                   4133: <p>Some of the modifiers split the string into words and then
                   4134:     operate on the words, others operate on the string as a whole. When
                   4135:     a string is split into words, it is split as you would expect
                   4136:     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.83    ! wiz      4137: <p>No rule without exception&#8212;the <span><strong class="command">.for</strong></span>
1.75      rillig   4138:     loop does not follow the shell quoting rules but splits at sequences
                   4139:     of whitespace.</p>
                   4140: <p>There are several types of variables that should be handled
                   4141:     differently. Strings and two types of lists.</p>
                   4142: <div class="itemizedlist"><ul type="disc">
                   4143: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
                   4144:       characters. Nevertheless, you should restrict yourself to only
                   4145:       using printable characters. Examples are
                   4146:       <code class="varname">PREFIX</code> and
                   4147:       <code class="varname">COMMENT</code>.</p></li>
                   4148: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
                   4149:       are never exported to any shell command. Their elements are
                   4150:       separated by whitespace. Therefore, the elements themselves cannot
                   4151:       have embedded whitespace. Any other characters are allowed.
                   4152:       Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
                   4153:       Examples are <code class="varname">DEPENDS</code> and
                   4154:       <code class="varname">BUILD_DEPENDS</code>.</p></li>
                   4155: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
                   4156:       may be exported to a shell command. Their elements can contain any
                   4157:       characters, including whitespace. That's why they cannot be used
                   4158:       in <span><strong class="command">.for</strong></span> loops. Examples are
                   4159:       <code class="varname">DISTFILES</code> and
                   4160:       <code class="varname">MASTER_SITES</code>.</p></li>
                   4161: </ul></div>
                   4162: <div class="sect2" lang="en">
                   4163: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4164: <a name="makefile.variables.names"></a>10.1.1. Naming conventions</h3></div></div></div>
1.75      rillig   4165: <div class="itemizedlist"><ul type="disc">
                   4166: <li><p>All variable names starting with an underscore
                   4167:        are reserved for use by the pkgsrc infrastructure. They shall
                   4168:        not be used by package
1.76      rillig   4169:        <code class="filename">Makefile</code>s.</p></li>
1.75      rillig   4170: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
                   4171:        lowercase variable names for the iteration
                   4172:        variables.</p></li>
                   4173: <li><p>All list variables should have a ``plural''
                   4174:        name, e.g. <code class="varname">PKG_OPTIONS</code> or
                   4175:        <code class="varname">DISTFILES</code>.</p></li>
                   4176: </ul></div>
                   4177: </div>
                   4178: </div>
                   4179: <div class="sect1" lang="en">
                   4180: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4181: <a name="makefile.code"></a>10.2. Code snippets</h2></div></div></div>
1.75      rillig   4182: <p>This section presents you with some code snippets you should
                   4183:     use in your own code. If you don't find anything appropriate here,
                   4184:     you should test your code and add it here.</p>
                   4185: <div class="sect2" lang="en">
                   4186: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4187: <a name="adding-to-list"></a>10.2.1. Adding things to a list</h3></div></div></div>
1.75      rillig   4188: <pre class="programlisting">
                   4189:     STRING=                 foo * bar `date`
                   4190:     INT_LIST=               # empty
                   4191:     ANOTHER_INT_LIST=       apache-[0-9]*:../../www/apache
                   4192:     EXT_LIST=               # empty
                   4193:     ANOTHER_EXT_LIST=       a=b c=d
1.1       grant    4194: 
1.75      rillig   4195:     INT_LIST+=              ${STRING}               # 1
                   4196:     INT_LIST+=              ${ANOTHER_INT_LIST}     # 2
                   4197:     EXT_LIST+=              ${STRING:Q}             # 3
                   4198:     EXT_LIST+=              ${ANOTHER_EXT_LIST}     # 4
1.1       grant    4199: </pre>
1.75      rillig   4200: <p>When you add a string to an external list (example 3), it
                   4201:       must be quoted. In all other cases, you must not add a quoting
                   4202:       level. You must not merge internal and external lists, unless you
                   4203:       are sure that all entries are correctly interpreted in both
                   4204:       lists.</p>
                   4205: </div>
                   4206: <div class="sect2" lang="en">
                   4207: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4208: <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   4209: <pre class="programlisting">
                   4210:     EXT_LIST=       # empty
                   4211:     .for i in ${INT_LIST}
                   4212:     EXT_LIST+=      ${i:Q}""
                   4213:     .endfor
1.1       grant    4214: </pre>
1.75      rillig   4215: <p>This code converts the internal list
                   4216:       <code class="varname">INT_LIST</code> into the external list
                   4217:       <code class="varname">EXT_LIST</code>. As the elements of an internal list
                   4218:       are unquoted they must be quoted here. The reason for appending
                   4219:       <code class="varname">""</code> is explained below.</p>
                   4220: </div>
                   4221: <div class="sect2" lang="en">
                   4222: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4223: <a name="passing-variable-to-shell"></a>10.2.3. Passing variables to a shell command</h3></div></div></div>
1.79      rillig   4224: <p>Sometimes you may want to print an arbitrary string. There
                   4225:        are many ways to get it wrong and only few that can handle every
                   4226:        nastiness.</p>
1.75      rillig   4227: <pre class="programlisting">
                   4228:     STRING=         foo bar &lt;    &gt; * `date` $$HOME ' "
                   4229:     EXT_LIST=       string=${STRING:Q} x=second\ item
1.1       grant    4230: 
1.75      rillig   4231:     all:
                   4232:             echo ${STRING}                  # 1
                   4233:             echo "${STRING}"                # 2
                   4234:             echo "${STRING:Q}"              # 3
                   4235:             echo ${STRING:Q}                # 4
                   4236:             echo x${STRING:Q} | sed 1s,.,,  # 5
1.79      rillig   4237:             printf "%s\\n" ${STRING:Q}""    # 6
1.75      rillig   4238:             env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1       grant    4239: </pre>
1.75      rillig   4240: <p>Example 1 leads to a syntax error in the shell, as the
                   4241:       characters are just copied.</p>
                   4242: <p>Example 2 leads to a syntax error too, and if you leave out
                   4243:       the last " character from <code class="varname">${STRING}</code>,
                   4244:       <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
                   4245:       variable would be evaluated, too.</p>
                   4246: <p>Example 3 outputs each space character preceded by a
                   4247:       backslash (or not), depending on the implementation of the
                   4248:       <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>
                   4249: <p>Example 4 handles correctly every string that does not start
                   4250:       with a dash. In that case, the result depends on the
                   4251:       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
                   4252:       guarantee that your input does not start with a dash, this form is
                   4253:       appropriate.</p>
                   4254: <p>Example 5 handles even the case of a leading dash
                   4255:       correctly.</p>
1.79      rillig   4256: <p>Example 6 also works with every string and is the
                   4257:       light-weight solution, since it does not involve a pipe, which has
                   4258:       its own problems.</p>
1.75      rillig   4259: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
                   4260:       because the quoting has already been done when adding elements to
                   4261:       the list.</p>
                   4262: <p>As internal lists shall not be passed to the shell, there is
                   4263:       no example for it.</p>
                   4264: </div>
                   4265: <div class="sect2" lang="en">
                   4266: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4267: <a name="quoting-guideline"></a>10.2.4. Quoting guideline</h3></div></div></div>
1.75      rillig   4268: <p>There are many possible sources of wrongly quoted variables.
                   4269:       This section lists some of the commonly known ones.</p>
                   4270: <div class="itemizedlist"><ul type="disc">
                   4271: <li>
                   4272: <p>Whenever you use the value of a list, think
                   4273:        about what happens to leading or trailing whitespace. If the
                   4274:        list is a well-formed shell expression, you can apply the
                   4275:        <code class="varname">:M*</code> modifier to strip leading and trailing
                   4276:        whitespace from each word. The <code class="varname">:M</code> operator
                   4277:        first splits its argument according to the rules of the shell,
                   4278:        and then creates a new list consisting of all words that match
                   4279:        the shell glob expression <code class="varname">*</code>, that is: all.
                   4280:        One class of situations where this is needed is when adding a
                   4281:        variable like <code class="varname">CPPFLAGS</code> to
                   4282:        <code class="varname">CONFIGURE_ARGS</code>. If the configure script
                   4283:        invokes other configure scripts, it strips the leading and
                   4284:        trailing whitespace from the variable and then passes it to the
                   4285:        other configure scripts. But these configure scripts expect the
                   4286:        (child) <code class="varname">CPPFLAGS</code> variable to be the same as
                   4287:        the parent <code class="varname">CPPFLAGS</code>. That's why we better
                   4288:        pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
                   4289:        here is how we do it:</p>
                   4290: <pre class="programlisting">
                   4291:     CPPFLAGS=               # empty
                   4292:     CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX:Q}\"
                   4293:     CPPFLAGS+=              ${MY_CPPFLAGS}
1.1       grant    4294: 
1.75      rillig   4295:     CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
1.1       grant    4296: 
1.75      rillig   4297:     all:
                   4298:             echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   4299:             echo x${CONFIGURE_ARGS}x        # properly trimmed
1.1       grant    4300: </pre>
1.75      rillig   4301: </li>
                   4302: <li><p>The example above contains one bug: The
                   4303:        <code class="varname">${PREFIX}</code> is a properly quoted shell
                   4304:        expression, but there is the C compiler after it, which also
                   4305:        expects a properly quoted string (this time in C syntax). The
                   4306:        version above is therefore only correct if
                   4307:        <code class="varname">${PREFIX}</code> does not have embedded backslashes
                   4308:        or double quotes. If you want to allow these, you have to add
                   4309:        another layer of quoting to each variable that is used as a C
                   4310:        string literal. You cannot use the <code class="varname">:Q</code>
                   4311:        operator for it, as this operator only works for the
                   4312:        shell.</p></li>
                   4313: <li>
                   4314: <p>Whenever a variable can be empty, the
                   4315:        <code class="varname">:Q</code> operator can have surprising results. Here
                   4316:        are two completely different cases which can be solved with the
                   4317:        same trick.</p>
                   4318: <pre class="programlisting">
                   4319:     EMPTY=                  # empty
                   4320:     empty_test:
                   4321:             for i in a ${EMPTY:Q} c; do \
                   4322:                     echo "$$i"; \
                   4323:             done
1.1       grant    4324: 
1.75      rillig   4325:     for_test:
                   4326:     .for i in a:\ a:\test.txt
                   4327:             echo ${i:Q}
                   4328:             echo "foo"
                   4329:     .endfor
1.1       grant    4330: </pre>
1.75      rillig   4331: <p>The first example will only print two of the three lines
                   4332:        we might have expected. This is because
                   4333:        <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
                   4334:        the shell cannot see. The workaround is to write
                   4335:        <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
                   4336:        as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
                   4337:        -f ${FNAME:Q}</code> (both of these are wrong).</p>
                   4338: <p>The second example will only print three lines instead of
                   4339:        four. The first line looks like <code class="varname">a:\ echo foo</code>.
                   4340:        This is because the backslash of the value
                   4341:        <code class="varname">a:\</code> is interpreted as a line-continuation by
                   4342:        <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
                   4343:        <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
                   4344:        <code class="varname">${i:Q}""</code>.</p>
                   4345: </li>
                   4346: </ul></div>
                   4347: </div>
                   4348: <div class="sect2" lang="en">
                   4349: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4350: <a name="bsd-make-bug-workaround"></a>10.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75      rillig   4351: <p>The pkgsrc bmake program does not handle the following
                   4352:       assignment correctly. In case <code class="varname">_othervar_</code>
                   4353:       contains a ``-'' character, one of the closing braces is included
                   4354:       in <code class="varname">${VAR}</code> after this code executes.</p>
                   4355: <pre class="programlisting">
                   4356:     VAR:=   ${VAR:N${_othervar_:C/-//}}
1.1       grant    4357: </pre>
1.75      rillig   4358: <p>For a more complex code snippet and a workaround, see the
1.76      rillig   4359:       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   4360:       <code class="varname">bug1</code>.</p>
                   4361: </div>
                   4362: </div>
                   4363: </div>
                   4364: <div class="chapter" lang="en">
                   4365: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   4366: <a name="plist"></a>Chapter 11. PLIST issues</h2></div></div></div>
1.75      rillig   4367: <div class="toc">
                   4368: <p><b>Table of Contents</b></p>
                   4369: <dl>
1.77      rillig   4370: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
                   4371: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
                   4372: <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>
                   4373: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
                   4374: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
                   4375: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
                   4376: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
                   4377: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
1.75      rillig   4378: </dl>
                   4379: </div>
1.76      rillig   4380: <p> The <code class="filename">PLIST</code> file contains a package's
1.75      rillig   4381:     &#8220;<span class="quote">packing list</span>&#8221;, i.e. a list of files that belong to
1.76      rillig   4382:     the package (relative to the <code class="filename">${PREFIX}</code>
1.75      rillig   4383:     directory it's been installed in) plus some additional statements
                   4384:     - 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.
                   4385:     This chapter addresses some issues that need attention when
1.76      rillig   4386:     dealing with the <code class="filename">PLIST</code> file (or files, see
1.75      rillig   4387:     below!).</p>
                   4388: <div class="sect1" lang="en">
                   4389: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4390: <a name="rcs-id"></a>11.1. RCS ID</h2></div></div></div>
1.75      rillig   4391: <p>
                   4392:       Be sure to add a RCS ID line as the first thing in any
1.76      rillig   4393:       <code class="filename">PLIST</code> file you write:
1.75      rillig   4394:     </p>
                   4395: <pre class="programlisting">
                   4396:     @comment $NetBSD$
1.55      rillig   4397: </pre>
1.75      rillig   4398: </div>
                   4399: <div class="sect1" lang="en">
                   4400: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4401: <a name="automatic-plist-generation"></a>11.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75      rillig   4402: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
                   4403:       to output a PLIST that matches any new files since the package
1.77      rillig   4404:       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   4405:       more information on this target.</p>
                   4406: </div>
                   4407: <div class="sect1" lang="en">
                   4408: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4409: <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   4410: <p> If you have used any of the *-dirs packages, as explained in
1.77      rillig   4411:       <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   4412:       <span><strong class="command">make print-PLIST</strong></span> outputs a set of
                   4413:       <code class="varname">@comment</code>s instead of real
                   4414:       <code class="varname">@dirrm</code> lines.  You can also do this for
                   4415:       specific directories and files, so that the results of that
                   4416:       command are very close to reality. This helps <span class="emphasis"><em>a
                   4417:       lot</em></span> during the update of packages. </p>
                   4418: <p> The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
                   4419:       of AWK patterns and actions that are used to filter the output of
                   4420:       print-PLIST.  You can <span class="emphasis"><em>append</em></span> any chunk of AWK
                   4421:       scripting you like to it, but be careful with quoting. </p>
                   4422: <p> For example, to get all files inside the
1.76      rillig   4423:       <code class="filename">libdata/foo</code> directory removed from the
1.75      rillig   4424:       resulting PLIST:</p>
                   4425: <pre class="programlisting">
                   4426:     PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
1.55      rillig   4427: </pre>
1.75      rillig   4428: <p> And to get all the <code class="varname">@dirrm</code> lines referring
                   4429:       to a specific (shared) directory converted to
                   4430:       <code class="varname">@comment</code>s: </p>
                   4431: <pre class="programlisting">
                   4432:     PRINT_PLIST_AWK+=       /^@dirrm share\/specific/ { print "@comment " $$0; next; }
1.51      rillig   4433: </pre>
1.75      rillig   4434: </div>
                   4435: <div class="sect1" lang="en">
                   4436: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4437: <a name="plist.misc"></a>11.4. Variable substitution in PLIST</h2></div></div></div>
1.75      rillig   4438: <p>
                   4439:       A number of variables are substituted automatically in PLISTs
                   4440:       when a package is installed on a system. This includes the
                   4441:       following variables: </p>
                   4442: <div class="variablelist"><dl>
                   4443: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
                   4444: <dd>
                   4445: <p>Some packages like emacs and perl embed information
                   4446:             about which architecture they were built on into the
                   4447:             pathnames where they install their files. To handle this
                   4448:             case, PLIST will be preprocessed before actually used, and
                   4449:             the symbol
                   4450:             &#8220;<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>&#8221; will be
                   4451:             replaced by what <span><strong class="command">uname -p</strong></span> gives. The
                   4452:             same is done if the string
                   4453:             <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
                   4454:             PLIST somewhere - use this on packages that have GNU
                   4455:             autoconf-created configure scripts.</p>
                   4456: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   4457: <h3 class="title">Legacy note</h3>
                   4458: <p>There used to be a symbol
                   4459:               &#8220;<span class="quote"><code class="varname">$ARCH</code></span>&#8221; that
                   4460:               was replaced by the output of <span><strong class="command">uname
                   4461:               -m</strong></span>, but that's no longer supported and has
                   4462:               been removed.</p>
                   4463: </div>
                   4464: </dd>
                   4465: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
                   4466: <dd>
                   4467: <p>Some packages want to embed the OS name and version
                   4468:             into some paths.  To do this, use these variables in the
1.76      rillig   4469:             <code class="filename">PLIST</code>:
1.75      rillig   4470:           </p>
                   4471: <div class="itemizedlist"><ul type="disc">
                   4472: <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>
                   4473: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. &#8220;<span class="quote">solaris</span>&#8221;)</p></li>
                   4474: <li><p><code class="varname">${OS_VERSION}</code> - &#8220;<span class="quote"><span><strong class="command">uname -r</strong></span></span>&#8221;</p></li>
                   4475: </ul></div>
                   4476: </dd>
                   4477: </dl></div>
                   4478: <p> For a complete list of values which are replaced by
1.76      rillig   4479:       default, please look in <code class="filename">bsd.pkg.mk</code> (and
1.75      rillig   4480:       search for <span class="emphasis"><em>PLIST_SUBST</em></span>). </p>
                   4481: <p> If you want to change other variables not listed above, you
                   4482:       can add variables and their expansions to this variable in the
1.77      rillig   4483:       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   4484: <pre class="programlisting">
                   4485:     PLIST_SUBST+=   SOMEVAR="somevalue"
1.1       grant    4486: </pre>
1.75      rillig   4487: <p>This replaces all occurrences of &#8220;<span class="quote">${SOMEVAR}</span>&#8221;
                   4488:       in the PLIST with &#8220;<span class="quote">somevalue</span>&#8221;.  </p>
                   4489: </div>
                   4490: <div class="sect1" lang="en">
                   4491: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4492: <a name="manpage-compression"></a>11.5. Man page compression</h2></div></div></div>
1.75      rillig   4493: <p>Man pages should be installed in compressed form if
1.76      rillig   4494:       <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
1.75      rillig   4495:       and uncompressed otherwise. To handle this in the
1.76      rillig   4496:       <code class="filename">PLIST</code> file, the suffix &#8220;<span class="quote">.gz</span>&#8221; is
1.75      rillig   4497:       appended/removed automatically for man pages according to
                   4498:       <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
                   4499:       or not, see above for details. This modification of the
1.76      rillig   4500:       <code class="filename">PLIST</code> file is done on a copy of it, not
                   4501:       <code class="filename">PLIST</code> itself.</p>
1.75      rillig   4502: </div>
                   4503: <div class="sect1" lang="en">
                   4504: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4505: <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   4506: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.75      rillig   4507:       in generating the binary package, set the variable
                   4508:       <code class="varname">PLIST_SRC</code> to the names of that file(s).
                   4509:       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
                   4510:       important.</p>
                   4511: </div>
                   4512: <div class="sect1" lang="en">
                   4513: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4514: <a name="platform-specific-plist"></a>11.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75      rillig   4515: <p>Some packages decide to install a different set of files based on
                   4516:       the operating system being used. These differences can be
                   4517:       automatically handled by using the following files:</p>
                   4518: <div class="itemizedlist"><ul type="disc">
1.76      rillig   4519: <li><p><code class="filename">PLIST.common</code></p></li>
                   4520: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
                   4521: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
                   4522: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
                   4523: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75      rillig   4524: </ul></div>
                   4525: </div>
                   4526: <div class="sect1" lang="en">
                   4527: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4528: <a name="faq.common-dirs"></a>11.8. Sharing directories between packages</h2></div></div></div>
1.75      rillig   4529: <p> A &#8220;<span class="quote">shared directory</span>&#8221; is a directory where
                   4530:       multiple (and unrelated) packages install files.  These
                   4531:       directories are problematic because you have to add special tricks
                   4532:       in the PLIST to conditionally remove them, or have some
                   4533:       centralized package handle them. </p>
                   4534: <p> Within pkgsrc, you'll find both approaches.  If a directory
                   4535:       is shared by a few unrelated packages, it's often not worth to add
                   4536:       an extra package to remove it.  Therefore, one simply does:
                   4537:       </p>
                   4538: <pre class="programlisting">
                   4539:     @unexec ${RMDIR} %D/path/to/shared/directory 2&gt;/dev/null || ${TRUE}
1.1       grant    4540: </pre>
1.75      rillig   4541: <p> in the PLISTs of all affected packages, instead of the
                   4542:       regular "@dirrm" line. </p>
                   4543: <p> However, if the directory is shared across many packages, two
                   4544:       different solutions are available: </p>
                   4545: <div class="orderedlist"><ol type="1">
                   4546: <li><p> If the packages have a common dependency, the directory
                   4547:           can be removed in that.  For example, see
1.76      rillig   4548:           <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   4549:          removes the shared directory
1.76      rillig   4550:          <code class="filename">share/omf</code>. </p></li>
1.75      rillig   4551: <li><p> If the packages using the directory are not related at
                   4552:           all (they have no common dependencies), a *-dirs package is
                   4553:           used. </p></li>
                   4554: </ol></div>
                   4555: <p> From now on, we'll discuss the second solution.  To get an
                   4556:       idea of the *-dirs packages available, issue: </p>
                   4557: <pre class="programlisting">
                   4558:     <code class="prompt">%</code> cd .../pkgsrc
                   4559:     <code class="prompt">%</code> ls -d */*-dirs
1.1       grant    4560: </pre>
1.75      rillig   4561: <p> Their use from other packages is very simple.  The
                   4562:       <code class="varname">USE_DIRS</code> variable takes a list of package names
                   4563:       (without the &#8220;<span class="quote">-dirs</span>&#8221; part) together with the required
                   4564:       version number (always pick the latest one when writing new
                   4565:       packages). </p>
                   4566: <p> For example, if a package installs files under
1.76      rillig   4567:       <code class="filename">share/applications</code>, it should have the
1.75      rillig   4568:       following line in it:
                   4569:       </p>
                   4570: <pre class="programlisting">
                   4571:     USE_DIRS+=      xdg-1.1
1.1       grant    4572: </pre>
1.75      rillig   4573: <p> After regenerating the PLIST using <span><strong class="command">make
                   4574:       print-PLIST</strong></span>, you should get the right (commented out)
                   4575:       lines. </p>
                   4576: <p> Note that even if your package is using
1.76      rillig   4577:       <code class="filename">$X11BASE</code>, it must not depend on the
1.75      rillig   4578:       *-x11-dirs packages.  Just specify the name without that part and
1.76      rillig   4579:       pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
1.75      rillig   4580:       care of it. </p>
                   4581: </div>
                   4582: </div>
                   4583: <div class="chapter" lang="en">
                   4584: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   4585: <a name="buildlink"></a>Chapter 12. Buildlink methodology</h2></div></div></div>
1.75      rillig   4586: <div class="toc">
                   4587: <p><b>Table of Contents</b></p>
                   4588: <dl>
1.77      rillig   4589: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
                   4590: <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   4591: <dd><dl>
1.77      rillig   4592: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
                   4593: <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   4594: </dl></dd>
1.77      rillig   4595: <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   4596: <dd><dl>
1.77      rillig   4597: <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>
                   4598: <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   4599: </dl></dd>
                   4600: </dl>
                   4601: </div>
                   4602: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
                   4603:     are seen by a package's configure and build processes.  This is implemented
                   4604:     in a two step process:</p>
                   4605: <div class="orderedlist"><ol type="1">
                   4606: <li><p>Symlink headers and libraries for dependencies into
                   4607:        <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
                   4608:        of <code class="varname">WRKDIR</code>.</p></li>
                   4609: <li><p>Create wrapper scripts that are used in place of the normal compiler
                   4610:        tools that translate <code class="option">-I${LOCALBASE}/include</code> and
                   4611:        <code class="option">-L${LOCALBASE}/lib</code> into references to
                   4612:        <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
                   4613:         native compiler on some operating systems look like GCC, so that
                   4614:         packages that expect GCC won't require modifications to build with
                   4615:         those native compilers.</p></li>
                   4616: </ol></div>
                   4617: <p>This normalizes the environment in which a package is built so that the
                   4618:     package may be built consistently despite what other software may be
                   4619:     installed. Please note that the normal system header and library paths,
1.76      rillig   4620:     e.g. <code class="filename">/usr/include</code>,
                   4621:     <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
1.75      rillig   4622:     designed to insulate the package build from non-system-supplied
                   4623:     software. </p>
                   4624: <div class="sect1" lang="en">
                   4625: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4626: <a name="converting-to-buildlink3"></a>12.1. Converting packages to use buildlink3</h2></div></div></div>
1.75      rillig   4627: <p>The process of converting packages to use the buildlink3
                   4628:       framework (&#8220;<span class="quote">bl3ifying</span>&#8221;) is fairly straightforward.
                   4629:       The things to keep in mind are:</p>
                   4630: <div class="orderedlist"><ol type="1">
                   4631: <li><p> Ensure that the build always calls the wrapper scripts
                   4632:           instead of the actual toolchain.  Some packages are tricky,
                   4633:           and the only way to know for sure is the check
1.76      rillig   4634:           <code class="filename">${WRKDIR}/.work.log</code> to see if the
1.75      rillig   4635:           wrappers are being invoked. </p></li>
                   4636: <li><p> Don't override <code class="varname">PREFIX</code> from within
                   4637:           the package Makefile, e.g. Java VMs, standalone shells,
                   4638:           etc., because the code to symlink files into
1.76      rillig   4639:           <code class="filename">${BUILDLINK_DIR}</code> looks for files
1.75      rillig   4640:           relative to &#8220;<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>&#8221;.
                   4641:          </p></li>
                   4642: <li><p> Remember that <span class="emphasis"><em>only</em></span> the
1.76      rillig   4643:           <code class="filename">buildlink3.mk</code> files that you list in a
1.75      rillig   4644:           package's Makefile are added as dependencies for that package.
                   4645:          </p></li>
                   4646: </ol></div>
                   4647: <p> If a dependency on a particular package is required for its libraries and
                   4648:       headers, then we replace: </p>
                   4649: <pre class="programlisting">
                   4650:     DEPENDS+=   foo&gt;=1.1.0:../../category/foo
1.1       grant    4651: </pre>
1.75      rillig   4652: <p>with</p>
                   4653: <pre class="programlisting">
                   4654:     .include "../../category/foo/buildlink3.mk"
1.1       grant    4655: </pre>
1.75      rillig   4656: <p>The buildlink3.mk files usually define the required dependencies.
                   4657:     If you need a newer version of the dependency when using buildlink3.mk
                   4658:     files, then you can define it in your Makefile; for example:
                   4659:     </p>
                   4660: <pre class="programlisting">
                   4661:     BUILDLINK_API_DEPENDS.foo+=   foo&gt;=1.1.0
                   4662:     .include "../../category/foo/buildlink3.mk"
1.1       grant    4663: </pre>
1.76      rillig   4664: <p>There are several <code class="filename">buildlink3.mk</code>
                   4665:       files in <code class="filename">pkgsrc/mk</code>
1.75      rillig   4666:       that handle special package issues:</p>
                   4667: <div class="itemizedlist"><ul type="disc">
1.76      rillig   4668: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.75      rillig   4669:           the native or a pkgsrc Berkeley DB implementation based on
                   4670:           the values of <code class="varname">BDB_ACCEPTED</code> and
                   4671:           <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76      rillig   4672: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.75      rillig   4673:           comes with neither Curses nor NCurses, this will take care
1.76      rillig   4674:          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>
                   4675: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.75      rillig   4676:           of <code class="varname">KRB5_ACCEPTED</code> to choose between
                   4677:          adding a dependency on Heimdal or MIT-krb5 for packages that
                   4678:           require a Kerberos 5 implementation.</p></li>
1.76      rillig   4679: <li><p><code class="filename">motif.buildlink3.mk</code> checks
1.75      rillig   4680:          for a system-provided
1.76      rillig   4681:          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
                   4682:          <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>
                   4683: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.75      rillig   4684:          variables that may be used by packages that use the
                   4685:          Open Sound System (OSS) API.</p></li>
1.76      rillig   4686: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.75      rillig   4687:         either Postgres 7.3 or 7.4, whichever is found installed. See
                   4688:         the file for more information. </p></li>
1.76      rillig   4689: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.75      rillig   4690:          <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
1.76      rillig   4691:          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>
                   4692: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.75      rillig   4693:          <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
                   4694:          library.</p></li>
                   4695: </ul></div>
1.76      rillig   4696: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.75      rillig   4697:       files provide a more complete
                   4698:       description of how to use them properly.</p>
                   4699: </div>
                   4700: <div class="sect1" lang="en">
                   4701: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4702: <a name="creating-buildlink3.mk"></a>12.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.76      rillig   4703: <p> A package's <code class="filename">buildlink3.mk</code> file is
1.75      rillig   4704:       included by Makefiles to indicate the need to compile and link
                   4705:       against header files and libraries provided by the package.  A
1.76      rillig   4706:       <code class="filename">buildlink3.mk</code> file should always provide
1.75      rillig   4707:       enough information to add the correct type of dependency
                   4708:       relationship and include any other
1.76      rillig   4709:       <code class="filename">buildlink3.mk</code> files that it needs to find
1.75      rillig   4710:       headers and libraries that it needs in turn.</p>
1.76      rillig   4711: <p> To generate an initial <code class="filename">buildlink3.mk</code>
                   4712:       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   4713:       package is highly recommended.  For most packages, the following
                   4714:       command will generate a good starting point for
1.76      rillig   4715:       <code class="filename">buildlink3.mk</code> files:</p>
1.75      rillig   4716: <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>
                   4717: <code class="prompt">%</code> createbuildlink &gt;buildlink3.mk</code></strong></pre>
                   4718: <div class="sect2" lang="en">
                   4719: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4720: <a name="anatomy-of-bl3"></a>12.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75      rillig   4721: <p>The following real-life example
1.76      rillig   4722:         <code class="filename">buildlink3.mk</code> is taken
                   4723:         from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75      rillig   4724: <pre class="programlisting">
                   4725:     # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1       grant    4726: 
1.75      rillig   4727:     BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH}+
                   4728:     TIFF_BUILDLINK3_MK:=    ${TIFF_BUILDLINK3_MK}+
1.1       grant    4729: 
1.75      rillig   4730:     .if !empty(BUILDLINK_DEPTH:M+)
                   4731:     BUILDLINK_DEPENDS+=     tiff
                   4732:     .endif
1.1       grant    4733: 
1.75      rillig   4734:     BUILDLINK_PACKAGES:=    ${BUILDLINK_PACKAGES:Ntiff}
                   4735:     BUILDLINK_PACKAGES+=    tiff
1.1       grant    4736: 
1.75      rillig   4737:     .if !empty(TIFF_BUILDLINK3_MK:M+)
                   4738:     BUILDLINK_API_DEPENDS.tiff+=        tiff&gt;=3.6.1
                   4739:     BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
                   4740:     .endif  # TIFF_BUILDLINK3_MK
1.1       grant    4741: 
1.75      rillig   4742:     .include "../../devel/zlib/buildlink3.mk"
                   4743:     .include "../../graphics/jpeg/buildlink3.mk"
1.1       grant    4744: 
1.75      rillig   4745:     BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH:S/+$//}
1.1       grant    4746: </pre>
1.75      rillig   4747: <p> The header and footer manipulate
                   4748:         <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
1.76      rillig   4749:         <code class="filename">buildlink3.mk</code> files and is used to track
1.75      rillig   4750:         at what depth we are including
1.76      rillig   4751:         <code class="filename">buildlink3.mk</code> files.</p>
1.75      rillig   4752: <p> The first section controls if the dependency on
                   4753:         <em class="replaceable"><code>pkg</code></em> is added.
                   4754:         <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
                   4755:         packages for which dependencies are added by
                   4756:         buildlink3.</p>
                   4757: <p> The second section advises pkgsrc that the
1.76      rillig   4758:         <code class="filename">buildlink3.mk</code> file for
1.75      rillig   4759:         <em class="replaceable"><code>pkg</code></em> has been included at some point.
                   4760:         <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
1.76      rillig   4761:         packages for which <code class="filename">buildlink3.mk</code> files
1.75      rillig   4762:         have been included.  It must <span class="emphasis"><em>always</em></span> be
1.76      rillig   4763:         appended to within a <code class="filename">buildlink3.mk</code>
1.75      rillig   4764:         file. </p>
                   4765: <p> The third section is protected from multiple inclusion
                   4766:         and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
                   4767:         added.  Several important variables are set in the section:
                   4768:         </p>
                   4769: <div class="itemizedlist"><ul type="disc">
                   4770: <li><p> <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4771:            is the actual dependency recorded in the installed
                   4772:             package; this should always be set using
                   4773:            <span><strong class="command">+=</strong></span> to ensure that
                   4774:             we're appending to any pre-existing list of values.  This
                   4775:             variable should be set to the first version of the
                   4776:             package that had an API change.
                   4777:            </p></li>
                   4778: <li><p> <code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
                   4779:            is the location of the <em class="replaceable"><code>pkg</code></em>
                   4780:            pkgsrc directory.</p></li>
                   4781: <li><p>
                   4782:            <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
                   4783:            (not shown above) controls whether we use
                   4784:            <code class="varname">BUILD_DEPENDS</code> or
                   4785:            <code class="varname">DEPENDS</code> to add the dependency on
                   4786:            <em class="replaceable"><code>pkg</code></em>.
                   4787:            The build dependency is selected by setting
                   4788:            <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
                   4789:            to &#8220;<span class="quote">build</span>&#8221;.  By default, the
                   4790:            full dependency is used.
                   4791:            </p></li>
                   4792: <li><p>
                   4793:            <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
                   4794:            and
                   4795:            <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
                   4796:            (not shown above) are lists of subdirectories of
1.76      rillig   4797:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4798:            to add to the header and library search paths.  These
                   4799:            default to &#8220;<span class="quote">include</span>&#8221; and &#8220;<span class="quote">lib</span>&#8221;
                   4800:            respectively. </p></li>
                   4801: <li><p>
                   4802:            <code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
                   4803:            (not shown above) is the list of preprocessor flags to add
                   4804:            to <code class="varname">CPPFLAGS</code>, which are passed on to the
                   4805:            configure and build phases.  The &#8220;<span class="quote">-I</span>&#8221; option
                   4806:            should be avoided and instead be handled using
                   4807:            <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
                   4808:            above.</p></li>
                   4809: </ul></div>
                   4810: <p> The following variables are all optionally defined within
                   4811:        this second section (protected against multiple inclusion) and
                   4812:        control which package files are symlinked into
1.76      rillig   4813:        <code class="filename">${BUILDLINK_DIR}</code> and how their names are
1.75      rillig   4814:        transformed during the symlinking: </p>
                   4815: <div class="itemizedlist"><ul type="disc">
                   4816: <li><p>
                   4817:            <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
                   4818:            (not shown above) is a shell glob pattern relative to
1.76      rillig   4819:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4820:            to be symlinked into
1.76      rillig   4821:            <code class="filename">${BUILDLINK_DIR}</code>,
                   4822:            e.g. <code class="filename">include/*.h</code>. </p></li>
1.75      rillig   4823: <li><p>
                   4824:            <code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
                   4825:              (not shown above) is a shell pipeline that
                   4826:              outputs to stdout a list of files relative to
1.76      rillig   4827:              <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
1.75      rillig   4828:              The resulting files are to be symlinked
1.76      rillig   4829:              into <code class="filename">${BUILDLINK_DIR}</code>.  By default,
                   4830:              this takes the <code class="filename">+CONTENTS</code> of a
1.75      rillig   4831:              <em class="replaceable"><code>pkg</code></em> and filters it through
                   4832:              <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.
                   4833:            </p></li>
                   4834: <li><p>
                   4835:            <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
                   4836:            (not shown above) is a filter command that filters
1.76      rillig   4837:            <code class="filename">+CONTENTS</code> input into a list of files
1.75      rillig   4838:            relative to
1.76      rillig   4839:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4840:            on stdout.  By default for overwrite packages,
                   4841:            <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76      rillig   4842:            outputs the contents of the <code class="filename">include</code>
                   4843:            and <code class="filename">lib</code> directories in the package
                   4844:            <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75      rillig   4845:            it outputs any libtool archives in
1.76      rillig   4846:            <code class="filename">lib</code> directories.
1.75      rillig   4847:            </p></li>
                   4848: <li><p>
                   4849:            <code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
                   4850:            (not shown above) is a list of sed arguments used to
                   4851:            transform the name of the source filename into a
                   4852:            destination filename, e.g. <span><strong class="command">-e
                   4853:            "s|/curses.h|/ncurses.h|g"</strong></span>.
                   4854:            </p></li>
                   4855: </ul></div>
                   4856: <p> The last section includes any
1.76      rillig   4857:            <code class="filename">buildlink3.mk</code> needed for
1.75      rillig   4858:            <em class="replaceable"><code>pkg</code></em>'s library dependencies.
1.76      rillig   4859:            Including these <code class="filename">buildlink3.mk</code> files
1.75      rillig   4860:            means that the headers and libraries for these
                   4861:            dependencies are also symlinked into
1.76      rillig   4862:            <code class="filename">${BUILDLINK_DIR}</code>
1.75      rillig   4863:            whenever the <em class="replaceable"><code>pkg</code></em>
1.76      rillig   4864:            <code class="filename">buildlink3.mk</code>
1.75      rillig   4865:            file is included.
                   4866:            </p>
                   4867: </div>
                   4868: <div class="sect2" lang="en">
                   4869: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4870: <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   4871: <p>
                   4872:         The situation that requires increasing the dependency listed in
                   4873:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4874:        after a package update is when the API or interface to the
                   4875:        header files change.</p>
                   4876: <p> In this case,
                   4877:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4878:        should be adjusted to require at least the new package
                   4879:        version.  In some cases, the packages that depend on this new
                   4880:        version may need their <code class="varname">PKGREVISION</code>s
1.76      rillig   4881:        increased and, if they have <code class="filename">buildlink3.mk</code>
1.75      rillig   4882:        files, their
                   4883:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4884:        adjusted, too.  This is needed so pkgsrc will require the
                   4885:        correct package dependency and not settle for an older one
                   4886:        when building the source.</p>
                   4887: <p>
                   4888:        <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4889:        should be increased when the binary interface or sonames
                   4890:        (major number of the library version) of any installed
                   4891:        shared libraries change.  This is needed so that binary
                   4892:        packages made using it will require the correct package
                   4893:        dependency and not settle for an older one which will not
                   4894:        contain the necessary shared libraries. </p>
                   4895: <p>
1.78      rillig   4896:        See <a href="#dependencies" title="17.1.6. Handling dependencies">Section 17.1.6, &#8220;Handling dependencies&#8221;</a> for
1.75      rillig   4897:        more information about dependencies on other packages,
                   4898:        including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
                   4899:        <code class="varname">ABI_DEPENDS</code> definitions. </p>
                   4900: <p> Please take careful consideration before adjusting
                   4901:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4902:        or
                   4903:        <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4904:        as we don't want to cause unneeded package deletions and
                   4905:        rebuilds.  In many cases, new versions of packages work just
                   4906:        fine with older dependencies.</p>
                   4907: <p>
                   4908:        Also it is not needed to set
                   4909:        <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4910:        when it is identical to
                   4911:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.       </p>
                   4912: </div>
                   4913: </div>
                   4914: <div class="sect1" lang="en">
                   4915: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   4916: <a name="writing-builtin.mk"></a>12.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.75      rillig   4917: <p>
                   4918:       Some packages in pkgsrc install headers and libraries that
                   4919:       coincide with headers and libraries present in the base system.
1.76      rillig   4920:       Aside from a <code class="filename">buildlink3.mk</code> file, these
                   4921:       packages should also include a <code class="filename">builtin.mk</code>
1.75      rillig   4922:       file that includes the necessary checks to decide whether using
                   4923:       the built-in software or the pkgsrc software is
                   4924:       appropriate. </p>
                   4925: <p> The only requirements of a builtin.mk file for
                   4926:       <em class="replaceable"><code>pkg</code></em> are:
                   4927:       </p>
                   4928: <div class="orderedlist"><ol type="1">
                   4929: <li><p> It should set
                   4930:           <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4931:           to either &#8220;<span class="quote">yes</span>&#8221; or &#8220;<span class="quote">no</span>&#8221;
                   4932:           after it is included.
                   4933:        </p></li>
                   4934: <li><p> It should <span class="emphasis"><em>not</em></span> override any
                   4935:           <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4936:           which is already set before the
1.76      rillig   4937:           <code class="filename">builtin.mk</code> file is included.
1.75      rillig   4938:        </p></li>
                   4939: <li><p> It should be written to allow multiple inclusion.  This
                   4940:           is <span class="emphasis"><em>very</em></span> important and takes careful
1.76      rillig   4941:           attention to <code class="filename">Makefile</code> coding.
1.75      rillig   4942:        </p></li>
                   4943: </ol></div>
                   4944: <div class="sect2" lang="en">
                   4945: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   4946: <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   4947: <p>The following is the recommended template for builtin.mk
                   4948:         files: </p>
                   4949: <pre class="programlisting">
                   4950:     .if !defined(IS_BUILTIN.foo)
                   4951:     #
                   4952:     # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   4953:     # genuinely exists in the system or not.
                   4954:     #
                   4955:     IS_BUILTIN.foo?=        no
1.1       grant    4956: 
1.75      rillig   4957:     # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   4958:     # version can be determined.
                   4959:     #
                   4960:     .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   4961:     BUILTIN_PKG.foo?=       foo-1.0
                   4962:     .  endif
                   4963:     .endif  # IS_BUILTIN.foo
1.1       grant    4964: 
1.75      rillig   4965:     .if !defined(USE_BUILTIN.foo)
                   4966:     USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   4967:     .  if defined(BUILTIN_PKG.foo)
                   4968:     .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   4969:     .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   4970:     USE_BUILTIN.foo!=                                                       \
                   4971:           if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then     \
                   4972:                   ${ECHO} "yes";                                            \
                   4973:           else                                                              \
                   4974:                   ${ECHO} "no";                                             \
                   4975:           fi
                   4976:     .      endif
                   4977:     .    endfor
                   4978:     .  endif
                   4979:     .endif  # USE_BUILTIN.foo
1.1       grant    4980: 
1.75      rillig   4981:     CHECK_BUILTIN.foo?=     no
                   4982:     .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   4983:     #
                   4984:     # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   4985:     # "yes" or "no".
                   4986:     #
                   4987:     .endif  # CHECK_BUILTIN.foo
1.1       grant    4988: </pre>
1.75      rillig   4989: <p> The first section sets
                   4990:         <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4991:         depending on if <em class="replaceable"><code>pkg</code></em> really exists
                   4992:         in the base system.  This should not be a base system software
                   4993:         with similar functionality to <em class="replaceable"><code>pkg</code></em>;
                   4994:         it should only be &#8220;<span class="quote">yes</span>&#8221; if the actual package is
                   4995:         included as part of the base system.  This variable is only
1.76      rillig   4996:         used internally within the <code class="filename">builtin.mk</code>
1.75      rillig   4997:         file. </p>
                   4998: <p> The second section sets
                   4999:         <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
                   5000:         to the version of <em class="replaceable"><code>pkg</code></em> in the base
                   5001:         system if it exists (if
                   5002:         <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5003:         is &#8220;<span class="quote">yes</span>&#8221;).  This variable is only used internally
1.76      rillig   5004:         within the <code class="filename">builtin.mk</code> file. </p>
1.75      rillig   5005: <p> The third section sets
                   5006:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5007:         and is <span class="emphasis"><em>required</em></span> in all
1.76      rillig   5008:         <code class="filename">builtin.mk</code> files.  The code in this
1.75      rillig   5009:         section must make the determination whether the built-in
                   5010:         software is adequate to satisfy the dependencies listed in
                   5011:         <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
                   5012:         This is typically done by comparing
                   5013:         <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
                   5014:         against each of the dependencies in
                   5015:         <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
                   5016:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5017:         <span class="emphasis"><em>must</em></span> be set to the correct value by the
1.76      rillig   5018:         end of the <code class="filename">builtin.mk</code> file.  Note that
1.75      rillig   5019:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5020:         may be &#8220;<span class="quote">yes</span>&#8221; even if
                   5021:         <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5022:         is &#8220;<span class="quote">no</span>&#8221; because we may make the determination
                   5023:         that the built-in version of the software is similar enough to
                   5024:         be used as a replacement. </p>
                   5025: <p> The last section is guarded by
                   5026:         <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
                   5027:         and includes code that uses the value of
                   5028:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   5029:         set in the previous section.  This typically includes, e.g.,
                   5030:         adding additional dependency restrictions and listing
                   5031:         additional files to symlink into
1.76      rillig   5032:         <code class="filename">${BUILDLINK_DIR}</code> (via
1.75      rillig   5033:         <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).
                   5034:         </p>
                   5035: </div>
                   5036: <div class="sect2" lang="en">
                   5037: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5038: <a name="native-or-pkgsrc-preference"></a>12.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.75      rillig   5039: <p>
                   5040:         When building packages, it's possible to choose whether to set
                   5041:         a global preference for using either the built-in (native)
                   5042:         version or the pkgsrc version of software to satisfy a
                   5043:         dependency.  This is controlled by setting
                   5044:         <code class="varname">PREFER_PKGSRC</code> and
                   5045:         <code class="varname">PREFER_NATIVE</code>.  These variables take values
                   5046:         of either &#8220;<span class="quote">yes</span>&#8221;, &#8220;<span class="quote">no</span>&#8221;, or a list of
                   5047:         packages.  <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
                   5048:         use the pkgsrc versions of software, while
                   5049:         <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
                   5050:         built-in versions.  Preferences are determined by the most
                   5051:         specific instance of the package in either
                   5052:         <code class="varname">PREFER_PKGSRC</code> or
                   5053:         <code class="varname">PREFER_NATIVE</code>.  If a package is specified
                   5054:         in neither or in both variables, then
                   5055:         <code class="varname">PREFER_PKGSRC</code> has precedence over
                   5056:         <code class="varname">PREFER_NATIVE</code>.  For example, to require
                   5057:         using pkgsrc versions of software for all but the most basic
                   5058:         bits on a NetBSD system, you can set: </p>
                   5059: <pre class="programlisting">
                   5060:     PREFER_PKGSRC=  yes
                   5061:     PREFER_NATIVE=  getopt skey tcp_wrappers
1.1       grant    5062: </pre>
1.75      rillig   5063: <p> A package <span class="emphasis"><em>must</em></span> have a
1.76      rillig   5064:         <code class="filename">builtin.mk</code>
1.75      rillig   5065:         file to be listed in <code class="varname">PREFER_NATIVE</code>,
                   5066:         otherwise it is simply ignored in that list.
                   5067:        </p>
                   5068: </div>
                   5069: </div>
                   5070: </div>
                   5071: <div class="chapter" lang="en">
                   5072: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   5073: <a name="pkginstall"></a>Chapter 13. The pkginstall framework</h2></div></div></div>
1.75      rillig   5074: <div class="toc">
                   5075: <p><b>Table of Contents</b></p>
                   5076: <dl>
1.77      rillig   5077: <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   5078: <dd><dl>
1.77      rillig   5079: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
                   5080: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
1.75      rillig   5081: </dl></dd>
1.77      rillig   5082: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
1.75      rillig   5083: <dd><dl>
1.77      rillig   5084: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
                   5085: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
                   5086: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
                   5087: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
                   5088: </dl></dd>
                   5089: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
                   5090: <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>
                   5091: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
                   5092: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
                   5093: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
                   5094: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
                   5095: <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   5096: </dl>
                   5097: </div>
                   5098: <p>This chapter describes the framework known as
                   5099: <code class="literal">pkginstall</code>, whose key features are:</p>
                   5100: <div class="itemizedlist"><ul type="disc">
                   5101: <li><p>Generic installation and manipulation of directories and files
                   5102:     outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
                   5103: <li><p>Automatic handling of configuration files during installation,
                   5104:     provided that packages are correctly designed.</p></li>
                   5105: <li><p>Generation and installation of system startup scripts.</p></li>
                   5106: <li><p>Registration of system users and groups.</p></li>
                   5107: <li><p>Registration of system shells.</p></li>
                   5108: <li><p>Automatic updating of fonts databases.</p></li>
                   5109: </ul></div>
                   5110: <p>The following sections inspect each of the above points in detail.</p>
                   5111: <p>You may be thinking that many of the things described here could be
                   5112: easily done with simple code in the package's post-installation target
                   5113: (<code class="literal">post-install</code>).  <span class="emphasis"><em>This is incorrect</em></span>,
                   5114: as the code in them is only executed when building from source.  Machines
                   5115: using binary packages could not benefit from it at all (as the code itself
                   5116: could be unavailable).  Therefore, the only way to achieve any of the items
                   5117: described above is by means of the installation scripts, which are
                   5118: automatically generated by pkginstall.</p>
                   5119: <div class="sect1" lang="en">
                   5120: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5121: <a name="files-and-dirs-outside-prefix"></a>13.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76      rillig   5122: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75      rillig   5123: of files and directories that belong to a package.  The names used in it
1.76      rillig   5124: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75      rillig   5125: which means that it cannot register files outside this directory (absolute
                   5126: path names are not allowed).  Despite this restriction, some packages need
                   5127: to install files outside this location; e.g., under
1.76      rillig   5128: <code class="filename">${VARBASE}</code> or
                   5129: <code class="filename">${PKG_SYSCONFDIR}</code>.</p>
1.75      rillig   5130: <p>The only way to achieve this is to create such files during
                   5131: installation time by using the installation scripts.  These scripts can run
                   5132: arbitrary commands, so they have the potential to create and manage files
                   5133: anywhere in the file system.  Here is where pkginstall comes into play: it
                   5134: provides generic scripts to abstract the manipulation of such files and
                   5135: directories based on variables set in the package's
1.76      rillig   5136: <code class="filename">Makefile</code>.  The rest of this section describes these
1.75      rillig   5137: variables.</p>
                   5138: <div class="sect2" lang="en">
                   5139: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5140: <a name="dirs-outside-prefix"></a>13.1.1. Directory manipulation</h3></div></div></div>
1.75      rillig   5141: <p>The following variables can be set to request the creation of
                   5142: directories anywhere in the file system:</p>
                   5143: <div class="itemizedlist"><ul type="disc">
                   5144: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
                   5145:     contain a list of directories that should be created and should attempt
                   5146:     to be destroyed by the installation scripts.  The difference between
                   5147:     the two is that the latter prompts the administrator to remove any
                   5148:     directories that may be left after deinstallation (because they were
                   5149:     not empty), while the former does not.</p></li>
                   5150: <li>
                   5151: <p><code class="varname">MAKE_DIRS_PERMS</code> and
                   5152:     <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
                   5153:     which directories should be created and should attempt to be destroyed
                   5154:     by the installation scripts.  Each tuple holds the following values,
                   5155:     separated by spaces: the directory name, its owner, its group and its
                   5156:     numerical mode.  For example:</p>
                   5157: <pre class="programlisting">
                   5158:     MAKE_DIRS_PERMS+=         ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1       grant    5159: </pre>
1.75      rillig   5160: <p>The difference between the two is exactly the same as their
                   5161:     non-<code class="varname">PERMS</code> counterparts.</p>
                   5162: </li>
                   5163: </ul></div>
                   5164: </div>
                   5165: <div class="sect2" lang="en">
                   5166: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5167: <a name="files-outside-prefix"></a>13.1.2. File manipulation</h3></div></div></div>
1.75      rillig   5168: <p>Creating non-empty files outside the installation prefix is tricky
1.76      rillig   5169: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75      rillig   5170: To overcome this problem, the only solution is to extract the file in the
                   5171: known place (i.e., inside the installation prefix) and copy it to the
                   5172: appropriate location during installation (done by the installation scripts
                   5173: generated by pkginstall).  We will call the former the <span class="emphasis"><em>master
                   5174: file</em></span> in the following paragraphs, which describe the variables
                   5175: that can be used to automatically and consistently handle files outside the
                   5176: installation prefix:</p>
                   5177: <div class="itemizedlist"><ul type="disc">
                   5178: <li>
                   5179: <p><code class="varname">CONF_FILES</code> and
                   5180:     <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
                   5181:     During installation time, the master file is copied to the target one
                   5182:     if and only if the latter does not exist.  Upon deinstallation, the
                   5183:     target file is removed provided that it was not modified by the
                   5184:     installation.</p>
                   5185: <p>The difference between the two is that the latter prompts the
                   5186:     administrator to remove any files that may be left after
                   5187:     deinstallation (because they were not empty), while the former does
                   5188:     not.</p>
                   5189: </li>
                   5190: <li>
                   5191: <p><code class="varname">CONF_FILES_PERMS</code> and
                   5192:     <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
                   5193:     files as well as their target locations.  For each of them, it also
                   5194:     specifies their owner, their group and their numeric permissions, in
                   5195:     this order.  For example:</p>
                   5196: <pre class="programlisting">
                   5197:     SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1       grant    5198: </pre>
1.75      rillig   5199: <p>The difference between the two is exactly the same as their
                   5200:     non-<code class="varname">PERMS</code> counterparts.</p>
                   5201: </li>
                   5202: </ul></div>
                   5203: </div>
                   5204: </div>
                   5205: <div class="sect1" lang="en">
                   5206: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5207: <a name="conf-files"></a>13.2. Configuration files</h2></div></div></div>
1.75      rillig   5208: <p>Configuration files are special in the sense that they are installed
                   5209: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
                   5210: need special treatment during installation (most of which is automated by
                   5211: pkginstall).  The main concept you must bear in mind is that files marked
                   5212: as configuration files are automatically copied to the right place (somewhere
                   5213: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
                   5214: and only if</em></span> they didn't exist before.  Similarly, they will not
                   5215: be removed if they have local modifications.  This ensures that
                   5216: administrators never lose any custom changes they may have made.</p>
                   5217: <div class="sect2" lang="en">
                   5218: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5219: <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   5220: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
                   5221: specifies where configuration files shall be installed.  Its contents are
                   5222: set based upon the following variables:</p>
                   5223: <div class="itemizedlist"><ul type="disc">
                   5224: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76      rillig   5225:     directory.  Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75      rillig   5226:     be overridden by the user to point to his preferred location (e.g.,
1.76      rillig   5227:     <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75      rillig   5228:     Packages must not use it directly.</p></li>
                   5229: <li>
                   5230: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
                   5231:     <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
                   5232:     for the package being built shall be installed.  The definition of this
                   5233:     variable only makes sense in the package's
1.76      rillig   5234:     <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75      rillig   5235: <p>As an example, consider the Apache package,
1.76      rillig   5236:     <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   5237:     configuration files under the
1.76      rillig   5238:     <code class="filename">httpd/</code> subdirectory of
1.75      rillig   5239:     <code class="varname">PKG_SYSCONFBASE</code>.  This should be set in the package
                   5240:     Makefile.</p>
                   5241: </li>
                   5242: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
                   5243:     variable that holds this package's configuration directory (if
                   5244:     different from <code class="varname">PKG_SYSCONFBASE</code>).  It defaults to
                   5245:     <code class="varname">PKGBASE</code>'s value, and is always prefixed with
                   5246:     <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
                   5247: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
                   5248:     directory where the configuration files for the package identified by
                   5249:     <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
                   5250: </ul></div>
                   5251: <p>Based on the above variables, pkginstall determines the value of
                   5252: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
                   5253: variable that can be used within a package to refer to its configuration
                   5254: directory.  The algorithm used to set its value is basically the
                   5255: following:</p>
                   5256: <div class="orderedlist"><ol type="1">
                   5257: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
                   5258:     its value is used.</p></li>
                   5259: <li><p>If the previous variable is not defined but
                   5260:     <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76      rillig   5261:     <code class="filename">Makefile</code>, the resulting value is
                   5262:     <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75      rillig   5263: <li><p>Otherwise, it is set to
1.76      rillig   5264:     <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75      rillig   5265: </ol></div>
1.76      rillig   5266: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.77      rillig   5267: 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   5268: </div>
                   5269: <div class="sect2" lang="en">
                   5270: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5271: <a name="conf-files-configure"></a>13.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75      rillig   5272: <p>Given that pkgsrc (and users!) expect configuration files to be in a
                   5273: known place, you need to teach each package where it shall install its
                   5274: files.  In some cases you will have to patch the package Makefiles to
                   5275: achieve it.  If you are lucky, though, it may be as easy as passing an
                   5276: extra flag to the configuration script; this is the case of GNU Autoconf-
                   5277: generated files:</p>
                   5278: <pre class="programlisting">
                   5279:     CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1       grant    5280: </pre>
1.75      rillig   5281: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
                   5282: for</em></span> its configuration files, not where they will be originally
                   5283: installed (although the difference is never explicit,
                   5284: unfortunately).</p>
                   5285: </div>
                   5286: <div class="sect2" lang="en">
                   5287: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5288: <a name="conf-files-patching"></a>13.2.3. Patching installations</h3></div></div></div>
1.75      rillig   5289: <p>As said before, pkginstall automatically handles configuration files.
                   5290: This means that <span class="strong"><strong>the packages themselves must not
1.76      rillig   5291: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75      rillig   5292: directly</strong></span>.  Bad news is that many software installation scripts
                   5293: will, out of the box, mess with the contents of that directory.  So what is
                   5294: the correct procedure to fix this issue?</p>
                   5295: <p>You must teach the package (usually by manually patching it) to
                   5296: install any configuration files under the examples hierarchy,
1.76      rillig   5297: <code class="filename">share/examples/${PKGBASE}/</code>.  This way, the
                   5298: <code class="filename">PLIST</code> registers them and the administrator always
1.75      rillig   5299: has the original copies available.</p>
                   5300: <p>Once the required configuration files are in place (i.e., under the
                   5301: examples hierarchy), the pkginstall framework can use them as master copies
                   5302: during the package installation to update what is in
1.76      rillig   5303: <code class="filename">${PKG_SYSCONFDIR}</code>.  To achieve this, the variables
1.75      rillig   5304: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.77      rillig   5305: 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   5306: about their syntax and their purpose.  Here is an example, taken from the
1.76      rillig   5307: <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   5308: <pre class="programlisting">
                   5309:     EGDIR=        ${PREFIX}/share/doc/mutt/samples
                   5310:     CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1       grant    5311: </pre>
1.75      rillig   5312: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
                   5313: package and has no meaning outside it.</p>
                   5314: </div>
                   5315: <div class="sect2" lang="en">
                   5316: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5317: <a name="conf-files-disable"></a>13.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75      rillig   5318: <p>The automatic copying of config files can be toggled by setting the
                   5319: environment variable <code class="varname">PKG_CONFIG</code> prior to package
                   5320: installation.</p>
                   5321: </div>
                   5322: </div>
                   5323: <div class="sect1" lang="en">
                   5324: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5325: <a name="rcd-scripts"></a>13.3. System startup scripts</h2></div></div></div>
1.75      rillig   5326: <p>System startup scripts are special files because they must be
                   5327: installed in a place known by the underlying OS, usually outside the
1.77      rillig   5328: 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   5329: can be used.  However, pkginstall provides a special mechanism to handle
                   5330: these files.</p>
                   5331: <p>In order to provide system startup scripts, the package has
                   5332: to:</p>
                   5333: <div class="orderedlist"><ol type="1">
1.76      rillig   5334: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75      rillig   5335:     the <code class="literal">.sh</code> suffix appended.  Considering the
1.76      rillig   5336:     <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
                   5337:     <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75      rillig   5338: <li>
                   5339: <p>Tell pkginstall to handle it, appending the name of the script,
                   5340:     without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
                   5341:     Continuing the previous example:</p>
                   5342: <pre class="programlisting">
                   5343:     RCD_SCRIPTS+=   cupsd
1.1       grant    5344: </pre>
1.75      rillig   5345: </li>
                   5346: </ol></div>
                   5347: <p>Once this is done, pkginstall will do the following steps for each
                   5348: script in an automated fashion:</p>
                   5349: <div class="orderedlist"><ol type="1">
                   5350: <li><p>Process the file found in the files directory applying all the
1.76      rillig   5351:     substitutions described in the <code class="filename">FILES_SUBST</code>
1.75      rillig   5352:     variable.</p></li>
                   5353: <li><p>Copy the script from the files directory to the examples
1.76      rillig   5354:     hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>.  Note
1.75      rillig   5355:     that this master file must be explicitly registered in the
1.76      rillig   5356:     <code class="filename">PLIST</code>.</p></li>
1.75      rillig   5357: <li><p>Add code to the installation scripts to copy the startup script
                   5358:     from the examples hierarchy into the system-wide startup scripts
                   5359:     directory.</p></li>
                   5360: </ol></div>
                   5361: <div class="sect2" lang="en">
                   5362: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5363: <a name="rcd-scripts-disable"></a>13.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75      rillig   5364: <p>The automatic copying of config files can be toggled by setting the
                   5365: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
                   5366: installation.  Note that the scripts will be always copied inside the
1.76      rillig   5367: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75      rillig   5368: matter what the value of this variable is.</p>
                   5369: </div>
                   5370: </div>
                   5371: <div class="sect1" lang="en">
                   5372: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5373: <a name="users-and-groups"></a>13.4. System users and groups</h2></div></div></div>
1.75      rillig   5374: <p>If a package needs to create special users and/or groups during
                   5375: installation, it can do so by using the pkginstall framework.</p>
                   5376: <p>Users can be created by adding entries to the
                   5377: <code class="varname">PKG_USERS</code> variable.  Each entry has the following
                   5378: syntax:</p>
                   5379: <pre class="programlisting">
                   5380:     user:group
1.1       grant    5381: </pre>
1.75      rillig   5382: <p>Further specification of user details may be done by setting per-user
                   5383: variables.
                   5384: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the numeric
                   5385: UID for the user.
                   5386: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the user's
                   5387: description or comment.
                   5388: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the user's
1.76      rillig   5389: home directory, and defaults to <code class="filename">/nonexistent</code> if not
1.75      rillig   5390: specified.
                   5391: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the user's
1.76      rillig   5392: shell, and defaults to <code class="filename">/sbinno/login</code> if not specified.
1.75      rillig   5393: </p>
                   5394: <p>Similarly, groups can be created by adding entries to the
                   5395: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
                   5396: <pre class="programlisting">
                   5397:     group
1.1       grant    5398: </pre>
1.75      rillig   5399: <p>The numeric GID of the group may be set by defining 
                   5400: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
                   5401: <p>If a package needs to create the users and groups at an earlier
                   5402: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
                   5403: either <code class="literal">configure</code> or <code class="literal">build</code> to
                   5404: indicate the phase before which the users and groups are created.  In
                   5405: this case, the numeric UIDs and GIDs of the created users and groups
                   5406: are automatically hardcoded into the final installation scripts.</p>
                   5407: </div>
                   5408: <div class="sect1" lang="en">
                   5409: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5410: <a name="shells"></a>13.5. System shells</h2></div></div></div>
1.75      rillig   5411: <p>Packages that install system shells should register them in the shell
1.76      rillig   5412: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75      rillig   5413: administrator.  This must be done from the installation scripts to keep
                   5414: binary packages working on any system.  pkginstall provides an easy way to
                   5415: accomplish this task.</p>
                   5416: <p>When a package provides a shell interpreter, it has to set the
                   5417: <code class="varname">PKG_SHELL</code> variable to its absolute file name.  This will
                   5418: add some hooks to the installation scripts to handle it.  Consider the
1.76      rillig   5419: 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   5420: <pre class="programlisting">
                   5421:     PKG_SHELL=      ${PREFIX}/bin/zsh
1.1       grant    5422: </pre>
1.75      rillig   5423: <div class="sect2" lang="en">
                   5424: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5425: <a name="shells-disable"></a>13.5.1. Disabling shell registration</h3></div></div></div>
1.75      rillig   5426: <p>The automatic registration of shell interpreters can be disabled by
1.76      rillig   5427: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75      rillig   5428: environment variable to <code class="literal">NO</code>.</p>
                   5429: </div>
                   5430: </div>
                   5431: <div class="sect1" lang="en">
                   5432: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5433: <a name="fonts"></a>13.6. Fonts</h2></div></div></div>
1.75      rillig   5434: <p>Packages that install X11 fonts should update the database files
                   5435: that index the fonts within each fonts directory.  This can easily be
                   5436: accomplished within the pkginstall framework.</p>
                   5437: <p>When a package installs X11 fonts, it must list the directories in
                   5438: which fonts are installed in the
                   5439: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
                   5440: where <em class="replaceable"><code>type</code></em> can be one of &#8220;<span class="quote">ttf</span>&#8221;,
                   5441: &#8220;<span class="quote">type1</span>&#8221; or &#8220;<span class="quote">x11</span>&#8221;.  This will add hooks to the
                   5442: installation scripts to run the appropriate commands to update the fonts
                   5443: database files within each of those directories.  For convenience, if the
                   5444: directory path is relative, it is taken to be relative to the package's
1.76      rillig   5445: 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   5446: <pre class="programlisting">
                   5447:     FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1       grant    5448: </pre>
1.75      rillig   5449: <div class="sect2" lang="en">
                   5450: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   5451: <a name="fonts-disable"></a>13.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75      rillig   5452: <p>The automatic update of fonts databases can be disabled by
1.76      rillig   5453: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75      rillig   5454: environment variable to <code class="literal">NO</code>.</p>
                   5455: </div>
                   5456: </div>
                   5457: </div>
                   5458: <div class="chapter" lang="en">
                   5459: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   5460: <a name="options"></a>Chapter 14. Options handling</h2></div></div></div>
1.75      rillig   5461: <div class="toc">
                   5462: <p><b>Table of Contents</b></p>
                   5463: <dl>
1.77      rillig   5464: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
                   5465: <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>
                   5466: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
1.75      rillig   5467: </dl>
                   5468: </div>
                   5469: <p>Many packages have the ability to be built to support different
1.76      rillig   5470: sets of features.  <code class="filename">bsd.options.mk</code> is a framework
1.75      rillig   5471: in pkgsrc that provides generic handling of those options that
                   5472: determine different ways in which the packages can be built.  It's
                   5473: possible for the user to specify exactly which sets of options will be
                   5474: built into a package or to allow a set of global default options
                   5475: apply.</p>
                   5476: <div class="sect1" lang="en">
                   5477: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5478: <a name="global-default-options"></a>14.1. Global default options</h2></div></div></div>
1.75      rillig   5479: <p>Global default options are listed in
                   5480: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
                   5481: that should be built into every package if that option is supported.
1.76      rillig   5482: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75      rillig   5483: </div>
                   5484: <div class="sect1" lang="en">
                   5485: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5486: <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   5487: <p>The following example shows how
1.76      rillig   5488: <code class="filename">bsd.options.mk</code> should be used
1.75      rillig   5489: by the hypothetical ``wibble'' package, either in the package
1.76      rillig   5490: <code class="filename">Makefile</code>, or in a file,
                   5491: e.g. <code class="filename">options.mk</code>, that is included by the
                   5492: main package <code class="filename">Makefile</code>.</p>
1.75      rillig   5493: <pre class="programlisting">
                   5494:     PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   5495:     PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   5496:     PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   5497:     PKG_OPTIONS_GROUP.database=     mysql pgsql
                   5498:     PKG_SUGGESTED_OPTIONS=          wibble-foo
                   5499:     PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   5500:     PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
1.1       grant    5501: 
1.75      rillig   5502:     .include "../../mk/bsd.prefs.mk"
1.69      rillig   5503: 
1.75      rillig   5504:     # this package was previously named wibble2
                   5505:     .if defined(PKG_OPTIONS.wibble2)
                   5506:     PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   5507:     PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78      rillig   5508:             "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75      rillig   5509:     .endif
1.69      rillig   5510: 
1.75      rillig   5511:     .include "../../mk/bsd.options.mk"
1.69      rillig   5512: 
1.75      rillig   5513:     # Package-specific option-handling
1.69      rillig   5514: 
1.75      rillig   5515:     ###
                   5516:     ### FOO support
                   5517:     ###
                   5518:     .if !empty(PKG_OPTIONS:Mwibble-foo)
                   5519:     CONFIGURE_ARGS+=    --enable-foo
                   5520:     .endif
1.69      rillig   5521: 
1.75      rillig   5522:     ###
                   5523:     ### LDAP support
                   5524:     ###
                   5525:     .if !empty(PKG_OPTIONS:Mldap)
1.77      rillig   5526:     .  include "../../databases/openldap-client/buildlink3.mk"
                   5527:     CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75      rillig   5528:     .endif
1.69      rillig   5529: 
1.75      rillig   5530:     ###
                   5531:     ### database support
                   5532:     ###
                   5533:     .if !empty(PKG_OPTIONS:Mmysql)
                   5534:     .  include "../../mk/mysql.buildlink3.mk"
                   5535:     .endif
                   5536:     .if !empty(PKG_OPTIONS:Mpgsql)
                   5537:     .  include "../../mk/pgsql.buildlink3.mk"
                   5538:     .endif
                   5539: </pre>
                   5540: <p>The first section contains the information about which build
                   5541: options are supported by the package, and any default options settings
                   5542: if needed.</p>
                   5543: <div class="orderedlist"><ol type="1">
                   5544: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
                   5545: <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
                   5546: options.  It should be set to
1.78      rillig   5547: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
                   5548: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
                   5549: at the point where the options are processed.</p></li>
1.75      rillig   5550: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
                   5551: build options supported by the package.</p></li>
                   5552: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
                   5553: list of names of groups of mutually exclusive options.  The options in
                   5554: each group are listed in
                   5555: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
                   5556: The most specific setting of any option from the group takes
                   5557: precedence over all other options in the group.  Options from the
                   5558: groups will be automatically added to
                   5559: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
                   5560: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
                   5561: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
                   5562: packages will fail if no option from the group is
                   5563: selected.</p></li>
                   5564: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
                   5565: of names of sets of options.  At least one option from each set must
                   5566: be selected.  The options in each set are listed in
                   5567: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
                   5568: Options from the sets will be automatically added to
                   5569: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.  Building the package will
                   5570: fail if no option from the set is selected.</p></li>
                   5571: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
                   5572: build options which are enabled by default.</p></li>
                   5573: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
                   5574: of
                   5575: &#8220;<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>&#8221;
1.76      rillig   5576: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75      rillig   5577: their option counterparts.  Pairs should be added with
                   5578: &#8220;<span class="quote">+=</span>&#8221; to keep the listing of global legacy variables.  A
                   5579: warning will be issued if the user uses a legacy
                   5580: variable.</p></li>
                   5581: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
                   5582: of
                   5583: &#8220;<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>&#8221;
                   5584: pairs that map options that have been renamed to their new
                   5585: counterparts.  Pairs should be added with &#8220;<span class="quote">+=</span>&#8221; to keep
                   5586: the listing of global legacy options.  A warning will be issued if
                   5587: the user uses a legacy option.</p></li>
                   5588: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
                   5589: options implied by deprecated variables used.  This can be used for
                   5590: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
                   5591: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
                   5592: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
                   5593: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
                   5594: a list of warnings about deprecated variables or options used, and
                   5595: what to use instead.</p></li>
                   5596: </ol></div>
                   5597: <p>A package should never modify
                   5598: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
                   5599: <code class="varname">PKG_OPTIONS_VAR</code>.  These are strictly user-settable.
                   5600: To suggest a default set of options, use
                   5601: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
                   5602: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76      rillig   5603: including <code class="filename">bsd.options.mk</code>.  If none of
1.75      rillig   5604: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
                   5605: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
                   5606: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
                   5607: happen with platform-specific options if none of them is supported on
                   5608: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
                   5609: empty list and the package is otherwise treated as not using the
                   5610: options framework.</p>
1.76      rillig   5611: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75      rillig   5612: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
                   5613: build options, properly filtered to remove unsupported and duplicate
                   5614: options.</p>
                   5615: <p>The remaining sections contain the logic that is specific to
                   5616: each option.  The correct way to check for an option is to check
                   5617: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
                   5618: <pre class="programlisting">
                   5619:     .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
                   5620: </pre>
                   5621: </div>
                   5622: <div class="sect1" lang="en">
                   5623: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5624: <a name="option-names"></a>14.3. Option Names</h2></div></div></div>
1.75      rillig   5625: <p>Options that enable similar features in different packages (like
                   5626: optional support for a library) should use a common name in all
                   5627: packages that support it (like the name of the library).  If another
                   5628: package already has an option with the same meaning, use the same
                   5629: name.</p>
                   5630: <p>Options that enable features specific to one package, where it's
                   5631: unlikely that another (unrelated) package has the same (or a similar)
                   5632: optional feature, should use a name prefixed with
                   5633: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
                   5634: <p>If a group of related packages share an optional feature
                   5635: specific to that group, prefix it with the name of the
                   5636: &#8220;<span class="quote">main</span>&#8221; package
                   5637: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
                   5638: <p>For new options, add a line to
1.76      rillig   5639: <code class="filename">mk/defaults/options.description</code>.  Lines have two
1.75      rillig   5640: fields, separated by tab.  The first field is the option name, the
                   5641: second its description.  The description should be a whole sentence
                   5642: (starting with an uppercase letter and ending with a period) that
                   5643: describes what enabling the option does.  E. g. &#8220;<span class="quote">Enable ispell
                   5644: support.</span>&#8221; The file is sorted by option names.</p>
                   5645: </div>
                   5646: </div>
                   5647: <div class="chapter" lang="en">
                   5648: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   5649: <a name="build"></a>Chapter 15. The build process</h2></div></div></div>
1.75      rillig   5650: <div class="toc">
                   5651: <p><b>Table of Contents</b></p>
                   5652: <dl>
1.77      rillig   5653: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
                   5654: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
                   5655: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
                   5656: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
                   5657: <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   5658: <dd><dl>
                   5659: <dt><span class="sect2"><a href="#build.fetch.what">15.5.1. What to fetch and where to get it from</a></span></dt>
                   5660: <dt><span class="sect2"><a href="#build.fetch.how">15.5.2. How are the files fetched?</a></span></dt>
                   5661: </dl></dd>
1.77      rillig   5662: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
                   5663: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
                   5664: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
                   5665: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
                   5666: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
                   5667: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
                   5668: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
                   5669: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
                   5670: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
                   5671: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
                   5672: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
1.75      rillig   5673: </dl>
                   5674: </div>
                   5675: <div class="sect1" lang="en">
                   5676: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5677: <a name="build.intro"></a>15.1. Introduction</h2></div></div></div>
1.75      rillig   5678: <p>This chapter gives a detailed description on how a package is
                   5679: built. Building a package is separated into different
                   5680: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
                   5681: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
                   5682: described in the following sections. Each phase is splitted into
                   5683: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
                   5684: containing phase, prefixed by one of <code class="varname">pre-</code>,
                   5685: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
                   5686: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
                   5687: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
                   5688: <p>The basic steps for building a program are always the same.  First
                   5689: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
                   5690: the local system and then extracted. After any pkgsrc-specific patches
                   5691: to compile properly are applied, the software can be configured, then
                   5692: built (usually by compiling), and finally the generated binaries, etc.
                   5693: can be put into place on the system.</p>
                   5694: </div>
                   5695: <div class="sect1" lang="en">
                   5696: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5697: <a name="build.prefix"></a>15.2. Program location</h2></div></div></div>
1.75      rillig   5698: <p>Before outlining the process performed by the NetBSD package system in
                   5699:       the next section, here's a brief discussion on where programs are
                   5700:       installed, and which variables influence this.</p>
                   5701: <p>The automatic variable <code class="varname">PREFIX</code> indicates
                   5702:       where all files of the final program shall be installed. It is
                   5703:       usually set to <code class="varname">LOCALBASE</code>
1.76      rillig   5704:       (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.75      rillig   5705:       for pkgs in the &#8220;<span class="quote">cross</span>&#8221; category.  The value of
                   5706:       <code class="varname">PREFIX</code> needs to be put
                   5707:       into the various places in the program's source where paths to
1.77      rillig   5708:       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   5709: <p>When choosing which of these variables to use,
                   5710:       follow the following rules:</p>
                   5711: <div class="itemizedlist"><ul type="disc">
                   5712: <li><p><code class="varname">PREFIX</code> always points to the location where the current
                   5713:          pkg will be installed.  When referring to a pkg's own installation path,
                   5714:          use &#8220;<span class="quote">${PREFIX}</span>&#8221;.</p></li>
                   5715: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs are installed.
                   5716:          If you need to construct a -I or -L argument to the compiler to find
                   5717:          includes and libraries installed by another non-X11 pkg, use
1.78      rillig   5718:          &#8220;<span class="quote">${LOCALBASE}</span>&#8221;. The name
                   5719:          <code class="varname">LOCALBASE</code> stems from FreeBSD, which
                   5720:          installed all packages in <code class="filename">/usr/local</code>. As
                   5721:          pkgsrc leaves <code class="filename">/usr/local</code> for the system
                   5722:          administrator, this variable is a misnomer.</p></li>
1.75      rillig   5723: <li><p><code class="varname">X11BASE</code> is where the actual X11 distribution (from
                   5724:          xsrc, etc.) is installed. When looking for
                   5725:          <span class="emphasis"><em>standard</em></span> X11 includes (not
                   5726:          those installed by a pkg), use &#8220;<span class="quote">${X11BASE}</span>&#8221;.</p></li>
                   5727: <li>
                   5728: <p>X11-based packages are special in that they may be installed in
                   5729:          either <code class="varname">X11BASE</code> or <code class="varname">LOCALBASE</code>.</p>
                   5730: <p>Usually, X11 packages should be installed under
                   5731:          <code class="varname">LOCALBASE</code> whenever possible.  Note that you will
1.76      rillig   5732:          need to include <code class="filename">../../mk/x11.buildlink3.mk</code>
1.75      rillig   5733:          in them to request the
                   5734:          presence of X11 and to get the right compilation flags.</p>
                   5735: <p>Even though, there are some packages that cannot be installed
                   5736:          under <code class="varname">LOCALBASE</code>: those that come with app-defaults
                   5737:          files. These packages are special and they must be placed under
                   5738:          <code class="varname">X11BASE</code>. To accomplish this, set either
                   5739:          <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
                   5740:          your package.</p>
                   5741: <p>Some notes: If you need
                   5742:          to find includes or libraries installed by a pkg that has
                   5743:          <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
1.76      rillig   5744:          its pkg <code class="filename">Makefile</code>, you need to look in
                   5745:          <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
                   5746:          <code class="filename">${LOCALBASE}</code>. To force installation of
1.75      rillig   5747:          all X11 packages in <code class="varname">LOCALBASE</code>, the
1.76      rillig   5748:          <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   5749:          is enabled by default.</p>
                   5750: </li>
                   5751: <li><p><code class="varname">X11PREFIX</code> should be used to refer to the installed
                   5752:          location of an X11 package. <code class="varname">X11PREFIX</code> will be set to
                   5753:          <code class="varname">X11BASE</code> if xpkgwedge is not installed,
                   5754:          and to <code class="varname">LOCALBASE</code> if xpkgwedge is installed.</p></li>
                   5755: <li>
                   5756: <p>If xpkgwedge is installed, it is possible to have some packages installed
                   5757:          in <code class="varname">X11BASE</code> and some in <code class="varname">LOCALBASE</code>.
                   5758:          To determine the prefix of an installed package, the
                   5759:          <code class="varname">EVAL_PREFIX</code> definition can be used. It takes pairs in the
                   5760:          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
                   5761:          <code class="varname">DIRNAME</code> will be set to the prefix of the installed
                   5762:          package &lt;package&gt;, or &#8220;<span class="quote">${X11PREFIX}</span>&#8221; if the package is
                   5763:          not installed.</p>
                   5764: <p>This is best illustrated by example.</p>
                   5765: <p>The following lines are taken from
1.76      rillig   5766:          <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75      rillig   5767: <pre class="programlisting">
                   5768:     EVAL_PREFIX+=           GTKDIR=gtk+
                   5769:     CONFIGURE_ARGS+=        --with-guile-prefix=${LOCALBASE:Q}
                   5770:     CONFIGURE_ARGS+=        --with-gtk-prefix=${GTKDIR:Q}
                   5771:     CONFIGURE_ARGS+=        --enable-multibyte
                   5772: </pre>
                   5773: <p>Specific defaults can be defined for the packages evaluated using
                   5774:          <code class="varname">EVAL_PREFIX</code>, by using a definition of the form:</p>
                   5775: <pre class="programlisting">
                   5776:     GTKDIR_DEFAULT= ${LOCALBASE}
                   5777: </pre>
                   5778: <p>where <code class="varname">GTKDIR</code> corresponds
                   5779:          to the first definition in
                   5780:          the <code class="varname">EVAL_PREFIX</code> pair.</p>
                   5781: </li>
1.76      rillig   5782: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.75      rillig   5783:           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   5784:           manual pages go into <code class="filename">${PREFIX}/man</code>, not
                   5785:           <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75      rillig   5786: </ul></div>
                   5787: </div>
                   5788: <div class="sect1" lang="en">
                   5789: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5790: <a name="build.builddirs"></a>15.3. Directories used during the build process</h2></div></div></div>
1.75      rillig   5791: <p>When building a package, a number of directories is used to store
                   5792: source files, temporary files, pkgsrc-internal files, and so on. These
                   5793: directories are explained here.</p>
                   5794: <p>Some of the directory variables contain relative pathnames. There
                   5795: are two common base directories for these relative directories:
                   5796: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
                   5797: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
                   5798: inside the package itself.</p>
                   5799: <div class="variablelist"><dl>
                   5800: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
                   5801: <dd><p>This is an absolute pathname that points to the pkgsrc
                   5802: root directory. Generally, you don't need
                   5803: it.</p></dd>
                   5804: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
                   5805: <dd><p>This is a pathname relative to
                   5806: <code class="varname">PKGSRCDIR</code> that points to the current
                   5807: package.</p></dd>
                   5808: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
                   5809: <dd><p>This is an absolute pathname pointing to the directory
                   5810: where all work takes place. The distfiles are extraced to this
                   5811: directory. It also contains temporary directories and log files used by
                   5812: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
                   5813: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
                   5814: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
                   5815: <dd><p>This is an absolute pathname pointing to the directory
                   5816: where the distfiles are extracted. It is usually a direct subdirectory
                   5817: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
                   5818: that isn't hidden. This variable may be changed by a package
1.76      rillig   5819: <code class="filename">Makefile</code>.</p></dd>
1.75      rillig   5820: </dl></div>
                   5821: </div>
                   5822: <div class="sect1" lang="en">
                   5823: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5824: <a name="build.running"></a>15.4. Running a phase</h2></div></div></div>
1.75      rillig   5825: <p>You can run a particular phase by typing <span><strong class="command">make
                   5826: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
                   5827: phase. This will automatically run all phases that are required for this
                   5828: phase. The default phase is <code class="varname">build</code>, that is, when you
                   5829: run <span><strong class="command">make</strong></span> without parameters in a package directory,
                   5830: the package will be built, but not installed.</p>
                   5831: </div>
                   5832: <div class="sect1" lang="en">
                   5833: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5834: <a name="build.fetch"></a>15.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.81      rillig   5835: <p>The first step in building a package is to fetch the
                   5836:        distribution files (distfiles) from the sites that are providing
                   5837:        them. This is the task of the <span class="emphasis"><em>fetch</em></span>
                   5838:        phase.</p>
                   5839: <div class="sect2" lang="en">
                   5840: <div class="titlepage"><div><div><h3 class="title">
                   5841: <a name="build.fetch.what"></a>15.5.1. What to fetch and where to get it from</h3></div></div></div>
                   5842: <p>In simple cases, <code class="varname">MASTER_SITES</code> defines
                   5843:        all URLs from where the distfile, whose name is derived from the
                   5844:        <code class="varname">DISTNAME</code> variable, is fetched. The more
                   5845:        complicated cases are described below.</p>
                   5846: <p>The variable <code class="varname">DISTFILES</code> specifies the
                   5847:        list of distfiles that have to be fetched. Its value defaults to
                   5848:        <code class="literal">${DISTNAME}${EXTRACT_SUFX}</code>, so that most
                   5849:        packages don't need to define it at all.
                   5850:        <code class="varname">EXTRACT_SUFX</code> is <code class="literal">.tar.gz</code> by
                   5851:        default, but can be changed freely. Note that if your package
                   5852:        requires additional distfiles to the default one, you cannot
                   5853:        just append the additional filenames using the
                   5854:        <code class="literal">+=</code> operator, but you have write for
                   5855:        example:</p>
                   5856: <pre class="programlisting">
                   5857:     DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   5858: </pre>
                   5859: <p>Each of the distfiles is fetched from a list of sites,
                   5860:        usually <code class="varname">MASTER_SITES</code>. If the package has
                   5861:        multiple <code class="varname">DISTFILES</code> or multiple
                   5862:        <code class="varname">PATCHFILES</code> from different sites, you can set
                   5863:        <code class="varname">SITES.<em class="replaceable"><code>distfile</code></em></code> to
                   5864:        the list of URLs where the file
                   5865:        <code class="filename"><em class="replaceable"><code>distfile</code></em></code>
                   5866:        (including the suffix) can be found.</p>
                   5867: <pre class="programlisting">
                   5868:     DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   5869:     DISTFILES+=     foo-file.tar.gz
                   5870:     SITES.foo-file.tar.gz= \
                   5871:             http://www.somewhere.com/somehow/ \
                   5872:             http://www.somewhereelse.com/mirror/somehow/
                   5873: </pre>
                   5874: <p>When actually fetching the distfiles, each item from
                   5875:        <code class="varname">MASTER_SITES</code> or <code class="varname">SITES.*</code>
                   5876:        gets the name of each distfile appended to it, without an
                   5877:        intermediate slash. Therefore, all site values have to end with
                   5878:        a slash or other separator character. This allows for example to
                   5879:        set <code class="varname">MASTER_SITES</code> to a URL of a CGI script
                   5880:        that gets the name of the distfile as a parameter. In this case,
                   5881:        the definition would look like:</p>
                   5882: <pre class="programlisting">
                   5883:     MASTER_SITES=   http://www.example.com/download.cgi?file=
                   5884: </pre>
                   5885: <p>There are some predefined values for
                   5886:        <code class="varname">MASTER_SITES</code>, which can be used in packages.
                   5887:        The names of the variables should speak for themselves.</p>
                   5888: <pre class="programlisting">
                   5889:     ${MASTER_SITE_APACHE}
                   5890:     ${MASTER_SITE_BACKUP}
                   5891:     ${MASTER_SITE_CYGWIN}
                   5892:     ${MASTER_SITE_DEBIAN}
                   5893:     ${MASTER_SITE_FREEBSD}
                   5894:     ${MASTER_SITE_FREEBSD_LOCAL}
                   5895:     ${MASTER_SITE_GNOME}
                   5896:     ${MASTER_SITE_GNU}
                   5897:     ${MASTER_SITE_GNUSTEP}
                   5898:     ${MASTER_SITE_IFARCHIVE}
                   5899:     ${MASTER_SITE_KDE}
                   5900:     ${MASTER_SITE_MOZILLA}
                   5901:     ${MASTER_SITE_MYSQL}
                   5902:     ${MASTER_SITE_OPENOFFICE}
                   5903:     ${MASTER_SITE_PERL_CPAN}
                   5904:     ${MASTER_SITE_PGSQL}
                   5905:     ${MASTER_SITE_R_CRAN}
                   5906:     ${MASTER_SITE_SOURCEFORGE}
                   5907:     ${MASTER_SITE_SOURCEFORGE_JP}
                   5908:     ${MASTER_SITE_SUNSITE}
                   5909:     ${MASTER_SITE_SUSE}
                   5910:     ${MASTER_SITE_TEX_CTAN}
                   5911:     ${MASTER_SITE_XCONTRIB}
                   5912:     ${MASTER_SITE_XEMACS}
                   5913: </pre>
                   5914: <p>If you choose one of these predefined sites, you may want
                   5915:        to specify a subdirectory of that site. Since these macros may
                   5916:        expand to more than one actual site, you
                   5917:        <span class="emphasis"><em>must</em></span> use the following construct to specify
                   5918:        a subdirectory:</p>
                   5919: <pre class="programlisting">
                   5920:     MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   5921:     MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
                   5922: </pre>
                   5923: <p>Note the trailing slash after the subdirectory
                   5924:        name.</p>
                   5925: </div>
                   5926: <div class="sect2" lang="en">
                   5927: <div class="titlepage"><div><div><h3 class="title">
                   5928: <a name="build.fetch.how"></a>15.5.2. How are the files fetched?</h3></div></div></div>
                   5929: <p>The <span class="emphasis"><em>fetch</em></span> phase makes sure that all
                   5930:        the distfiles exist in a local directory
                   5931:        (<code class="varname">DISTDIR</code>), which can be set by the pkgsrc
                   5932:        user). If the files do not exist, they are fetched using
                   5933:        commands of the form
                   5934: 
                   5935: </p>
1.75      rillig   5936: <pre class="programlisting">
                   5937:     ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
                   5938: </pre>
1.81      rillig   5939: <p>
                   5940: 
                   5941:        where <code class="literal">${site}</code> varies through several
                   5942:        possibilities in turn: first,
                   5943:        <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the sites
                   5944:        specified in either <code class="varname">SITES.file</code> if defined,
                   5945:        else <code class="varname">MASTER_SITES</code> or
                   5946:        <code class="varname">PATCH_SITES</code>, as applies, then finally the
                   5947:        value of <code class="varname">MASTER_SITE_BACKUP</code>. The order of all
                   5948:        except the first can be optionally sorted by the user, via
                   5949:        setting either <code class="varname">MASTER_SORT_AWK</code> or
                   5950:        <code class="varname">MASTER_SORT_REGEX</code>.</p>
                   5951: </div>
1.75      rillig   5952: </div>
                   5953: <div class="sect1" lang="en">
                   5954: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5955: <a name="build.checksum"></a>15.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.75      rillig   5956: <p>After the distfile(s) are fetched, their checksum is generated and
                   5957:            compared with the checksums stored in the distinfo file. If the
                   5958:            checksums don't match, the build is aborted. This is to ensure the same
                   5959:            distfile is used for building, and that the distfile wasn't changed,
                   5960:            e.g. by some malign force, deliberately changed distfiles on the master
                   5961:            distribution site or network lossage.</p>
                   5962: </div>
                   5963: <div class="sect1" lang="en">
                   5964: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   5965: <a name="build.extract"></a>15.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75      rillig   5966: <p>When the distfiles are present on the local system, they
                   5967:        need to be extracted, as they usually come in the form of some
                   5968:        compressed archive format.</p>
                   5969: <p>By default, all <code class="varname">DISTFILES</code> are
                   5970:        extracted. If you only need some of them, you can set the
                   5971:        <code class="varname">EXTRACT_ONLY</code> variable to the list of those
                   5972:        files.</p>
                   5973: <p>Extracting the files is usually done by a little program,
1.76      rillig   5974:        <code class="filename">mk/scripts/extract</code>, which already knows how
1.75      rillig   5975:        to extract various archive formats, so most likely you will not
                   5976:        need to change anything here. But if you need, the following
                   5977:        variables may help you:</p>
                   5978: <div class="variablelist"><dl>
                   5979: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
                   5980: <dd><p>Use these variables to override the default
                   5981:        options for an extract command, which are defined in
1.76      rillig   5982:        <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75      rillig   5983: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
                   5984: <dd><p>This variable can be set to
                   5985:        <code class="literal">pax</code>, <code class="literal">tar</code> or an absolute
                   5986:        pathname pointing to the command with which tar archives should
                   5987:        be extracted.</p></dd>
                   5988: </dl></div>
1.76      rillig   5989: <p>If the <code class="filename">extract</code> program doesn't serve
1.75      rillig   5990:        your needs, you can also override the
                   5991:        <code class="varname">EXTRACT_CMD</code> variable, which holds the command
                   5992:        used for extracting the files. This command is executed in the
1.76      rillig   5993:        <code class="filename">${WRKSRC}</code> directory. During execution of
1.75      rillig   5994:        this command, the shell variable <code class="varname">extract_file</code>
                   5995:        holds the absolute pathname of the file that is going to be
                   5996:        extracted.</p>
                   5997: <p>And if that still does not suffice, you can override the
                   5998:        <code class="varname">do-extract</code> target in the package
                   5999:        Makefile.</p>
                   6000: </div>
                   6001: <div class="sect1" lang="en">
                   6002: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6003: <a name="build.patch"></a>15.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75      rillig   6004: <p>After extraction, all the patches named by the
                   6005:            <code class="varname">PATCHFILES</code>, those present in the patches
                   6006:            subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
1.76      rillig   6007:            <code class="filename">/usr/local/patches/graphics/png</code>) are applied.
                   6008:            Patchfiles ending in <code class="filename">.Z</code> or
                   6009:            <code class="filename">.gz</code> are uncompressed before they are applied,
                   6010:            files ending in <code class="filename">.orig</code> or
                   6011:            <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   6012:            can be handed in <code class="varname">PATCH_DIST_ARGS</code>.
1.77      rillig   6013:            See <a href="#components.patches" title="9.3. patches/*">Section 9.3, &#8220;patches/*&#8221;</a> for more details.</p>
1.75      rillig   6014: <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
                   6015:            patches apply with some lines of fuzz. Please fix (regen) the patches
                   6016:            so that they apply cleanly. The rationale behind this is that
                   6017:            patches that don't apply cleanly may end up being applied in the wrong
                   6018:            place, and cause severe harm there.</p>
                   6019: </div>
                   6020: <div class="sect1" lang="en">
                   6021: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6022: <a name="build.tools"></a>15.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.75      rillig   6023: <p>This is covered in
1.77      rillig   6024: <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   6025: </p>
                   6026: </div>
                   6027: <div class="sect1" lang="en">
                   6028: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6029: <a name="build.wrapper"></a>15.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75      rillig   6030: <p>This phase creates wrapper programs for the compilers and
                   6031:        linkers. The following variables can be used to tweak the
                   6032:        wrappers.</p>
                   6033: <div class="variablelist"><dl>
                   6034: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
                   6035: <dd><p>The command used to print progress
                   6036:                messages. Does nothing by default. Set to
                   6037:                <code class="literal">${ECHO}</code> to see the progress
                   6038:                messages.</p></dd>
                   6039: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
                   6040: <dd><p>This variable can be set to
                   6041:                <code class="literal">yes</code> (default) or
                   6042:                <code class="literal">no</code>, depending on whether you want
                   6043:                additional information in the wrapper log
                   6044:                file.</p></dd>
                   6045: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
                   6046: <dd><p>This variable can be set to
                   6047:                <code class="literal">yes</code> or <code class="literal">no</code>,
                   6048:                depending on whether the wrapper should use its cache,
                   6049:                which will improve the speed. The default value is
                   6050:                <code class="literal">yes</code>, but is forced to
                   6051:                <code class="literal">no</code> if the platform does not support
                   6052:                it.</p></dd>
                   6053: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
                   6054: <dd><p>A list of reordering commands. A
                   6055:                reordering command has the form
                   6056:                <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
                   6057:                It ensures that that
                   6058:                <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code>
                   6059:                occurs before
                   6060:                <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
                   6061:                </p></dd>
                   6062: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
                   6063: <dd><p>A list of transformation commands. [TODO:
                   6064:                investigate further]</p></dd>
                   6065: </dl></div>
                   6066: </div>
                   6067: <div class="sect1" lang="en">
                   6068: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6069: <a name="build.configure"></a>15.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75      rillig   6070: <p>Most pieces of software need information on the header files,
                   6071: system calls, and library routines which are available on the platform
                   6072: they run on. The process of determining this information is known as
                   6073: configuration, and is usually automated. In most cases, a script is
                   6074: supplied with the distfiles, and its invocation results in generation of
                   6075: header files, Makefiles, etc.</p>
                   6076: <p>If the package contains a configure script, this can be invoked by
                   6077: setting <code class="varname">HAS_CONFIGURE</code> to &#8220;<span class="quote">yes</span>&#8221;. If the
                   6078: configure script is a GNU autoconf script, you should set
                   6079: <code class="varname">GNU_CONFIGURE</code> to &#8220;<span class="quote">yes</span>&#8221; instead. What
                   6080: happens in the <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
                   6081: <pre class="programlisting">
                   6082:     .for d in ${CONFIGURE_DIRS}
                   6083:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${CONFIGURE_ENV} \
                   6084:                 ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
                   6085:     .endfor
                   6086: </pre>
                   6087: <p><code class="varname">CONFIGURE_DIRS</code> (default: &#8220;<span class="quote">.</span>&#8221;) is a
                   6088: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
                   6089: these directories, the configure script is run with the environment
                   6090: <code class="varname">CONFIGURE_ENV</code> and arguments
                   6091: <code class="varname">CONFIGURE_ARGS</code>. The variables
                   6092: <code class="varname">CONFIGURE_ENV</code>, <code class="varname">CONFIGURE_SCRIPT</code>
                   6093: (default: &#8220;<span class="quote">./configure</span>&#8221;) and
                   6094: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
                   6095: package.</p>
1.76      rillig   6096: <p>If the program uses an <code class="filename">Imakefile</code> for
1.75      rillig   6097: configuration, the appropriate steps can be invoked by setting
                   6098: <code class="varname">USE_IMAKE</code> to &#8220;<span class="quote">yes</span>&#8221;. (If you only want
                   6099: the package installed in <code class="varname">${X11PREFIX}</code> but xmkmf not
                   6100: being run, set <code class="varname">USE_X11BASE</code> instead.)</p>
                   6101: </div>
                   6102: <div class="sect1" lang="en">
                   6103: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6104: <a name="build.build"></a>15.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.75      rillig   6105: <p>For building a package, a rough equivalent of the following code
                   6106: is executed.</p>
                   6107: <pre class="programlisting">
                   6108:     .for d in ${BUILD_DIRS}
                   6109:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${MAKE_ENV} \
                   6110:                 ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
                   6111:                     -f ${MAKEFILE} ${BUILD_TARGET}
                   6112:     .endfor
                   6113: </pre>
                   6114: <p><code class="varname">BUILD_DIRS</code> (default: &#8220;<span class="quote">.</span>&#8221;) is a
                   6115: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
                   6116: these directories, <code class="varname">MAKE_PROGRAM</code> is run with the
                   6117: environment <code class="varname">MAKE_ENV</code> and arguments
                   6118: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
                   6119: <code class="varname">MAKE_ENV</code>, <code class="varname">BUILD_MAKE_FLAGS</code>,
                   6120: <code class="varname">MAKEFILE</code> and <code class="varname">BUILD_TARGET</code> may all
                   6121: be changed by the package.</p>
                   6122: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
                   6123: &#8220;<span class="quote">gmake</span>&#8221; if <code class="varname">USE_TOOLS</code> contains
                   6124: &#8220;<span class="quote">gmake</span>&#8221;, &#8220;<span class="quote">make</span>&#8221; otherwise. The default value
                   6125: of <code class="varname">MAKEFILE</code> is &#8220;<span class="quote">Makefile</span>&#8221;, and
                   6126: <code class="varname">BUILD_TARGET</code> defaults to &#8220;<span class="quote">all</span>&#8221;.</p>
                   6127: </div>
                   6128: <div class="sect1" lang="en">
                   6129: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6130: <a name="build.test"></a>15.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75      rillig   6131: <p>[TODO]</p>
                   6132: </div>
                   6133: <div class="sect1" lang="en">
                   6134: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6135: <a name="build.install"></a>15.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75      rillig   6136: <p>Once the build stage has completed, the final step is to
                   6137:        install the software in public directories, so users can access
                   6138:        the programs and files.</p>
                   6139: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
                   6140:        equivalent of the following code is executed. Additionally,
                   6141:        before and after this code, much magic is performed to do
                   6142:        consistency checks, registering the package, and so on.</p>
                   6143: <pre class="programlisting">
                   6144:     .for d in ${INSTALL_DIRS}
                   6145:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${MAKE_ENV} \
                   6146:                 ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
                   6147:                     -f ${MAKEFILE} ${BUILD_TARGET}
                   6148:     .endfor
                   6149: </pre>
                   6150: <p>The variable's meanings are analogous to the ones in the
                   6151:        <span class="emphasis"><em>build</em></span> phase.
                   6152:        <code class="varname">INSTALL_DIRS</code> defaults to
                   6153:        <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
                   6154:        is &#8220;<span class="quote">install</span>&#8221; by default, plus
                   6155:        &#8220;<span class="quote">install.man</span>&#8221; if <code class="varname">USE_IMAKE</code> is
                   6156:        defined.</p>
                   6157: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
                   6158:        variables are useful. They are all variations of the
                   6159:        <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
                   6160:        permissions preset. <code class="varname">INSTALL</code> is the plain
                   6161:        install command. The specialized variants, together with their
                   6162:        intended use, are:</p>
                   6163: <div class="variablelist"><dl>
                   6164: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
                   6165: <dd><p>directories that contain binaries</p></dd>
                   6166: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
                   6167: <dd><p>directories that contain scripts</p></dd>
                   6168: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
                   6169: <dd><p>directories that contain shared and static libraries</p></dd>
                   6170: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
                   6171: <dd><p>directories that contain data files</p></dd>
                   6172: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
                   6173: <dd><p>directories that contain man pages</p></dd>
                   6174: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
                   6175: <dd><p>binaries that can be stripped from debugging symbols</p></dd>
                   6176: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
                   6177: <dd><p>binaries that cannot be stripped</p></dd>
                   6178: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
                   6179: <dd><p>game binaries</p></dd>
                   6180: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
                   6181: <dd><p>shared and static libraries</p></dd>
                   6182: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
                   6183: <dd><p>data files</p></dd>
                   6184: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
                   6185: <dd><p>data files for games</p></dd>
                   6186: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
                   6187: <dd><p>man pages</p></dd>
                   6188: </dl></div>
                   6189: <p>Some other variables are:</p>
                   6190: <div class="variablelist"><dl>
                   6191: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
                   6192: <dd><p>A list of directories relative to
                   6193:                <code class="varname">PREFIX</code> that are created by pkgsrc at
1.78      rillig   6194:                the beginning of the <span class="emphasis"><em>install</em></span> phase.
                   6195:                If this variable is set,
1.75      rillig   6196:                <code class="varname">NO_MTREE</code>=&#8220;<span class="quote">yes</span>&#8221; is
                   6197:                assumed, which means that the package claims to create
                   6198:                all needed directories itself before installing files to
                   6199:                it. Therefore this variable should only be set in
1.76      rillig   6200:                <code class="filename">Makefile</code>s that are under control of
1.78      rillig   6201:                the package's author. The directories are created with
                   6202:                the correct ownership, depending on their
                   6203:                name.</p></dd>
1.75      rillig   6204: </dl></div>
                   6205: </div>
                   6206: <div class="sect1" lang="en">
                   6207: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6208: <a name="build.package"></a>15.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.75      rillig   6209: <p>[TODO]</p>
                   6210: </div>
                   6211: <div class="sect1" lang="en">
                   6212: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6213: <a name="build.helpful-targets"></a>15.16. Other helpful targets</h2></div></div></div>
1.75      rillig   6214: <div class="variablelist"><dl>
                   6215: <dt><span class="term">pre/post-*</span></dt>
                   6216: <dd><p>For any of the main targets described in the previous section, two
                   6217:            auxiliary targets exist with &#8220;<span class="quote">pre-</span>&#8221; and
                   6218:            &#8220;<span class="quote">post-</span>&#8221; used as a prefix
                   6219:            for the main target's name.  These targets are invoked before and
                   6220:            after the main target is called, allowing extra configuration or
                   6221:            installation steps be performed from a package's Makefile, for
                   6222:            example, which a program's configure script
                   6223:            or install target omitted.</p></dd>
                   6224: <dt><span class="term">do-*</span></dt>
                   6225: <dd><p>Should one of the main targets do the wrong thing, and should there
                   6226:            be no variable to fix this, you can redefine it with the do-*
                   6227:            target.  (Note that redefining the target itself instead of the
                   6228:            do-* target is a bad idea, as the pre-* and post-* targets won't be
                   6229:            called anymore, etc.) You will not usually need to do this.</p></dd>
                   6230: <dt><span class="term">reinstall</span></dt>
                   6231: <dd><p>If you did a <span><strong class="command">make install</strong></span> and you noticed some file
                   6232:            was not installed properly, you can repeat the installation with this
                   6233:            target, which will ignore the &#8220;<span class="quote">already installed</span>&#8221; flag.</p></dd>
                   6234: <dt><span class="term">deinstall</span></dt>
                   6235: <dd>
                   6236: <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,
                   6237:            effectively de-installing the package. The following variables can
                   6238:            be used to tune the behaviour:</p>
                   6239: <div class="variablelist"><dl>
                   6240: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
                   6241: <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>
                   6242: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
                   6243: <dd><p>Remove all packages that require (depend on) the given package.
                   6244:                  This can be used to remove any packages that may have been pulled in
                   6245:                  by a given package, e.g. if <span><strong class="command">make deinstall
                   6246:                    DEINSTALLDEPENDS=1</strong></span> is done in
1.76      rillig   6247:                  <code class="filename">pkgsrc/x11/kde</code>, this is likely to remove whole
1.75      rillig   6248:                  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>
                   6249: </dl></div>
                   6250: </dd>
                   6251: <dt><span class="term">update</span></dt>
                   6252: <dd>
                   6253: <p>This target causes the current package to be updated to the latest
                   6254:            version.  The package and all depending packages first get de-installed,
                   6255:            then current versions of the corresponding packages get compiled and
                   6256:            installed.  This is similar to manually noting which packages are
                   6257:            currently installed, then performing a series of <span><strong class="command">make
                   6258:              deinstall</strong></span> and <span><strong class="command">make install</strong></span> (or whatever
                   6259:            <code class="varname">UPDATE_TARGET</code> is set to) for these packages.</p>
                   6260: <p>You can use the &#8220;<span class="quote">update</span>&#8221; target to resume package
                   6261:            updating in case a previous <span><strong class="command">make update</strong></span> was interrupted
                   6262:            for some reason.  However, in this case, make sure you don't call
                   6263:            <span><strong class="command">make clean</strong></span> or otherwise remove the list of dependent
                   6264:            packages in <code class="varname">WRKDIR</code>.  Otherwise, you lose the
                   6265:            ability to automatically update the current package along with the
                   6266:            dependent packages you have installed.</p>
                   6267: <p>Resuming an interrupted <span><strong class="command">make update</strong></span> will only work as
                   6268:            long as the package tree remains unchanged.  If the source code for
                   6269:            one of the packages to be updated has been changed, resuming
                   6270:            <span><strong class="command">make update</strong></span> will most certainly fail!</p>
                   6271: <p>The following variables can be used either on the command line or in
1.76      rillig   6272:            <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75      rillig   6273:            <span><strong class="command">make update</strong></span>:</p>
                   6274: <div class="variablelist"><dl>
                   6275: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
                   6276: <dd><p>Install target to recursively use for the updated package and the
                   6277:                  dependent packages.  Defaults to <code class="varname">DEPENDS_TARGET</code> if set,
                   6278:                  &#8220;<span class="quote">install</span>&#8221; otherwise for <span><strong class="command">make update</strong></span>.
                   6279:                  e.g. <span><strong class="command">make update UPDATE_TARGET=package</strong></span></p></dd>
                   6280: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
                   6281: <dd><p>Don't clean up after updating.  Useful if you want to leave the
                   6282:                  work sources of the updated packages around for inspection or
                   6283:                  other purposes.  Be sure you eventually clean up the source
                   6284:                  tree (see the &#8220;<span class="quote">clean-update</span>&#8221; target below) or you may
                   6285:                  run into troubles with old source code still lying around on your
                   6286:                  next <span><strong class="command">make</strong></span> or <span><strong class="command">make update</strong></span>.</p></dd>
                   6287: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
                   6288: <dd><p>Deinstall each package before installing (making
                   6289:                  <code class="varname">DEPENDS_TARGET</code>). This may be necessary if the
                   6290:                  &#8220;<span class="quote">clean-update</span>&#8221; target (see below) was called after
                   6291:                  interrupting a running <span><strong class="command">make update</strong></span>.</p></dd>
                   6292: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
                   6293: <dd><p>Allows you to disable recursion and hardcode the target for
                   6294:                  packages.  The default is &#8220;<span class="quote">update</span>&#8221; for the update target,
                   6295:                  facilitating a recursive update of prerequisite packages.
                   6296:                  Only set <code class="varname">DEPENDS_TARGET</code> if you want to disable
                   6297:                  recursive updates. Use <code class="varname">UPDATE_TARGET</code> instead to just
                   6298:                  set a specific target for each package to be installed during
                   6299:                  <span><strong class="command">make update</strong></span> (see above).</p></dd>
                   6300: </dl></div>
                   6301: </dd>
                   6302: <dt><span class="term">clean-update</span></dt>
                   6303: <dd>
                   6304: <p>Clean the source tree for all packages that would get updated if
                   6305:            <span><strong class="command">make update</strong></span> was called from the current directory.
                   6306:            This target should not be used if the current package (or any of its
                   6307:            depending packages) have already been de-installed (e.g., after calling
                   6308:            <span><strong class="command">make update</strong></span>) or you may lose some packages you intended
                   6309:            to update. As a rule of thumb: only use this target
                   6310:            <span class="emphasis"><em>before</em></span> the first time you run
                   6311:            <span><strong class="command">make update</strong></span> and only if you have a dirty package tree
                   6312:            (e.g., if you used <code class="varname">NOCLEAN</code>).</p>
                   6313: <p>If you are unsure about whether your tree is clean, you can either
                   6314:            perform a <span><strong class="command">make clean</strong></span> at the top of the tree, or use
                   6315:            the following sequence of commands from the directory of the package
                   6316:            you want to update (<span class="emphasis"><em>before</em></span> running
                   6317:            <span><strong class="command">make update</strong></span> for the first time, otherwise you lose
                   6318:            all the packages you wanted to update!):</p>
                   6319: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
                   6320: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
                   6321: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong></pre>
                   6322: <p>The following variables can be used either on the command line or in
1.76      rillig   6323:            <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75      rillig   6324:            <span><strong class="command">make clean-update</strong></span>:</p>
                   6325: <div class="variablelist"><dl>
                   6326: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
                   6327: <dd><p>After <span><strong class="command">make clean</strong></span>, do not reconstruct the list of
                   6328:                  directories to update for this package.  Only use this if <span><strong class="command">make
                   6329:                    update</strong></span> successfully installed all packages you wanted to
                   6330:                  update.  Normally, this is done automatically on <span><strong class="command">make
                   6331:                    update</strong></span>, but may have been suppressed by the
                   6332:                  <code class="varname">NOCLEAN</code> variable (see above).</p></dd>
                   6333: </dl></div>
                   6334: </dd>
                   6335: <dt><span class="term">info</span></dt>
                   6336: <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
                   6337:            package. You can use this to check which version of a package is
                   6338:            installed.</p></dd>
                   6339: <dt><span class="term">readme</span></dt>
1.76      rillig   6340: <dd><p>This target generates a <code class="filename">README.html</code> file, which
1.75      rillig   6341:            can be viewed using a browser such as
1.83    ! wiz      6342:            <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   6343:            <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   6344:            The generated files contain references to any
                   6345:            packages which are in the <code class="varname">PACKAGES</code> directory on
                   6346:            the local host. The generated files can be made to refer to URLs based on
                   6347:            <code class="varname">FTP_PKG_URL_HOST</code> and
                   6348:            <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I wanted to generate
1.76      rillig   6349:            <code class="filename">README.html</code> files which pointed to binary packages
1.75      rillig   6350:            on the local machine, in the directory
1.76      rillig   6351:            <code class="filename">/usr/packages</code>, set
1.75      rillig   6352:            <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
                   6353:            <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
                   6354:            <code class="varname">${PACKAGES}</code> directory and its subdirectories will be
                   6355:            searched for all the binary packages.</p></dd>
                   6356: <dt><span class="term">readme-all</span></dt>
1.76      rillig   6357: <dd><p>Use this target to create a file <code class="filename">README-all.html</code>
1.75      rillig   6358:            which contains a list of all packages currently available in the NetBSD
                   6359:            Packages Collection, together with the category they belong to and a
                   6360:            short description. This file is compiled from the
1.76      rillig   6361:            <code class="filename">pkgsrc/*/README.html</code> files, so be sure to run
1.75      rillig   6362:            this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make readme</strong></span>.</p></dd>
                   6363: <dt><span class="term">cdrom-readme</span></dt>
                   6364: <dd><p>This is very much the same as the &#8220;<span class="quote">readme</span>&#8221; target (see
                   6365:            above), but is to be used when generating a pkgsrc tree to be written
                   6366:            to a CD-ROM.  This target also produces
1.76      rillig   6367:            <code class="filename">README.html</code> files, and can be made to refer
1.75      rillig   6368:            to URLs based on <code class="varname">CDROM_PKG_URL_HOST</code> and
                   6369:            <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
                   6370: <dt><span class="term">show-distfiles</span></dt>
                   6371: <dd><p>This target shows which distfiles and patchfiles are needed to build
                   6372:            the package. (<code class="varname">DISTFILES</code> and
1.76      rillig   6373:            <code class="varname">PATCHFILES</code>, but not <code class="filename">patches/*</code>)</p></dd>
1.75      rillig   6374: <dt><span class="term">show-downlevel</span></dt>
                   6375: <dd><p>This target shows nothing if the package is not installed. If a version
                   6376:            of this package is installed, but is not the version provided in this
                   6377:            version of pkgsrc, then a warning message is displayed. This target can
                   6378:            be used to show which of your installed packages are downlevel, and so
                   6379:            the old versions can be deleted, and the current ones added.</p></dd>
                   6380: <dt><span class="term">show-pkgsrc-dir</span></dt>
                   6381: <dd><p>This target shows the directory in the pkgsrc hierarchy from which the
                   6382:            package can be built and installed. This may not be the same directory
                   6383:            as the one from which the package was installed. This target is intended
                   6384:            to be used by people who may wish to upgrade many packages on a single
                   6385:            host, and can be invoked from the top-level pkgsrc Makefile by using the
                   6386:            &#8220;<span class="quote">show-host-specific-pkgs</span>&#8221; target.</p></dd>
                   6387: <dt><span class="term">show-installed-depends</span></dt>
                   6388: <dd><p>This target shows which installed packages match the current package's
                   6389:            <code class="varname">DEPENDS</code>. Useful if out of date dependencies are
                   6390:            causing build problems.</p></dd>
                   6391: <dt><span class="term">check-shlibs</span></dt>
                   6392: <dd><p>After a package is installed, check all its binaries and (on ELF
                   6393:            platforms) shared libraries to see if they find the shared libs they need.
                   6394:            Run by default if <code class="varname">PKG_DEVELOPER</code> is set in
1.76      rillig   6395:            <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75      rillig   6396: <dt><span class="term">print-PLIST</span></dt>
                   6397: <dd>
                   6398: <p>After a &#8220;<span class="quote">make install</span>&#8221; from a new or
                   6399:            upgraded pkg, this prints out an attempt to generate a new
1.76      rillig   6400:            <code class="filename">PLIST</code> from a <span><strong class="command">find -newer
1.75      rillig   6401:            work/.extract_done</strong></span>.  An attempt is made to care
                   6402:            for shared libs etc., but it is
                   6403:            <span class="emphasis"><em>strongly</em></span> recommended to review the
                   6404:            result before putting it into
1.76      rillig   6405:            <code class="filename">PLIST</code>. On upgrades, it's useful to
1.75      rillig   6406:            diff the output of this command against an already
1.76      rillig   6407:            existing <code class="filename">PLIST</code> file.</p>
1.75      rillig   6408: <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
                   6409:            methods that don't update file access times, be sure to
                   6410:            add these files manually to your
1.76      rillig   6411:            <code class="filename">PLIST</code>, as the &#8220;<span class="quote">find
1.75      rillig   6412:            -newer</span>&#8221; command used by this target won't catch
                   6413:            them!</p>
1.77      rillig   6414: <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   6415:            information on this target.</p>
                   6416: </dd>
                   6417: <dt><span class="term">bulk-package</span></dt>
                   6418: <dd>
                   6419: <p>Used to do bulk builds. If an appropriate binary package already exists,
                   6420:            no action is taken. If not, this target will compile, install and
                   6421:            package it (and its depends, if <code class="varname">PKG_DEPENDS</code> is
                   6422:            set properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, &#8220;Configuration&#8221;</a>).
                   6423:            After creating the binary
                   6424:            package, the sources, the just-installed package and its required
                   6425:            packages are removed, preserving free disk space.</p>
                   6426: <p><span class="emphasis"><em>Beware that this target may deinstall all
                   6427:            packages installed on a system!</em></span></p>
                   6428: </dd>
                   6429: <dt><span class="term">bulk-install</span></dt>
                   6430: <dd>
                   6431: <p>Used during bulk-installs to install required packages. If an
                   6432:            up-to-date binary package is available, it will be installed via
                   6433:            <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,
                   6434:            but the installed binary won't be removed. </p>
                   6435: <p> A binary package is considered &#8220;<span class="quote">up-to-date</span>&#8221; to be
                   6436:            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>
                   6437: <div class="itemizedlist"><ul type="disc">
1.76      rillig   6438: <li><p>None of the package's files (<code class="filename">Makefile</code>,
1.75      rillig   6439:                ...) were modified since it was built.</p></li>
                   6440: <li><p>None of the package's required (binary) packages were
                   6441:                modified since it was built.</p></li>
                   6442: </ul></div>
                   6443: <p><span class="emphasis"><em>Beware that this target may deinstall all
                   6444:            packages installed on a system!</em></span></p>
                   6445: </dd>
                   6446: </dl></div>
                   6447: </div>
                   6448: </div>
                   6449: <div class="chapter" lang="en">
                   6450: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   6451: <a name="tools"></a>Chapter 16. Tools needed for building or running</h2></div></div></div>
1.75      rillig   6452: <div class="toc">
                   6453: <p><b>Table of Contents</b></p>
                   6454: <dl>
1.77      rillig   6455: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
                   6456: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
                   6457: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
1.75      rillig   6458: </dl>
                   6459: </div>
                   6460: <p>
                   6461: The <code class="varname">USE_TOOLS</code> definition is used both internally
                   6462: by pkgsrc and also for individual packages to define what commands
                   6463: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
                   6464: or for later run-time of an installed packaged (such as
                   6465: <code class="varname">DEPENDS</code>).
                   6466: If the native system provides an adequate tool, then in many cases, a pkgsrc
                   6467: package will not be used.
                   6468: </p>
                   6469: <p>
                   6470: When building a package, the replacement tools are
                   6471: made available in a directory (as symlinks or wrapper scripts)
                   6472: that is early in the executable search path. Just like the buildlink
                   6473: system, this helps with consistent builds.
                   6474: </p>
                   6475: <p>
                   6476: A tool may be needed to help build a specific package. For example,
                   6477: perl, GNU make (gmake) or yacc may be needed.
                   6478: </p>
                   6479: <p>
                   6480: Also a tool may be needed, for example, because the native system's supplied
                   6481: tool may be inefficient for building a package with pkgsrc.
                   6482: For example, a package may need GNU awk, bison (instead of
                   6483: yacc) or a better sed.
                   6484: </p>
                   6485: <p>
                   6486: The tools used by a package can be listed by running
                   6487: <span><strong class="command">make show-tools</strong></span>.
                   6488: </p>
                   6489: <div class="sect1" lang="en">
                   6490: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6491: <a name="pkgsrc-tools"></a>16.1. Tools for pkgsrc builds</h2></div></div></div>
1.75      rillig   6492: <p>
                   6493: The default set of tools used by pkgsrc is defined in
1.76      rillig   6494: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75      rillig   6495: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
                   6496: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
                   6497: These can be seen by running:
                   6498: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.
                   6499: </p>
                   6500: <p>
                   6501: If a package needs a specific program to build
                   6502: then the <code class="varname">USE_TOOLS</code> variable can be used
                   6503: to define the tools needed.
                   6504: </p>
                   6505: </div>
                   6506: <div class="sect1" lang="en">
                   6507: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6508: <a name="package-tools"></a>16.2. Tools needed by packages</h2></div></div></div>
1.75      rillig   6509: <p>
                   6510: In the following examples, the :pkgsrc means to use the pkgsrc version
                   6511: and not the native version for a build dependency.
                   6512: And the :run means that it is used for a
                   6513: run-time dependencies also (and becomes a DEPENDS).
                   6514: The default is a build dependency which can be set with
                   6515: :build. (So in this example, it is the same as gmake:build
                   6516: and pkg-config:build.)
                   6517: </p>
                   6518: <pre class="programlisting">
                   6519: USE_TOOLS+=     mktemp:pkgsrc
                   6520: USE_TOOLS+=     gmake perl:run pkg-config
                   6521: </pre>
                   6522: <p>
                   6523: When using the tools framework, a
                   6524: <code class="varname">TOOLS_PATH.foo</code> variable is defined
                   6525: which contains the full path to the appropriate tool. For example,
                   6526: <code class="varname">TOOLS_PATH.bash</code> could be &#8220;<span class="quote">/bin/bash</span>&#8221;
                   6527: on Linux systems.
                   6528: </p>
                   6529: <p>
                   6530: If you always need a pkgsrc version of the
                   6531: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
                   6532: 
                   6533: </p>
                   6534: </div>
                   6535: <div class="sect1" lang="en">
                   6536: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6537: <a name="platform-tools"></a>16.3. Tools provided by platforms</h2></div></div></div>
1.75      rillig   6538: <p>
                   6539: When improving or porting pkgsrc to a new platform, have a look
                   6540: at (or create) the corresponding platform specific make file fragment under
1.76      rillig   6541: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75      rillig   6542: the name of the common tools. For example:</p>
                   6543: <pre class="programlisting">
                   6544: .if exists(/usr/bin/bzcat)
                   6545: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   6546: .elif exists(/usr/bin/bzip2)
                   6547: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   6548: .endif
1.69      rillig   6549: 
1.75      rillig   6550: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   6551: </pre>
                   6552: </div>
                   6553: </div>
                   6554: <div class="chapter" lang="en">
                   6555: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   6556: <a name="fixes"></a>Chapter 17. Making your package work</h2></div></div></div>
1.75      rillig   6557: <div class="toc">
                   6558: <p><b>Table of Contents</b></p>
                   6559: <dl>
1.77      rillig   6560: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
1.75      rillig   6561: <dd><dl>
1.78      rillig   6562: <dt><span class="sect2"><a href="#portability-of-packages">17.1.1. Portability of packages</a></span></dt>
                   6563: <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>
                   6564: <dt><span class="sect2"><a href="#user-interaction">17.1.3. User interaction</a></span></dt>
                   6565: <dt><span class="sect2"><a href="#handling-licenses">17.1.4. Handling licenses</a></span></dt>
                   6566: <dt><span class="sect2"><a href="#restricted-packages">17.1.5. Restricted packages</a></span></dt>
                   6567: <dt><span class="sect2"><a href="#dependencies">17.1.6. Handling dependencies</a></span></dt>
                   6568: <dt><span class="sect2"><a href="#conflicts">17.1.7. Handling conflicts with other packages</a></span></dt>
                   6569: <dt><span class="sect2"><a href="#not-building-packages">17.1.8. Packages that cannot or should not be built</a></span></dt>
                   6570: <dt><span class="sect2"><a href="#undeletable-packages">17.1.9. Packages which should not be deleted, once installed</a></span></dt>
                   6571: <dt><span class="sect2"><a href="#security-handling">17.1.10. Handling packages with security problems</a></span></dt>
                   6572: <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   6573: <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   6574: </dl></dd>
                   6575: <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>
                   6576: <dd><dl>
                   6577: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
                   6578: <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>
                   6579: </dl></dd>
                   6580: <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>
                   6581: <dd><dl>
                   6582: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
                   6583: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
                   6584: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
                   6585: </dl></dd>
                   6586: <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>
                   6587: <dd><dl>
1.78      rillig   6588: <dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt>
                   6589: <dt><span class="sect2"><a href="#compiler-bugs">17.4.2. How to handle compiler bugs</a></span></dt>
                   6590: <dt><span class="sect2"><a href="#undefined-reference">17.4.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</a></span></dt>
                   6591: </dl></dd>
                   6592: <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>
                   6593: <dd><dl>
                   6594: <dt><span class="sect2"><a href="#install-scripts">17.5.1. Creating needed directories</a></span></dt>
                   6595: <dt><span class="sect2"><a href="#where-to-install-documentation">17.5.2. Where to install documentation</a></span></dt>
                   6596: <dt><span class="sect2"><a href="#installing-score-files">17.5.3. Installing score files</a></span></dt>
                   6597: <dt><span class="sect2"><a href="#perl-scripts">17.5.4. Packages containing perl scripts</a></span></dt>
                   6598: <dt><span class="sect2"><a href="#hardcoded-paths">17.5.5. Packages with hardcoded paths to other interpreters</a></span></dt>
                   6599: <dt><span class="sect2"><a href="#perl-modules">17.5.6. Packages installing perl modules</a></span></dt>
                   6600: <dt><span class="sect2"><a href="#faq.info-files">17.5.7. Packages installing info files</a></span></dt>
                   6601: <dt><span class="sect2"><a href="#manpages">17.5.8. Packages installing man pages</a></span></dt>
                   6602: <dt><span class="sect2"><a href="#gconf2-data-files">17.5.9. Packages installing GConf2 data files</a></span></dt>
                   6603: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.5.10. Packages installing scrollkeeper data files</a></span></dt>
                   6604: <dt><span class="sect2"><a href="#x11-fonts">17.5.11. Packages installing X11 fonts</a></span></dt>
                   6605: <dt><span class="sect2"><a href="#gtk2-modules">17.5.12. Packages installing GTK2 modules</a></span></dt>
                   6606: <dt><span class="sect2"><a href="#sgml-xml-data">17.5.13. Packages installing SGML or XML data</a></span></dt>
                   6607: <dt><span class="sect2"><a href="#mime-database">17.5.14. Packages installing extensions to the MIME database</a></span></dt>
                   6608: <dt><span class="sect2"><a href="#intltool">17.5.15. Packages using intltool</a></span></dt>
                   6609: <dt><span class="sect2"><a href="#startup-scripts">17.5.16. Packages installing startup scripts</a></span></dt>
                   6610: <dt><span class="sect2"><a href="#tex-packages">17.5.17. Packages installing TeX modules</a></span></dt>
1.75      rillig   6611: </dl></dd>
1.78      rillig   6612: <dt><span class="sect1"><a href="#feedback-to-author">17.6. Feedback to the author</a></span></dt>
1.75      rillig   6613: </dl>
                   6614: </div>
                   6615: <div class="sect1" lang="en">
                   6616: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   6617: <a name="general-operation"></a>17.1. General operation</h2></div></div></div>
1.75      rillig   6618: <div class="sect2" lang="en">
                   6619: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6620: <a name="portability-of-packages"></a>17.1.1. Portability of packages</h3></div></div></div>
                   6621: <p>One appealing feature of pkgsrc is that it runs on many
                   6622:        different platforms. As a result, it is important to ensure,
                   6623:        where possible, that packages in pkgsrc are portable. This
                   6624:        chapter mentions some particular details you should pay
                   6625:        attention to while working on pkgsrc.</p>
                   6626: </div>
                   6627: <div class="sect2" lang="en">
                   6628: <div class="titlepage"><div><div><h3 class="title">
                   6629: <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>
                   6630: <p>The pkgsrc user can configure pkgsrc by overriding several
                   6631:        variables in the file pointed to by <code class="varname">MAKECONF</code>,
                   6632:        which is <code class="filename">/etc/mk.conf</code> by default. When you
                   6633:        want to use those variables in the preprocessor directives of
                   6634:        <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
                   6635:        <code class="literal">.for</code>), you need to include the file
                   6636:        <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
                   6637:        loads the user preferences.</p>
                   6638: <p>But note that some variables may not be completely defined
                   6639:        after <code class="filename">../../mk/bsd.prefs.mk</code> has been
                   6640:        included, as they may contain references to variables that are
                   6641:        not yet defined. In shell commands this is no problem, since
                   6642:        variables are actually macros, which are only expanded when they
                   6643:        are used. But in the preprocessor directives mentioned above and
                   6644:        in dependency lines (of the form <code class="literal">target:
                   6645:        dependencies</code>) the variables are expanded at load
                   6646:        time.</p>
                   6647: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   6648: <h3 class="title">Note</h3>
                   6649: <p>Currently there is no exhaustive list of all
                   6650:        variables that tells you whether they can be used at load time
                   6651:        or only at run time, but it is in preparation.</p>
                   6652: </div>
                   6653: </div>
                   6654: <div class="sect2" lang="en">
                   6655: <div class="titlepage"><div><div><h3 class="title">
                   6656: <a name="user-interaction"></a>17.1.3. User interaction</h3></div></div></div>
                   6657: <p>Occasionally, packages require interaction from the user, and this can be
                   6658:         in a number of ways:</p>
                   6659: <div class="itemizedlist"><ul type="disc">
1.79      rillig   6660: <li><p>When fetching the distfiles, some packages require user
                   6661:          interaction such as entering username/password or accepting a
                   6662:          license on a web page.</p></li>
1.78      rillig   6663: <li><p>When extracting the distfiles, some packages may ask for passwords.</p></li>
                   6664: <li><p>help to configure the package before it is built</p></li>
                   6665: <li><p>help during the build process</p></li>
                   6666: <li><p>help during the installation of a package</p></li>
                   6667: </ul></div>
                   6668: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is provided to notify
                   6669:         the pkgsrc mechanism of an interactive stage which will be needed, and
                   6670:         this should be set in the package's <code class="filename">Makefile</code>, e.g.:</p>
1.75      rillig   6671: <pre class="programlisting">
1.78      rillig   6672:     INTERACTIVE_STAGE=      build
1.75      rillig   6673: </pre>
1.78      rillig   6674: <p>Multiple interactive stages can be specified:</p>
1.75      rillig   6675: <pre class="programlisting">
1.78      rillig   6676:     INTERACTIVE_STAGE=      configure install
1.75      rillig   6677: </pre>
                   6678: </div>
                   6679: <div class="sect2" lang="en">
                   6680: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6681: <a name="handling-licenses"></a>17.1.4. Handling licenses</h3></div></div></div>
                   6682: <p>A package may be covered by a license which the user has
                   6683:         or has not agreed to accept.  For these cases, pkgsrc contains
                   6684:         a mechanism to note that a package is covered by a particular
                   6685:         license, and the package cannot be built unless the user has
                   6686:         accepted the license.  (Installation of binary packages are
                   6687:         not currently subject to this mechanism.)  Packages with
                   6688:         licenses that are either Open Source according to the Open
                   6689:         Source Initiative or Free according to the Free Software
                   6690:         Foundation will not be marked with a license tag.  Packages
                   6691:         with licenses that have not been determined to meet either
                   6692:         definition will be marked with a license tag referring to the
                   6693:         license.  This will prevent building unless pkgsrc is informed
                   6694:         that the license is acceptable, and enables displaying the
                   6695:         license.</p>
                   6696: <p>The license tag mechanism is intended to address
                   6697:        copyright-related issues surrounding building, installing and
                   6698:        using a package, and not to address redistribution issues (see
                   6699:        <code class="varname">RESTRICTED</code> and
                   6700:        <code class="varname">NO_SRC_ON_FTP</code>, etc.).  However, the above
                   6701:        definition of licenses for which tags are not needed implies
                   6702:        that packages with redistribution restrictions should have
                   6703:        tags.</p>
                   6704: <p>
                   6705:         Denoting that a package is covered by a particular license is
                   6706:         done by placing the license in
                   6707:         <code class="filename">pkgsrc/licenses</code> and setting the
                   6708:         <code class="varname">LICENSE</code> variable to a string identifying
                   6709:         the license, e.g. in
                   6710:        <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>: </p>
                   6711: <pre class="programlisting">
                   6712:     LICENSE=        xv-license
                   6713: </pre>
                   6714: <p>
                   6715:        When trying to build, the user will get a notice that the
                   6716:         package is covered by a license which has not been
                   6717:         accepted:</p>
                   6718: <pre class="programlisting">
                   6719:     <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
                   6720:     ===&gt; xv-3.10anb9 has an unacceptable license: xv-license.
                   6721:     ===&gt;     To view the license, enter "/usr/bin/make show-license".
                   6722:     ===&gt;     To indicate acceptance, add this line to your /etc/mk.conf:
                   6723:     ===&gt;     ACCEPTABLE_LICENSES+=xv-license
                   6724:     *** Error code 1
                   6725: </pre>
                   6726: <p>The license can be viewed with <span><strong class="command">make
                   6727:           show-license</strong></span>, and if it is considered appropriate,
                   6728:           the line printed above can be added to
                   6729:           <code class="filename">/etc/mk.conf</code> to indicate acceptance of
                   6730:           the particular license:</p>
                   6731: <pre class="programlisting">
                   6732:     ACCEPTABLE_LICENSES+=xv-license
                   6733: </pre>
                   6734: <p>When adding a package with a new license, the license
                   6735:           text should be added to <code class="filename">pkgsrc/licenses</code>
                   6736:           for displaying. A list of known licenses can be seen in this
                   6737:           directory as well as by looking at the list of (commented
                   6738:           out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
                   6739:           settings in
                   6740:           <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
                   6741: <p>The use of <code class="varname">LICENSE=shareware</code>,
                   6742:          <code class="varname">LICENSE=no-commercial-use</code>, and similar
                   6743:          language is deprecated because it does not crisply refer to
                   6744:          a particular license text.  Another problem with such usage
                   6745:          is that it does not enable a user to denote acceptance of
                   6746:          the license for a single package without accepting the same
                   6747:          license text for another package.  In particular, this can
                   6748:          be inappropriate when e.g. one accepts a particular license to
                   6749:          indicate to pkgsrc that a fee has been paid.</p>
1.75      rillig   6750: </div>
                   6751: <div class="sect2" lang="en">
                   6752: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6753: <a name="restricted-packages"></a>17.1.5. Restricted packages</h3></div></div></div>
1.75      rillig   6754: <p>Some licenses restrict how software may be re-distributed.
                   6755:         In order to satisfy these restrictions, the package system
                   6756:         defines five make variables that can be set to note these
                   6757:         restrictions:</p>
                   6758: <div class="itemizedlist"><ul type="disc">
                   6759: <li>
                   6760: <p><code class="varname">RESTRICTED</code></p>
                   6761: <p>This variable should be set whenever a restriction
                   6762:             exists (regardless of its kind).  Set this variable to a
                   6763:             string containing the reason for the restriction.</p>
                   6764: </li>
                   6765: <li>
                   6766: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
                   6767: <p>Binaries may not be placed on CD-ROM.  Set this
                   6768:             variable to <code class="varname">${RESTRICTED}</code> whenever a
                   6769:             binary package may not be included on a CD-ROM.</p>
                   6770: </li>
                   6771: <li>
                   6772: <p><code class="varname">NO_BIN_ON_FTP</code></p>
                   6773: <p>Binaries may not be placed on an FTP server.  Set
                   6774:             this variable to <code class="varname">${RESTRICTED}</code>
                   6775:             whenever a binary package may not not be made available
                   6776:             on the Internet.</p>
                   6777: </li>
                   6778: <li>
                   6779: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
                   6780: <p>Distfiles may not be placed on CD-ROM.  Set this
                   6781:             variable to <code class="varname">${RESTRICTED}</code> if
                   6782:             re-distribution of the source code or other distfile(s) is
                   6783:             not allowed on CD-ROMs.</p>
                   6784: </li>
                   6785: <li>
                   6786: <p><code class="varname">NO_SRC_ON_FTP</code></p>
                   6787: <p>Distfiles may not be placed on FTP.  Set this variable
                   6788:             to <code class="varname">${RESTRICTED}</code> if re-distribution of
                   6789:             the source code or other distfile(s) via the Internet is not
                   6790:             allowed.</p>
                   6791: </li>
                   6792: </ul></div>
                   6793: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
                   6794:         <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
                   6795:         generic make variables to denote restrictions is deprecated,
                   6796:         because they unconditionally prevent users from generating
                   6797:         binary packages!</p>
                   6798: </div>
                   6799: <div class="sect2" lang="en">
                   6800: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6801: <a name="dependencies"></a>17.1.6. Handling dependencies</h3></div></div></div>
1.75      rillig   6802: <p>Your package may depend on some other package being present
                   6803:         - and there are various ways of expressing this
                   6804:         dependency. pkgsrc supports the <code class="varname">BUILD_DEPENDS</code>
                   6805:         and <code class="varname">DEPENDS</code> definitions, the
                   6806:         <code class="varname">USE_TOOLS</code> definition, as well as
1.76      rillig   6807:         dependencies via <code class="filename">buildlink3.mk</code>, which is
1.75      rillig   6808:         the preferred way to handle dependencies, and which uses the
1.77      rillig   6809:         variables named above. See <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a> for more
1.75      rillig   6810:         information.</p>
                   6811: <p>The basic difference between the two variables is as
                   6812:         follows: The <code class="varname">DEPENDS</code> definition registers
                   6813:         that pre-requisite in the binary package so it will be pulled in
                   6814:         when the binary package is later installed, whilst the
                   6815:         <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
                   6816:         dependency that is only needed for building the package.
                   6817: </p>
                   6818: <p>This means that if you only need a package present whilst
                   6819:         you are building, it should be noted as a
                   6820:         <code class="varname">BUILD_DEPENDS</code>.</p>
                   6821: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
                   6822:         <code class="varname">DEPENDS</code> definition is:</p>
                   6823: <pre class="programlisting">
                   6824:     &lt;pre-req-package-name&gt;:../../&lt;category&gt;/&lt;pre-req-package&gt;
                   6825: </pre>
                   6826: <p>Please note that the &#8220;<span class="quote">pre-req-package-name</span>&#8221;
                   6827:         may include any of the wildcard version numbers recognized by
                   6828:         <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>
                   6829: <div class="orderedlist"><ol type="1">
                   6830: <li>
                   6831: <p>If your package needs another package's binaries or
                   6832:             libraries to build or run, and if that package has a
1.76      rillig   6833:             <code class="filename">buildlink3.mk</code> file available, use it:
1.75      rillig   6834: </p>
                   6835: <pre class="programlisting">
                   6836:     .include "../../graphics/jpeg/buildlink3.mk"
                   6837: </pre>
                   6838: </li>
                   6839: <li>
                   6840: <p>If your package needs to use another package to build
1.76      rillig   6841:             itself and there is no <code class="filename">buildlink3.mk</code>
1.75      rillig   6842:             file available, use the <code class="varname">BUILD_DEPENDS</code>
                   6843:             definition:</p>
                   6844: <pre class="programlisting">
                   6845:     BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
                   6846: </pre>
                   6847: </li>
                   6848: <li>
                   6849: <p>If your package needs a library with which to link and
1.76      rillig   6850:        again there is no <code class="filename">buildlink3.mk</code> file
1.75      rillig   6851:         available, this is specified using the
                   6852:         <code class="varname">DEPENDS</code> definition. For example:</p>
                   6853: <pre class="programlisting">
                   6854:     DEPENDS+=       xpm-3.4j:../../graphics/xpm
                   6855: </pre>
                   6856: <p>You can also use wildcards in package dependences:</p>
                   6857: <pre class="programlisting">
                   6858:     DEPENDS+=       xpm-[0-9]*:../../graphics/xpm
                   6859: </pre>
                   6860: <p>Note that such wildcard dependencies are retained when
                   6861:             creating binary packages.  The dependency is checked when
                   6862:             installing the binary package and any package which matches
                   6863:             the pattern will be used.  Wildcard dependencies should be
                   6864:             used with care.</p>
                   6865: <p>The &#8220;<span class="quote">-[0-9]*</span>&#8221; should be used instead of
                   6866:             &#8220;<span class="quote">-*</span>&#8221; to avoid potentially ambiguous matches
                   6867:             such as &#8220;<span class="quote">tk-postgresql</span>&#8221; matching a
                   6868:             &#8220;<span class="quote">tk-*</span>&#8221; <code class="varname">DEPENDS</code>.</p>
                   6869: <p>Wildcards can also be used to specify that a package
                   6870:             will only  build against a certain minimum version of a
                   6871:             pre-requisite:</p>
                   6872: <pre class="programlisting">
                   6873:     DEPENDS+=       tiff&gt;=3.5.4:../../graphics/tiff
                   6874: </pre>
                   6875: <p>This means that the package will build against version
                   6876:             3.5.4 of the tiff library or newer.  Such a dependency may
                   6877:             be warranted if, for example, the API of the library has
                   6878:             changed with version 3.5.4 and a package would not compile
                   6879:             against an earlier version of tiff.</p>
                   6880: <p>Please note that such dependencies should only be
                   6881:             updated if a package requires  a newer pre-requisite, but
                   6882:             not to denote recommendations such as 
                   6883:             ABI changes that do not prevent a package from building
                   6884:             correctly.  Such recommendations can be expressed using
                   6885:             <code class="varname">ABI_DEPENDS</code>:</p>
                   6886: <pre class="programlisting">
                   6887:     ABI_DEPENDS+=   tiff&gt;=3.6.1:../../graphics/tiff
                   6888: </pre>
                   6889: <p>In addition to the above <code class="varname">DEPENDS</code>
                   6890:             line, this denotes that while a package will build against
                   6891:             tiff&gt;=3.5.4, at least version 3.6.1 is recommended.
                   6892:             <code class="varname">ABI_DEPENDS</code> entries will be turned into
                   6893:             dependencies unless explicitly ignored (in which case a
                   6894:             warning will be printed).</p>
                   6895: <p>To ignore these ABI dependency recommendations and just
                   6896:             use the required <code class="varname">DEPENDS</code>, set
                   6897:             <code class="varname">USE_ABI_DEPENDS=NO</code>.   This may make
                   6898:             it easier and faster to update packages built using pkgsrc,
                   6899:             since older compatible dependencies can continue to be
                   6900:             used. This is useful for people who watch their rebuilds
                   6901:             very carefully; it is not very good as a general-purpose
                   6902:             hammer.  If you use it, you need to be mindful of possible
                   6903:             ABI changes, including those from the underlying OS.
                   6904: </p>
                   6905: <p>Packages that are built with recommendations ignored
                   6906:             may not be uploaded to ftp.NetBSD.org by developers and
                   6907:             should not be used across different systems that may have
                   6908:             different versions of binary packages installed.</p>
                   6909: <p>For security fixes, please update the package
1.78      rillig   6910:             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   6911:             information.</p>
                   6912: </li>
                   6913: <li>
                   6914: <p>If your package needs some executable to be able to run
                   6915:             correctly and if there's no
1.76      rillig   6916:             <code class="filename">buildlink3.mk</code> file, this is specified
1.75      rillig   6917:             using the <code class="varname">DEPENDS</code> variable. The
1.76      rillig   6918:             <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   6919:            be able to execute the latex binary from the teTeX package
                   6920:            when it runs, and that is specified:</p>
                   6921: <pre class="programlisting">
                   6922:     DEPENDS+=        teTeX-[0-9]*:../../print/teTeX
                   6923: </pre>
                   6924: <p>The comment about wildcard dependencies from previous
                   6925:             paragraph  applies here, too.</p>
                   6926: </li>
                   6927: </ol></div>
                   6928: <p>If your package needs files from another package to build,
                   6929:        add the relevant distribution files to
                   6930:        <code class="varname">DISTFILES</code>, so they will be extracted
1.76      rillig   6931:        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   6932:        (It relies on the jpeg sources being present in source form
                   6933:        during the build.)</p>
                   6934: <p>Please also note the <code class="varname">BUILD_USES_MSGFMT</code>
                   6935:         and <code class="varname">BUILD_USES_GETTEXT_M4</code> definitions, which
                   6936:         are provided as convenience definitions.  The former works out
                   6937:         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   6938:         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   6939:        The latter adds a build dependency on either an installed
                   6940:        version of an older gettext package, or if it isn't, installs the
1.76      rillig   6941:         <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   6942: </div>
                   6943: <div class="sect2" lang="en">
                   6944: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6945: <a name="conflicts"></a>17.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75      rillig   6946: <p>Your package may conflict with other packages a user might
                   6947:         already have installed on his system, e.g. if your package
                   6948:         installs the same set of files like another package in our
                   6949:         pkgsrc tree.</p>
                   6950: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
                   6951:         space-separated list of packages (including version string) your
                   6952:         package conflicts with.</p>
1.76      rillig   6953: <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>
                   6954:         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   6955:         install the same shared library, thus you set in
1.76      rillig   6956:         <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
1.75      rillig   6957: <pre class="programlisting">
                   6958:     CONFLICTS=      Xaw-Xpm-[0-9]*
                   6959: </pre>
1.76      rillig   6960: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:
1.75      rillig   6961: </p>
                   6962: <pre class="programlisting">
                   6963:     CONFLICTS=      Xaw3d-[0-9]*
                   6964: </pre>
                   6965: <p>Packages will automatically conflict with other packages
                   6966:         with the name prefix  and a different version
                   6967:         string. &#8220;<span class="quote">Xaw3d-1.5</span>&#8221; e.g. will automatically
                   6968:         conflict  with the older version &#8220;<span class="quote">Xaw3d-1.3</span>&#8221;.
                   6969: </p>
                   6970: </div>
                   6971: <div class="sect2" lang="en">
                   6972: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6973: <a name="not-building-packages"></a>17.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75      rillig   6974: <p>There are several reasons why a package might be
                   6975:         instructed to not build under certain circumstances. If the
                   6976:         package builds and runs on most platforms, the exceptions
                   6977:         should be noted with <code class="varname">NOT_FOR_PLATFORM</code>.  If
                   6978:         the package builds and runs on a small handful of platforms,
                   6979:         set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
                   6980:        Both <code class="varname">ONLY_FOR_PLATFORM</code> and
                   6981:         <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
                   6982:         (OS-version-platform) that can use glob-style
                   6983:         wildcards.</p>
                   6984: <p>If the package should be skipped (for example, because it
                   6985:         provides functionality already provided by the system), set
                   6986:         <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.
                   6987:         If the package should fail because some preconditions are not
                   6988:         met, set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
                   6989:         message.</p>
                   6990: </div>
                   6991: <div class="sect2" lang="en">
                   6992: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   6993: <a name="undeletable-packages"></a>17.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75      rillig   6994: <p>To ensure that a package may not be deleted, once it has been
                   6995:         installed, the <code class="varname">PKG_PRESERVE</code> definition should
                   6996:         be set in the package Makefile. This will be carried into any
                   6997:         binary package that is made from this pkgsrc entry. A
                   6998:         &#8220;<span class="quote">preserved</span>&#8221; package will
                   6999:         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
                   7000:         &#8220;<span class="quote">-f</span>&#8221; option is used.</p>
                   7001: </div>
                   7002: <div class="sect2" lang="en">
                   7003: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7004: <a name="security-handling"></a>17.1.10. Handling packages with security problems</h3></div></div></div>
1.75      rillig   7005: <p>When a vulnerability is found, this should be noted in
1.76      rillig   7006:         <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
1.75      rillig   7007:         and after committing that file, use <span><strong class="command">make upload</strong></span>
                   7008:        in the same directory to update the file on ftp.NetBSD.org.</p>
                   7009: <p>After fixing the vulnerability by a patch, its
                   7010:        <code class="varname">PKGREVISION</code> should be increased (this
                   7011:        is of course not necessary if the problem is fixed by using
                   7012:        a newer release of the software).</p>
                   7013: <p>Also, if the fix should be applied to the stable pkgsrc
                   7014:         branch, be sure to submit a pullup request!</p>
                   7015: <p>Binary packages already on ftp.NetBSD.org will be handled
                   7016:        semi-automatically by a weekly cron job.</p>
                   7017: </div>
                   7018: <div class="sect2" lang="en">
                   7019: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7020: <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   7021: <p>When making fixes to an existing package it can be useful
                   7022:         to change the version number in <code class="varname">PKGNAME</code>. To
                   7023:         avoid conflicting with future versions by the original author, a
                   7024:         &#8220;<span class="quote">nb1</span>&#8221;, &#8220;<span class="quote">nb2</span>&#8221;, ... suffix can be used
                   7025:         on package versions by setting <code class="varname">PKGREVISION=1</code>
                   7026:         (2, ...). The &#8220;<span class="quote">nb</span>&#8221; is treated like a
                   7027:         &#8220;<span class="quote">.</span>&#8221; by the pkg tools. e.g.</p>
                   7028: <pre class="programlisting">
                   7029:     DISTNAME=       foo-17.42
                   7030:     PKGREVISION=    9
                   7031: </pre>
                   7032: <p>will result in a <code class="varname">PKGNAME</code> of
                   7033:         &#8220;<span class="quote">foo-17.42nb9</span>&#8221;.</p>
                   7034: <p>When a new release of the package is released, the
                   7035:         <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
                   7036:         minor release of the above package, things should be like:</p>
                   7037: <pre class="programlisting">
                   7038:     DISTNAME=       foo-17.43
                   7039: </pre>
1.78      rillig   7040: <p>PKGREVISION should be incremented for any non-trivial change in the
                   7041:     resulting binary package.  Without a PKGREVISION bump, someone with
                   7042:     the previous version installed has no way of knowing that their
                   7043:     package is out of date.  Thus, changes without increasing PKGREVISION
                   7044:     are essentially labeled "this is so trivial that no reasonable person
                   7045:     would want to upgrade", and this is the rough test for when increasing
                   7046:     PKGREVISION is appropriate.  Examples of changes that do not merit
                   7047:     increasing PKGREVISION are:</p>
                   7048: <pre class="programlisting">
                   7049: Changing HOMEPAGE, MAINTAINER, or comments in Makefile.
                   7050: Changing build variables if the resulting binary package is the same.
                   7051: Changing DESCR.
                   7052: Adding PKG_OPTIONS if the default options don't change.
                   7053: </pre>
                   7054: <p>Examples of changes that do merit an increase to PKGREVISION
                   7055:     include:</p>
                   7056: <pre class="programlisting">
                   7057: Security fixes
                   7058: Changes or additions to a patch file
                   7059: Changes to the PLIST
1.75      rillig   7060: </pre>
1.78      rillig   7061: <p>PKGREVISION must also be incremented when dependencies have ABI
                   7062:     changes.</p>
1.75      rillig   7063: </div>
1.79      rillig   7064: <div class="sect2" lang="en">
                   7065: <div class="titlepage"><div><div><h3 class="title">
                   7066: <a name="fixes.subst"></a>17.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
                   7067: <p>When you want to replace the same text in multiple files
                   7068:        or when the replacement text varies, patches alone cannot help.
                   7069:        This is where the SUBST framework comes in. It provides an
                   7070:        easy-to-use interface for replacing text in files.
                   7071:        Example:</p>
                   7072: <pre class="programlisting">
                   7073:     SUBST_CLASSES+=                 fix-paths
                   7074:     SUBST_STAGE.fix-paths=          pre-configure
                   7075:     SUBST_MESSAGE.fix-paths=        Fixing absolute paths.
                   7076:     SUBST_FILES.fix-paths=          src/*.c
                   7077:     SUBST_FILES.fix-paths+=         scripts/*.sh
                   7078:     SUBST_SED.fix-paths=            -e 's,"/usr/local,"${PREFIX},g'
                   7079:     SUBST_SED.fix-paths+=           -e 's,"/var/log,"${VARBASE}/log,g'
                   7080: </pre>
                   7081: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
                   7082:        that are used to identify the different SUBST blocks that are
                   7083:        defined. The SUBST framework is heavily used by pkgsrc, so it is
                   7084:        important to always use the <code class="literal">+=</code> operator with
                   7085:        this variable. Otherwise some substitutions may be
                   7086:        skipped.</p>
                   7087: <p>The remaining variables of each SUBST block are
                   7088:        parameterized with the identifier from the first line
                   7089:        (<code class="literal">fix-paths</code> in this case.) They can be seen as
                   7090:        parameters to a function call.</p>
                   7091: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
                   7092:        which the replacement will take place. All combinations of
                   7093:        <code class="literal">pre-</code>, <code class="literal">do-</code> and
                   7094:        <code class="literal">post-</code> together with a phase name are
                   7095:        possible, though only few are actually used. Most commonly used
                   7096:        are <code class="literal">post-patch</code> and
                   7097:        <code class="literal">pre-configure</code>. Of these two,
                   7098:        <code class="literal">pre-configure</code> should be preferred because
                   7099:        then it is possible to run <span><strong class="command">bmake patch</strong></span> and
                   7100:        have the state after applying the patches but before making any
                   7101:        other changes. This is especially useful when you are debugging
                   7102:        a package in order to create new patches for it. Similarly,
                   7103:        <code class="literal">post-build</code> is preferred over
                   7104:        <code class="literal">pre-install</code>, because the install phase should
                   7105:        generally be kept as simple as possible. When you use
                   7106:        <code class="literal">post-build</code>, you have the same files in the
                   7107:        working directory that will be installed later, so you can check
                   7108:        if the substitution has succeeded.</p>
                   7109: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
                   7110:        that is printed just before the substitution is done.</p>
                   7111: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
                   7112:        globbing patterns that specifies the files in which the
                   7113:        substitution will take place. The patterns are interpreted
                   7114:        relatively to the <code class="varname">WRKSRC</code> directory.</p>
                   7115: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
                   7116:        <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
                   7117:        command should be prefixed with <code class="literal">-e</code>, so that
                   7118:        all SUBST blocks look uniform.</p>
                   7119: <p>There are some more variables, but they are so seldomly
                   7120:        used that they are only documented in the
1.80      rillig   7121:        <code class="filename">mk/subst.mk</code> file.</p>
1.79      rillig   7122: </div>
1.75      rillig   7123: </div>
                   7124: <div class="sect1" lang="en">
                   7125: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   7126: <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   7127: <div class="sect2" lang="en">
                   7128: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7129: <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   7130: <p>If you need to download from a dynamic URL you can set
                   7131:         <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
1.76      rillig   7132:         fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
1.75      rillig   7133:         with the name of each file to download as an argument, expecting
                   7134:         it to output the URL of the directory from which to download
1.76      rillig   7135:         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   7136:        example of this usage.</p>
1.75      rillig   7137: <p>If the download can't be automated, because the user must
                   7138:        submit personal information to apply for a password, or must pay
                   7139:        for the source, or whatever, you can set
                   7140:        <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
                   7141:        displayed to the user before aborting the build. Example:</p>
                   7142: <pre class="programlisting">
                   7143:     FETCH_MESSAGE=  "Please download the files"
                   7144:     FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   7145:     FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   7146: </pre>
                   7147: </div>
                   7148: <div class="sect2" lang="en">
                   7149: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7150: <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   7151: <p>Sometimes authors of a software package make some
                   7152:         modifications after the software was released, and they put up a
                   7153:         new distfile without changing the package's version number. If a
                   7154:         package is already in pkgsrc at that time, the checksum will
                   7155:         no longer match. The contents of the new distfile should be
                   7156:        compared against the old one before changing anything, to make
                   7157:        sure the distfile was really updated on purpose, and that
                   7158:         no trojan horse or so crept in.
                   7159:        Then, the correct way to work around this is to
                   7160:        set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
                   7161:        usually based on <code class="varname">PKGNAME_NOREV</code>. In case this
                   7162:        happens more often, <code class="varname">PKGNAME</code> can be used (thus
1.76      rillig   7163:        including the <code class="filename">nbX</code> suffix) or a date stamp
1.75      rillig   7164:        can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
1.76      rillig   7165:        Do not forget regenerating the <code class="filename">distinfo</code> file
1.75      rillig   7166:        after that, since it contains the <code class="varname">DIST_SUBDIR</code>
                   7167:        path in the filenames.
                   7168:         Furthermore, a mail to the package's authors seems appropriate
                   7169:        telling them that changing distfiles after releases without
                   7170:        changing the file names is not good practice.</p>
                   7171: </div>
                   7172: </div>
                   7173: <div class="sect1" lang="en">
                   7174: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   7175: <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   7176: <div class="sect2" lang="en">
                   7177: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7178: <a name="fixes.libtool"></a>17.3.1. Shared libraries - libtool</h3></div></div></div>
1.75      rillig   7179: <p>pkgsrc supports many different machines, with different
                   7180:         object formats like a.out and ELF, and varying abilities to do
                   7181:         shared library and dynamic loading at all. To accompany this,
                   7182:         varying commands and options have to be passed to the
                   7183:         compiler, linker, etc. to get the Right Thing, which can be
                   7184:         pretty annoying especially if you don't have all the machines
                   7185:         at your hand to test things.  The
1.76      rillig   7186:        <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   7187:         can help here, as it just &#8220;<span class="quote">knows</span>&#8221; how to build
                   7188:         both static and dynamic libraries from a set of source files,
                   7189:         thus being platform-independent.</p>
                   7190: <p>Here's how to use libtool in a pkg in seven simple
                   7191:         steps:</p>
                   7192: <div class="orderedlist"><ol type="1">
                   7193: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
                   7194:             Makefile.</p></li>
                   7195: <li><p>For library objects, use &#8220;<span class="quote">${LIBTOOL} --mode=compile
                   7196:             ${CC}</span>&#8221; in place of &#8220;<span class="quote">${CC}</span>&#8221;. You could even
                   7197:             add it to the definition of <code class="varname">CC</code>, if only
                   7198:             libraries are being built in a given Makefile. This one command
                   7199:             will build both PIC and non-PIC library objects, so you need not
                   7200:             have separate shared and non-shared library rules.</p></li>
                   7201: <li>
                   7202: <p>For the linking of the library, remove any
                   7203:             &#8220;<span class="quote">ar</span>&#8221;, &#8220;<span class="quote">ranlib</span>&#8221;, and &#8220;<span class="quote">ld
                   7204:             -Bshareable</span>&#8221; commands, and instead use:</p>
                   7205: <pre class="programlisting">
                   7206:     ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
                   7207:         -rpath ${PREFIX}/lib -version-info major:minor
                   7208: </pre>
                   7209: <p>Note that the library is changed to have a
1.76      rillig   7210:             <code class="filename">.la</code> extension, and the objects are
                   7211:             changed to have a <code class="filename">.lo</code>
1.75      rillig   7212:             extension. Change <code class="varname">OBJS</code> as
                   7213:             necessary. This automatically creates all of the
1.76      rillig   7214:             <code class="filename">.a</code>,
                   7215:             <code class="filename">.so.major.minor</code>, and ELF symlinks (if
1.75      rillig   7216:             necessary) in the build directory. Be sure to include
                   7217:             &#8220;<span class="quote">-version-info</span>&#8221;, especially when major and
                   7218:             minor are zero, as libtool will otherwise strip off the
                   7219:             shared library version.</p>
                   7220: <p>From the libtool manual:</p>
                   7221: <pre class="programlisting">
                   7222:     So, libtool library versions are described by three integers:
1.69      rillig   7223: 
1.75      rillig   7224:     CURRENT
                   7225:         The most recent interface number that this library implements.
1.69      rillig   7226: 
1.75      rillig   7227:     REVISION
                   7228:         The implementation number of the CURRENT interface.
1.69      rillig   7229: 
1.75      rillig   7230:     AGE
                   7231:         The difference between the newest and oldest interfaces that
                   7232:         this library implements.  In other words, the library implements
                   7233:         all the interface numbers in the range from number `CURRENT -
                   7234:         AGE' to `CURRENT'.
1.1       grant    7235: 
1.75      rillig   7236:     If two libraries have identical CURRENT and AGE numbers, then the
                   7237:     dynamic linker chooses the library with the greater REVISION number.
                   7238: </pre>
                   7239: <p>The &#8220;<span class="quote">-release</span>&#8221; option will produce
                   7240:             different results for a.out and ELF (excluding symlinks)
                   7241:             in only one case. An ELF library of the form
                   7242:             &#8220;<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;
                   7243:             will have a symlink of
                   7244:             &#8220;<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;
                   7245:             on an a.out platform. This is handled
                   7246:             automatically.</p>
                   7247: <p>The &#8220;<span class="quote">-rpath argument</span>&#8221; is the install
                   7248:             directory of the library being built.</p>
1.76      rillig   7249: <p>In the <code class="filename">PLIST</code>, include only the
                   7250:             <code class="filename">.la</code> file, the other files will be
1.75      rillig   7251:            added automatically.</p>
                   7252: </li>
                   7253: <li>
1.76      rillig   7254: <p>When linking shared object (<code class="filename">.so</code>)
1.75      rillig   7255:             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
                   7256:             shared libraries, use &#8220;<span class="quote">-module
                   7257:             -avoid-version</span>&#8221; to prevent them getting version
                   7258:             tacked on.</p>
1.76      rillig   7259: <p>The <code class="filename">PLIST</code> file gets the
                   7260:             <code class="filename">foo.so</code> entry.</p>
1.75      rillig   7261: </li>
                   7262: <li>
                   7263: <p>When linking programs that depend on these libraries
                   7264:             <span class="emphasis"><em>before</em></span> they are installed, preface
                   7265:             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}
                   7266:             --mode=link</span>&#8221;, and it will find the correct
                   7267:             libraries (static or shared), but please be aware that
                   7268:             libtool will not allow you to specify a relative path in
                   7269:             -L (such as &#8220;<span class="quote">-L../somelib</span>&#8221;), because it
                   7270:             expects you to change that argument to be the
1.76      rillig   7271:             <code class="filename">.la</code> file. e.g.</p>
1.75      rillig   7272: <pre class="programlisting">
                   7273:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   7274: </pre>
                   7275: <p>should be changed to:</p>
                   7276: <pre class="programlisting">
                   7277:     ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
                   7278: </pre>
                   7279: <p>and it will do the right thing with the libraries.</p>
                   7280: </li>
                   7281: <li>
                   7282: <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>
                   7283:             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}
                   7284:             --mode=install</span>&#8221;, and change the library name to
1.76      rillig   7285:             <code class="filename">.la</code>. e.g.</p>
1.75      rillig   7286: <pre class="programlisting">
                   7287:     ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
                   7288: </pre>
1.76      rillig   7289: <p>This will install the static <code class="filename">.a</code>,
1.75      rillig   7290:             shared library, any needed symlinks, and run
                   7291:             <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>
                   7292: </li>
1.76      rillig   7293: <li><p>In your <code class="filename">PLIST</code>, include only
                   7294:             the <code class="filename">.la</code>
1.75      rillig   7295:             file (this is a change from previous behaviour).</p></li>
                   7296: </ol></div>
                   7297: </div>
                   7298: <div class="sect2" lang="en">
                   7299: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7300: <a name="using-libtool"></a>17.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75      rillig   7301: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
                   7302:         package Makefile. This will override the package's own libtool
                   7303:         in most cases.  For older libtool using packages,  libtool is
                   7304:         made by ltconfig script during the do-configure step; you can
                   7305:         check the libtool script location by doing <span><strong class="command">make
                   7306:         configure; find work*/ -name libtool</strong></span>.</p>
                   7307: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
                   7308:         scripts, relative to <code class="varname">WRKSRC</code>, to override.  By
                   7309:         default, it is set to &#8220;<span class="quote">libtool */libtool
                   7310:         */*/libtool</span>&#8221;.  If this does not match the location of the
                   7311:         package's libtool script(s), set it as appropriate.</p>
1.76      rillig   7312: <p>If you do not need <code class="filename">*.a</code> static
1.75      rillig   7313:         libraries built and installed, then use
                   7314:         <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
                   7315: <p>If your package makes use of the platform-independent library
                   7316:         for loading dynamic shared objects, that comes with libtool
                   7317:         (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
                   7318: <p>Some packages use libtool incorrectly so that the package may not work or
                   7319:         build in some circumstances. Some of the more common errors are:</p>
                   7320: <div class="itemizedlist"><ul type="disc">
                   7321: <li>
                   7322: <p>The inclusion of a shared object (-module) as a dependent library in an
                   7323:             executable or library. This in itself isn't a problem if one of two things
                   7324:             has been done:</p>
                   7325: <div class="orderedlist"><ol type="1">
                   7326: <li><p>The shared object is named correctly, i.e.
1.76      rillig   7327:                 <code class="filename">libfoo.la</code>, not
                   7328:                 <code class="filename">foo.la</code></p></li>
1.75      rillig   7329: <li><p>The -dlopen option is used when linking an executable.</p></li>
                   7330: </ol></div>
                   7331: </li>
                   7332: <li><p>The use of libltdl without the correct calls to initialisation routines.
                   7333:             The function lt_dlinit() should be called and the macro
                   7334:             <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
                   7335:             executables.</p></li>
                   7336: </ul></div>
                   7337: </div>
                   7338: <div class="sect2" lang="en">
                   7339: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   7340: <a name="autoconf-automake"></a>17.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75      rillig   7341: <p>If a package needs GNU autoconf or automake to be executed
                   7342:         to regenerate the configure script and Makefile.in makefile
                   7343:         templates, then they should be executed in a pre-configure
                   7344:         target.</p>
                   7345: <p>For packages that need only autoconf:</p>
                   7346: <pre class="programlisting">
                   7347:     AUTOCONF_REQD=  2.50            # if default version is not good enough
                   7348:     USE_TOOLS+=     autoconf        # use "autoconf213" for autoconf-2.13
                   7349:     ...
1.1       grant    7350: 
1.75      rillig   7351:     pre-configure:
                   7352:             cd ${WRKSRC}; autoconf
1.1       grant    7353: 
1.75      rillig   7354:     ...
                   7355: </pre>
                   7356: <p>and for packages that need automake and autoconf:</p>
                   7357: <pre class="programlisting">
                   7358:     AUTOMAKE_REQD=  1.7.1           # if default version is not good enough
                   7359:     USE_TOOLS+=     automake        # use "automake14" for automake-1.4
                   7360:     ...
1.1       grant    7361: 
1.75      rillig   7362:     pre-configure:
                   7363:             cd ${WRKSRC};                          \
                   7364:             aclocal; autoheader;                   \
                   7365:             automake -a --foreign -i; autoconf
1.1       grant    7366: 
1.75      rillig   7367:     ...
                   7368: </pre>
                   7369: <p>Packages which use GNU Automake will almost certainly
                   7370:           require GNU Make.</p>
                   7371: <p>There are times when the configure process makes
                   7372:           additional  changes to the generated files, which then causes
                   7373:           the build  process to try to re-execute the automake sequence.
                   7374:           This is  prevented by touching various files in the configure
                   7375:           stage. If  this causes problems with your package you can set
                   7376:           <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
                   7377:           Makefile.</p>
                   7378: </div>
                   7379: </div>
                   7380: <div class="sect1" lang="en">
                   7381: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   7382: <a name="fixes.build"></a>17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
                   7383: <p>The most common failures when building a package are that
                   7384:        some platforms do not provide certain header files, functions or
                   7385:        libraries, or they provide the functions in a library that the
                   7386:        original package author didn't know. To work around this, you
                   7387:        can rewrite the source code in most cases so that it does not
                   7388:        use the missing functions or provides a replacement function.</p>
                   7389: <div class="sect2" lang="en">
                   7390: <div class="titlepage"><div><div><h3 class="title">
                   7391: <a name="fixes.build.cpp"></a>17.4.1. Compiling C and C++ code conditionally</h3></div></div></div>
                   7392: <p>If a package already comes with a GNU configure script, the
                   7393:        preferred way to fix the build failure is to change the
                   7394:        configure script, not the code. In the other cases, you can
                   7395:        utilize the C preprocessor, which defines certain macros
                   7396:        depending on the operating system and hardware architecture it
                   7397:        compiles for. These macros can be queried using for example
                   7398:        <code class="varname">#if defined(__i386)</code>. Almost every operating
                   7399:        system, hardware architecture and compiler has its own macro.
                   7400:        For example, if the macros <code class="varname">__GNUC__</code>,
                   7401:        <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
                   7402:        are all defined, you know that you are using NetBSD on an i386
                   7403:        compatible CPU, and your compiler is GCC.</p>
                   7404: <p>The list of the following macros for hardware and
                   7405:        operating system depends on the compiler that is used. For
                   7406:        example, if you want to conditionally compile code on Solaris,
                   7407:        don't use <code class="varname">__sun__</code>, as the SunPro compiler
                   7408:        does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75      rillig   7409: <div class="sect3" lang="en">
                   7410: <div class="titlepage"><div><div><h4 class="title">
1.77      rillig   7411: <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   7412: <p>To distinguish between 4.4 BSD-derived systems and the
                   7413:         rest of the world, you should use the following code.</p>
                   7414: <pre class="programlisting">
                   7415:     #include &lt;sys/param.h&gt;
                   7416:     #if (defined(BSD) &amp;&amp; BSD &gt;= 199306)
                   7417:       /* BSD-specific code goes here */
                   7418:     #else
                   7419:       /* non-BSD-specific code goes here */
                   7420:     #endif
                   7421: </pre>
1.77      rillig   7422: <p>If this distinction is not fine enough, you can also test
                   7423:        for the following macros.</p>
1.75      rillig   7424: <pre class="programlisting">
                   7425:     FreeBSD     __FreeBSD__
                   7426:     DragonFly   __DragonFly__
                   7427:     Interix     __INTERIX
                   7428:     Linux       linux, __linux, __linux__
                   7429:     NetBSD      __NetBSD__
                   7430:     OpenBSD     __OpenBSD__
                   7431:     Solaris     sun, __sun
                   7432: </pre>
                   7433: </div>
                   7434: <div class="sect3" lang="en">
                   7435: <div class="titlepage"><div><div><h4 class="title">
1.77      rillig   7436: <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   7437: <pre class="programlisting">
                   7438:     i386        i386, __i386, __i386__
                   7439:     MIPS        __mips
                   7440:     SPARC       sparc, __sparc
                   7441: </pre>
                   7442: </div>
                   7443: <div class="sect3" lang="en">
                   7444: <div class="titlepage"><div><div><h4 class="title">
1.77      rillig   7445: <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   7446: <pre class="programlisting">
                   7447:     GCC         __GNUC__ (major version), __GNUC_MINOR__
                   7448:     SunPro      __SUNPRO_C (0x570 for version 5.7)
1.81      rillig   7449:     SunPro C++  __SUNPRO_CC (0x580 for version 5.8)
1.75      rillig   7450: </pre>
                   7451: </div>
                   7452: </div>
1.78      rillig   7453: <div class="sect2" lang="en">
                   7454: <div class="titlepage"><div><div><h3 class="title">
                   7455: <a name="compiler-bugs"></a>17.4.2. How to handle compiler bugs</h3></div></div></div>
                   7456: <p>Some source files trigger bugs in the compiler, based on
                   7457:         combinations  of compiler version and architecture and almost
                   7458:         always relation to  optimisation being enabled.  Common symptoms
                   7459:         are gcc internal errors  or never finishing compiling a
                   7460:        file.</p>
                   7461: <p>Typically, a workaround involves testing the
                   7462:         <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
                   7463:         optimisation for that combination of file,
                   7464:        <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
                   7465:        in  <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
                   7466:        number of examples.</p>
                   7467: </div>
                   7468: <div class="sect2" lang="en">
                   7469: <div class="titlepage"><div><div><h3 class="title">
                   7470: <a name="undefined-reference"></a>17.4.3. Undefined reference to &#8220;<span class="quote">...</span>&#8221;</h3></div></div></div>
                   7471: <p>This compiler error often means that a package did not
                   7472:        link to a shared library it needs. The following functions are
                   7473:        known to cause this error message over and over.</p>
                   7474: <div class="informaltable">
                   7475: <a name="undefined-reference-functions"></a><table border="1">
                   7476: <colgroup>
                   7477: <col>
                   7478: <col>
                   7479: <col>
                   7480: </colgroup>
                   7481: <thead><tr>
                   7482: <th>Function</th>
                   7483: <th>Library</th>
                   7484: <th>Affected platforms</th>
                   7485: </tr></thead>
                   7486: <tbody>
                   7487: <tr>
                   7488: <td>accept, bind, connect</td>
                   7489: <td>-lsocket</td>
                   7490: <td>Solaris</td>
                   7491: </tr>
                   7492: <tr>
                   7493: <td>crypt</td>
                   7494: <td>-lcrypt</td>
                   7495: <td>DragonFly, NetBSD</td>
                   7496: </tr>
                   7497: <tr>
                   7498: <td>dlopen, dlsym</td>
                   7499: <td>-ldl</td>
                   7500: <td>Linux</td>
                   7501: </tr>
                   7502: <tr>
                   7503: <td>gethost*</td>
                   7504: <td>-lnsl</td>
                   7505: <td>Solaris</td>
                   7506: </tr>
                   7507: <tr>
                   7508: <td>inet_aton</td>
                   7509: <td>-lresolv</td>
                   7510: <td>Solaris</td>
                   7511: </tr>
                   7512: <tr>
                   7513: <td>nanosleep, sem_*, timer_*</td>
                   7514: <td>-lrt</td>
                   7515: <td>Solaris</td>
                   7516: </tr>
                   7517: <tr>
                   7518: <td>openpty</td>
                   7519: <td>-lutil</td>
                   7520: <td>Linux</td>
                   7521: </tr>
                   7522: </tbody>
                   7523: </table>
                   7524: </div>
                   7525: <p>To fix these linker errors, it is often sufficient to say
                   7526:        <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
                   7527:        -l<em class="replaceable"><code>foo</code></em></code> to the package
                   7528:        <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
                   7529:        bmake</strong></span>.</p>
                   7530: </div>
1.75      rillig   7531: </div>
                   7532: <div class="sect1" lang="en">
                   7533: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78      rillig   7534: <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   7535: <div class="sect2" lang="en">
                   7536: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7537: <a name="install-scripts"></a>17.5.1. Creating needed directories</h3></div></div></div>
                   7538: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
                   7539:        with some operating systems cannot create more than one
                   7540:        directory at a time. As such, you should call
                   7541:        <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
1.75      rillig   7542: <pre class="programlisting">
1.78      rillig   7543:     ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   7544:     ${INSTALL_DATA_DIR} ${PREFIX}/dir2
1.75      rillig   7545: </pre>
1.78      rillig   7546: <p>You can also just append &#8220;<span class="quote"><code class="literal">dir1
                   7547:        dir2</code></span>&#8221; to the
                   7548:        <code class="varname">INSTALLATION_DIRS</code> variable, which will
                   7549:        automatically do the right thing.</p>
1.75      rillig   7550: </div>
                   7551: <div class="sect2" lang="en">
                   7552: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7553: <a name="where-to-install-documentation"></a>17.5.2. Where to install documentation</h3></div></div></div>
1.83    ! wiz      7554: <p>In general, documentation should be installed into
1.78      rillig   7555:        <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
                   7556:        <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
                   7557:        includes the version number of the package).</p>
1.83    ! wiz      7558: <p>Many modern packages using GNU autoconf allow to set the directory
        !          7559:        where HTML documentation is installed with the &#8220;<span class="quote">--with-html-dir</span>&#8221;
        !          7560:        option.</p>
        !          7561: <p>An exception to the above is that library API
        !          7562:        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
        !          7563:        special browsers (devhelp) should be left at their default
        !          7564:        location, which is
        !          7565:        <code class="filename">${PREFIX}/share/gtk-doc</code>.  Such
        !          7566:        documentation can be recognized from files ending in
        !          7567:        <code class="filename">.devhelp</code> or
        !          7568:        <code class="filename">.devhelp2</code>.  (It is also acceptable to
        !          7569:        install such files in
        !          7570:        <code class="filename">${PREFIX}/share/doc</code>; no additional
        !          7571:        subdirectory level is allowed in this case.)</p>
1.75      rillig   7572: </div>
                   7573: <div class="sect2" lang="en">
                   7574: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7575: <a name="installing-score-files"></a>17.5.3. Installing score files</h3></div></div></div>
1.75      rillig   7576: <p>Certain packages, most of them in the games category, install
                   7577:         a score file that allows all users on the system to record their
                   7578:         highscores.  In order for this to work, the binaries need to be
                   7579:         installed setgid and the score files owned by the appropriate
                   7580:         group and/or owner (traditionally the "games" user/group).  The
                   7581:         following variables, documented in more detail in
1.76      rillig   7582:         <code class="filename">mk/defaults/mk.conf</code>, control this
1.75      rillig   7583:         behaviour: <code class="varname">SETGIDGAME</code>,
                   7584:         <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
                   7585:         <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
                   7586: <p>Note that per default, setgid installation of games is
                   7587:         disabled;  setting <code class="varname">SETGIDGAME=YES</code> will set all
                   7588:         the other variables accordingly.</p>
                   7589: <p>A package should therefor never hard code file ownership or
                   7590:         access permissions but rely on <code class="varname">INSTALL_GAME</code> and
                   7591:         <code class="varname">INSTALL_GAME_DATA</code> to set these
                   7592:         correctly.</p>
                   7593: </div>
                   7594: <div class="sect2" lang="en">
                   7595: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7596: <a name="perl-scripts"></a>17.5.4. Packages containing perl scripts</h3></div></div></div>
1.75      rillig   7597: <p>
                   7598:         If your package contains interpreted perl scripts, set
                   7599:         <code class="varname">REPLACE_PERL</code> to ensure that the proper
                   7600:         interpreter path is set. <code class="varname">REPLACE_PERL</code> should
                   7601:         contain a list of scripts, relative to
                   7602:         <code class="varname">WRKSRC</code>, that you want adjusted.</p>
                   7603: </div>
                   7604: <div class="sect2" lang="en">
                   7605: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7606: <a name="hardcoded-paths"></a>17.5.5. Packages with hardcoded paths to other interpreters</h3></div></div></div>
1.75      rillig   7607: <p>
                   7608:         Your package may also contain scripts with hardcoded paths to
                   7609:         other interpreters besides (or as well as) perl.  To correct the
                   7610:         full pathname to the script interpreter, you need to set the
1.76      rillig   7611:         following definitions in your <code class="filename">Makefile</code> (we
1.75      rillig   7612:         shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
                   7613: <pre class="programlisting">
                   7614:     REPLACE_INTERPRETER+=   tcl
                   7615:     REPLACE.tcl.old=        .*/bin/tclsh
                   7616:     REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   7617:     REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   7618:                             # relative to ${WRKSRC}, just as in REPLACE_PERL
                   7619: </pre>
                   7620: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   7621: <h3 class="title">Note</h3>
                   7622: <p>Before March 2006, these variables were called
                   7623:        <code class="varname">_REPLACE.*</code> and
                   7624:        <code class="varname">_REPLACE_FILES.*</code>.</p>
                   7625: </div>
                   7626: </div>
                   7627: <div class="sect2" lang="en">
                   7628: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7629: <a name="perl-modules"></a>17.5.6. Packages installing perl modules</h3></div></div></div>
1.75      rillig   7630: <p>Makefiles of packages providing perl5 modules should include
                   7631:         the Makefile fragment
1.76      rillig   7632:         <code class="filename">../../lang/perl5/module.mk</code>.  It provides a
1.75      rillig   7633:         <span><strong class="command">do-configure</strong></span> target for the standard perl
                   7634:         configuration for such modules as well as various hooks to tune
                   7635:         this configuration.  See comments in this file for
                   7636:         details.</p>
                   7637: <p>Perl5 modules will install into different places depending
                   7638:         on the version of perl used during the build process.  To
                   7639:         address this, pkgsrc will append lines to the
1.76      rillig   7640:         <code class="filename">PLIST</code> corresponding to the files listed in
                   7641:         the installed <code class="filename">.packlist</code> file generated by
1.75      rillig   7642:         most perl5 modules.  This is invoked by defining
                   7643:         <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
                   7644:         paths to packlist files, e.g.:</p>
                   7645: <pre class="programlisting">
                   7646:     PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
                   7647: </pre>
                   7648: <p>The variables <code class="varname">PERL5_SITELIB</code>,
                   7649:         <code class="varname">PERL5_SITEARCH</code>, and
                   7650:         <code class="varname">PERL5_ARCHLIB</code> represent the three locations
                   7651:         in which perl5 modules may be installed, and may be used by
                   7652:         perl5 packages that don't have a packlist.  These three
                   7653:         variables are also substituted for in the
1.76      rillig   7654:         <code class="filename">PLIST</code>.</p>
1.75      rillig   7655: </div>
                   7656: <div class="sect2" lang="en">
                   7657: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7658: <a name="faq.info-files"></a>17.5.7. Packages installing info files</h3></div></div></div>
1.75      rillig   7659: <p>Some packages install info files or use the
                   7660:         &#8220;<span class="quote">makeinfo</span>&#8221;  or &#8220;<span class="quote">install-info</span>&#8221;
                   7661:        commands.  <code class="varname">INFO_FILES</code> should be defined in
1.76      rillig   7662:        the package Makefile so that <code class="filename">INSTALL</code> and
                   7663:         <code class="filename">DEINSTALL</code> scripts will be generated to
1.75      rillig   7664:         handle registration of the info files in the Info directory
                   7665:         file. The &#8220;<span class="quote">install-info</span>&#8221; command used for the info
                   7666:         files registration is either provided by the system, or by a
                   7667:         special purpose package automatically added as dependency if
                   7668:         needed.</p>
                   7669: <p><code class="varname">PKGINFODIR</code> is the directory under
1.76      rillig   7670:        <code class="filename">${PREFIX}</code> where info files are primarily
1.75      rillig   7671:        located. <code class="varname">PKGINFODIR</code> defaults to
                   7672:        &#8220;<span class="quote">info</span>&#8221; and can be overridden by the user.</p>
                   7673: <p>The info files for the package should be listed in the
1.76      rillig   7674:        package <code class="filename">PLIST</code>; however any split info files
1.75      rillig   7675:        need not be listed.</p>
                   7676: <p>A package which needs the &#8220;<span class="quote">makeinfo</span>&#8221; command
                   7677:         at build time must add &#8220;<span class="quote">makeinfo</span>&#8221; to
                   7678:         <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
                   7679:         version of the &#8220;<span class="quote">makeinfo</span>&#8221; command is needed it
                   7680:         should be noted with the <code class="varname">TEXINFO_REQD</code>
1.76      rillig   7681:         variable in the package <code class="filename">Makefile</code>. By
1.75      rillig   7682:         default, a minimum version of 3.12 is required. If the system
                   7683:         does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
                   7684:         does not match the required minimum, a build dependency on the
1.76      rillig   7685:         <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   7686:        be added automatically.</p>
                   7687: <p>The build and installation process of the software provided
                   7688:         by the package should not use the
                   7689:         <span><strong class="command">install-info</strong></span> command as the registration of
                   7690:         info files is the task of the package
1.76      rillig   7691:         <code class="filename">INSTALL</code> script, and it must use the
1.75      rillig   7692:         appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
                   7693: <p>To achieve this goal, the pkgsrc infrastructure creates
                   7694:         overriding scripts for the <span><strong class="command">install-info</strong></span> and
                   7695:         <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
                   7696:         in <code class="varname">PATH</code>.</p>
                   7697: <p>The script overriding <span><strong class="command">install-info</strong></span> has
                   7698:         no effect except the logging of a message. The script overriding
                   7699:         <span><strong class="command">makeinfo</strong></span> logs a message and according to the
                   7700:         value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
                   7701:        <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
                   7702: </div>
                   7703: <div class="sect2" lang="en">
                   7704: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7705: <a name="manpages"></a>17.5.8. Packages installing man pages</h3></div></div></div>
1.81      rillig   7706: <p>All packages that install manual pages should install them
                   7707:        into the same directory, so that there is one common place to
                   7708:        look for them. In pkgsrc, this place is
                   7709:        <code class="literal">${PREFIX}/${PKGMANDIR}</code>, and this expression
                   7710:        should be used in packages. The default for
                   7711:        <code class="varname">PKGMANDIR</code> is
                   7712:        &#8220;<span class="quote"><code class="filename">man</code></span>&#8221;. Another often-used
                   7713:        value is &#8220;<span class="quote"><code class="filename">share/man</code></span>&#8221;.</p>
1.75      rillig   7714: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   7715: <h3 class="title">Note</h3>
1.81      rillig   7716: <p>The support for a custom
                   7717:        <code class="varname">PKGMANDIR</code> is far from complete.</p>
1.75      rillig   7718: </div>
1.81      rillig   7719: <p>The <code class="filename">PLIST</code> files can just use
                   7720:        <code class="filename">man/</code> as the top level directory for the man
                   7721:        page file entries, and the pkgsrc framework will convert as
                   7722:        needed. In all other places, the correct
                   7723:        <code class="varname">PKGMANDIR</code> must be used.</p>
1.75      rillig   7724: <p> Packages that are
                   7725:        configured with <code class="varname">GNU_CONFIGURE</code> set as
                   7726:        &#8220;<span class="quote">yes</span>&#8221;, by default will use the
1.76      rillig   7727:        <code class="filename">./configure</code>
1.75      rillig   7728:        --mandir switch to set where the man pages should be installed.
                   7729:        The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
                   7730:        to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.
                   7731:       </p>
                   7732: <p>
                   7733:        Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
                   7734:        use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
                   7735:        to &#8220;<span class="quote">no</span>&#8221;.
1.76      rillig   7736:        Or if the <code class="filename">./configure</code> script uses
1.75      rillig   7737:        a non-standard use of --mandir, you can set
                   7738:        <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.
                   7739:       </p>
1.77      rillig   7740: <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   7741:        information on installation of compressed manual pages.
                   7742:       </p>
                   7743: </div>
                   7744: <div class="sect2" lang="en">
                   7745: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7746: <a name="gconf2-data-files"></a>17.5.9. Packages installing GConf2 data files</h3></div></div></div>
1.75      rillig   7747: <p>
1.76      rillig   7748:         If a package installs <code class="filename">.schemas</code> or
                   7749:         <code class="filename">.entries</code> files, used by GConf2,
1.75      rillig   7750:         you need to take some extra steps to make sure they get registered
                   7751:         in the database:
                   7752: </p>
                   7753: <div class="orderedlist"><ol type="1">
1.76      rillig   7754: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
                   7755:           instead of its <code class="filename">buildlink3.mk</code> file.  This
1.75      rillig   7756:           takes care of rebuilding the GConf2 database at installation and
                   7757:           deinstallation time, and tells the package where to install
                   7758:           GConf2 data files using some standard configure arguments.  It
                   7759:           also disallows any access to the database directly from the
                   7760:           package.</p></li>
                   7761: <li><p>Ensure that the package installs its
1.76      rillig   7762:           <code class="filename">.schemas</code> files under
                   7763:           <code class="filename">${PREFIX}/share/gconf/schemas</code>.  If they get
                   7764:           installed under <code class="filename">${PREFIX}/etc</code>, you will
1.75      rillig   7765:           need to manually patch the package.</p></li>
                   7766: <li><p>Check the PLIST and remove any entries under the etc/gconf
                   7767:           directory, as they will be handled automatically.  See
                   7768:           <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>
                   7769: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.76      rillig   7770:           your <code class="filename">Makefile</code> with a list of all
                   7771:           <code class="filename">.schemas</code> files installed by the package, if
1.75      rillig   7772:           any.  Names must not contain any directories in them.</p></li>
                   7773: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.76      rillig   7774:           your <code class="filename">Makefile</code> with a
                   7775:           list of all <code class="filename">.entries</code> files installed by the
1.75      rillig   7776:           package, if any. Names must not contain any directories in
                   7777:           them.</p></li>
                   7778: </ol></div>
                   7779: </div>
                   7780: <div class="sect2" lang="en">
                   7781: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7782: <a name="scrollkeeper-data-files"></a>17.5.10. Packages installing scrollkeeper data files</h3></div></div></div>
1.75      rillig   7783: <p>
1.76      rillig   7784:         If a package installs <code class="filename">.omf</code> files, used by
1.75      rillig   7785:         scrollkeeper, you need to take some extra steps to make sure they
                   7786:         get registered in the database:
                   7787: </p>
                   7788: <div class="orderedlist"><ol type="1">
                   7789: <li><p>Include
1.76      rillig   7790:             <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
                   7791:             instead of its <code class="filename">buildlink3.mk</code> file.  This
1.75      rillig   7792:             takes care of rebuilding the scrollkeeper database at
                   7793:             installation and deinstallation time, and disallows any access
                   7794:             to it directly from the package.
                   7795: </p></li>
                   7796: <li><p>Check the PLIST and remove any entries under the
1.76      rillig   7797:             <code class="filename">libdata/scrollkeeper</code> directory, as they
1.75      rillig   7798:             will be handled automatically.</p></li>
1.76      rillig   7799: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.75      rillig   7800:             the PLIST.  It will be handled by scrollkeeper.</p></li>
                   7801: </ol></div>
                   7802: </div>
                   7803: <div class="sect2" lang="en">
                   7804: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7805: <a name="x11-fonts"></a>17.5.11. Packages installing X11 fonts</h3></div></div></div>
1.75      rillig   7806: <p>If a package installs font files, you will need to rebuild
                   7807:         the fonts database in the directory where they get installed at
                   7808:         installation and deinstallation time.  This can be automatically
                   7809:         done by using the pkginstall framework.</p>
                   7810: <p>You can list the directories where fonts are installed in the
                   7811:         <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
                   7812:         variables, where <em class="replaceable"><code>type</code></em> can be one of
                   7813:         &#8220;<span class="quote">ttf</span>&#8221;, &#8220;<span class="quote">type1</span>&#8221; or &#8220;<span class="quote">x11</span>&#8221;.
                   7814:         Also make sure that the database file
1.76      rillig   7815:         <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75      rillig   7816: <p>Note that you should not create new directories for fonts;
                   7817:         instead use the standard ones to avoid that the user needs to
                   7818:         manually configure his X server to find them.</p>
                   7819: </div>
                   7820: <div class="sect2" lang="en">
                   7821: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7822: <a name="gtk2-modules"></a>17.5.12. Packages installing GTK2 modules</h3></div></div></div>
1.75      rillig   7823: <p>If a package installs GTK2 immodules or loaders, you need to
                   7824:         take some extra steps to get them registered in the GTK2 database
                   7825:         properly:</p>
                   7826: <div class="orderedlist"><ol type="1">
                   7827: <li><p>Include
1.76      rillig   7828:         <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
                   7829:         <code class="filename">buildlink3.mk</code> file.  This takes care of
1.75      rillig   7830:         rebuilding the database at installation and deinstallation time.
                   7831: </p></li>
                   7832: <li><p>
                   7833:         Set <code class="varname">GTK2_IMMODULES=YES</code> if
                   7834:             your package installs GTK2 immodules.</p></li>
                   7835: <li><p>
                   7836:         Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
                   7837:             GTK2 loaders.</p></li>
                   7838: <li>
                   7839: <p>
                   7840:         Patch the package to not touch any of the GTK2 databases directly.
                   7841:         These are:
                   7842: 
                   7843:         </p>
                   7844: <div class="itemizedlist"><ul type="disc">
1.76      rillig   7845: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
                   7846: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75      rillig   7847: </ul></div>
                   7848: <p>
                   7849: </p>
                   7850: </li>
                   7851: <li><p>
                   7852:         Check the PLIST and remove any entries under the
1.76      rillig   7853:         <code class="filename">libdata/gtk-2.0</code> directory, as they will be
1.75      rillig   7854:         handled automatically.</p></li>
                   7855: </ol></div>
                   7856: </div>
                   7857: <div class="sect2" lang="en">
                   7858: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7859: <a name="sgml-xml-data"></a>17.5.13. Packages installing SGML or XML data</h3></div></div></div>
1.75      rillig   7860: <p>If a package installs SGML or XML data files that need to be
                   7861:         registered in system-wide catalogs (like DTDs, sub-catalogs,
                   7862:         etc.), you need to take some extra steps:
                   7863: </p>
                   7864: <div class="orderedlist"><ol type="1">
                   7865: <li><p>Include
1.76      rillig   7866:             <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
                   7867:             your <code class="filename">Makefile</code>, which takes care of
1.75      rillig   7868:             registering those files in system-wide catalogs at
                   7869:             installation and deinstallation time.</p></li>
                   7870: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
                   7871:             any SGML catalogs installed by the package.</p></li>
                   7872: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
                   7873:             any XML catalogs installed by the package.</p></li>
                   7874: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
                   7875:             to be added to the SGML catalog.  These come in groups of
                   7876:             three strings; see xmlcatmgr(1) for more information
                   7877:             (specifically, arguments recognized by the 'add' action).
                   7878:             Note that you will normally not use this variable.</p></li>
                   7879: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
                   7880:             to be added to the XML catalog.  These come in groups of three
                   7881:             strings; see xmlcatmgr(1) for more information (specifically,
                   7882:             arguments recognized by the 'add' action).  Note that you will
                   7883:             normally not use this variable.
                   7884: </p></li>
                   7885: </ol></div>
                   7886: </div>
                   7887: <div class="sect2" lang="en">
                   7888: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7889: <a name="mime-database"></a>17.5.14. Packages installing extensions to the MIME database</h3></div></div></div>
1.75      rillig   7890: <p>If a package provides extensions to the MIME database by
1.76      rillig   7891:         installing <code class="filename">.xml</code> files inside
                   7892:         <code class="filename">${PREFIX}/share/mime/packages</code>, you
1.75      rillig   7893:         need to take some extra steps to ensure that the database is kept
                   7894:         consistent with respect to these new files:
                   7895: </p>
                   7896: <div class="orderedlist"><ol type="1">
                   7897: <li><p>Include
1.76      rillig   7898:             <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
                   7899:             (avoid using the <code class="filename">buildlink3.mk</code> file from
1.75      rillig   7900:             this same directory, which is reserved for inclusion from
1.76      rillig   7901:             other <code class="filename">buildlink3.mk</code> files).  It takes
1.75      rillig   7902:             care of rebuilding the MIME database at installation and
                   7903:             deinstallation time, and disallows any access to it directly
                   7904:             from the package.</p></li>
                   7905: <li><p>Check the PLIST and remove any entries under the
1.76      rillig   7906:             <code class="filename">share/mime</code> directory,
1.75      rillig   7907:             <span class="emphasis"><em>except</em></span> for files saved under
1.76      rillig   7908:             <code class="filename">share/mime/packages</code>.  The former are
1.75      rillig   7909:             handled automatically by
                   7910:             the update-mime-database program, but the latter are
                   7911:             package-dependent and must be removed by the package that
                   7912:             installed them in the first place.</p></li>
1.76      rillig   7913: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.75      rillig   7914:             from the PLIST.  They will be handled by the shared-mime-info
                   7915:             package.</p></li>
                   7916: </ol></div>
                   7917: </div>
                   7918: <div class="sect2" lang="en">
                   7919: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7920: <a name="intltool"></a>17.5.15. Packages using intltool</h3></div></div></div>
1.75      rillig   7921: <p>If a package uses intltool during its build, include the
1.76      rillig   7922:         <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
1.75      rillig   7923:         which forces it to use the intltool package provided by pkgsrc,
                   7924:         instead of the one bundled with the distribution file.
                   7925: </p>
                   7926: <p>This tracks intltool's build-time dependencies and uses the
                   7927:         latest available version; this way, the package benefits of any
                   7928:         bug fixes that may have appeared since it was released.
                   7929: </p>
                   7930: </div>
                   7931: <div class="sect2" lang="en">
                   7932: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7933: <a name="startup-scripts"></a>17.5.16. Packages installing startup scripts</h3></div></div></div>
1.75      rillig   7934: <p>If a package contains a rc.d script, it won't be copied into
                   7935:         the startup directory by default, but you can enable it, by adding
                   7936:         the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
1.76      rillig   7937:         <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
                   7938:         into <code class="filename">/etc/rc.d</code> when a package is installed, and
1.75      rillig   7939:         it will automatically remove the scripts when the package is
                   7940:         deinstalled.</p>
                   7941: </div>
                   7942: <div class="sect2" lang="en">
                   7943: <div class="titlepage"><div><div><h3 class="title">
1.78      rillig   7944: <a name="tex-packages"></a>17.5.17. Packages installing TeX modules</h3></div></div></div>
1.75      rillig   7945: <p>If a package installs TeX packages into the texmf tree,
1.76      rillig   7946:         the <code class="filename">ls-R</code> database of the tree needs to be
1.75      rillig   7947:         updated.</p>
                   7948: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   7949: <h3 class="title">Note</h3>
                   7950: <p>Except the main TeX packages such as teTeX-texmf,
                   7951:          packages should install files
                   7952:          into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
                   7953:          not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
                   7954: </div>
                   7955: <div class="orderedlist"><ol type="1">
                   7956: <li><p>Include
1.76      rillig   7957:             <code class="filename">../../print/teTeX/module.mk</code> instead
                   7958:             of <code class="filename">../../mk/tex.buildlink3.mk</code>.  This
                   7959:             takes care of rebuilding the <code class="filename">ls-R</code>
1.75      rillig   7960:             database at installation and deinstallation time.</p></li>
                   7961: <li>
                   7962: <p>If your package installs files into a texmf
                   7963:             tree other than the one
                   7964:             at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
                   7965:             set <code class="varname">TEXMFDIRS</code> to the list of all texmf
                   7966:             trees that need database update.</p>
                   7967: <p>If your package also installs font map files that need
                   7968:            to be registered using <span><strong class="command">updmap</strong></span>,
                   7969:            set <code class="varname">TEX_FONTMAPS</code> to the list of all
                   7970:            such font map files.  Then <span><strong class="command">updmap</strong></span> will
                   7971:            be run automatically at installation/deinstallation to
                   7972:            enable/disable font map files for TeX output
                   7973:            drivers.</p>
                   7974: </li>
1.76      rillig   7975: <li><p>Make sure that none of <code class="filename">ls-R</code>
                   7976:             databases are included in <code class="filename">PLIST</code>, as
1.75      rillig   7977:             they will be removed only by the teTeX-bin package.</p></li>
                   7978: </ol></div>
                   7979: </div>
                   7980: </div>
                   7981: <div class="sect1" lang="en">
                   7982: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78      rillig   7983: <a name="feedback-to-author"></a>17.6. Feedback to the author</h2></div></div></div>
1.75      rillig   7984: <p>If you have found any bugs in the package you make available,
                   7985:       if you had to do special steps to make it run under NetBSD or
                   7986:       if you enhanced the software in various other ways, be sure
                   7987:       to report these changes back to the original author of the
                   7988:       program! With that kind of support, the next release of the
                   7989:       program can incorporate these fixes, and people not using the
                   7990:       NetBSD packages system can win from your efforts.</p>
                   7991: <p>Support the idea of free software!</p>
                   7992: </div>
                   7993: </div>
                   7994: <div class="chapter" lang="en">
                   7995: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   7996: <a name="debug"></a>Chapter 18. Debugging</h2></div></div></div>
1.75      rillig   7997: <p>To check out all the gotchas when building a package, here are the steps
                   7998:     that I do in order to get a package working. Please note this is basically
                   7999:     the same as what was explained in the previous sections, only with some
                   8000:     debugging aids.</p>
                   8001: <div class="itemizedlist"><ul type="disc">
                   8002: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code>
1.76      rillig   8003:        in <code class="filename">/etc/mk.conf</code></p></li>
1.75      rillig   8004: <li>
1.76      rillig   8005: <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   8006:         create a directory for a new package, change into it, then run
                   8007:         <span><strong class="command">url2pkg</strong></span>:</p>
                   8008: <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>
                   8009: <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>
                   8010: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
                   8011: </li>
1.76      rillig   8012: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
                   8013: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.75      rillig   8014: <li><p>Run <span><strong class="command">make configure</strong></span>
                   8015:       </p></li>
                   8016: <li><p>Add any dependencies glimpsed from documentation and the
                   8017:        configure step to the package's
1.76      rillig   8018:        <code class="filename">Makefile</code>.</p></li>
1.75      rillig   8019: <li>
                   8020: <p>Make the package compile, doing multiple rounds of</p>
                   8021: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
                   8022: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
                   8023: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
                   8024: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
                   8025: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
                   8026: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
                   8027: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
                   8028: <p>Doing as non-root user will ensure that no files are modified that
                   8029:        shouldn't be, especially during the build
                   8030:        phase. <span><strong class="command">mkpatches</strong></span>,
                   8031:        <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
1.76      rillig   8032:        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   8033:        package. </p>
                   8034: </li>
1.76      rillig   8035: <li><p>Look at the <code class="filename">Makefile</code>, fix if necessary;
1.77      rillig   8036:        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   8037: <li>
1.76      rillig   8038: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75      rillig   8039: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
                   8040: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST &gt;PLIST</code></strong>
                   8041: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
                   8042: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
                   8043: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.76      rillig   8044: <p>You usually need to be <code class="username">root</code> to do this.
1.75      rillig   8045:        Look if there are any files left:</p>
                   8046: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
                   8047: <p>If this reveals any files that are missing in
1.76      rillig   8048:        <code class="filename">PLIST</code>, add them.</p>
1.75      rillig   8049: </li>
                   8050: <li>
1.76      rillig   8051: <p>Now that the <code class="filename">PLIST</code> is OK,
1.75      rillig   8052:        install the package again and make a binary package:</p>
                   8053: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
                   8054: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
                   8055: </li>
                   8056: <li>
                   8057: <p>Delete the installed package:</p>
                   8058: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete blub</code></strong></pre>
                   8059: </li>
                   8060: <li>
                   8061: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span> command,
                   8062:        which shouldn't find anything now:</p>
                   8063: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
                   8064: </li>
                   8065: <li>
                   8066: <p>Reinstall the binary package:</p>
                   8067: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../blub.tgz</code></strong></pre>
                   8068: </li>
                   8069: <li><p>Play with it. Make sure everything works.</p></li>
                   8070: <li>
                   8071: <p>Run <span><strong class="command">pkglint</strong></span> from
1.76      rillig   8072:         <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   8073:        and fix the problems it reports:</p>
                   8074: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
                   8075: </li>
                   8076: <li><p>Submit (or commit, if you have cvs access);
1.77      rillig   8077:        see <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a>.</p></li>
1.75      rillig   8078: </ul></div>
                   8079: </div>
                   8080: <div class="chapter" lang="en">
                   8081: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   8082: <a name="submit"></a>Chapter 19. Submitting and Committing</h2></div></div></div>
1.75      rillig   8083: <div class="toc">
                   8084: <p><b>Table of Contents</b></p>
                   8085: <dl>
1.77      rillig   8086: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
                   8087: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
                   8088: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
                   8089: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
                   8090: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
                   8091: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig   8092: </dl>
                   8093: </div>
                   8094: <div class="sect1" lang="en">
                   8095: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8096: <a name="submitting-binary-packages"></a>19.1. Submitting binary packages</h2></div></div></div>
1.75      rillig   8097: <p>Our policy is that we accept binaries only from pkgsrc
                   8098:        developers to guarantee that the packages don't contain any
                   8099:        trojan horses etc. This is not to annoy anyone but rather to
                   8100:        protect our users! You're still free to put up your home-made
                   8101:        binary packages and tell the world where to get them. NetBSD
                   8102:        developers doing bulk builds and wanting to upload them please
                   8103:        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>
                   8104: </div>
                   8105: <div class="sect1" lang="en">
                   8106: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8107: <a name="submitting-your-package"></a>19.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75      rillig   8108: <p>First, check that your package is complete, compiles and
1.77      rillig   8109:        runs well; see <a href="#debug" title="Chapter 18. Debugging">Chapter 18, <i>Debugging</i></a> and the rest of this
1.75      rillig   8110:        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   8111:        archive that contains all files that make up the package.
1.75      rillig   8112:        Finally, <span><strong class="command">send-pr</strong></span> with category
                   8113:        &#8220;<span class="quote">pkg</span>&#8221;, a synopsis which includes the package name
                   8114:        and version number, a short description of your package
                   8115:        (contents of the COMMENT variable or DESCR file are OK) and
                   8116:        attach the archive to your PR.</p>
                   8117: <p>If you want to submit several packages, please send a
                   8118:        separate PR for each one, it's easier for us to track things
                   8119:        that way.</p>
                   8120: <p>Alternatively, you can also import new packages into
                   8121:        pkgsrc-wip (&#8220;<span class="quote">pkgsrc work-in-progress</span>&#8221;); see the
                   8122:        homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
                   8123:        for details.</p>
                   8124: </div>
                   8125: <div class="sect1" lang="en">
                   8126: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8127: <a name="general-notes-for-changes"></a>19.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75      rillig   8128: <p>Please note all package additions, updates, moves, and
1.76      rillig   8129:        removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75      rillig   8130:        important to keep this file up to date and conforming to the
                   8131:        existing format, because it will be used by scripts to
                   8132:        automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
                   8133:        sites. Additionally, check the
1.76      rillig   8134:        <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75      rillig   8135:        for the package you updated or removed, in case it was mentioned
                   8136:        there.</p>
                   8137: <p>When the <code class="varname">PKGREVISION</code> of a package is
                   8138:        bumped, the change should appear in
1.76      rillig   8139:        <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75      rillig   8140:        related or otherwise relevant. Mass bumps that result from a
                   8141:        dependency being updated should not be mentioned. In all other
                   8142:        cases it's the developer's decision.</p>
                   8143: <p>There is a make target that helps in creating proper
1.76      rillig   8144:   <code class="filename">CHANGES</code> entries:  <span><strong class="command">make
1.75      rillig   8145:   changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
                   8146:   and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76      rillig   8147:   usage is to first make sure that your <code class="filename">CHANGES</code>
1.75      rillig   8148:   file is up-to-date (to avoid having to resolve conflicts later-on)
                   8149:   and then to <span><strong class="command">cd</strong></span> to the package directory.  For
                   8150:   package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
                   8151:   For new packages, or package moves or removals, set the
                   8152:   <code class="varname">CTYPE</code> variable on the command line to "Added",
                   8153:   "Moved", or "Removed".  You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76      rillig   8154:   in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75      rillig   8155:   not the same as your NetBSD login name. Don't forget to commit
1.76      rillig   8156:   the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75      rillig   8157: </div>
                   8158: <div class="sect1" lang="en">
                   8159: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8160: <a name="committing-importing"></a>19.4. Committing: Importing a package into CVS</h2></div></div></div>
1.75      rillig   8161: <p>
                   8162:   This section is only of interest for pkgsrc developers with write
                   8163:   access to the pkgsrc repository. Please remember that cvs
                   8164:   imports files relative to the current working directory, and that
                   8165:   the pathname that you
                   8166:   give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
                   8167:   to place the files in the repository.  Newly created packages should be
                   8168:   imported with a vendor tag of &#8220;<span class="quote">TNF</span>&#8221; and a release tag of
                   8169:   &#8220;<span class="quote">pkgsrc-base</span>&#8221;, e.g:
                   8170: </p>
                   8171: <pre class="programlisting">
                   8172:     <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
                   8173:     <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
                   8174: </pre>
                   8175: <p>
                   8176:   Remember to move the directory from which you imported out of
                   8177:   the way, or cvs will complain the next time you &#8220;<span class="quote">cvs
                   8178:   update</span>&#8221; your source tree.  Also don't forget to add the new
1.76      rillig   8179:   package to the category's <code class="filename">Makefile</code>.
1.75      rillig   8180: </p>
                   8181: <p>
                   8182:   The commit message of the initial import should include part of the
1.76      rillig   8183:   <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.75      rillig   8184:   what the package is/does.
                   8185: </p>
                   8186: <p>
                   8187:   For new packages, &#8220;<span class="quote">cvs import</span>&#8221; is preferred to &#8220;<span class="quote">cvs
                   8188:   add</span>&#8221; because the former gets everything with a single command,
                   8189:   and provides a consistent tag.
                   8190: </p>
                   8191: </div>
                   8192: <div class="sect1" lang="en">
                   8193: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8194: <a name="updating-package"></a>19.5. Updating a package to a newer version</h2></div></div></div>
1.75      rillig   8195: <p>
                   8196:   Please always put a concise, appropriate and relevant summary of the
                   8197:   changes between old and new versions into the commit log when updating
                   8198:   a package. There are various reasons for this:
                   8199: </p>
                   8200: <div class="itemizedlist"><ul type="disc">
                   8201: <li><p>
                   8202:   A URL is volatile, and can change over time. It may go away completely
                   8203:   or its information may be overwritten by newer information.
                   8204: </p></li>
                   8205: <li><p>
                   8206:   Having the change information between old and new versions in our CVS
                   8207:   repository is very useful for people who use either cvs or anoncvs.
                   8208: </p></li>
                   8209: <li><p>
                   8210:   Having the change information between old and new versions in our CVS
                   8211:   repository is very useful for people who read the pkgsrc-changes mailing
                   8212:   list, so that they can make tactical decisions about when to upgrade
                   8213:   the package.
                   8214: </p></li>
                   8215: </ul></div>
                   8216: <p>
                   8217:   Please also recognize that, just because a new version of a package
                   8218:   has been released, it should not automatically be upgraded in the CVS
                   8219:   repository.  We prefer to be conservative in the packages that are
                   8220:   included in pkgsrc - development or beta packages are not really the
                   8221:   best thing for most places in which pkgsrc is used. Please use your
                   8222:   judgement about what should go into pkgsrc, and bear in mind that
                   8223:   stability is to be preferred above new and possibly untested features.
                   8224: </p>
                   8225: </div>
                   8226: <div class="sect1" lang="en">
                   8227: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8228: <a name="moving-package"></a>19.6. Moving a package in pkgsrc</h2></div></div></div>
1.75      rillig   8229: <div class="orderedlist"><ol type="1">
                   8230: <li><p>Make a copy of the directory somewhere else.</p></li>
                   8231: <li>
                   8232: <p>Remove all CVS dirs.</p>
                   8233: <p>
                   8234:   Alternatively to the first two steps you can also do:
                   8235: </p>
                   8236: <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>
                   8237: <p>
                   8238:   and use that for further work.
                   8239: </p>
                   8240: </li>
                   8241: <li><p>Fix <code class="varname">CATEGORIES</code> and any
                   8242: <code class="varname">DEPENDS</code> paths that just did &#8220;<span class="quote">../package</span>&#8221;
                   8243: instead of &#8220;<span class="quote">../../category/package</span>&#8221;.</p></li>
                   8244: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
                   8245: place.</p></li>
                   8246: <li>
                   8247: <p>Check if any package depends on it:
                   8248: </p>
                   8249: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   8250: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
                   8251: <p>
                   8252: </p>
                   8253: </li>
                   8254: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
                   8255: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76      rillig   8256: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
                   8257: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75      rillig   8258: <li>
                   8259: <p>Commit the changed and removed files:</p>
                   8260: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
                   8261: <p>
                   8262:   (and any packages from step 5, of course).
                   8263: </p>
                   8264: </li>
                   8265: </ol></div>
                   8266: </div>
                   8267: </div>
                   8268: <div class="chapter" lang="en">
                   8269: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   8270: <a name="devfaq"></a>Chapter 20. Frequently Asked Questions</h2></div></div></div>
1.75      rillig   8271: <p>This section contains the answers to questions that may
                   8272:        arise when you are writing a package. If you don't find your
                   8273:        question answered here, first have a look in the other chapters,
                   8274:        and if you still don't have the answer, ask on the
                   8275:        <code class="literal">pkgsrc-users</code> mailing list.</p>
                   8276: <div class="qandaset">
                   8277: <dl>
1.83    ! wiz      8278: <dt>20.1. <a href="#id2698199">What is the difference between
1.75      rillig   8279:        MAKEFLAGS, .MAKEFLAGS and
                   8280:        MAKE_FLAGS?</a>
                   8281: </dt>
1.83    ! wiz      8282: <dt>20.2. <a href="#id2698235">What is the difference between
1.75      rillig   8283:        MAKE, GMAKE and
                   8284:        MAKE_PROGRAM?</a>
                   8285: </dt>
1.83    ! wiz      8286: <dt>20.3. <a href="#id2698342">What is the difference between
1.75      rillig   8287:        CC, PKG_CC and
                   8288:        PKGSRC_COMPILER?</a>
                   8289: </dt>
1.83    ! wiz      8290: <dt>20.4. <a href="#id2698379">What is the difference between
1.75      rillig   8291:        BUILDLINK_LDFLAGS,
                   8292:        BUILDLINK_LDADD and
                   8293:        BUILDLINK_LIBS?</a>
                   8294: </dt>
1.83    ! wiz      8295: <dt>20.5. <a href="#id2698397">Why does make show-var
1.75      rillig   8296:        VARNAME=BUILDLINK_PREFIX.foo
                   8297:        say it's empty?</a>
                   8298: </dt>
1.83    ! wiz      8299: <dt>20.6. <a href="#id2698425">What does
1.78      rillig   8300:        ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
                   8301:        don't understand the := inside
                   8302:        it.</a>
                   8303: </dt>
1.83    ! wiz      8304: <dt>20.7. <a href="#id2698500">Which mailing lists are there for package
1.78      rillig   8305:        developers?</a>
                   8306: </dt>
1.83    ! wiz      8307: <dt>20.8. <a href="#id2698536">Where is the pkgsrc
1.80      rillig   8308:        documentation?</a>
                   8309: </dt>
1.75      rillig   8310: </dl>
                   8311: <table border="0" summary="Q and A Set">
                   8312: <col align="left" width="1%">
                   8313: <tbody>
                   8314: <tr class="question">
                   8315: <td align="left" valign="top">
1.83    ! wiz      8316: <a name="id2698199"></a><a name="id2698200"></a><b>20.1.</b>
1.75      rillig   8317: </td>
                   8318: <td align="left" valign="top"><p>What is the difference between
                   8319:        <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
                   8320:        <code class="varname">MAKE_FLAGS</code>?</p></td>
                   8321: </tr>
                   8322: <tr class="answer">
1.83    ! wiz      8323: <td align="left" valign="top"></td>
1.75      rillig   8324: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
                   8325:        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
                   8326:        <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
                   8327:        the <code class="varname">MAKE_PROGRAM</code> when building the
                   8328:        package. [FIXME: What is .MAKEFLAGS for?]</p></td>
                   8329: </tr>
                   8330: <tr class="question">
                   8331: <td align="left" valign="top">
1.83    ! wiz      8332: <a name="id2698235"></a><a name="id2698236"></a><b>20.2.</b>
1.75      rillig   8333: </td>
                   8334: <td align="left" valign="top"><p>What is the difference between
                   8335:        <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
                   8336:        <code class="varname">MAKE_PROGRAM</code>?</p></td>
                   8337: </tr>
                   8338: <tr class="answer">
1.83    ! wiz      8339: <td align="left" valign="top"></td>
1.75      rillig   8340: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
                   8341:        <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
                   8342:        infrastructure. <code class="varname">GMAKE</code> is the path to GNU
                   8343:        Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
                   8344:        use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
                   8345:        Make program that is used for building the
                   8346:        package.</p></td>
                   8347: </tr>
                   8348: <tr class="question">
                   8349: <td align="left" valign="top">
1.83    ! wiz      8350: <a name="id2698342"></a><a name="id2698343"></a><b>20.3.</b>
1.75      rillig   8351: </td>
                   8352: <td align="left" valign="top"><p>What is the difference between
                   8353:        <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
                   8354:        <code class="varname">PKGSRC_COMPILER</code>?</p></td>
                   8355: </tr>
                   8356: <tr class="answer">
1.83    ! wiz      8357: <td align="left" valign="top"></td>
1.75      rillig   8358: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
                   8359:        compiler, which can be configured by the pkgsrc user.
                   8360:        <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
                   8361:        <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
                   8362:        path to a compiler, but the type of compiler that should be
1.76      rillig   8363:        used. See <code class="filename">mk/compiler.mk</code> for more
1.75      rillig   8364:        information about the latter variable.</p></td>
                   8365: </tr>
                   8366: <tr class="question">
                   8367: <td align="left" valign="top">
1.83    ! wiz      8368: <a name="id2698379"></a><a name="id2698380"></a><b>20.4.</b>
1.75      rillig   8369: </td>
                   8370: <td align="left" valign="top"><p>What is the difference between
                   8371:        <code class="varname">BUILDLINK_LDFLAGS</code>,
                   8372:        <code class="varname">BUILDLINK_LDADD</code> and
                   8373:        <code class="varname">BUILDLINK_LIBS</code>?</p></td>
                   8374: </tr>
                   8375: <tr class="answer">
1.83    ! wiz      8376: <td align="left" valign="top"></td>
1.75      rillig   8377: <td align="left" valign="top"><p>[FIXME]</p></td>
                   8378: </tr>
                   8379: <tr class="question">
                   8380: <td align="left" valign="top">
1.83    ! wiz      8381: <a name="id2698397"></a><a name="id2698398"></a><b>20.5.</b>
1.75      rillig   8382: </td>
                   8383: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
                   8384:        VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
                   8385:        say it's empty?</p></td>
                   8386: </tr>
                   8387: <tr class="answer">
1.83    ! wiz      8388: <td align="left" valign="top"></td>
1.75      rillig   8389: <td align="left" valign="top"><p>For optimization reasons, some variables are only
                   8390:        available in the &#8220;<span class="quote">wrapper</span>&#8221; phase and later. To
                   8391:        &#8220;<span class="quote">simulate</span>&#8221; the wrapper phase, append
                   8392:        <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
                   8393:        command.</p></td>
                   8394: </tr>
1.78      rillig   8395: <tr class="question">
                   8396: <td align="left" valign="top">
1.83    ! wiz      8397: <a name="id2698425"></a><a name="id2698426"></a><b>20.6.</b>
1.78      rillig   8398: </td>
                   8399: <td align="left" valign="top"><p>What does
                   8400:        <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
                   8401:        don't understand the <code class="literal">:=</code> inside
                   8402:        it.</p></td>
                   8403: </tr>
                   8404: <tr class="answer">
1.83    ! wiz      8405: <td align="left" valign="top"></td>
1.78      rillig   8406: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
                   8407:        assignment operator, like you might expect at first sight.
                   8408:        Instead, it is a degenerate form of
                   8409:        <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
                   8410:        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
                   8411:        may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
                   8412:        case of <code class="varname">MASTER_SITE_*</code>,
                   8413:        <em class="replaceable"><code>old_string</code></em> is the empty string and
                   8414:        <em class="replaceable"><code>new_string</code></em> is
                   8415:        <code class="literal">package/</code>. That's where the
                   8416:        <code class="literal">:</code> and the <code class="literal">=</code> fall
                   8417:        together.</p></td>
                   8418: </tr>
                   8419: <tr class="question">
                   8420: <td align="left" valign="top">
1.83    ! wiz      8421: <a name="id2698500"></a><a name="id2698501"></a><b>20.7.</b>
1.78      rillig   8422: </td>
                   8423: <td align="left" valign="top"><p>Which mailing lists are there for package
                   8424:        developers?</p></td>
                   8425: </tr>
                   8426: <tr class="answer">
1.83    ! wiz      8427: <td align="left" valign="top"></td>
1.78      rillig   8428: <td align="left" valign="top"><div class="variablelist"><dl>
                   8429: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
                   8430: <dd><p>This is a list for technical discussions related
                   8431:        to pkgsrc development, e.g. soliciting feedback for changes to
                   8432:        pkgsrc infrastructure, proposed new features, questions related
                   8433:        to porting pkgsrc to a new platform, advice for maintaining a
                   8434:        package, patches that affect many packages, help requests moved
                   8435:        from pkgsrc-users when an infrastructure bug is found,
                   8436:        etc.</p></dd>
                   8437: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
                   8438: <dd><p>All bug reports in category "pkg" sent with
                   8439:        <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
                   8440:        directly; use one of the other mailing
                   8441:        lists.</p></dd>
                   8442: </dl></div></td>
                   8443: </tr>
1.80      rillig   8444: <tr class="question">
                   8445: <td align="left" valign="top">
1.83    ! wiz      8446: <a name="id2698536"></a><a name="id2698537"></a><b>20.8.</b>
1.80      rillig   8447: </td>
                   8448: <td align="left" valign="top"><p>Where is the pkgsrc
                   8449:        documentation?</p></td>
                   8450: </tr>
                   8451: <tr class="answer">
1.83    ! wiz      8452: <td align="left" valign="top"></td>
1.80      rillig   8453: <td align="left" valign="top">
                   8454: <p>There are many places where you can find
                   8455:        documentation about pkgsrc:</p>
                   8456: <div class="itemizedlist"><ul type="disc">
                   8457: <li><p>The pkgsrc guide (this document) is a collection
                   8458:        of chapters that explain large parts of pkgsrc, but some
                   8459:        chapters tend to be outdated. Which ones they are is hard to
                   8460:        say.</p></li>
                   8461: <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
                   8462:        about certain features, announcements of new parts of the pkgsrc
                   8463:        infrastructure and sometimes even announcements that a certain
                   8464:        feature has been marked as obsolete. The benefit here is that
                   8465:        each message has a date appended to it.</p></li>
                   8466: <li><p>Many of the files in the
                   8467:        <code class="filename">mk/</code> directory start with a comment that
                   8468:        describes the purpose of the file and how it can be used by the
                   8469:        pkgsrc user and package authors.</p></li>
                   8470: <li><p>The CVS log messages are a rich source of
                   8471:        information, but they tend to be highly abbreviated, especially
                   8472:        for actions that occur often. Some contain a detailed
                   8473:        description of what has changed, but they are geared towards the
                   8474:        other pkgsrc developers, not towards an average pkgsrc user.
                   8475:        They also only document <span class="emphasis"><em>changes</em></span>, so if you
                   8476:        don't know what has been before, these messages may not be worth
                   8477:        too much to you.</p></li>
                   8478: <li><p>Some parts of pkgsrc are only &#8220;<span class="quote">implicitly
                   8479:        documented</span>&#8221;, that is the documentation exists only in the
                   8480:        mind of the developer who wrote the code. To get this
                   8481:        information, use the the <span><strong class="command">cvs annotate</strong></span> command
                   8482:        to see who has written it and ask on the
                   8483:        <code class="literal">tech-pkg</code> mailing list, so that others can
                   8484:        find your questions later (see above). To be sure that the
                   8485:        developer in charge reads the mail, you may CC him or
                   8486:        her.</p></li>
                   8487: </ul></div>
                   8488: </td>
                   8489: </tr>
1.75      rillig   8490: </tbody>
                   8491: </table>
                   8492: </div>
                   8493: </div>
                   8494: </div>
                   8495: <div class="part" lang="en">
                   8496: <div class="titlepage"><div><div><h1 class="title">
                   8497: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
                   8498: <div class="partintro" lang="en">
                   8499: <div></div>
                   8500: <p>This part of the guide deals with everything
                   8501:        from the infrastructure that is behind the interfaces described
                   8502:        in the developer's guide. A casual package maintainer should not
                   8503:        need anything from this part.</p>
                   8504: <div class="toc">
                   8505: <p><b>Table of Contents</b></p>
                   8506: <dl>
1.77      rillig   8507: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75      rillig   8508: <dd><dl>
1.81      rillig   8509: <dt><span class="sect1"><a href="#infr.vardef">21.1. The meaning of variable definitions</a></span></dt>
                   8510: <dt><span class="sect1"><a href="#infr.vardef.problems">21.2. Avoiding problems before they arise</a></span></dt>
                   8511: <dt><span class="sect1"><a href="#infr.var">21.3. Variable evaluation</a></span></dt>
1.75      rillig   8512: <dd><dl>
1.81      rillig   8513: <dt><span class="sect2"><a href="#infr.var.load">21.3.1. At load time</a></span></dt>
                   8514: <dt><span class="sect2"><a href="#infr.var.run">21.3.2. At runtime</a></span></dt>
1.75      rillig   8515: </dl></dd>
1.81      rillig   8516: <dt><span class="sect1"><a href="#infr.varspec">21.4. How can variables be specified?</a></span></dt>
                   8517: <dt><span class="sect1"><a href="#infr.design.intf">21.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig   8518: <dd><dl>
1.81      rillig   8519: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.5.1. Procedures with parameters</a></span></dt>
                   8520: <dt><span class="sect2"><a href="#infr.design.intf.action">21.5.2. Actions taken on behalf of parameters</a></span></dt>
                   8521: </dl></dd>
                   8522: <dt><span class="sect1"><a href="#infr.order">21.6. The order in which files are loaded</a></span></dt>
                   8523: <dd><dl>
                   8524: <dt><span class="sect2"><a href="#infr.order.prefs">21.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
                   8525: <dt><span class="sect2"><a href="#infr.order.pkg">21.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75      rillig   8526: </dl></dd>
                   8527: </dl></dd>
1.77      rillig   8528: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75      rillig   8529: <dd><dl>
1.77      rillig   8530: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
                   8531: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
                   8532: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75      rillig   8533: <dd><dl>
1.77      rillig   8534: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
                   8535: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75      rillig   8536: </dl></dd>
                   8537: </dl></dd>
1.80      rillig   8538: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75      rillig   8539: <dd><dl>
1.80      rillig   8540: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
                   8541: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75      rillig   8542: </dl></dd>
                   8543: </dl>
                   8544: </div>
                   8545: </div>
                   8546: <div class="chapter" lang="en">
                   8547: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   8548: <a name="infr.design"></a>Chapter 21. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75      rillig   8549: <div class="toc">
                   8550: <p><b>Table of Contents</b></p>
                   8551: <dl>
1.81      rillig   8552: <dt><span class="sect1"><a href="#infr.vardef">21.1. The meaning of variable definitions</a></span></dt>
                   8553: <dt><span class="sect1"><a href="#infr.vardef.problems">21.2. Avoiding problems before they arise</a></span></dt>
                   8554: <dt><span class="sect1"><a href="#infr.var">21.3. Variable evaluation</a></span></dt>
                   8555: <dd><dl>
                   8556: <dt><span class="sect2"><a href="#infr.var.load">21.3.1. At load time</a></span></dt>
                   8557: <dt><span class="sect2"><a href="#infr.var.run">21.3.2. At runtime</a></span></dt>
                   8558: </dl></dd>
                   8559: <dt><span class="sect1"><a href="#infr.varspec">21.4. How can variables be specified?</a></span></dt>
                   8560: <dt><span class="sect1"><a href="#infr.design.intf">21.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig   8561: <dd><dl>
1.81      rillig   8562: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.5.1. Procedures with parameters</a></span></dt>
                   8563: <dt><span class="sect2"><a href="#infr.design.intf.action">21.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75      rillig   8564: </dl></dd>
1.81      rillig   8565: <dt><span class="sect1"><a href="#infr.order">21.6. The order in which files are loaded</a></span></dt>
1.75      rillig   8566: <dd><dl>
1.81      rillig   8567: <dt><span class="sect2"><a href="#infr.order.prefs">21.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
                   8568: <dt><span class="sect2"><a href="#infr.order.pkg">21.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75      rillig   8569: </dl></dd>
                   8570: </dl>
                   8571: </div>
                   8572: <p>The pkgsrc infrastructure consists of many small Makefile
                   8573:        fragments. Each such fragment needs a properly specified
                   8574:        interface. This chapter explains how such an interface looks
                   8575:        like.</p>
                   8576: <div class="sect1" lang="en">
                   8577: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.81      rillig   8578: <a name="infr.vardef"></a>21.1. The meaning of variable definitions</h2></div></div></div>
                   8579: <p>Whenever a variable is defined in the pkgsrc
                   8580:        infrastructure, the location and the way of definition provide
                   8581:        much information about the intended use of that variable.
                   8582:        Additionally, more documentation may be found in a header
                   8583:        comment or in this pkgsrc guide.</p>
                   8584: <p>A special file is
                   8585:        <code class="filename">mk/defaults/mk.conf</code>, which lists all
                   8586:        variables that are intended to be user-defined. They are either
                   8587:        defined using the <code class="literal">?=</code> operator or they are
                   8588:        left undefined because defining them to anything would
                   8589:        effectively mean &#8220;<span class="quote">yes</span>&#8221;. All these variables may be
                   8590:        overridden by the pkgsrc user in the <code class="varname">MAKECONF</code>
                   8591:        file.</p>
                   8592: <p>Outside this file, the following conventions apply:
                   8593:        Variables that are defined using the <code class="literal">?=</code>
                   8594:        operator may be overridden by a package.</p>
                   8595: <p>Variables that are defined using the <code class="literal">=</code>
                   8596:        operator may be used read-only at run-time.</p>
                   8597: <p>Variables whose name starts with an underscore must not be
                   8598:        accessed outside the pkgsrc infrastructure at all. They may
                   8599:        change without further notice.</p>
                   8600: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   8601: <h3 class="title">Note</h3>
                   8602: <p>These conventions are currently not applied
                   8603:        consistently to the complete pkgsrc
                   8604:        infrastructure.</p>
                   8605: </div>
                   8606: </div>
                   8607: <div class="sect1" lang="en">
                   8608: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8609: <a name="infr.vardef.problems"></a>21.2. Avoiding problems before they arise</h2></div></div></div>
                   8610: <p>All variables that contain lists of things should default
                   8611:        to being empty. Two examples that do not follow this rule are
                   8612:        <code class="varname">USE_LANGUAGES</code> and
                   8613:        <code class="varname">DISTFILES</code>. These variables cannot simply be
                   8614:        modified using the <code class="literal">+=</code> operator in package
                   8615:        <code class="filename">Makefile</code>s (or other files included by
                   8616:        them), since there is no guarantee whether the variable is
                   8617:        already set or not, and what its value is. In the case of
                   8618:        <code class="varname">DISTFILES</code>, the packages &#8220;<span class="quote">know</span>&#8221;
                   8619:        the default value and just define it as in the following
                   8620:        example.</p>
                   8621: <pre class="programlisting">
                   8622:     DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   8623: </pre>
                   8624: <p>Because of the selection of this default value, the same
                   8625:        value appears in many package Makefiles. Similarly for
                   8626:        <code class="varname">USE_LANGUAGES</code>, but in this case the default
                   8627:        value (&#8220;<span class="quote"><code class="literal">c</code></span>&#8221;) is so short that it
                   8628:        doesn't stand out. Nevertheless it is mentioned in many
                   8629:        files.</p>
                   8630: </div>
                   8631: <div class="sect1" lang="en">
                   8632: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8633: <a name="infr.var"></a>21.3. Variable evaluation</h2></div></div></div>
1.75      rillig   8634: <div class="sect2" lang="en">
                   8635: <div class="titlepage"><div><div><h3 class="title">
1.81      rillig   8636: <a name="infr.var.load"></a>21.3.1. At load time</h3></div></div></div>
1.75      rillig   8637: <p>Variable evaluation takes place either at load time or at
                   8638:        runtime, depending on the context in which they occur. The
                   8639:        contexts where variables are evaluated at load time are:</p>
                   8640: <div class="itemizedlist"><ul type="disc">
                   8641: <li><p>The right hand side of the <code class="literal">:=</code>
                   8642:        and <code class="literal">!=</code> operators,</p></li>
                   8643: <li><p>Make directives like <code class="literal">.if</code> or
                   8644:        <code class="literal">.for</code>,</p></li>
                   8645: <li><p>Dependency lines.</p></li>
                   8646: </ul></div>
                   8647: <p>A special exception are references to the iteration
                   8648:        variables of <code class="literal">.for</code> loops, which are expanded
                   8649:        inline, no matter in which context they appear.</p>
                   8650: <p>As the values of variables may change during load time,
                   8651:        care must be taken not to evaluate them by accident. Typical
                   8652:        examples for variables that should not be evaluated at load time
                   8653:        are <code class="varname">DEPENDS</code> and
                   8654:        <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
                   8655:        clear, here is an example:</p>
                   8656: <pre class="programlisting">
                   8657:     CONFIGURE_ARGS=         # none
                   8658:     CFLAGS=                 -O
                   8659:     CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
1.1       grant    8660: 
1.75      rillig   8661:     CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
1.1       grant    8662: 
1.75      rillig   8663:     CFLAGS+=                -Wall
                   8664:        </pre>
                   8665: <p>This code shows how the use of the <code class="literal">:=</code>
                   8666:        operator can quickly lead to unexpected results. The first
                   8667:        paragraph is fairly common code. The second paragraph evaluates
                   8668:        the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
                   8669:        <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
                   8670:        <code class="literal">-Wall</code> is appended to the
                   8671:        <code class="varname">CFLAGS</code>, but this addition will not appear in
                   8672:        <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
                   8673:        paragraphs from above typically occur in completely unrelated
                   8674:        files.</p>
                   8675: </div>
                   8676: <div class="sect2" lang="en">
                   8677: <div class="titlepage"><div><div><h3 class="title">
1.81      rillig   8678: <a name="infr.var.run"></a>21.3.2. At runtime</h3></div></div></div>
1.75      rillig   8679: <p>After all the files have been loaded, the values of the
                   8680:        variables cannot be changed anymore. Variables that are used in
                   8681:        the shell commands are expanded at this point.</p>
                   8682: </div>
                   8683: </div>
                   8684: <div class="sect1" lang="en">
                   8685: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.81      rillig   8686: <a name="infr.varspec"></a>21.4. How can variables be specified?</h2></div></div></div>
1.78      rillig   8687: <p>There are many ways in which the definition and use of a
                   8688:        variable can be restricted in order to detect bugs and
                   8689:        violations of the (mostly unwritten) policies. See the
                   8690:        <code class="literal">pkglint</code> developer's documentation for further
                   8691:        details.</p>
                   8692: </div>
                   8693: <div class="sect1" lang="en">
                   8694: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.81      rillig   8695: <a name="infr.design.intf"></a>21.5. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76      rillig   8696: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75      rillig   8697:        of the following classes. Cases where a file falls into more
                   8698:        than one class should be avoided as it often leads to subtle
                   8699:        bugs.</p>
                   8700: <div class="sect2" lang="en">
                   8701: <div class="titlepage"><div><div><h3 class="title">
1.81      rillig   8702: <a name="infr.design.intf.proc"></a>21.5.1. Procedures with parameters</h3></div></div></div>
1.75      rillig   8703: <p>In a traditional imperative programming language some of
1.76      rillig   8704:        the <code class="filename">.mk</code> files could be described as
1.83    ! wiz      8705:        procedures. They take some input parameters and&#8212;after
        !          8706:        inclusion&#8212;provide a result in output parameters. Since all
1.76      rillig   8707:        variables in <code class="filename">Makefile</code>s have global scope
1.75      rillig   8708:        care must be taken not to use parameter names that have already
                   8709:        another meaning. For example, <code class="varname">PKGNAME</code> is a
                   8710:        bad choice for a parameter name.</p>
                   8711: <p>Procedures are completely evaluated at preprocessing time.
                   8712:        That is, when calling a procedure all input parameters must be
                   8713:        completely resolvable. For example,
                   8714:        <code class="varname">CONFIGURE_ARGS</code> should never be an input
                   8715:        parameter since it is very likely that further text will be
                   8716:        added after calling the procedure, which would effectively apply
                   8717:        the procedure to only a part of the variable. Also, references
                   8718:        to other variables wit will be modified after calling the
                   8719:        procedure.</p>
                   8720: <p>A procedure can declare its output parameters either as
                   8721:        suitable for use in preprocessing directives or as only
                   8722:        available at runtime. The latter alternative is for variables
                   8723:        that contain references to other runtime variables.</p>
                   8724: <p>Procedures shall be written such that it is possible to
                   8725:        call the procedure more than once. That is, the file must not
                   8726:        contain multiple-inclusion guards.</p>
                   8727: <p>Examples for procedures are
1.76      rillig   8728:        <code class="filename">mk/bsd.options.mk</code> and
                   8729:        <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75      rillig   8730:        that the parameters are evaluated at load time, they should be
                   8731:        assigned using the <code class="literal">:=</code> operator, which should
                   8732:        be used only for this purpose.</p>
                   8733: </div>
                   8734: <div class="sect2" lang="en">
                   8735: <div class="titlepage"><div><div><h3 class="title">
1.81      rillig   8736: <a name="infr.design.intf.action"></a>21.5.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75      rillig   8737: <p>Action files take some input parameters and may define
                   8738:        runtime variables. They shall not define loadtime variables.
                   8739:        There are action files that are included implicitly by the
                   8740:        pkgsrc infrastructure, while other must be included
                   8741:        explicitly.</p>
                   8742: <p>An example for action files is
1.76      rillig   8743:        <code class="filename">mk/subst.mk</code>.</p>
1.75      rillig   8744: </div>
                   8745: </div>
1.81      rillig   8746: <div class="sect1" lang="en">
                   8747: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8748: <a name="infr.order"></a>21.6. The order in which files are loaded</h2></div></div></div>
                   8749: <p>Package <code class="filename">Makefile</code>s usually consist of
                   8750:        a set of variable definitions, and include the file
                   8751:        <code class="filename">../../mk/bsd.pkg.mk</code> in the very last line.
                   8752:        Before that, they may also include various other
                   8753:        <code class="filename">*.mk</code> files if they need to query the
                   8754:        availability of certain features like the type of compiler or
                   8755:        the X11 implementation. Due to the heavy use of preprocessor
                   8756:        directives like <code class="literal">.if</code> and
                   8757:        <code class="literal">.for</code>, the order in which the files are loaded
                   8758:        matters.</p>
                   8759: <p>This section describes at which point the various files
                   8760:        are loaded and gives reasons for that order.</p>
                   8761: <div class="sect2" lang="en">
                   8762: <div class="titlepage"><div><div><h3 class="title">
                   8763: <a name="infr.order.prefs"></a>21.6.1. The order in <code class="filename">bsd.prefs.mk</code></h3></div></div></div>
                   8764: <p>The very first action in <code class="filename">bsd.pkg.mk</code>
                   8765:        is to define some essential variables like
                   8766:        <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code> and
                   8767:        <code class="varname">MACHINE_ARCH</code>.</p>
                   8768: <p>Then, the user settings are loaded from the file specified
                   8769:        in <code class="varname">MAKECONF</code>. If the bmake command from pkgsrc
                   8770:        is used, <code class="varname">MAKECONF</code> defaults to
                   8771:        <code class="filename"><em class="replaceable"><code>${prefix}</code></em>/etc/mk.conf</code>.
                   8772:        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
                   8773:        <code class="filename">/etc/mk.conf</code>. After that, those variables
                   8774:        that have not been overridden by the user are loaded from
                   8775:        <code class="filename">mk/defaults/mk.conf</code>.</p>
                   8776: <p>After the user settings, the system settings and platform
                   8777:        settings are loaded, which may override the user
                   8778:        settings.</p>
                   8779: <p>Then, the tool definitions are loaded. The tool wrappers
                   8780:        are not yet in effect. This only happens when building a
                   8781:        package, so the proper variables must be used instead of the
                   8782:        direct tool names.</p>
                   8783: <p>As the last steps, some essential variables from the
                   8784:        wrapper and the package system flavor are loaded, as well as the
                   8785:        variables that have been cached in earlier phases of a package
                   8786:        build.</p>
                   8787: </div>
                   8788: <div class="sect2" lang="en">
                   8789: <div class="titlepage"><div><div><h3 class="title">
                   8790: <a name="infr.order.pkg"></a>21.6.2. The order in <code class="filename">bsd.pkg.mk</code></h3></div></div></div>
                   8791: <p>First, <code class="filename">bsd.prefs.mk</code> is loaded.</p>
                   8792: <p>Then, the various <code class="filename">*-vars.mk</code> files are
                   8793:        loaded, which fill default values for those variables that have
                   8794:        not been defined by the the package. These variables may later
                   8795:        be used even in unrelated files.</p>
                   8796: <p>Then, the file <code class="filename">bsd.pkg.error.mk</code>
                   8797:        provides the target <code class="literal">error-check</code> that is added
                   8798:        as a special dependency to all other targets that use
                   8799:        <code class="varname">DELAYED_ERROR_MSG</code> or
                   8800:        <code class="varname">DELAYED_WARNING_MSG</code>.</p>
                   8801: <p>Then, the package-specific hacks from
                   8802:        <code class="filename">hacks.mk</code> are included.</p>
                   8803: <p>Then, various other files follow. Most of them don't have
                   8804:        any dependencies on what they need to have included before or
                   8805:        after them, though some do.</p>
                   8806: <p>The code to check <code class="varname">PKG_FAIL_REASON</code> and
                   8807:        <code class="varname">PKG_SKIP_REASON</code> is then executed, which
                   8808:        restricts the use of these variables to all the files that have
                   8809:        been included before. Appearances in later files will be
                   8810:        silently ignored.</p>
                   8811: <p>Then, the files for the main targets are included, in the
                   8812:        order of later execution, though the actual order should not
                   8813:        matter.</p>
                   8814: <p>At last, some more files are included that don't set any
                   8815:        interesting variables but rather just define make targets to be
                   8816:        executed.</p>
                   8817: </div>
                   8818: </div>
1.75      rillig   8819: </div>
                   8820: <div class="chapter" lang="en">
                   8821: <div class="titlepage"><div><div><h2 class="title">
1.77      rillig   8822: <a name="regression"></a>Chapter 22. Regression tests</h2></div></div></div>
1.75      rillig   8823: <div class="toc">
                   8824: <p><b>Table of Contents</b></p>
                   8825: <dl>
1.77      rillig   8826: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
                   8827: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
                   8828: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75      rillig   8829: <dd><dl>
1.77      rillig   8830: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
                   8831: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75      rillig   8832: </dl></dd>
                   8833: </dl>
                   8834: </div>
                   8835: <p>The pkgsrc infrastructure consists of a large codebase,
                   8836:        and there are many corners where every little bit of a file is
                   8837:        well thought out, making pkgsrc likely to fail as soon as
                   8838:        anything is changed near those parts. To prevent most changes
                   8839:        from breaking anything, a suite of regression tests should go
                   8840:        along with every important part of the pkgsrc infrastructure.
                   8841:        This chapter describes how regression tests work in pkgsrc and
                   8842:        how you can add new tests.</p>
                   8843: <div class="sect1" lang="en">
                   8844: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8845: <a name="regression.descr"></a>22.1. The regression tests framework</h2></div></div></div>
1.75      rillig   8846: <p></p>
                   8847: </div>
                   8848: <div class="sect1" lang="en">
                   8849: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8850: <a name="regression.run"></a>22.2. Running the regression tests</h2></div></div></div>
1.76      rillig   8851: <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   8852:        provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
                   8853:        can simply run that command, which will run all tests in the
1.76      rillig   8854:        <code class="filename">regress</code> category.</p>
1.75      rillig   8855: </div>
                   8856: <div class="sect1" lang="en">
                   8857: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77      rillig   8858: <a name="regression.new"></a>22.3. Adding a new regression test</h2></div></div></div>
1.76      rillig   8859: <p>Every directory in the <code class="filename">regress</code>
                   8860:        category that contains a file called <code class="filename">spec</code>
1.75      rillig   8861:        is considered a regression test. This file is a shell program
                   8862:        that is included by the <span><strong class="command">pkg_regress</strong></span> command.
                   8863:        The following functions can be overridden to suit your
                   8864:        needs.</p>
                   8865: <div class="sect2" lang="en">
                   8866: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   8867: <a name="regression.fun.override"></a>22.3.1. Overridable functions</h3></div></div></div>
1.75      rillig   8868: <p>These functions do not take any parameters. They are all
                   8869:        called in &#8220;<span class="quote">set -e</span>&#8221; mode, so you should be careful
                   8870:        to check the exitcodes of any commands you run in the
                   8871:        test.</p>
                   8872: <div class="variablelist"><dl>
                   8873: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
                   8874: <dd><p>This function prepares the environment for the
                   8875:        test. By default it does nothing.</p></dd>
                   8876: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
                   8877: <dd><p>This function runs the actual test. By default,
                   8878:        it calls <code class="varname">TEST_MAKE</code> with the arguments
                   8879:        <code class="varname">MAKEARGS_TEST</code> and writes its output including
                   8880:        error messages into the file
                   8881:        <code class="varname">TEST_OUTFILE</code>.</p></dd>
                   8882: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
                   8883: <dd><p>This function is run after the test and is
                   8884:        typically used to compare the actual output from the one that is
                   8885:        expected. It can make use of the various helper functions from
                   8886:        the next section.</p></dd>
                   8887: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
                   8888: <dd><p>This function cleans everything up after the
                   8889:        test has been run. By default it does nothing.</p></dd>
                   8890: </dl></div>
                   8891: </div>
                   8892: <div class="sect2" lang="en">
                   8893: <div class="titlepage"><div><div><h3 class="title">
1.77      rillig   8894: <a name="regression.fun.helper"></a>22.3.2. Helper functions</h3></div></div></div>
1.75      rillig   8895: <div class="variablelist"><dl>
                   8896: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
                   8897: <dd><p>This function compares the exitcode of the
                   8898:        <span><strong class="command">do_test()</strong></span> function with its first parameter.
                   8899:        If they differ, the test will fail.</p></dd>
                   8900: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
                   8901: <dd><p>This function checks for each of its parameters
                   8902:        if the output from <span><strong class="command">do_test()</strong></span> matches the
                   8903:        extended regular expression. If it does not, the test will
                   8904:        fail.</p></dd>
                   8905: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
                   8906: <dd><p>This function checks for each of its parameters
                   8907:        if the output from <span><strong class="command">do_test()</strong></span> does
                   8908:        <span class="emphasis"><em>not</em></span> match the extended regular expression.
                   8909:        If any of the regular expressions matches, the test will
                   8910:        fail.</p></dd>
                   8911: </dl></div>
                   8912: </div>
                   8913: </div>
                   8914: </div>
                   8915: <div class="chapter" lang="en">
                   8916: <div class="titlepage"><div><div><h2 class="title">
1.80      rillig   8917: <a name="porting"></a>Chapter 23. Porting pkgsrc</h2></div></div></div>
1.75      rillig   8918: <div class="toc">
                   8919: <p><b>Table of Contents</b></p>
                   8920: <dl>
1.80      rillig   8921: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
                   8922: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75      rillig   8923: </dl>
                   8924: </div>
                   8925: <p>The pkgsrc system has already been ported to many
                   8926:        operating systems, hardware architectures and compilers. This
                   8927:        chapter explains the necessary steps to make pkgsrc even more
                   8928:        portable.</p>
                   8929: <div class="sect1" lang="en">
                   8930: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.80      rillig   8931: <a name="porting.opsys"></a>23.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75      rillig   8932: <p>To port pkgsrc to a new operating system (called
                   8933:        <code class="literal">MyOS</code> in this example), you need to touch the
                   8934:        following files:</p>
                   8935: <div class="variablelist"><dl>
1.76      rillig   8936: <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   8937: <dd><p>This file contains some basic definitions, for
                   8938:        example the name of the C
                   8939:        compiler.</p></dd>
1.76      rillig   8940: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75      rillig   8941: <dd><p>Insert code that defines the variables
                   8942:        <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
                   8943:        <code class="varname">LOWER_OS_VERSION</code>,
                   8944:        <code class="varname">LOWER_VENDOR</code>,
                   8945:        <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
                   8946:        <code class="varname">APPEND_ELF</code>, and the other variables that
                   8947:        appear in this file.</p></dd>
1.76      rillig   8948: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75      rillig   8949: <dd><p>This file contains the platform-specific
                   8950:        definitions that are used by pkgsrc. Start by copying one of the
                   8951:        other files and edit it to your
                   8952:        needs.</p></dd>
1.76      rillig   8953: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75      rillig   8954: <dd><p>This file contains a list of directories,
                   8955:        together with their permission bits and ownership. These
                   8956:        directories will be created automatically with every package
                   8957:        that does not explicitly set <code class="varname">NO_MTREE</code>. There
                   8958:        have been some discussions about whether this file is needed at
                   8959:        all, but with no result.</p></dd>
1.76      rillig   8960: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75      rillig   8961: <dd><p>Just copy one of the pre-existing x11.dist files
                   8962:        to your
1.76      rillig   8963:        <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
                   8964: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75      rillig   8965: <dd><p>On some operating systems, the tools that are
                   8966:        provided with the base system are not good enough for pkgsrc.
                   8967:        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
                   8968:        narrow limit on the line length they can process. Therefore
                   8969:        pkgsrc brings its own tools, which can be enabled
                   8970:        here.</p></dd>
1.76      rillig   8971: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75      rillig   8972: <dd><p>This file defines the paths to all the tools
                   8973:        that are needed by one or the other package in pkgsrc, as well
                   8974:        as by pkgsrc itself. Find out where these tools are on your
                   8975:        platform and add them.</p></dd>
                   8976: </dl></div>
                   8977: <p>Now, you should be able to build some basic packages, like
1.76      rillig   8978:        <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   8979: </div>
                   8980: <div class="sect1" lang="en">
                   8981: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.80      rillig   8982: <a name="porting.compiler"></a>23.2. Adding support for a new compiler</h2></div></div></div>
1.75      rillig   8983: <p>TODO</p>
                   8984: </div>
                   8985: </div>
                   8986: </div>
                   8987: <div class="appendix" lang="en">
                   8988: <div class="titlepage"><div><div><h2 class="title">
                   8989: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
                   8990: <div class="toc">
                   8991: <p><b>Table of Contents</b></p>
                   8992: <dl>
                   8993: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
                   8994: <dd><dl>
                   8995: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
                   8996: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
                   8997: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
                   8998: <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>
                   8999: </dl></dd>
                   9000: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
                   9001: </dl>
                   9002: </div>
                   9003: <p>We checked to find a piece of software that wasn't in the packages
                   9004:     collection, and picked GNU bison. Quite why someone would want to have
                   9005:     <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
                   9006:     present in the tree is beyond us, but it's useful for the purposes of
                   9007:     this exercise.</p>
                   9008: <div class="sect1" lang="en">
                   9009: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9010: <a name="example-files"></a>A.1. files</h2></div></div></div>
                   9011: <div class="sect2" lang="en">
                   9012: <div class="titlepage"><div><div><h3 class="title">
                   9013: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
                   9014: <pre class="programlisting">
1.51      rillig   9015:     # $NetBSD$
                   9016:     #
1.1       grant    9017: 
1.51      rillig   9018:     DISTNAME=       bison-1.25
                   9019:     CATEGORIES=     devel
                   9020:     MASTER_SITES=   ${MASTER_SITE_GNU}
1.1       grant    9021: 
1.51      rillig   9022:     MAINTAINER=     thorpej@NetBSD.org
                   9023:     HOMEPAGE=       http://www.gnu.org/software/bison/bison.html
                   9024:     COMMENT=        GNU yacc clone
1.1       grant    9025: 
1.51      rillig   9026:     GNU_CONFIGURE=  yes
                   9027:     INFO_FILES=     bison.info
1.1       grant    9028: 
1.51      rillig   9029:     .include "../../mk/bsd.pkg.mk"
1.1       grant    9030: </pre>
1.75      rillig   9031: </div>
                   9032: <div class="sect2" lang="en">
                   9033: <div class="titlepage"><div><div><h3 class="title">
                   9034: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
                   9035: <pre class="programlisting">
1.51      rillig   9036:     GNU version of yacc.  Can make re-entrant parsers, and numerous other
1.75      rillig   9037:     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   9038:     of the NetBSD source tree is beyond me.
1.1       grant    9039: </pre>
1.75      rillig   9040: </div>
                   9041: <div class="sect2" lang="en">
                   9042: <div class="titlepage"><div><div><h3 class="title">
                   9043: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
                   9044: <pre class="programlisting">
1.51      rillig   9045:     @comment $NetBSD$
                   9046:     bin/bison
                   9047:     man/man1/bison.1.gz
                   9048:     share/bison.simple
                   9049:     share/bison.hairy
1.1       grant    9050: </pre>
1.75      rillig   9051: </div>
                   9052: <div class="sect2" lang="en">
                   9053: <div class="titlepage"><div><div><h3 class="title">
                   9054: <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>
                   9055: <p>The NetBSD package system comes with
1.76      rillig   9056:         <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   9057:        which helps to check the contents of these
                   9058:        files. After installation it is quite easy to use, just change to the
                   9059:        directory of the package you wish to examine and execute
                   9060:        <span><strong class="command">pkglint</strong></span>:</p>
                   9061: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
                   9062: looks fine.</pre>
                   9063: <p>Depending on the supplied command line arguments (see pkglint(1)),
                   9064:        more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
                   9065:        -Wall</strong></span> for a very thorough check.</p>
                   9066: </div>
                   9067: </div>
                   9068: <div class="sect1" lang="en">
                   9069: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9070: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
                   9071: <p>Create the directory where the package lives,
                   9072:       plus any auxiliary directories:</p>
                   9073: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
                   9074: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
                   9075: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
                   9076: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76      rillig   9077: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.77      rillig   9078:       <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   9079:       then continue with fetching the distfile:</p>
                   9080: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1       grant    9081: &gt;&gt; bison-1.25.tar.gz doesn't seem to exist on this system.
                   9082: &gt;&gt; Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   9083: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   9084: ftp: Error retrieving file: 500 Internal error
                   9085: 
                   9086: &gt;&gt; Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   9087: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   9088: ftp: Error retrieving file: 500 Internal error
                   9089: 
                   9090: &gt;&gt; Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   9091: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75      rillig   9092: Successfully retrieved file.</pre>
                   9093: <p>Generate the checksum of the distfile into
1.76      rillig   9094:       <code class="filename">distinfo</code>:</p>
1.75      rillig   9095: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makesum</code></strong></pre>
                   9096: <p>Now compile:</p>
                   9097: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1       grant    9098: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   9099: ===&gt;  Extracting for bison-1.25
                   9100: ===&gt;  Patching for bison-1.25
                   9101: ===&gt;   Ignoring empty patch directory
                   9102: ===&gt;  Configuring for bison-1.25
                   9103: creating cache ./config.cache
                   9104: checking for gcc... cc
                   9105: checking whether we are using GNU C... yes
                   9106: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   9107: checking how to run the C preprocessor... cc -E
                   9108: checking for minix/config.h... no
                   9109: checking for POSIXized ISC... no
                   9110: checking whether cross-compiling... no
                   9111: checking for ANSI C header files... yes
                   9112: checking for string.h... yes
                   9113: checking for stdlib.h... yes
                   9114: checking for memory.h... yes
                   9115: checking for working const... yes
                   9116: checking for working alloca.h... no
                   9117: checking for alloca... yes
                   9118: checking for strerror... yes
                   9119: updating cache ./config.cache
                   9120: creating ./config.status
                   9121: creating Makefile
                   9122: ===&gt;  Building for bison-1.25
                   9123: 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
                   9124: 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
                   9125: 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
                   9126: 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
                   9127: 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   9128: 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    9129: 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
                   9130: 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
                   9131: 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
                   9132: 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
                   9133: 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
                   9134: 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
                   9135: 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
                   9136: 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
                   9137: 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
                   9138: 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
                   9139: 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
                   9140: 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
                   9141: 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
                   9142: 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
                   9143: 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
                   9144: 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
                   9145: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   9146: rm -f bison.s1
1.75      rillig   9147: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" &lt; ./bison.simple &gt; bison.s1</pre>
                   9148: <p>Everything seems OK, so install the files:</p>
                   9149: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1       grant    9150: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   9151: ===&gt;  Installing for bison-1.25
                   9152: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   9153: rm -f /usr/pkg/bin/bison
                   9154: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   9155: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   9156: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   9157: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   9158: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   9159: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   9160: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75      rillig   9161: ===&gt;  Registering installation for bison-1.25</pre>
                   9162: <p>You can now use bison, and also - if you decide so - remove it with
                   9163:       <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
                   9164:       binary package, do this now:</p>
                   9165: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1       grant    9166: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   9167: ===&gt;  Building package for bison-1.25
                   9168: Creating package bison-1.25.tgz
                   9169: Registering depends:.
1.75      rillig   9170: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
                   9171: <p>Now that you don't need the source and object files
                   9172:       any more, clean up:</p>
                   9173: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
                   9174: ===&gt;  Cleaning for bison-1.25</pre>
                   9175: </div>
                   9176: </div>
                   9177: <div class="appendix" lang="en">
                   9178: <div class="titlepage"><div><div><h2 class="title">
                   9179: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
                   9180: <div class="toc">
                   9181: <p><b>Table of Contents</b></p>
                   9182: <dl>
                   9183: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
                   9184: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
                   9185: </dl>
                   9186: </div>
                   9187: <div class="sect1" lang="en">
                   9188: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9189: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
                   9190: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1       grant    9191: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   9192: =&gt; figlet221.tar.gz doesn't seem to exist on this system.
                   9193: =&gt; Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   9194: =&gt; [172219 bytes]
                   9195: Connected to ftp.plig.net.
                   9196: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   9197: 331 Guest login ok, send your complete e-mail address as password.
                   9198: 230-You are user #5 of 500 simultaneous users allowed.
                   9199: 230-
1.68      rillig   9200: 230-  ___ _             _ _
                   9201: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
1.1       grant    9202: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   9203: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   9204: 230-         |_|   |_|     |___|         |___|
                   9205: 230-
                   9206: 230-** Welcome to ftp.plig.org **
                   9207: 230-
                   9208: 230-Please note that all transfers from this FTP site are logged. If you
                   9209: 230-do not like this, please disconnect now.
                   9210: 230-
                   9211: 230-This arhive is available via
                   9212: 230-
                   9213: 230-HTTP:  http://ftp.plig.org/
                   9214: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   9215: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   9216: 230-
                   9217: 230-Please email comments, bug reports and requests for packages to be
1.68      rillig   9218: 230-mirrored to ftp-admin@plig.org.
1.1       grant    9219: 230-
                   9220: 230-
                   9221: 230 Logged in anonymously.
                   9222: Remote system type is UNIX.
                   9223: Using binary mode to transfer files.
                   9224: 200 Type okay.
                   9225: 250 "/pub" is new cwd.
                   9226: 250-"/pub/figlet" is new cwd.
                   9227: 250-
                   9228: 250-Welcome to the figlet archive at ftp.figlet.org
1.68      rillig   9229: 250-
1.75      rillig   9230: 250-   ftp://ftp.figlet.org/pub/figlet/
1.1       grant    9231: 250-
                   9232: 250-The official FIGlet web page is:
1.75      rillig   9233: 250-   http://www.figlet.org/
1.1       grant    9234: 250-
                   9235: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   9236: 250-contribute a font or something else, you can email us.
1.68      rillig   9237: 250
1.1       grant    9238: 250 "/pub/figlet/program" is new cwd.
                   9239: 250 "/pub/figlet/program/unix" is new cwd.
                   9240: local: figlet221.tar.gz remote: figlet221.tar.gz
                   9241: 502 Unimplemented command.
                   9242: 227 Entering Passive Mode (195,40,6,41,246,104)
                   9243: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   9244: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   9245: 226 Transfer completed.
                   9246: 172219 bytes received in 00:02 (75.99 KB/s)
                   9247: 221 Goodbye.
                   9248: =&gt; Checksum OK for figlet221.tar.gz.
                   9249: ===&gt; Extracting for figlet-2.2.1nb2
                   9250: ===&gt; Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   9251: ===&gt; Patching for figlet-2.2.1nb2
                   9252: ===&gt; Applying pkgsrc patches for figlet-2.2.1nb2
                   9253: ===&gt; Overriding tools for figlet-2.2.1nb2
                   9254: ===&gt; Creating toolchain wrappers for figlet-2.2.1nb2
                   9255: ===&gt; Configuring for figlet-2.2.1nb2
                   9256: ===&gt; Building for figlet-2.2.1nb2
                   9257: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   9258: chmod a+x figlet
                   9259: gcc -O2 -o chkfont chkfont.c
                   9260: =&gt; Unwrapping files-to-be-installed.
1.14      xtraeme  9261: <code class="prompt">#</code>
1.75      rillig   9262: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1       grant    9263: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   9264: ===&gt; Installing for figlet-2.2.1nb2
                   9265: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   9266: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   9267: mkdir -p /usr/pkg/share/figlet
                   9268: cp figlet /usr/pkg/bin
                   9269: cp chkfont /usr/pkg/bin
                   9270: chmod 555 figlist showfigfonts
                   9271: cp figlist /usr/pkg/bin
                   9272: cp showfigfonts /usr/pkg/bin
                   9273: cp fonts/*.flf /usr/pkg/share/figlet
                   9274: cp fonts/*.flc /usr/pkg/share/figlet
                   9275: cp figlet.6 /usr/pkg/man/man6
                   9276: ===&gt; Registering installation for figlet-2.2.1nb2
1.75      rillig   9277: <code class="prompt">#</code></pre>
                   9278: </div>
                   9279: <div class="sect1" lang="en">
                   9280: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9281: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
                   9282: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1       grant    9283: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   9284: ===&gt; Packaging figlet-2.2.1nb2
                   9285: ===&gt; Building binary package for figlet-2.2.1nb2
                   9286: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   9287: Using SrcDir value of /usr/pkg
1.68      rillig   9288: Registering depends:.
1.75      rillig   9289: <code class="prompt">#</code></pre>
                   9290: </div>
                   9291: </div>
                   9292: <div class="appendix" lang="en">
                   9293: <div class="titlepage"><div><div><h2 class="title">
1.76      rillig   9294: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
                   9295: <div class="toc">
                   9296: <p><b>Table of Contents</b></p>
                   9297: <dl>
                   9298: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
                   9299: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
                   9300: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
                   9301: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
                   9302: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
                   9303: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
                   9304: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                   9305: source packages</a></span></dt>
                   9306: </dl>
                   9307: </div>
                   9308: <p>As in other big projects, the directory layout of pkgsrc
                   9309:        is quite complex for newbies. This chapter explains where you
                   9310:        find things on the FTP server. The base directory on
                   9311:        <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>.
                   9312:        This directory contains some subdirectories, which are explained
                   9313:        below.</p>
                   9314: <div class="sect1" lang="en">
                   9315: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9316: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
                   9317: <p>For those who only want to manage binary packages on
                   9318:        systems other than NetBSD, we provide the package management
                   9319:        tools in a separate, small tar file.</p>
                   9320: </div>
                   9321: <div class="sect1" lang="en">
                   9322: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9323: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
                   9324: <p>The directory <code class="filename">distfiles</code> contains lots
                   9325:        of archive files from all pkgsrc packages, which are mirrored
                   9326:        here. The subdirectories are called after their package names
                   9327:        and are used when the distributed files have names that don't
                   9328:        explicitly contain a version number or are otherwise too generic
                   9329:        (for example <code class="filename">release.tar.gz</code>).</p>
                   9330: </div>
                   9331: <div class="sect1" lang="en">
                   9332: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9333: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
                   9334: <p>This directory is currently not in use.</p>
                   9335: </div>
                   9336: <div class="sect1" lang="en">
                   9337: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9338: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
                   9339: <p>This directory contains things that individual pkgsrc
                   9340:        developers find worth publishing.</p>
                   9341: </div>
                   9342: <div class="sect1" lang="en">
                   9343: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9344: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
                   9345: <p>These directories contain binary packages. Those
                   9346:        directories that have a branch name
                   9347:        (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
                   9348:        contain packages from that particular branch. The directory
                   9349:        <code class="filename">packages</code> contains binary packages from
                   9350:        pkgsrc-current. (However, this does not necessarily mean that
                   9351:        the packages are still current anymore.)</p>
                   9352: <p>Below the <code class="filename">packages*</code> directories are
                   9353:        directories that distinguish the packages by operating system
                   9354:        and version, the next directory level specifies the hardware
                   9355:        architecture.</p>
                   9356: <p>In each of the platform-specific directories, there is a
                   9357:        whole binary packages collection. It has a directory called
                   9358:        <code class="filename">All</code> which contains all binary packages.
                   9359:        Besides that, there are various category directories that
                   9360:        contain symbolic links to the real binary packages.</p>
                   9361: </div>
                   9362: <div class="sect1" lang="en">
                   9363: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9364: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
                   9365: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                   9366: source packages</h2></div></div></div>
                   9367: <p>These directories contain the &#8220;<span class="quote">real</span>&#8221; pkgsrc,
                   9368:        that is the files that define how to create binary packages from
                   9369:        source archives.</p>
                   9370: <p>The directory <code class="filename">pkgsrc</code> contains a
                   9371:        snapshot of the CVS repository, which is updated on a regularly
                   9372:        basis. The file <code class="filename">pkgsrc.tar.gz</code> contains the
                   9373:        same as the directory, ready to be downloaded as a whole.</p>
                   9374: <p>In the directories for the quarterly branches, there is an
                   9375:        additional file called
                   9376:        <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
                   9377:        which contains the state of pkgsrc when it was branched.</p>
                   9378: </div>
1.75      rillig   9379: </div>
                   9380: <div class="appendix" lang="en">
                   9381: <div class="titlepage"><div><div><h2 class="title">
                   9382: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
                   9383: <div class="toc">
                   9384: <p><b>Table of Contents</b></p>
                   9385: <dl>
1.79      rillig   9386: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75      rillig   9387: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
                   9388: </dl>
                   9389: </div>
1.79      rillig   9390: <p>This section contains information on editing the pkgsrc
                   9391:        guide itself.</p>
1.75      rillig   9392: <div class="sect1" lang="en">
                   9393: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79      rillig   9394: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
                   9395: <p>The pkgsrc guide's source code is stored in
                   9396:        <code class="filename">pkgsrc/doc/guide/files</code>, and several files
                   9397:        are created from it:</p>
                   9398: <div class="itemizedlist"><ul type="disc">
                   9399: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
                   9400: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
                   9401: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/</a></p></li>
                   9402: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</a>:
                   9403:        The PDF version of the pkgsrc guide.</p></li>
                   9404: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</a>:
                   9405:        PostScript version of the pkgsrc guide.</p></li>
1.75      rillig   9406: </ul></div>
                   9407: </div>
                   9408: <div class="sect1" lang="en">
                   9409: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   9410: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
1.79      rillig   9411: <p>The procedure to edit the pkgsrc guide is:</p>
                   9412: <div class="procedure"><ol type="1">
                   9413: <li><p>Make sure you have the packages needed to
1.83    ! wiz      9414:        regenerate the pkgsrc guide (and other XML-based NetBSD
1.79      rillig   9415:        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
                   9416:        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
                   9417:        PostScript and PDF versions. You will need both packages
                   9418:        installed, to make sure documentation is consistent across all
                   9419:        formats.</p></li>
                   9420: <li><p>Run <span><strong class="command">cd doc/guide</strong></span> to get to the
                   9421:        right directory. All further steps will take place
                   9422:        here.</p></li>
                   9423: <li><p>Edit the XML file(s) in
                   9424:        <code class="filename">files/</code>.</p></li>
                   9425: <li><p>Run <span><strong class="command">bmake</strong></span> to check the pkgsrc
                   9426:        guide for valid XML and to build the final output files. If you
                   9427:        get any errors at this stage, you can just edit the files, as
                   9428:        there are only symbolic links in the working directory, pointing
                   9429:        to the files in <code class="filename">files/</code>.</p></li>
                   9430: <li><p><span><strong class="command">(cd files &amp;&amp; cvs
                   9431:        commit)</strong></span></p></li>
                   9432: <li><p>Run <span><strong class="command">bmake clean &amp;&amp; bmake</strong></span> to
                   9433:        regenerate the output files with the proper RCS
                   9434:        Ids.</p></li>
1.83    ! wiz      9435: <li><p>Run <span><strong class="command">bmake regenerate</strong></span> to
        !          9436:        regenerate the files in both <code class="filename">pkgsrc/doc</code> and
        !          9437:        <code class="filename">htdocs</code>.</p></li>
        !          9438: <li><p>If you have added, removed or renamed some chapters,
        !          9439:        you need to synchronize them using <span><strong class="command">cvs add</strong></span> or
        !          9440:        <span><strong class="command">cvs delete</strong></span> in the htdocs
        !          9441:        directory.</p></li>
1.79      rillig   9442: </ol></div>
1.75      rillig   9443: </div>
                   9444: </div>
                   9445: </div></body>
1.1       grant    9446: </html>

CVSweb <webmaster@jp.NetBSD.org>