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

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">
                      8: <meta name="description" content="pkgsrc is a centralized package management system for
                      9:        Unix-like operating systems. This guide provides information for
                     10:        users and developers of pkgsrc. It covers installation of binary
                     11:        and source packages, creation of binary and source packages and
                     12:        a high-level overview about the infrastructure.">
                     13: </head>
                     14: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en">
                     15: <div class="titlepage">
                     16: <div>
                     17: <div><h1 class="title">
                     18: <a name="the-pkgsrc-guide"></a>The pkgsrc guide</h1></div>
                     19: <div><h2 class="subtitle">Documentation on the NetBSD packages system</h2></div>
                     20: <div><div class="authorgroup">
                     21: <div class="author">
                     22: <h3 class="author">
                     23: <span class="firstname">Alistair</span> <span class="surname">Crooks</span>
                     24: </h3>
                     25: <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>
                     26: </div>
                     27: <div class="author">
                     28: <h3 class="author">
                     29: <span class="firstname">Hubert</span> <span class="surname">Feyrer</span>
                     30: </h3>
                     31: <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>
                     32: </div>
                     33: <h3 class="corpauthor">
                     34:         The pkgsrc Developers
                     35:       </h3>
                     36: </div></div>
                     37: <div><p class="copyright">Copyright © 1994-2006 The NetBSD Foundation, Inc</p></div>
1.77    ! rillig     38: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.19 2006/06/01 08:39:03 rillig Exp $</p></div>
1.76      rillig     39: <div><div class="abstract">
1.75      rillig     40: <p class="title"><b>Abstract</b></p>
                     41: <p>pkgsrc is a centralized package management system for
                     42:        Unix-like operating systems. This guide provides information for
                     43:        users and developers of pkgsrc. It covers installation of binary
                     44:        and source packages, creation of binary and source packages and
                     45:        a high-level overview about the infrastructure.</p>
                     46: </div></div>
                     47: </div>
                     48: <hr>
                     49: </div>
                     50: <div class="toc">
                     51: <p><b>Table of Contents</b></p>
                     52: <dl>
                     53: <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
                     54: <dd><dl>
                     55: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
                     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>
                     58: <dd><dl><dt><span class="sect2"><a href="#term.people">1.3.1. People involved in pkgsrc</a></span></dt></dl></dd>
                     59: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
                     60: </dl></dd>
                     61: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
                     62: <dd><dl>
                     63: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
                     64: <dd><dl>
                     65: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                     66: <dd><dl>
                     67: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                     68: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                     69: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                     70: </dl></dd>
                     71: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                     72: <dd><dl>
                     73: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                     74: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                     75: </dl></dd>
                     76: </dl></dd>
                     77: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
                     78: <dd><dl>
                     79: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
                     80: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
                     81: <dd><dl>
                     82: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
                     83: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
                     84: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
                     85: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
                     86: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
                     87: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
                     88: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
                     89: </dl></dd>
                     90: </dl></dd>
                     91: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
                     92: <dd><dl>
                     93: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                     94: <dd><dl>
                     95: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                     96: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
                     97: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
                     98: </dl></dd>
                     99: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                    100: <dd><dl>
                    101: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                    102: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                    103: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                    104: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
                    105: </dl></dd>
                    106: </dl></dd>
                    107: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
                    108: <dd><dl>
                    109: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                    110: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
                    111: <dt><span class="sect1"><a href="#developer-advanced-settings">5.3. Developer/advanced settings</a></span></dt>
                    112: <dt><span class="sect1"><a href="#selecting-build-options">5.4. Selecting Build Options</a></span></dt>
                    113: </dl></dd>
                    114: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
                    115: <dd><dl>
                    116: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                    117: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                    118: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                    119: <dd><dl>
                    120: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                    121: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                    122: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                    123: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                    124: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                    125: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                    126: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                    127: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                    128: </dl></dd>
                    129: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                    130: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                    131: </dl></dd>
                    132: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
                    133: <dd><dl>
                    134: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                    135: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
                    136: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
                    137: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
                    138: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
                    139: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                    140: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                    141: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
                    142: <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>
                    143: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
                    144: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does &#8220;<span class="quote">Don't know how to make
                    145: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
                    146: <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>
                    147: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
                    148: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
                    149: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
                    150: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
                    151: </dl></dd>
                    152: </dl></dd>
                    153: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
                    154: <dd><dl>
1.77    ! rillig    155: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
        !           156: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75      rillig    157: <dd><dl>
1.77    ! rillig    158: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
        !           159: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
        !           160: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
        !           161: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
        !           162: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
        !           163: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
        !           164: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
        !           165: </dl></dd>
        !           166: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
        !           167: <dd><dl>
        !           168: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
        !           169: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
        !           170: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
        !           171: <dd><dl>
        !           172: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
        !           173: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
        !           174: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
        !           175: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
        !           176: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
        !           177: </dl></dd>
        !           178: </dl></dd>
        !           179: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
        !           180: <dd><dl>
        !           181: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
        !           182: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
        !           183: <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>
        !           184: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
        !           185: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
        !           186: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
        !           187: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
        !           188: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
        !           189: </dl></dd>
        !           190: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
        !           191: <dd><dl>
        !           192: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
        !           193: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
        !           194: <dd><dl>
        !           195: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
        !           196: <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>
        !           197: </dl></dd>
        !           198: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
        !           199: <dd><dl>
        !           200: <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>
        !           201: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
        !           202: </dl></dd>
        !           203: </dl></dd>
        !           204: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
        !           205: <dd><dl>
        !           206: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
        !           207: <dd><dl>
        !           208: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
        !           209: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
        !           210: </dl></dd>
        !           211: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
        !           212: <dd><dl>
        !           213: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
        !           214: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
        !           215: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
        !           216: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
        !           217: </dl></dd>
        !           218: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
        !           219: <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>
        !           220: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
        !           221: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
        !           222: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
        !           223: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
        !           224: <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>
        !           225: </dl></dd>
        !           226: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
        !           227: <dd><dl>
        !           228: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
        !           229: <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>
        !           230: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
        !           231: </dl></dd>
        !           232: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
        !           233: <dd><dl>
        !           234: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
        !           235: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
        !           236: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
        !           237: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
        !           238: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
        !           239: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
        !           240: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
        !           241: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
        !           242: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
        !           243: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
        !           244: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
        !           245: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
        !           246: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
        !           247: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
        !           248: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
        !           249: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
        !           250: </dl></dd>
        !           251: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
        !           252: <dd><dl>
        !           253: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
        !           254: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
        !           255: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
        !           256: </dl></dd>
        !           257: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
        !           258: <dd><dl>
        !           259: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
        !           260: <dd><dl>
        !           261: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">17.1.1. How to pull in variables from /etc/mk.conf</a></span></dt>
        !           262: <dt><span class="sect2"><a href="#where-to-install-documentation">17.1.2. Where to install documentation</a></span></dt>
        !           263: <dt><span class="sect2"><a href="#restricted-packages">17.1.3. Restricted packages</a></span></dt>
        !           264: <dt><span class="sect2"><a href="#dependencies">17.1.4. Handling dependencies</a></span></dt>
        !           265: <dt><span class="sect2"><a href="#conflicts">17.1.5. Handling conflicts with other packages</a></span></dt>
        !           266: <dt><span class="sect2"><a href="#not-building-packages">17.1.6. Packages that cannot or should not be built</a></span></dt>
        !           267: <dt><span class="sect2"><a href="#undeletable-packages">17.1.7. Packages which should not be deleted, once installed</a></span></dt>
        !           268: <dt><span class="sect2"><a href="#security-handling">17.1.8. Handling packages with security problems</a></span></dt>
        !           269: <dt><span class="sect2"><a href="#compiler-bugs">17.1.9. How to handle compiler bugs</a></span></dt>
        !           270: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.10. How to handle incrementing versions when fixing an existing package</a></span></dt>
        !           271: <dt><span class="sect2"><a href="#portability-of-packages">17.1.11. Portability of packages</a></span></dt>
        !           272: </dl></dd>
        !           273: <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>
        !           274: <dd><dl>
        !           275: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
        !           276: <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>
        !           277: </dl></dd>
        !           278: <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>
        !           279: <dd><dl>
        !           280: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
        !           281: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
        !           282: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
        !           283: </dl></dd>
        !           284: <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>
        !           285: <dd><dl><dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt></dl></dd>
        !           286: <dt><span class="sect1"><a href="#package-specific-actions">17.5. Package specific actions</a></span></dt>
        !           287: <dd><dl>
        !           288: <dt><span class="sect2"><a href="#user-interaction">17.5.1. User interaction</a></span></dt>
        !           289: <dt><span class="sect2"><a href="#handling-licenses">17.5.2. Handling licenses</a></span></dt>
        !           290: </dl></dd>
        !           291: <dt><span class="sect1"><a href="#fixes.install">17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
        !           292: <dd><dl>
        !           293: <dt><span class="sect2"><a href="#installing-score-files">17.6.1. Installing score files</a></span></dt>
        !           294: <dt><span class="sect2"><a href="#perl-scripts">17.6.2. Packages containing perl scripts</a></span></dt>
        !           295: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.3. Packages with hardcoded paths to other interpreters</a></span></dt>
        !           296: <dt><span class="sect2"><a href="#perl-modules">17.6.4. Packages installing perl modules</a></span></dt>
        !           297: <dt><span class="sect2"><a href="#faq.info-files">17.6.5. Packages installing info files</a></span></dt>
        !           298: <dt><span class="sect2"><a href="#manpages">17.6.6. Packages installing man pages</a></span></dt>
        !           299: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.7. Packages installing GConf2 data files</a></span></dt>
        !           300: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.8. Packages installing scrollkeeper data files</a></span></dt>
        !           301: <dt><span class="sect2"><a href="#x11-fonts">17.6.9. Packages installing X11 fonts</a></span></dt>
        !           302: <dt><span class="sect2"><a href="#gtk2-modules">17.6.10. Packages installing GTK2 modules</a></span></dt>
        !           303: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.11. Packages installing SGML or XML data</a></span></dt>
        !           304: <dt><span class="sect2"><a href="#mime-database">17.6.12. Packages installing extensions to the MIME database</a></span></dt>
        !           305: <dt><span class="sect2"><a href="#intltool">17.6.13. Packages using intltool</a></span></dt>
        !           306: <dt><span class="sect2"><a href="#startup-scripts">17.6.14. Packages installing startup scripts</a></span></dt>
        !           307: <dt><span class="sect2"><a href="#tex-packages">17.6.15. Packages installing TeX modules</a></span></dt>
        !           308: </dl></dd>
        !           309: <dt><span class="sect1"><a href="#feedback-to-author">17.7. Feedback to the author</a></span></dt>
        !           310: </dl></dd>
        !           311: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
        !           312: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
        !           313: <dd><dl>
        !           314: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
        !           315: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
        !           316: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
        !           317: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
        !           318: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
        !           319: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig    320: </dl></dd>
1.77    ! rillig    321: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75      rillig    322: </dl></dd>
                    323: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
                    324: <dd><dl>
1.77    ! rillig    325: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75      rillig    326: <dd><dl>
1.77    ! rillig    327: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75      rillig    328: <dd><dl>
1.77    ! rillig    329: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
        !           330: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75      rillig    331: </dl></dd>
1.77    ! rillig    332: <dt><span class="sect1"><a href="#infr.design.intf">21.2. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig    333: <dd><dl>
1.77    ! rillig    334: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.2.1. Procedures with parameters</a></span></dt>
        !           335: <dt><span class="sect2"><a href="#infr.design.intf.action">21.2.2. Actions taken on behalf of parameters</a></span></dt>
1.75      rillig    336: </dl></dd>
                    337: </dl></dd>
1.77    ! rillig    338: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75      rillig    339: <dd><dl>
1.77    ! rillig    340: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
        !           341: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
        !           342: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75      rillig    343: <dd><dl>
1.77    ! rillig    344: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
        !           345: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75      rillig    346: </dl></dd>
                    347: </dl></dd>
1.77    ! rillig    348: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75      rillig    349: <dd><dl>
1.77    ! rillig    350: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
        !           351: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75      rillig    352: </dl></dd>
                    353: </dl></dd>
                    354: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
                    355: <dd><dl>
                    356: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
                    357: <dd><dl>
                    358: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
                    359: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
                    360: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
                    361: <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>
                    362: </dl></dd>
                    363: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
                    364: </dl></dd>
                    365: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
                    366: <dd><dl>
                    367: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
                    368: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
                    369: </dl></dd>
1.76      rillig    370: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
                    371: <dd><dl>
                    372: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
                    373: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
                    374: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
                    375: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
                    376: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
                    377: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
                    378: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                    379: source packages</a></span></dt>
                    380: </dl></dd>
1.75      rillig    381: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
                    382: <dd><dl>
                    383: <dt><span class="sect1"><a href="#targets">D.1. Targets</a></span></dt>
                    384: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
                    385: </dl></dd>
                    386: </dl>
                    387: </div>
                    388: <div class="chapter" lang="en">
                    389: <div class="titlepage"><div><div><h2 class="title">
                    390: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
                    391: <div class="toc">
                    392: <p><b>Table of Contents</b></p>
                    393: <dl>
                    394: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
                    395: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
                    396: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
                    397: <dd><dl><dt><span class="sect2"><a href="#term.people">1.3.1. People involved in pkgsrc</a></span></dt></dl></dd>
                    398: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
                    399: </dl>
                    400: </div>
                    401: <div class="sect1" lang="en">
                    402: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    403: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
                    404: <p> There is a lot of software freely available for Unix-based
                    405:       systems, which usually runs on NetBSD and other Unix-flavoured
                    406:       systems, too, sometimes with some modifications.  The NetBSD
                    407:       Packages Collection (pkgsrc) incorporates any such changes
                    408:       necessary to make that software run, and makes the installation
                    409:       (and de-installation) of the software package easy by means of a
                    410:       single command. </p>
                    411: <p>Once the software
                    412:       has been built, it is manipulated with the <span><strong class="command">pkg_*</strong></span> tools
                    413:       so that installation
                    414:       and de-installation, printing of an inventory of all installed packages and
                    415:       retrieval of one-line comments or more verbose descriptions are all
                    416:       simple.</p>
                    417: <p>pkgsrc currently contains several thousand packages,
                    418:       including:</p>
                    419: <div class="itemizedlist"><ul type="disc">
1.76      rillig    420: <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    421:          web server</p></li>
1.76      rillig    422: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html" target="_top"><code class="filename">www/mozilla</code></a> - The Mozilla
1.75      rillig    423:          web browser</p></li>
1.76      rillig    424: <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    425:          Desktop Environment</p></li>
1.76      rillig    426: <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    427:          Desktop Environment</p></li>
                    428: </ul></div>
                    429: <p>...just to name a few.</p>
                    430: <p>pkgsrc has built-in support for handling varying dependencies,
                    431:       such as pthreads and X11, and extended features such as IPv6 support on
                    432:       a range of platforms.</p>
                    433: <p>pkgsrc was derived from FreeBSD's ports system, and
                    434:       initially developed for NetBSD only. Since then, pkgsrc has
                    435:       grown a lot, and now supports the following platforms:</p>
                    436: <div class="itemizedlist"><ul type="disc">
                    437: <li><p><a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
                    438:          (<a href="http://www.apple.com/macosx/" target="_top">Mac OS X</a>)</p></li>
                    439: <li><p><a href="http://www.DragonFlyBSD.org/" target="_top">DragonFly BSD</a></p></li>
                    440: <li><p><a href="http://www.FreeBSD.org/" target="_top">FreeBSD</a></p></li>
                    441: <li><p>Microsoft Windows, via <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a></p></li>
                    442: <li><p><a href="http://www.sgi.com/software/irix6.5/" target="_top">IRIX</a></p></li>
                    443: <li><p><a href="http://www.linux.org/" target="_top">Linux</a></p></li>
                    444: <li><p><a href="http://www.NetBSD.org/" target="_top">NetBSD</a> (of
                    445:          course)</p></li>
                    446: <li><p><a href="http://h30097.www3.hp.com/" target="_top">Tru64</a>
                    447:          (Digital UNIX, OSF1)</p></li>
                    448: <li><p><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></p></li>
                    449: <li><p><a href="http://www.sun.com/solaris/" target="_top">Solaris</a></p></li>
                    450: </ul></div>
                    451: </div>
                    452: <div class="sect1" lang="en">
                    453: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    454: <a name="overview"></a>1.2. Overview</h2></div></div></div>
                    455: <p>This document is divided into three parts. The first,
                    456:        <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
                    457:        describes how one can use one of the packages in the Package
                    458:        Collection, either by installing a precompiled binary package,
                    459:        or by building one's own copy using the NetBSD package system. 
                    460:        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
                    461:        package so it can be easily built by other NetBSD users without
                    462:        knowing about the package's building details. The third part,
                    463:        <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
                    464:        is intended for those who want to understand how pkgsrc is
                    465:        implemented.</p>
                    466: <p>This document is available in various formats:
                    467:        <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>
                    468: </div>
                    469: <div class="sect1" lang="en">
                    470: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    471: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
                    472: <p>There has been a lot of talk about &#8220;<span class="quote">ports</span>&#8221;,
                    473:       &#8220;<span class="quote">packages</span>&#8221;, etc. so far. Here is a description of all the
                    474:       terminology used within this document.</p>
                    475: <div class="variablelist"><dl>
                    476: <dt><span class="term">Package</span></dt>
                    477: <dd><p>A set of files and building instructions
                    478:            that describe what's necessary
                    479:            to build a certain piece of software using
                    480:             pkgsrc. Packages are traditionally stored under
1.76      rillig    481:            <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75      rillig    482: <dt><span class="term">The NetBSD package system</span></dt>
                    483: <dd><p>
                    484:            This is the former name of &#8220;<span class="quote">pkgsrc</span>&#8221;.  It is
                    485:            part of the NetBSD operating system and can be bootstrapped to
                    486:            run on non-NetBSD operating systems as well.  It handles
                    487:            building (compiling), installing, and removing of
                    488:            packages.
                    489:            </p></dd>
                    490: <dt><span class="term">Distfile</span></dt>
                    491: <dd><p>This term describes the file or files that are
                    492:            provided by the author of the piece of software to
                    493:            distribute his work. All the changes necessary to build on
                    494:            NetBSD are reflected in the corresponding package. Usually
                    495:            the distfile is in the form of a compressed tar-archive,
                    496:            but other types are possible, too. Distfiles are usually
                    497:            stored below
1.76      rillig    498:            <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75      rillig    499: <dt><span class="term">Port</span></dt>
                    500: <dd><p>This is the term used by FreeBSD and OpenBSD people
                    501:            for what we call a package.
                    502:            In NetBSD terminology, &#8220;<span class="quote">port</span>&#8221; refers to a different
                    503:            architecture.</p></dd>
                    504: <dt><span class="term">Precompiled/binary package</span></dt>
                    505: <dd>
                    506: <p>A set of binaries built with pkgsrc from a distfile
1.76      rillig    507:            and stuffed together in a single <code class="filename">.tgz</code>
1.75      rillig    508:            file so it can be installed on machines of the same
                    509:            machine architecture without the need to
                    510:            recompile. Packages are usually generated in
1.76      rillig    511:            <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75      rillig    512:            an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
                    513: <p>Sometimes, this is referred to by the term &#8220;<span class="quote">package</span>&#8221; too,
                    514:            especially in the context of precompiled packages.</p>
                    515: </dd>
                    516: <dt><span class="term">Program</span></dt>
                    517: <dd><p>The piece of software to be installed which will be constructed from
                    518:            all the files in the distfile by the actions defined in the
                    519:            corresponding package.</p></dd>
                    520: </dl></div>
                    521: <div class="sect2" lang="en">
                    522: <div class="titlepage"><div><div><h3 class="title">
                    523: <a name="term.people"></a>1.3.1. People involved in pkgsrc</h3></div></div></div>
                    524: <div class="variablelist"><dl>
                    525: <dt><span class="term">pkgsrc users</span></dt>
                    526: <dd>
                    527: <p>The
                    528:        pkgsrc users are people who use the packages provided by pkgsrc.
                    529:        Typically they are system administrators. The people using the
                    530:        software that is inside the packages (maybe called &#8220;<span class="quote">end
                    531:        users</span>&#8221;) are not covered by the pkgsrc guide.</p>
                    532: <p>There are two kinds of pkgsrc users: Some only want to
                    533:        install pre-built binary packages. Others build the pkgsrc
                    534:        packages from source, either for installing them directly or for
                    535:        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
                    536:        documentation.</p>
                    537: </dd>
                    538: <dt><span class="term">package maintainers</span></dt>
                    539: <dd><p>A
                    540:        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>
                    541: <dt><span class="term">infrastructure developers</span></dt>
                    542: <dd><p>These people are involved in all those files
1.76      rillig    543:        that live in the <code class="filename">mk/</code> directory and below.
1.75      rillig    544:        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,
                    545:        too.</p></dd>
                    546: </dl></div>
                    547: </div>
                    548: </div>
                    549: <div class="sect1" lang="en">
                    550: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    551: <a name="typography"></a>1.4. Typography</h2></div></div></div>
                    552: <p>When giving examples for commands, shell prompts are used to
                    553:       show if the command should/can be issued as root, or if
                    554:       &#8220;<span class="quote">normal</span>&#8221; user privileges are sufficient. We use a
                    555:       <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
                    556:       shell prompt, assuming they use the C-shell or tcsh.</p>
                    557: </div>
                    558: </div>
                    559: <div class="part" lang="en">
                    560: <div class="titlepage"><div><div><h1 class="title">
                    561: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
                    562: <div class="toc">
                    563: <p><b>Table of Contents</b></p>
                    564: <dl>
                    565: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
                    566: <dd><dl>
                    567: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                    568: <dd><dl>
                    569: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                    570: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                    571: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                    572: </dl></dd>
                    573: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                    574: <dd><dl>
                    575: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                    576: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                    577: </dl></dd>
                    578: </dl></dd>
                    579: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
                    580: <dd><dl>
                    581: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
                    582: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
                    583: <dd><dl>
                    584: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
                    585: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
                    586: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
                    587: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
                    588: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
                    589: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
                    590: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
                    591: </dl></dd>
                    592: </dl></dd>
                    593: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
                    594: <dd><dl>
                    595: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                    596: <dd><dl>
                    597: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                    598: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
                    599: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
                    600: </dl></dd>
                    601: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                    602: <dd><dl>
                    603: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                    604: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                    605: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                    606: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
                    607: </dl></dd>
                    608: </dl></dd>
                    609: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
                    610: <dd><dl>
                    611: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                    612: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
                    613: <dt><span class="sect1"><a href="#developer-advanced-settings">5.3. Developer/advanced settings</a></span></dt>
                    614: <dt><span class="sect1"><a href="#selecting-build-options">5.4. Selecting Build Options</a></span></dt>
                    615: </dl></dd>
                    616: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
                    617: <dd><dl>
                    618: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                    619: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                    620: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                    621: <dd><dl>
                    622: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                    623: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                    624: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                    625: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                    626: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                    627: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                    628: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                    629: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                    630: </dl></dd>
                    631: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                    632: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                    633: </dl></dd>
                    634: <dt><span class="chapter"><a href="#faq">7. Frequently Asked Questions</a></span></dt>
                    635: <dd><dl>
                    636: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                    637: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
                    638: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
                    639: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
                    640: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
                    641: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                    642: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                    643: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
                    644: <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>
                    645: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
                    646: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does &#8220;<span class="quote">Don't know how to make
                    647: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
                    648: <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>
                    649: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
                    650: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
                    651: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
                    652: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
                    653: </dl></dd>
                    654: </dl>
                    655: </div>
                    656: <div class="chapter" lang="en">
                    657: <div class="titlepage"><div><div><h2 class="title">
                    658: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
                    659: <div class="toc">
                    660: <p><b>Table of Contents</b></p>
                    661: <dl>
                    662: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
                    663: <dd><dl>
                    664: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
                    665: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
                    666: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
                    667: </dl></dd>
                    668: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
                    669: <dd><dl>
                    670: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
                    671: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
                    672: </dl></dd>
                    673: </dl>
                    674: </div>
                    675: <p>The most common location where pkgsrc is installed is
1.76      rillig    676:        <code class="filename">/usr/pkgsrc</code> for the &#8220;<span class="quote">package
                    677:        sources</span>&#8221; and <code class="filename">/usr/pkg</code> for the
1.75      rillig    678:        installed binary packages. You are though free to install the
                    679:        sources and binary packages wherever you want in your
                    680:        filesystem, provided that both paths do not contain white-space
                    681:        or other characters that are interpreted specially by the shell
                    682:        and some other programs. A safe bet is to use only letters,
                    683:        digits, underscores and dashes in the names.</p>
                    684: <div class="sect1" lang="en">
                    685: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    686: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
                    687: <p>Before you download any pkgsrc files, you should decide
                    688:        whether you want the <span class="emphasis"><em>current</em></span> branch or the
                    689:        <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
                    690:        quarterly basis from the current branch and only gets modified
                    691:        for security updates. The names of the stable branches are built
                    692:        from the year and the quarter, for example
                    693:        <code class="literal">2006Q1</code>.</p>
                    694: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
                    695:        want to download pkgsrc. You can get it as a tar file, via SUP,
                    696:        or via CVS. All three ways are described here.</p>
                    697: <div class="sect2" lang="en">
                    698: <div class="titlepage"><div><div><h3 class="title">
                    699: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
                    700: <p>The primary download location for all pkgsrc files is
                    701:        <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
                    702:        number of subdirectories for different purposes, which are
1.76      rillig    703:        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    704: <p>The tar file for the current branch is in the directory
1.76      rillig    705:        <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    706:        It is autogenerated daily.</p>
                    707: <p>The tar file for the stable branch 2006Q1 is in the
1.76      rillig    708:        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    709: <p>After downloading the tar file, change to the directory
                    710:        where you want to have pkgsrc. This is usually
1.76      rillig    711:        <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75      rillig    712:        pkgsrc.tar.gz</strong></span> to extract the files.</p>
                    713: </div>
                    714: <div class="sect2" lang="en">
                    715: <div class="titlepage"><div><div><h3 class="title">
                    716: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
                    717: <p>As an alternative to the tar file, you can get pkgsrc via
                    718:        the Software Update Protocol, SUP. To do so, make sure your
                    719:        supfile has a line
1.1       grant     720: 
1.75      rillig    721: </p>
                    722: <pre class="programlisting">
1.51      rillig    723:     release=pkgsrc
1.1       grant     724: </pre>
1.75      rillig    725: <p>
1.1       grant     726: 
1.75      rillig    727:        in it, see the examples in
1.76      rillig    728:        <code class="filename">/usr/share/examples/supfiles</code>, and that the
                    729:        <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75      rillig    730:        run <span><strong class="command">sup -v
                    731:        <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
                    732: </div>
                    733: <div class="sect2" lang="en">
                    734: <div class="titlepage"><div><div><h3 class="title">
                    735: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
                    736: <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>
                    737:        installed. To do an initial (full) checkout of pkgsrc, you first
                    738:        have to set some environment variables. For the C-Shell,
                    739:        type:</p>
                    740: <pre class="screen">
                    741:     <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
                    742:     <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
                    743: </pre>
                    744: <p>Or, the same for the bourne shell:</p>
                    745: <pre class="screen">
                    746:     <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
                    747:     <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
                    748:     <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
                    749: </pre>
                    750: <p>Then, you change to the directory where you want to have
                    751:        your copy of pkgsrc. In most cases this is
1.76      rillig    752:        <code class="filename">/usr</code>. In that directory you run the
1.75      rillig    753:        checkout command, which is <span><strong class="command">cvs -q checkout -P
                    754:        pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
                    755:        checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
                    756:        branch. This command will create a directory called
1.76      rillig    757:        <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75      rillig    758:        it.</p>
                    759: </div>
                    760: </div>
                    761: <div class="sect1" lang="en">
                    762: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    763: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
                    764: <p>The preferred way to keep pkgsrc up-to-date is via CVS
                    765:        (which also works if you have first installed it via a tar
                    766:        file). It saves bandwidth and hard disk activity, compared to
                    767:        downloading the tar file again.</p>
                    768: <div class="sect2" lang="en">
                    769: <div class="titlepage"><div><div><h3 class="title">
                    770: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
                    771: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
                    772: <h3 class="title">Warning</h3>
1.77    ! rillig    773: <p>When updating from a tar file, you first need to
        !           774:        completely remove the old pkgsrc directory. Otherwise those
        !           775:        files that have been removed from pkgsrc in the mean time will
        !           776:        not be removed on your local disk, resulting in inconsistencies.
        !           777:        When removing the old files, any changes that you have done to
        !           778:        the pkgsrc files will be lost after updating. Therefore updating
        !           779:        via CVS is strongly recommended.</p>
1.75      rillig    780: </div>
                    781: <p>To update pkgsrc from a tar file, download the tar file as
                    782:        explained above. Then, make sure that you have not made any
                    783:        changes to the files in the pkgsrc directory. Remove the pkgsrc
                    784:        directory and extract the new tar file. Done.</p>
                    785: </div>
                    786: <div class="sect2" lang="en">
                    787: <div class="titlepage"><div><div><h3 class="title">
                    788: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
                    789: <p>To update pkgsrc via CVS, make sure the environment
                    790:        variable <code class="varname">CVS_RSH</code> is set as above. Then,
                    791:        change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77    ! rillig    792:        -dP</strong></span>.</p>
1.75      rillig    793: <div class="sect3" lang="en">
                    794: <div class="titlepage"><div><div><h4 class="title">
                    795: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
                    796: <p>When updating pkgsrc, the CVS program keeps track of the
                    797:        branch you selected. But if you, for whatever reason, want to
                    798:        switch from the stable branch to the current one, you can do it
                    799:        by adding the option &#8220;<span class="quote">-A</span>&#8221; after the
                    800:        &#8220;<span class="quote">update</span>&#8221; keyword. To switch from the current branch
                    801:        back to the stable branch, add the
                    802:        &#8220;<span class="quote">-rpkgsrc-2006Q1</span>&#8221; option.</p>
                    803: </div>
                    804: <div class="sect3" lang="en">
                    805: <div class="titlepage"><div><div><h4 class="title">
                    806: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
                    807: <p>When you update pkgsrc, the CVS program will only touch
                    808:        those files that are registered in the CVS repository. That
                    809:        means that any packages that you created on your own will stay
                    810:        unmodified. If you change files that are managed by CVS, later
                    811:        updates will try to merge your changes with those that have been
                    812:        done by others. See the CVS manual, chapter
                    813:        &#8220;<span class="quote">update</span>&#8221; for details.</p>
                    814: </div>
                    815: </div>
                    816: </div>
                    817: </div>
                    818: <div class="chapter" lang="en">
                    819: <div class="titlepage"><div><div><h2 class="title">
                    820: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
                    821: <div class="toc">
                    822: <p><b>Table of Contents</b></p>
                    823: <dl>
                    824: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.1. Bootstrapping pkgsrc</a></span></dt>
                    825: <dt><span class="sect1"><a href="#platform-specific-notes">3.2. Platform-specific notes</a></span></dt>
                    826: <dd><dl>
                    827: <dt><span class="sect2"><a href="#darwin">3.2.1. Darwin (Mac OS X)</a></span></dt>
                    828: <dt><span class="sect2"><a href="#freebsd">3.2.2. FreeBSD</a></span></dt>
                    829: <dt><span class="sect2"><a href="#interix">3.2.3. Interix</a></span></dt>
                    830: <dt><span class="sect2"><a href="#irix">3.2.4. IRIX</a></span></dt>
                    831: <dt><span class="sect2"><a href="#linux">3.2.5. Linux</a></span></dt>
                    832: <dt><span class="sect2"><a href="#openbsd">3.2.6. OpenBSD</a></span></dt>
                    833: <dt><span class="sect2"><a href="#solaris">3.2.7. Solaris</a></span></dt>
                    834: </dl></dd>
                    835: </dl>
                    836: </div>
                    837: <div class="sect1" lang="en">
                    838: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    839: <a name="bootstrapping-pkgsrc"></a>3.1. Bootstrapping pkgsrc</h2></div></div></div>
                    840: <p>For operating systems other than NetBSD, we provide a bootstrap kit to
                    841:       build the required tools to use pkgsrc on your platform. Besides
                    842:       support for native NetBSD, pkgsrc and the bootstrap kit have support for
                    843:       the following operating systems:</p>
                    844: <div class="itemizedlist"><ul type="disc">
                    845: <li><p>Darwin (Mac OS X)</p></li>
                    846: <li><p>DragonFly BSD</p></li>
                    847: <li><p>FreeBSD</p></li>
                    848: <li><p>Interix (Windows 2000, XP, 2003)</p></li>
                    849: <li><p>IRIX</p></li>
                    850: <li><p>Linux</p></li>
                    851: <li><p>OpenBSD</p></li>
                    852: <li><p>Solaris</p></li>
                    853: <li><p>Tru64 (Digital UNIX/OSF1)</p></li>
                    854: </ul></div>
                    855: <p>Support for other platforms is under development.</p>
                    856: <p>Installing the bootstrap kit should be as simple as:</p>
                    857: <pre class="screen">
                    858: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
                    859: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
                    860: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong></pre>
                    861: <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
                    862:       pkgsrc before bootstrapping. The given
                    863:       <span><strong class="command">bootstrap</strong></span> command will use the defaults of
1.76      rillig    864:       <code class="filename">/usr/pkg</code> for the
1.75      rillig    865:       <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1.76      rillig    866:       and <code class="filename">/var/db/pkg</code> for the package database
1.75      rillig    867:       directory where pkgsrc will do its internal bookkeeping.
                    868:       However, these can also be set using command-line
                    869:       arguments.</p>
                    870: <p>Binary packages for the pkgsrc tools and an initial set of packages is
                    871:       available for supported platforms. An up-to-date list of these can be
                    872:       found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
                    873:       Note that this only works for privileged builds that install
1.76      rillig    874:       into <code class="filename">/usr/pkg</code>.</p>
1.75      rillig    875: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                    876: <h3 class="title">Note</h3>
                    877: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
                    878:        Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
                    879:        For examples in this guide, use <span><strong class="command">bmake</strong></span>
                    880:        instead of &#8220;<span class="quote">make</span>&#8221;.</p>
                    881: </div>
                    882: </div>
                    883: <div class="sect1" lang="en">
                    884: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    885: <a name="platform-specific-notes"></a>3.2. Platform-specific notes</h2></div></div></div>
                    886: <p>Here are some platform-specific notes you should be aware of.</p>
                    887: <div class="sect2" lang="en">
                    888: <div class="titlepage"><div><div><h3 class="title">
                    889: <a name="darwin"></a>3.2.1. Darwin (Mac OS X)</h3></div></div></div>
                    890: <p>Darwin 5.x and 6.x are supported. There are two methods of using
                    891:        pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.2.1.1. Using a disk image">disk
                    892:          image</a>, or a <a href="#platform.osx-ufs" title="3.2.1.2. Using a UFS partition">UFS
                    893:          partition</a>.</p>
                    894: <p>Before you start, you will need to download and install the Mac OS X Developer
                    895:        Tools from Apple's Developer Connection.  See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
                    896:        for details.  Also, make sure you install X11 for Mac OS X and the X11 SDK
                    897:        from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
                    898:        if you intend to build packages that use the X11 Window System.</p>
                    899: <p>If you already have a UFS partition, or have a spare partition
                    900:        that you can format as UFS, it is recommended to use that instead of
                    901:        the disk image. It'll be somewhat faster and will mount automatically
                    902:        at boot time, where you must manually mount a disk image.</p>
                    903: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                    904: <h3 class="title">Note</h3>
                    905: <p>You cannot use a HFS+ file system for pkgsrc, because pkgsrc currently
                    906:          requires the file system to be case-sensitive, and HFS+ is not.</p>
                    907: </div>
                    908: <div class="sect3" lang="en">
                    909: <div class="titlepage"><div><div><h4 class="title">
                    910: <a name="platform.osx-image"></a>3.2.1.1. Using a disk image</h4></div></div></div>
                    911: <p>Create the disk image:</p>
                    912: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
                    913: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
                    914: <code class="prompt">#</code> <strong class="userinput"><code>./ufsdiskimage mount ~/Documents/NetBSD</code></strong>
                    915: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
                    916: <p>That's it!</p>
                    917: </div>
                    918: <div class="sect3" lang="en">
                    919: <div class="titlepage"><div><div><h4 class="title">
                    920: <a name="platform.osx-ufs"></a>3.2.1.2. Using a UFS partition</h4></div></div></div>
1.76      rillig    921: <p>By default, <code class="filename">/usr</code> will be on your root file
1.75      rillig    922:          system, normally HFS+. It is possible to use the default
1.76      rillig    923:          <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
                    924:          by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1.75      rillig    925:          file system. Obviously, another symlink is required if you want to
                    926:          place the package database directory outside the
                    927:          <span class="emphasis"><em>prefix</em></span>. e.g.</p>
                    928: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
                    929: <p>If you created your partitions at the time of installing Mac OS X
                    930:          and formatted the target partition as UFS, it should automatically
1.76      rillig    931:          mount on <code class="filename">/Volumes/&lt;volume name&gt;</code> when the
1.75      rillig    932:          machine boots. If you are (re)formatting a partition as UFS, you need
                    933:          to ensure that the partition map correctly reflects
                    934:          &#8220;<span class="quote">Apple_UFS</span>&#8221; and not &#8220;<span class="quote">Apple_HFS</span>&#8221;.</p>
                    935: <p>The problem is that none of the disk tools will let you touch a
                    936:          disk that is booted from. You can unmount the partition, but even if
                    937:          you newfs it, the partition type will be incorrect and the
                    938:          automounter won't mount it. It can be mounted manually, but it won't
                    939:          appear in Finder.</p>
                    940: <p>You'll need to boot off of the OS X Installation (User) CD.  When
                    941:          the Installation program starts, go up to the menu and select Disk
                    942:          Utility.  Now, you will be able to select the partition you want
                    943:          to be UFS, and Format it Apple UFS. Quit the Disk Utility, quit the
                    944:          installer which will reboot your machine. The new UFS file system
                    945:          will appear in Finder.</p>
                    946: <p>Be aware that the permissions on the new file system will be writable
                    947:          by root only.</p>
                    948: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
                    949:          Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
                    950: </div>
                    951: </div>
                    952: <div class="sect2" lang="en">
                    953: <div class="titlepage"><div><div><h3 class="title">
                    954: <a name="freebsd"></a>3.2.2. FreeBSD</h3></div></div></div>
                    955: <p>
                    956:        FreeBSD 4.7 and 5.0 have been tested and are supported, other versions
                    957:        may work.</p>
                    958: <p>Care should be taken so that the tools that this kit installs do not conflict
                    959:        with the FreeBSD userland tools. There are several steps:</p>
                    960: <div class="orderedlist"><ol type="1">
                    961: <li><p>FreeBSD stores its ports pkg database in
1.76      rillig    962:            <code class="filename">/var/db/pkg</code>. It is therefore
1.75      rillig    963:            recommended that you choose a different location (e.g.
1.76      rillig    964:            <code class="filename">/usr/pkgdb</code>) by
1.75      rillig    965:            using the --pkgdbdir option to the bootstrap script.</p></li>
                    966: <li>
                    967: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
                    968:            good idea to move them out of the way to avoid confusion, e.g.</p>
                    969: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
                    970: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
                    971: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
                    972: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
                    973: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
                    974: </li>
1.76      rillig    975: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
                    976:            <code class="filename">/etc/mk.conf.example</code> file
1.75      rillig    977:            when you use the bootstrap script.</p></li>
                    978: </ol></div>
                    979: </div>
                    980: <div class="sect2" lang="en">
                    981: <div class="titlepage"><div><div><h3 class="title">
                    982: <a name="interix"></a>3.2.3. Interix</h3></div></div></div>
                    983: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
                    984:        providing a Unix-like environment with a tighter kernel integration than
                    985:        available with Cygwin.  It is part of the Windows Services for Unix
                    986:        package, available for free for any licensed copy of Windows 2000, XP
                    987:        (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>
                    988: <p>Services for Unix 3.5, current as of this writing, has been tested.  3.0
                    989:        or 3.1 may work, but are not officially supported.  (The main difference
                    990:        in 3.0/3.1 is lack of pthreads.)</p>
                    991: <div class="sect3" lang="en">
                    992: <div class="titlepage"><div><div><h4 class="title">
                    993: <a name="platform.interix-sfu-install"></a>3.2.3.1. When installing Interix/SFU</h4></div></div></div>
                    994: <p>At an absolute minimum, the following packages must be installed from
                    995:          the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
                    996: <div class="itemizedlist"><ul type="disc">
                    997: <li><p>Utilities -&gt; Base Utilities</p></li>
                    998: <li><p>Interix GNU Components -&gt; (all)</p></li>
                    999: <li><p>Remote Connectivity</p></li>
                   1000: <li><p>Interix SDK</p></li>
                   1001: </ul></div>
                   1002: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
                   1003:          "UNIX Perl".  That is Perl 5.6 without shared module support, installed to
                   1004:          /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
                   1005:          pkgsrc (or from a binary package).</p>
                   1006: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
                   1007:          not need to be installed, but Remote Connectivity itself should be
                   1008:          installed in order to have a working inetd.</p>
                   1009: <p>During installation you may be asked whether to enable setuid
                   1010:          behavior for Interix programs, and whether to make pathnames default to
                   1011:          case-sensitive.  Setuid should be enabled, and case-sensitivity MUST be
                   1012:          enabled.  (Without case-sensitivity, a large number of packages including
                   1013:          perl will not build.)</p>
                   1014: <p>NOTE:  Newer Windows service packs change the way binary execution
                   1015:          works (via the Data Execution Prevention feature).  In order to use
                   1016:          pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
                   1017:          POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
                   1018:          must be installed.  Hotfixes are available from Microsoft through a
                   1019:          support contract; however, a NetBSD developer has made most Interix
                   1020:          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>
                   1021: </div>
                   1022: <div class="sect3" lang="en">
                   1023: <div class="titlepage"><div><div><h4 class="title">
                   1024: <a name="platform.interix-sfu-postinstall"></a>3.2.3.2. What to do if Interix/SFU is already installed</h4></div></div></div>
                   1025: <p>If SFU is already installed and you wish to alter these settings to work
                   1026:          with pkgsrc, note the following things.</p>
                   1027: <div class="itemizedlist"><ul type="disc">
                   1028: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
                   1029:              Windows Services for UNIX, then click Change.  In the installer, choose
                   1030:              Add or Remove, then uncheck Utilities-&gt;UNIX Perl.</p></li>
                   1031: <li>
                   1032: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
                   1033:              change the following registry key:</p>
                   1034: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
                   1035: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
                   1036: </li>
                   1037: <li>
                   1038: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
                   1039:              following registry key:</p>
                   1040: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
                   1041: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
                   1042: </li>
                   1043: </ul></div>
                   1044: </div>
                   1045: <div class="sect3" lang="en">
                   1046: <div class="titlepage"><div><div><h4 class="title">
                   1047: <a name="platform.interix-notes"></a>3.2.3.3. Important notes for using pkgsrc</h4></div></div></div>
                   1048: <p>The package manager (either the pkgsrc "su" user, or the user
                   1049:          running "pkg_add") must be a member of the local Administrators
                   1050:          group.  Such a user must also be used to run the bootstrap.  This is
                   1051:          slightly relaxed from the normal pkgsrc requirement of "root".</p>
                   1052: <p>The package manager should use a umask of 002.  "make install" will
                   1053:          automatically complain if this is not the case.  This ensures that
                   1054:          directories written in /var/db/pkg are Administrators-group writeable.</p>
                   1055: <p>The popular Interix binary packages from http://www.interopsystems.com/
                   1056:          use an older version of pkgsrc's pkg_* tools.  Ideally, these should
                   1057:          NOT be used in conjunction with pkgsrc.  If you choose to use them at
                   1058:          the same time as the pkgsrc packages, ensure that you use the proper
                   1059:          pkg_* tools for each type of binary package.</p>
                   1060: <p>The TERM setting used for DOS-type console windows (including those
                   1061:          invoked by the csh and ksh startup shortcuts) is "interix".  Most systems
                   1062:          don't have a termcap/terminfo entry for it, but the following .termcap
                   1063:          entry provides adequate emulation in most cases:</p>
                   1064: <pre class="programlisting">
                   1065:     interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
                   1066: </pre>
                   1067: </div>
                   1068: <div class="sect3" lang="en">
                   1069: <div class="titlepage"><div><div><h4 class="title">
                   1070: <a name="platform.interix-limits"></a>3.2.3.4. Limitations of the Interix platform</h4></div></div></div>
                   1071: <p>Though Interix suffices as a familiar and flexible substitute
                   1072:          for a full Unix-like platform, it has some drawbacks that should
                   1073:          be noted for those desiring to make the most of Interix.</p>
                   1074: <div class="itemizedlist"><ul type="disc">
                   1075: <li>
                   1076: <p><span class="strong"><strong>X11:</strong></span></p>
                   1077: <p>Interix comes with the standard set of X11R6 client libraries,
                   1078:            and can run X11 based applications, but it does
                   1079:            <span class="emphasis"><em>not</em></span> come with an X server.  Some options are
                   1080:            <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
                   1081:            <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
                   1082:            (available in a trimmed version for Interix from Interop Systems as the
                   1083:            <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
                   1084:            and the free X11 server included with
                   1085:            <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
                   1086: <p>Also, StarNet Communications has graciously provided a free
                   1087:            version of their X-Win32 product that accepts connections only
                   1088:            from localhost:
                   1089:            <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
                   1090:            recommended by the maintainer of Interix pkgsrc support.</p>
                   1091: </li>
                   1092: <li>
                   1093: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
                   1094: <p>Because Interix runs in a completely different NT subsystem from
                   1095:            Win32 applications, it does not currently support various X11
                   1096:            protocol extensions for acceleration (such as MIT-SHM or DGA).
                   1097:            Most interactive applications to a local X server will run
                   1098:            reasonably fast, but full motion video and other graphics
                   1099:            intensive applications may require a faster-than-expected CPU.</p>
                   1100: </li>
                   1101: <li>
                   1102: <p><span class="strong"><strong>Audio:</strong></span></p>
                   1103: <p>Interix has no native support for audio output.  For audio
                   1104:            support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
                   1105:            audio system on Interix.  Unlike on most platforms, the
1.76      rillig   1106:            <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   1107:            <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
                   1108:            server component.  To output audio via an Interix host, the
1.76      rillig   1109:            <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   1110:            must also be installed.</p>
                   1111: </li>
                   1112: <li>
                   1113: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
                   1114: <p>Direct device access is not currently supported in Interix, so it
                   1115:            is not currently possible to access CD/DVD drives, USB devices,
                   1116:            or SCSI devices through non-filesystem means.  Among other things,
                   1117:            this makes it impossible to use Interix directly for CD/DVD
                   1118:            burning.</p>
                   1119: </li>
                   1120: <li>
                   1121: <p><span class="strong"><strong>Tape drives:</strong></span></p>
                   1122: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
                   1123:            drives are also not directly accessible in Interix.  However,
                   1124:            support is in work to make tape drive access possible by using
                   1125:            Cygwin as a bridge (similarly to audio bridged via Cygwin's
                   1126:            esound server).</p>
                   1127: </li>
                   1128: </ul></div>
                   1129: </div>
                   1130: <div class="sect3" lang="en">
                   1131: <div class="titlepage"><div><div><h4 class="title">
                   1132: <a name="platform.interix-knownissues"></a>3.2.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
                   1133: <p>It is not necessary, in general, to have a "root" user on the
                   1134:          Windows system; any member of the local Administrators group will
                   1135:          suffice.  However, some packages currently assume that the user
                   1136:          named "root" is the privileged user.  To accommodate these, you
                   1137:          may create such a user; make sure it is in the local group
                   1138:          Administrators (or your language equivalent).</p>
                   1139: <p>"pkg_add" creates directories of mode 0755, not 0775, in
                   1140:          $PKG_DBDIR.  For the time being, install packages as the local
                   1141:          Administrator (or your language equivalent), or run the following
                   1142:          command after installing a package to work around the issue:</p>
                   1143: <pre class="screen">
                   1144: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong></pre>
                   1145: </div>
                   1146: </div>
                   1147: <div class="sect2" lang="en">
                   1148: <div class="titlepage"><div><div><h3 class="title">
                   1149: <a name="irix"></a>3.2.4. IRIX</h3></div></div></div>
                   1150: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
                   1151:        compiler (cc/c89).  Please set the <code class="varname">CC</code> environment variable
                   1152:        according to your preference.  If you do not have a license for the MIPSpro
                   1153:        compiler suite, you can download a gcc tardist file from <a href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
                   1154: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
                   1155:        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>,
                   1156:        etc.</p>
                   1157: <p>At this point in time, pkgsrc only supports one ABI at a time.  That is, you can not
                   1158:        switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI.  If
                   1159:        you start out using "abi=n32", that's what all your packages will be built
                   1160:        with.</p>
                   1161: <p>Therefore, please make sure that you have no conflicting
                   1162:        <code class="varname">CFLAGS</code> in your environment or the
1.76      rillig   1163:        <code class="filename">/etc/mk.conf</code>.  Particularly, make sure that you do not
1.75      rillig   1164:        try to link n32 object files with lib64 or vice versa.  Check your
1.76      rillig   1165:        <code class="filename">/etc/compiler.defaults</code>!</p>
1.75      rillig   1166: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
                   1167:        please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
                   1168:        as it appears that IRIX linker occasionally runs into issues when trying to
                   1169:        link over a network-mounted file system.</p>
                   1170: <p>The bootstrapping process should set all the right options for programs such
                   1171:        as imake(1), but you may want to set some options depending on your local
1.76      rillig   1172:        setup.  Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1.75      rillig   1173:        course, your compiler's man pages for details.</p>
                   1174: <p>If you are using SGI's MIPSPro compiler, please set
1.1       grant    1175: 
1.75      rillig   1176: </p>
                   1177: <pre class="programlisting">
                   1178:     PKGSRC_COMPILER=        mipspro
                   1179: </pre>
                   1180: <p>
1.1       grant    1181: 
1.76      rillig   1182:         in <code class="filename">/etc/mk.conf</code>.  Otherwise, pkgsrc will assume you
1.75      rillig   1183:         are using gcc and may end up passing invalid flags to the compiler.  Note that
1.76      rillig   1184:         bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1.75      rillig   1185:         default.</p>
                   1186: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
                   1187:         but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
                   1188:         to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1.76      rillig   1189:         <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1.75      rillig   1190:         '--preserve-path' flag.</p>
                   1191: </div>
                   1192: <div class="sect2" lang="en">
                   1193: <div class="titlepage"><div><div><h3 class="title">
                   1194: <a name="linux"></a>3.2.5. Linux</h3></div></div></div>
                   1195: <p>
                   1196:         Some versions of Linux (for example Debian GNU/Linux) need either
                   1197:         libtermcap or libcurses (libncurses).  Installing the distributions
                   1198:         libncurses-dev package (or equivalent) should fix the problem.</p>
                   1199: <p>
                   1200:         pkgsrc supports both gcc (GNU Compiler Collection) and icc (Intel C++
                   1201:         Compiler). gcc is the default. icc 8.0 and 8.1 on i386 have been tested.
                   1202:       </p>
                   1203: <p>To bootstrap using icc, assuming the default icc installation
                   1204:         directory:</p>
                   1205: <pre class="programlisting">
                   1206:     env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
                   1207:             ac_cv___attribute__=yes ./bootstrap
                   1208: </pre>
                   1209: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1210: <h3 class="title">Note</h3>
                   1211: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
                   1212: </div>
                   1213: <p>icc supports __attribute__, but the GNU configure test uses a nested
                   1214:         function, which icc does not support. #undef'ing __attribute__ has the
                   1215:         unfortunate side-effect of breaking many of the Linux header files, which
                   1216:         cannot be compiled properly without __attribute__. The test must be
                   1217:         overridden so that __attribute__ is assumed supported by the
                   1218:         compiler.</p>
                   1219: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.76      rillig   1220:         in <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   1221: <pre class="programlisting">
                   1222:     PKGSRC_COMPILER=        icc
                   1223: </pre>
                   1224: <p>The default installation directory for icc is
1.76      rillig   1225:         <code class="filename">/opt/intel_cc_80</code>, which
1.75      rillig   1226:         is also the pkgsrc default. If you have installed it into a different
                   1227:         directory, set <code class="varname">ICCBASE</code> in
1.76      rillig   1228:         <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   1229: <pre class="programlisting">
                   1230:     ICCBASE=                /opt/icc
                   1231: </pre>
                   1232: <p>pkgsrc uses the static linking method of the runtime libraries
                   1233:         provided by icc, so binaries can be run on other systems which do not
                   1234:         have the shared libraries installed.</p>
                   1235: <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>
                   1236:         command run when linking a C++ shared library and records it, throwing
                   1237:         away the -Bstatic and -Bdynamic options interspersed between the libraries.
                   1238:         This means that libtool-linked C++ shared libraries will have a
                   1239:         runtime dependency on the icc libraries until this is fixed in libtool.
                   1240:       </p>
                   1241: </div>
                   1242: <div class="sect2" lang="en">
                   1243: <div class="titlepage"><div><div><h3 class="title">
                   1244: <a name="openbsd"></a>3.2.6. OpenBSD</h3></div></div></div>
                   1245: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
                   1246: <p>Care should be taken so that the tools that this kit installs do not conflict
                   1247:        with the OpenBSD userland tools. There are several steps:</p>
                   1248: <div class="orderedlist"><ol type="1">
                   1249: <li><p>OpenBSD stores its ports pkg database in
1.76      rillig   1250:            <code class="filename">/var/db/pkg</code>. It is therefore
1.75      rillig   1251:            recommended that you choose a different location (e.g.
1.76      rillig   1252:            <code class="filename">/usr/pkgdb</code>) by
1.75      rillig   1253:            using the --pkgdbdir option to the bootstrap script.</p></li>
                   1254: <li>
                   1255: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
                   1256:            good idea to move them out of the way to avoid confusion, e.g.</p>
                   1257: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
                   1258: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
                   1259: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
                   1260: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
                   1261: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong></pre>
                   1262: </li>
                   1263: <li>
1.76      rillig   1264: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
                   1265:            <code class="filename">/etc/mk.conf.example</code> file
1.75      rillig   1266:            when you use the bootstrap script. OpenBSD's make program uses
1.76      rillig   1267:            <code class="filename">/etc/mk.conf</code>
1.75      rillig   1268:            as well. You can work around this by enclosing all the pkgsrc-specific parts
                   1269:            of the file with:</p>
                   1270: <pre class="programlisting">
                   1271:     .ifdef BSD_PKG_MK
                   1272:     # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
                   1273:     .else
                   1274:     # OpenBSD stuff
1.1       grant    1275:     .endif
                   1276: </pre>
1.75      rillig   1277: </li>
                   1278: </ol></div>
                   1279: </div>
                   1280: <div class="sect2" lang="en">
                   1281: <div class="titlepage"><div><div><h3 class="title">
                   1282: <a name="solaris"></a>3.2.7. Solaris</h3></div></div></div>
                   1283: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
                   1284:         You will need a working C compiler. Both gcc 2.95.3 and
                   1285:         Sun WorkShop 5 have been tested.</p>
                   1286: <p>The following packages are required on Solaris 8 for the bootstrap
                   1287:        process and to build packages.</p>
                   1288: <div class="itemizedlist"><ul type="disc">
                   1289: <li><p>SUNWsprot</p></li>
                   1290: <li><p>SUNWarc</p></li>
                   1291: <li><p>SUNWbtool</p></li>
                   1292: <li><p>SUNWtoo</p></li>
                   1293: <li><p>SUNWlibm</p></li>
                   1294: </ul></div>
                   1295: <p>Please note the use of GNU binutils on Solaris is
                   1296:        <span class="emphasis"><em>not</em></span> supported.</p>
                   1297: <p>Whichever compiler you use, please ensure the compiler tools and
                   1298:          your $prefix are in your <code class="varname">PATH</code>. This includes
1.76      rillig   1299:          <code class="filename">/usr/ccs/{bin,lib}</code>
                   1300:          and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75      rillig   1301: <div class="sect3" lang="en">
                   1302: <div class="titlepage"><div><div><h4 class="title">
                   1303: <a name="solaris-gcc-note"></a>3.2.7.1. If you are using gcc</h4></div></div></div>
                   1304: <p>It makes life much simpler if you only use the same gcc consistently
                   1305:          for building all packages.</p>
                   1306: <p>It is recommended that an external gcc be used only for bootstrapping,
                   1307:          then either build gcc from
1.76      rillig   1308:          <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   1309:          package, then remove gcc used during bootstrapping.</p>
                   1310: <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>
                   1311: </div>
                   1312: <div class="sect3" lang="en">
                   1313: <div class="titlepage"><div><div><h4 class="title">
                   1314: <a name="solaris-sun-workshop-note"></a>3.2.7.2. If you are using Sun WorkShop</h4></div></div></div>
                   1315: <p>You will need at least the following packages installed (from WorkShop
                   1316:          5.0)</p>
                   1317: <div class="itemizedlist"><ul type="disc">
                   1318: <li><p>SPROcc
                   1319:                - Sun WorkShop Compiler C 5.0</p></li>
                   1320: <li><p>SPROcpl
                   1321:                - Sun WorkShop Compiler C++ 5.0</p></li>
                   1322: <li><p>SPROild
                   1323:                - Sun WorkShop Incremental Linker</p></li>
                   1324: <li><p>SPROlang
                   1325:                - Sun WorkShop Compilers common components</p></li>
                   1326: </ul></div>
                   1327: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.76      rillig   1328:          optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
1.75      rillig   1329:          e.g.:</p>
                   1330: <pre class="programlisting">
                   1331:     CC=     cc
                   1332:     CXX=    CC
                   1333:     CPP=    /usr/ccs/lib/cpp
1.1       grant    1334: </pre>
1.75      rillig   1335: </div>
                   1336: <div class="sect3" lang="en">
                   1337: <div class="titlepage"><div><div><h4 class="title">
                   1338: <a name="solaris-sunpro-64"></a>3.2.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
                   1339: <p>Building 64-bit binaries is a little trickier. First, you
                   1340:        need to bootstrap pkgsrc in 64-bit mode. One problem here is
                   1341:        that while building one of the programs in the bootstrap kit
1.76      rillig   1342:        (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75      rillig   1343:        variable is not honored, even if it is set in the environment.
                   1344:        To work around this bug, you can create a simple shell script
1.76      rillig   1345:        called <code class="filename">cc64</code> and put it somewhere in the
1.75      rillig   1346:        <code class="varname">PATH</code>:</p>
                   1347: <pre class="programlisting">
                   1348:     #! /bin/sh
                   1349:     exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
1.1       grant    1350: </pre>
1.75      rillig   1351: <p>Then, pass the definition for <code class="varname">CC</code> in the
                   1352:        environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
                   1353: <pre class="programlisting">
                   1354:     <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
                   1355:     <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
                   1356: </pre>
                   1357: <p>After bootstrapping, there are two alternative ways,
                   1358:        depending on whether you want to find bugs in packages or get
                   1359:        your system ready quickly. If you just want a running system,
1.76      rillig   1360:        add the following lines to your <code class="filename">mk.conf</code>
1.75      rillig   1361:        file:</p>
                   1362: <pre class="programlisting">
                   1363:     CC=                     cc64
                   1364:     CXX=                    CC64
                   1365:     PKGSRC_COMPILER=        sunpro
1.1       grant    1366: </pre>
1.75      rillig   1367: <p>This way, all calls to the compiler will be intercepted by
                   1368:        the above wrapper and therefore get the necessary ABI options
                   1369:        automatically. (Don't forget to create the shell script
1.76      rillig   1370:        <code class="filename">CC64</code>, too.)</p>
1.75      rillig   1371: <p>To find packages that ignore the user-specified
                   1372:        <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76      rillig   1373:        the following lines to your <code class="filename">mk.conf</code>
1.75      rillig   1374:        file:</p>
                   1375: <pre class="programlisting">
                   1376:     CC=                     cc
                   1377:     CXX=                    CC
                   1378:     PKGSRC_COMPILER=        sunpro
                   1379:     CFLAGS=                 -xtarget=ultra -xarch=v9
                   1380:     CXXFLAGS=               -xtarget=ultra -xarch=v9
                   1381:     LDFLAGS=                -xtarget=ultra -xarch=v9
1.1       grant    1382: </pre>
1.75      rillig   1383: <p>Packages that don't use the flags provided in the
                   1384:        configuration file will try to build 32-bit binaries and fail
                   1385:        during linking. Detecting this is useful to prevent bugs on
                   1386:        other platforms where the error would not show up but pass
                   1387:        silently.</p>
                   1388: </div>
                   1389: <div class="sect3" lang="en">
                   1390: <div class="titlepage"><div><div><h4 class="title">
                   1391: <a name="plat.sunos.problems"></a>3.2.7.4. Common problems</h4></div></div></div>
                   1392: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.76      rillig   1393:        <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1.75      rillig   1394:        The workaround is to use another shell for the configure
1.76      rillig   1395:        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
                   1396:        to your <code class="filename">mk.conf</code>:</p>
1.75      rillig   1397: <pre class="programlisting">
                   1398:     CONFIG_SHELL=   ${LOCALBASE}/bin/bash
                   1399:     WRAPPER_SHELL=  ${LOCALBASE}/bin/bash
1.1       grant    1400: </pre>
1.76      rillig   1401: <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   1402: </div>
                   1403: </div>
                   1404: </div>
                   1405: </div>
                   1406: <div class="chapter" lang="en">
                   1407: <div class="titlepage"><div><div><h2 class="title">
                   1408: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
                   1409: <div class="toc">
                   1410: <p><b>Table of Contents</b></p>
                   1411: <dl>
                   1412: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
                   1413: <dd><dl>
                   1414: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
                   1415: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
                   1416: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.3. A word of warning</a></span></dt>
                   1417: </dl></dd>
                   1418: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                   1419: <dd><dl>
                   1420: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
                   1421: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                   1422: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                   1423: <dt><span class="sect2"><a href="#selecting-the-compiler">4.2.4. Selecting the compiler</a></span></dt>
                   1424: </dl></dd>
                   1425: </dl>
                   1426: </div>
                   1427: <p>Basically, there are two ways of using pkgsrc. The first
                   1428:        is to only install the package tools and to use binary packages
                   1429:        that someone else has prepared. This is the &#8220;<span class="quote">pkg</span>&#8221;
                   1430:        in pkgsrc. The second way is to install the &#8220;<span class="quote">src</span>&#8221;
                   1431:        of pkgsrc, too. Then you are able to build your own packages,
                   1432:        and you can still use binary packages from someone else.</p>
                   1433: <div class="sect1" lang="en">
                   1434: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1435: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
                   1436: <p>To use binary packages, you need some tools to manage
                   1437:        them. On NetBSD, these tools are already installed. On all other
                   1438:        operating systems, you need to install them first. For the
                   1439:        following platforms, prebuilt versions of the package tools
                   1440:        are available and can simply be downloaded and unpacked in the
1.76      rillig   1441:        <code class="filename">/</code> directory:</p>
1.75      rillig   1442: <div class="informaltable">
                   1443: <a name="binary-bootstrap-kits"></a><table border="1">
                   1444: <colgroup>
                   1445: <col>
                   1446: <col>
                   1447: </colgroup>
                   1448: <thead><tr>
                   1449: <th>Platform</th>
                   1450: <th>URL</th>
                   1451: </tr></thead>
                   1452: <tbody>
                   1453: <tr>
                   1454: <td>Solaris 9</td>
1.76      rillig   1455: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75      rillig   1456: </tr>
                   1457: <tr>
                   1458: <td>Solaris 10</td>
1.76      rillig   1459: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75      rillig   1460: </tr>
                   1461: </tbody>
                   1462: </table>
                   1463: </div>
                   1464: <p>These prebuilt package tools use
1.76      rillig   1465:        <code class="filename">/usr/pkg</code> for the base directory, and
                   1466:        <code class="filename">/var/db/pkg</code> for the database of installed
1.75      rillig   1467:        packages. If you cannot use these directories for whatever
                   1468:        reasons (maybe because you're not root), you have to build the
                   1469:        package tools yourself, which is explained in <a href="#bootstrapping-pkgsrc" title="3.1. Bootstrapping pkgsrc">Section 3.1, &#8220;Bootstrapping pkgsrc&#8221;</a>.</p>
                   1470: <div class="sect2" lang="en">
                   1471: <div class="titlepage"><div><div><h3 class="title">
                   1472: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
                   1473: <p>To install binary packages, you first need to know from
                   1474:        where to get them. You can get them on CD-ROMs, DVDs, or via FTP
                   1475:        or HTTP.</p>
                   1476: <p>For NetBSD, the binary packages are made available on
1.76      rillig   1477:        <code class="filename">ftp.NetBSD.org</code> and its mirrors, in the
1.75      rillig   1478:        directory
1.76      rillig   1479:        <code class="filename">/pub/NetBSD/packages/<em class="replaceable"><code>OSVERSION</code></em>/<em class="replaceable"><code>ARCH</code></em>/</code>.
1.75      rillig   1480:        For <em class="replaceable"><code>OSVERSION</code></em>, you should insert the
                   1481:        output of <span><strong class="command">uname -r</strong></span>, and for
                   1482:        <em class="replaceable"><code>ARCH</code></em> the output of <span><strong class="command">uname
                   1483:        -p</strong></span>.</p>
                   1484: <p>For some other platforms, binary packages can be found at
                   1485:        the following locations:</p>
                   1486: <div class="informaltable">
                   1487: <a name="binary-packages"></a><table border="1">
                   1488: <colgroup>
                   1489: <col>
                   1490: <col>
                   1491: </colgroup>
                   1492: <thead><tr>
                   1493: <th>Platform</th>
                   1494: <th>URL</th>
                   1495: </tr></thead>
                   1496: <tbody>
                   1497: <tr>
                   1498: <td>Solaris 9</td>
1.76      rillig   1499: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75      rillig   1500: </tr>
                   1501: <tr>
                   1502: <td>Solaris 10</td>
1.76      rillig   1503: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75      rillig   1504: </tr>
                   1505: </tbody>
                   1506: </table>
                   1507: </div>
                   1508: <p>Most of these directories contain the pkgsrc distribution
                   1509:        for multiple platforms. Select the appropriate subdirectories,
                   1510:        according to your machine architecture and operating system,
1.76      rillig   1511:        until you find a directory called <code class="filename">All</code>. This
1.75      rillig   1512:        directory contains all the binary packages. Further, there are
                   1513:        subdirectories for categories that contain symbolic links that
                   1514:        point to the actual binary package in
1.76      rillig   1515:        <code class="filename">../All</code>. This directory layout is used for
1.75      rillig   1516:        all package repositories, no matter if they are accessed via
                   1517:        HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
                   1518: </div>
                   1519: <div class="sect2" lang="en">
                   1520: <div class="titlepage"><div><div><h3 class="title">
                   1521: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
                   1522: <p> If you have the files on a CD-ROM or downloaded them to
                   1523:         your hard disk, you can install them with the following command
                   1524:         (be sure to <span><strong class="command">su</strong></span> to root first):</p>
                   1525: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
                   1526: <p> If you have FTP access and you don't want to download the
                   1527:         packages via FTP prior to installation, you can do this
                   1528:         automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:
                   1529:         </p>
                   1530: <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.tgz</code></strong></pre>
                   1531: <p>Note that any prerequisite packages needed to run the
                   1532:         package in question will be installed, too, assuming they are
                   1533:         present where you install from. </p>
                   1534: <p>To save some typing, you can set the
                   1535:         <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
                   1536:        list of paths (including remote URLs); trailing slashes are not allowed.
                   1537:        </p>
1.76      rillig   1538: <p>Additionally to the <code class="filename">All</code> directory
                   1539:         there exists a <code class="filename">vulnerable</code> directory to
1.75      rillig   1540:         which binary packages with known vulnerabilities are
                   1541:         moved, since removing them could cause missing dependencies. To
1.76      rillig   1542:         use these packages, add the <code class="filename">vulnerable</code>
1.75      rillig   1543:         directory to your <code class="varname">PKG_PATH</code>. However, you should run
1.76      rillig   1544:         <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   1545:        especially after installing new packages, and verify that the
                   1546:        vulnerabilities are acceptable for your configuration. An example
                   1547:         <code class="varname">PKG_PATH</code> would be:
1.76      rillig   1548:       <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   1549:         Please note that semicolon (';') is a shell meta-character, so
                   1550:         you'll probably have to quote it.</p>
                   1551: <p>After you've installed packages, be sure to have
1.76      rillig   1552:         <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1.75      rillig   1553:         <code class="varname">PATH</code> so you can actually start the just
                   1554:         installed program. </p>
                   1555: </div>
                   1556: <div class="sect2" lang="en">
                   1557: <div class="titlepage"><div><div><h3 class="title">
                   1558: <a name="a-word-of-warning"></a>4.1.3. A word of warning</h3></div></div></div>
                   1559: <p>Please pay very careful attention to the warnings
                   1560:         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
                   1561:         inherent dangers of installing binary packages which you did
                   1562:         not create yourself, and the security holes that can be
                   1563:         introduced onto your system by indiscriminate adding of such
                   1564:         files.</p>
                   1565: <p>The same warning of course applies to every package you
                   1566:       install from source when you haven't completely read and
                   1567:       understood the source code of the package, the compiler that
                   1568:       is used to build the package and all the other tools that are
                   1569:       involved.</p>
                   1570: </div>
                   1571: </div>
                   1572: <div class="sect1" lang="en">
                   1573: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1574: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
                   1575: <p> This assumes that the package is already in pkgsrc. If it
                   1576:       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
                   1577:       how to create your own packages.</p>
                   1578: <div class="sect2" lang="en">
                   1579: <div class="titlepage"><div><div><h3 class="title">
                   1580: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
                   1581: <p> To build packages from source on a NetBSD system the
                   1582:         &#8220;<span class="quote">comp</span>&#8221; and the &#8220;<span class="quote">text</span>&#8221; distribution
                   1583:         sets must be installed. If you want to build X11-related
                   1584:         packages the &#8220;<span class="quote">xbase</span>&#8221; and &#8220;<span class="quote">xcomp</span>&#8221;
                   1585:         distribution sets are required, too.</p>
                   1586: </div>
                   1587: <div class="sect2" lang="en">
                   1588: <div class="titlepage"><div><div><h3 class="title">
                   1589: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
                   1590: <p>The first step for building a package is downloading the
                   1591:       distfiles (i.e. the unmodified source). If they have not yet been
                   1592:       downloaded, pkgsrc will fetch them automatically.</p>
                   1593: <p>You can overwrite some of the major distribution sites to fit to sites
                   1594:         that are close to your own.  Have a look at
1.76      rillig   1595:         <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find some examples
1.75      rillig   1596:         &#8212; in particular, look for the <code class="varname">MASTER_SORT</code>,
                   1597:         <code class="varname">MASTER_SORT_REGEX</code> and
                   1598:         <code class="varname">INET_COUNTRY</code> definitions.  This may save some of your
                   1599:         bandwidth and time.</p>
                   1600: <p>You can change these settings either in your shell's environment, or,
                   1601:         if you want to keep the settings, by editing the
1.76      rillig   1602:         <code class="filename">/etc/mk.conf</code> file,
1.75      rillig   1603:         and adding the definitions there.</p>
                   1604: <p>If you don't have a permanent Internet connection and you want to know
                   1605:         which files to download, <span><strong class="command">make fetch-list</strong></span> will tell you
                   1606:         what you'll need. Put these distfiles into
1.76      rillig   1607:         <code class="filename">/usr/pkgsrc/distfiles</code>.</p>
1.75      rillig   1608: </div>
                   1609: <div class="sect2" lang="en">
                   1610: <div class="titlepage"><div><div><h3 class="title">
                   1611: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
                   1612: <p>Assuming that the distfile has been fetched (see previous section), become
                   1613:         root and change into the relevant directory and run
                   1614:         <span><strong class="command">make</strong></span>.</p>
                   1615: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   1616: <h3 class="title">Note</h3>
                   1617: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
                   1618:         use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
                   1619:         &#8220;<span class="quote">make</span>&#8221; in the examples in this guide.</p>
                   1620: </div>
                   1621: <p>For example, type </p>
                   1622: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
                   1623: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong></pre>
                   1624: <p>at the shell prompt to build the various components of the
                   1625:         package, and</p>
                   1626: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong></pre>
                   1627: <p>to install the various components into the correct places
                   1628:         on your system. Installing the package on your system requires
                   1629:         you to be root.  However, pkgsrc has a
                   1630:         <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
                   1631:         to only become root for the actual installation step</p>
                   1632: <p>Taking the figlet utility as an example, we can install it on our
                   1633:         system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
                   1634: <p>The program is installed under the default root of the packages tree -
1.76      rillig   1635:         <code class="filename">/usr/pkg</code>. Should this not conform to your tastes,
1.75      rillig   1636:         set the <code class="varname">LOCALBASE</code>
                   1637:         variable in your environment, and it will use that value as the root of
1.76      rillig   1638:         your packages tree. So, to use <code class="filename">/usr/local</code>, set
1.75      rillig   1639:         <code class="varname">LOCALBASE=/usr/local</code> in your environment.  Please note
                   1640:         that you should use a directory which is
                   1641:         dedicated to packages and not shared with other programs (i.e., do not try
                   1642:         and use <code class="varname">LOCALBASE=/usr</code>).  Also, you should not try to
1.76      rillig   1643:         add any of your own files or directories (such as <code class="filename">src/</code>,
                   1644:         <code class="filename">obj/</code>, or <code class="filename">pkgsrc/</code>) below the
1.75      rillig   1645:         <code class="varname">LOCALBASE</code> tree.  This is to prevent possible conflicts
                   1646:         between programs and other files installed by the package system and
                   1647:         whatever else may have been installed there.</p>
1.76      rillig   1648: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to alter some
1.75      rillig   1649:         configuration options at build time.  Have a look at
1.76      rillig   1650:         <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to
1.75      rillig   1651:         get an overview of what will be set there by default.  Environment
                   1652:         variables such as <code class="varname">LOCALBASE</code>
1.76      rillig   1653:         can be set in <code class="filename">/etc/mk.conf</code> to
1.75      rillig   1654:         save having to remember to set them each time you want to use pkgsrc.</p>
                   1655: <p>Occasionally, people want to &#8220;<span class="quote">look under the covers</span>&#8221; to see
                   1656:         what is going on when a package is building or being installed. This may be
                   1657:         for debugging purposes, or out of simple curiosity. A number of utility
                   1658:         values have been added to help with this.</p>
                   1659: <div class="orderedlist"><ol type="1">
                   1660: <li>
                   1661: <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>,
                   1662:             then a huge amount of information will be displayed. For example,</p>
                   1663: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
                   1664: <p>will show all the commands that are invoked, up to and including the
                   1665:             &#8220;<span class="quote">patch</span>&#8221; stage.</p>
                   1666: </li>
                   1667: <li>
                   1668: <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
                   1669:             the <code class="varname">VARNAME</code> definition should be used, in conjunction
                   1670:             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
                   1671:             <code class="varname">LOCALBASE</code>:</p>
                   1672: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
                   1673: /usr/pkg
                   1674: <code class="prompt">%</code>
                   1675:           </pre>
                   1676: </li>
                   1677: </ol></div>
                   1678: <p>If you want to install a binary package that you've either
                   1679:         created yourself (see next section), that you put into pkgsrc/packages manually or
                   1680:         that is located on a remote FTP server, you can use the "bin-install"
                   1681:         target. This target will install a binary package - if available - via
                   1682:         <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>.
                   1683:         The list of remote
                   1684:         FTP sites searched is kept in the variable
                   1685:         <code class="varname">BINPKG_SITES</code>, which defaults to
                   1686:         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
                   1687:         into <code class="varname">BIN_INSTALL_FLAGS</code>.
1.76      rillig   1688:         See <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more details.</p>
1.75      rillig   1689: <p>A final word of warning: If you set up a system that has a non-standard
                   1690:         setting for <code class="varname">LOCALBASE</code>, be sure to set that
                   1691:         before any packages are installed, as you can not use several directories
                   1692:         for the same purpose. Doing so will result in pkgsrc not being able to
                   1693:         properly detect your installed packages, and fail miserably. Note also that
                   1694:         precompiled binary packages are usually built with the default
                   1695:         <code class="varname">LOCALBASE</code> of
1.76      rillig   1696:         <code class="filename">/usr/pkg</code>, and that you should <span class="emphasis"><em>not</em></span>
1.75      rillig   1697:         install any if you use a non-standard <code class="varname">LOCALBASE</code>.</p>
                   1698: </div>
                   1699: <div class="sect2" lang="en">
                   1700: <div class="titlepage"><div><div><h3 class="title">
                   1701: <a name="selecting-the-compiler"></a>4.2.4. Selecting the compiler</h3></div></div></div>
                   1702: <p>By default, pkgsrc will use GCC to build packages.  This may be
                   1703:         overridden by setting the following variables in /etc/mk.conf:
                   1704:         </p>
                   1705: <div class="variablelist"><dl>
                   1706: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
                   1707: <dd>
                   1708: <p> This is a list of values specifying the chain of
                   1709:               compilers to invoke when building packages.  Valid values
                   1710:               are: </p>
                   1711: <div class="itemizedlist"><ul type="disc">
                   1712: <li><p><code class="varname">distcc</code>:
                   1713:                 distributed C/C++ (chainable)</p></li>
                   1714: <li><p><code class="varname">ccache</code>:
                   1715:                 compiler cache (chainable)</p></li>
                   1716: <li><p><code class="varname">gcc</code>:
                   1717:                 GNU C/C++ Compiler</p></li>
                   1718: <li><p><code class="varname">mipspro</code>:
                   1719:                 Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
                   1720: <li><p><code class="varname">mipspro</code>:
                   1721:                 Silicon Graphics, Inc. MIPSpro (o32)</p></li>
                   1722: <li><p><code class="varname">sunpro</code>:
                   1723:                 Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
                   1724: </ul></div>
                   1725: <p> The default is
                   1726:               &#8220;<span class="quote"><code class="varname">gcc</code></span>&#8221;.  You can use
                   1727:               <code class="varname">ccache</code> and/or
                   1728:               <code class="varname">distcc</code> with an appropriate
                   1729:               <code class="varname">PKGSRC_COMPILER</code> setting,
                   1730:               e.g. &#8220;<span class="quote"><code class="varname">ccache gcc</code></span>&#8221;.  This
                   1731:               variable should always be
                   1732:               terminated with a value for a real compiler.  </p>
                   1733: </dd>
                   1734: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
                   1735: <dd><p> This specifies the minimum version of GCC to use
                   1736:               when building packages.  If the system GCC doesn't
                   1737:               satisfy this requirement, then pkgsrc will build and
                   1738:               install one of the GCC packages to use instead. </p></dd>
                   1739: </dl></div>
                   1740: </div>
                   1741: </div>
                   1742: </div>
                   1743: <div class="chapter" lang="en">
                   1744: <div class="titlepage"><div><div><h2 class="title">
                   1745: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
                   1746: <div class="toc">
                   1747: <p><b>Table of Contents</b></p>
                   1748: <dl>
                   1749: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
                   1750: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
                   1751: <dt><span class="sect1"><a href="#developer-advanced-settings">5.3. Developer/advanced settings</a></span></dt>
                   1752: <dt><span class="sect1"><a href="#selecting-build-options">5.4. Selecting Build Options</a></span></dt>
                   1753: </dl>
                   1754: </div>
                   1755: <div class="sect1" lang="en">
                   1756: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1757: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
                   1758: <p>In this section, you can find some variables that apply to all
                   1759:       pkgsrc packages.  The preferred method of setting these variables
1.76      rillig   1760:       is by setting them in <code class="filename">/etc/mk.conf</code>.
1.75      rillig   1761:       </p>
                   1762: <div class="itemizedlist"><ul type="disc">
                   1763: <li><p><code class="varname">LOCALBASE</code>: Where
                   1764:            packages will be installed. The default is
1.76      rillig   1765:            <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75      rillig   1766:            with different <code class="varname">LOCALBASE</code>s!</p></li>
                   1767: <li><p><code class="varname">CROSSBASE</code>: Where
                   1768:            &#8220;<span class="quote">cross</span>&#8221; category packages will be
                   1769:            installed. The default is
1.76      rillig   1770:            <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75      rillig   1771: <li><p><code class="varname">X11BASE</code>: Where
                   1772:            X11 is installed on the system. The default is
1.76      rillig   1773:            <code class="filename">/usr/X11R6</code>.</p></li>
1.75      rillig   1774: <li><p><code class="varname">DISTDIR</code>: Where to store the
                   1775:            downloaded copies of the original source distributions used
                   1776:            for building pkgsrc packages. The default is
1.76      rillig   1777:            <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75      rillig   1778: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
                   1779:            If set, override the packages'
                   1780:            <code class="varname">MASTER_SITES</code> with this value.</p></li>
                   1781: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
                   1782:            Backup location(s) for distribution files and patch files
                   1783:            if not found locally or in
1.76      rillig   1784:            <code class="filename">${MASTER_SITES}</code> or
                   1785:            <code class="filename">${PATCH_SITES}</code> respectively.
1.75      rillig   1786:            The defaults are
1.76      rillig   1787:            <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75      rillig   1788:            and
1.76      rillig   1789:            <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75      rillig   1790: <li><p><code class="varname">BINPKG_SITES</code>:
                   1791:            List of sites carrying binary pkgs.</p></li>
                   1792: </ul></div>
                   1793: <p>
                   1794:     </p>
                   1795: </div>
                   1796: <div class="sect1" lang="en">
                   1797: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1798: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
                   1799: <p>XXX
                   1800:       </p>
                   1801: <div class="itemizedlist"><ul type="disc">
                   1802: <li><p><code class="varname">PACKAGES</code>: The top level
                   1803:            directory for the binary packages. The default is
1.76      rillig   1804:            <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75      rillig   1805: <li><p><code class="varname">WRKOBJDIR</code>:
                   1806:            The top level directory where, if defined, the separate
                   1807:            working directories will get created, and symbolically
1.76      rillig   1808:            linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75      rillig   1809:            This is useful for building packages on several
1.76      rillig   1810:            architectures, then <code class="filename">${PKGSRCDIR}</code>
                   1811:            can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75      rillig   1812:            is local to every architecture. (It should be noted that
                   1813:            <code class="varname">PKGSRCDIR</code> should not be set by the user
                   1814:            &#8212; it is an internal definition which refers to the
                   1815:            root of the pkgsrc tree. It is possible to have many
                   1816:            pkgsrc tree instances.)</p></li>
                   1817: <li><p><code class="varname">LOCALPATCHES</code>:
                   1818:            Directory for local patches that aren't part of pkgsrc.
1.77    ! rillig   1819:            See <a href="#components.patches" title="9.3. patches/*">Section 9.3, &#8220;patches/*&#8221;</a> for more
1.75      rillig   1820:            information. <em class="replaceable"><code>rel</code></em> and
                   1821:            <em class="replaceable"><code>arch</code></em> are replaced with OS
                   1822:            release (&#8220;<span class="quote">2.0</span>&#8221;, etc.) and architecture
                   1823:            (&#8220;<span class="quote">mipsel</span>&#8221;, etc.).</p></li>
                   1824: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76      rillig   1825:            the <code class="filename">mk.conf</code> file used by a package's
1.75      rillig   1826:            BSD-style Makefile. If this is not set,
                   1827:            <code class="varname">MAKECONF</code> is set to
1.76      rillig   1828:            <code class="filename">/dev/null</code> to avoid picking up
                   1829:            settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.75      rillig   1830: </ul></div>
                   1831: <p>
                   1832:     </p>
                   1833: </div>
                   1834: <div class="sect1" lang="en">
                   1835: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1836: <a name="developer-advanced-settings"></a>5.3. Developer/advanced settings</h2></div></div></div>
                   1837: <p>XXX
                   1838:       </p>
                   1839: <div class="itemizedlist"><ul type="disc">
                   1840: <li>
                   1841: <p><code class="varname">PKG_DEVELOPER</code>:
                   1842:            Run some sanity checks that package developers want:
                   1843:            </p>
                   1844: <div class="itemizedlist"><ul type="circle">
                   1845: <li><p>make sure patches apply with zero fuzz</p></li>
                   1846: <li><p>run check-shlibs to see that all binaries will
                   1847:                find their shared libs.</p></li>
                   1848: </ul></div>
                   1849: <p>
                   1850:          </p>
                   1851: </li>
                   1852: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>:
                   1853:            The level of debugging output which is displayed whilst
                   1854:            making and installing the package.
                   1855:            The default value for this is 0, which will not display
                   1856:            the commands as they are executed (normal, default, quiet
                   1857:            operation); the value 1 will display all shell commands
                   1858:            before their invocation, and the value 2 will display both
                   1859:            the shell commands before their invocation, and their
                   1860:            actual execution progress with <span><strong class="command">set -x</strong></span>
                   1861:            will be displayed.</p></li>
                   1862: <li><p><code class="varname">ALLOW_VULNERABILITIES.<em class="replaceable"><code>pkgbase</code></em></code>:
                   1863:            A space separated list of vulnerability IDs that may be ignored when
                   1864:                performing the automated security checks.  These IDs are listed in the
                   1865:                pkg-vulnerabilities file and are displayed by
                   1866:                <span><strong class="command">audit-packages</strong></span> when
                   1867:                it finds a vulnerable package.
                   1868:          </p></li>
                   1869: <li><p><code class="varname">SKIP_AUDIT_PACKAGES</code>:
                   1870:            If this is set to &#8220;<span class="quote">yes</span>&#8221;, the automated security checks
1.76      rillig   1871:                (which use 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   1872:                package) will be <span class="strong"><strong>entirely</strong></span> skipped
                   1873:                for <span class="strong"><strong>all</strong></span> packages built.  Normally
                   1874:                you'll want to use ALLOW_VULNERABILITIES instead of this.
                   1875:          </p></li>
                   1876: </ul></div>
                   1877: <p>
                   1878:     </p>
                   1879: </div>
                   1880: <div class="sect1" lang="en">
                   1881: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1882: <a name="selecting-build-options"></a>5.4. Selecting Build Options</h2></div></div></div>
                   1883: <p>Some packages have build time options, usually to select between
                   1884:       different dependencies, enable optional support for big dependencies
                   1885:       or enable experimental features.</p>
                   1886: <p>To see which options, if any, a package supports, and which
                   1887:       options are mutually exclusive, run <span><strong class="command">make show-options</strong></span>,
                   1888:       for example:</p>
                   1889: <pre class="programlisting">
                   1890:     The following options are supported by this package:
                   1891:         ssl      Enable SSL support.
                   1892:     Exactly one of the following gecko options is required:
                   1893:         firefox  Use firefox as gecko rendering engine.
                   1894:         mozilla  Use mozilla as gecko rendering engine.
                   1895:     At most one of the following database options may be selected:
                   1896:         mysql    Enable support for MySQL database.
                   1897:         pgsql    Enable support for PostgreSQL database.
1.1       grant    1898: 
1.75      rillig   1899:     These options are enabled by default: firefox
                   1900:     These options are currently enabled: mozilla ssl
1.1       grant    1901: </pre>
1.75      rillig   1902: <p>The following variables can be defined in
1.76      rillig   1903:       <code class="filename">/etc/mk.conf</code> to select which options to enable
1.75      rillig   1904:       for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which can be
                   1905:       used to select or disable options for all packages that support them,
                   1906:       and <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
                   1907:       which can be used to select or disable options specifically for
                   1908:       package <em class="replaceable"><code>pkgbase</code></em>.  Options listed in these
                   1909:       variables are selected, options preceded by &#8220;<span class="quote">-</span>&#8221; are
                   1910:       disabled. A few examples:</p>
                   1911: <pre class="screen">
                   1912: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
                   1913: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   1914: PKG_OPTIONS.kdebase=    debug -sasl
                   1915: PKG_OPTIONS.apache=     suexec </pre>
                   1916: <p>The following settings are consulted in the order given, and the
                   1917:       last setting that selects or disables an option is used:</p>
                   1918: <div class="orderedlist"><ol type="1">
                   1919: <li><p>the default options as suggested by the package
                   1920:          maintainer</p></li>
                   1921: <li><p>the options implied by the settings of legacy
                   1922:          variables (see below)</p></li>
                   1923: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
                   1924: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
                   1925: </ol></div>
                   1926: <p>For groups of mutually exclusive options, the last option
                   1927:       selected is used, all others are automatically disabled.  If an option
                   1928:       of the group is explicitly disabled, the previously selected option,
                   1929:       if any, is used.  It is an error if no option from a required group of
                   1930:       options is selected, and building the package will fail.</p>
                   1931: <p>Before the options framework was introduced, build options were
                   1932:       selected by setting a variable (often named
                   1933:       <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
1.76      rillig   1934:       <code class="filename">/etc/mk.conf</code> for each option.  To ease transition
1.75      rillig   1935:       to the options framework for the user, these legacy variables are
                   1936:       converted to the appropriate options setting
                   1937:       (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
                   1938:       automatically.  A warning is issued to prompt the user to
1.76      rillig   1939:       update <code class="filename">/etc/mk.conf</code> to use the options framework
1.75      rillig   1940:       directly.  Support for the legacy variables will be removed
                   1941:       eventually.</p>
                   1942: </div>
                   1943: </div>
                   1944: <div class="chapter" lang="en">
                   1945: <div class="titlepage"><div><div><h2 class="title">
                   1946: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
                   1947: <div class="toc">
                   1948: <p><b>Table of Contents</b></p>
                   1949: <dl>
                   1950: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
                   1951: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
                   1952: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
                   1953: <dd><dl>
                   1954: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
                   1955: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
                   1956: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
                   1957: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
                   1958: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
                   1959: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
                   1960: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
                   1961: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
                   1962: </dl></dd>
                   1963: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
                   1964: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
                   1965: </dl>
                   1966: </div>
                   1967: <div class="sect1" lang="en">
                   1968: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1969: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
                   1970: <p>
                   1971:       Once you have built and installed a package, you can create a
                   1972:       <span class="emphasis"><em>binary package</em></span> which can be installed on
                   1973:       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
                   1974:       the same package on a group of hosts and wasting CPU time. It
                   1975:       also provides a simple means for others to install your package,
                   1976:       should you distribute it.
                   1977:     </p>
                   1978: <p>
                   1979:       To create a binary package, change into the appropriate
                   1980:       directory in pkgsrc, and run <span><strong class="command">make
                   1981:       package</strong></span>:
                   1982:     </p>
                   1983: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
                   1984: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
                   1985: <p>
                   1986:       This will build and install your package (if not already done),
                   1987:       and then build a binary package from what was installed. You can
                   1988:       then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
                   1989:       it. Binary packages are created by default in
1.76      rillig   1990:       <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
1.75      rillig   1991:       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   1992:       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   1993: <p>
1.77    ! rillig   1994:       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   1995:       such a binary package.</p>
                   1996: </div>
                   1997: <div class="sect1" lang="en">
                   1998: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   1999: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.77    ! rillig   2000: <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   2001: </div>
                   2002: <div class="sect1" lang="en">
                   2003: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2004: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
                   2005: <p>If you want to get a full set of precompiled binary
                   2006:       packages, this section describes how to get them. Beware that
                   2007:       the bulk build will remove all currently installed packages from
                   2008:       your system!</p>
                   2009: <p>Having an FTP server configured either on the
                   2010:       machine doing the bulk builds or on a nearby NFS server can help
                   2011:       to make the packages available to other machines that can then
                   2012:       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
                   2013:       more information. If you use a remote NFS server's storage, be
                   2014:       sure to not actually compile on NFS storage, as this slows
                   2015:       things down a lot.</p>
                   2016: <div class="sect2" lang="en">
                   2017: <div class="titlepage"><div><div><h3 class="title">
                   2018: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
                   2019: <div class="sect3" lang="en">
                   2020: <div class="titlepage"><div><div><h4 class="title">
1.76      rillig   2021: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
                   2022: <p>The <code class="filename">build.conf</code> file is the main
1.75      rillig   2023:         configuration file for bulk builds. You can configure how your
                   2024:         copy of pkgsrc is kept up to date, how the distfiles are
                   2025:         downloaded, how the packages are built and how the report is
                   2026:         generated. You can find an annotated example file in
1.76      rillig   2027:         <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
                   2028:         it, copy <code class="filename">build.conf-example</code> to
                   2029:         <code class="filename">build.conf</code> and edit it, following the
1.75      rillig   2030:         comments in that file.</p>
                   2031: </div>
                   2032: <div class="sect3" lang="en">
                   2033: <div class="titlepage"><div><div><h4 class="title">
                   2034: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
                   2035: <p>You may want to set variables in
1.76      rillig   2036:          <code class="filename">/etc/mk.conf</code>.
                   2037:          Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
1.75      rillig   2038:          details of the default settings. You will want to ensure that
                   2039:          <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
                   2040:          As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
                   2041:          accepts <span class="emphasis"><em>all</em></span> licenses.</p>
                   2042: <pre class="programlisting">
                   2043:     PACKAGES?=      ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
                   2044:     WRKOBJDIR?=     /usr/tmp/pkgsrc   # build here instead of in pkgsrc
                   2045:     BSDSRCDIR=      /usr/src
                   2046:     BSDXSRCDIR=     /usr/xsrc         # for x11/xservers
                   2047:     OBJHOSTNAME?=   yes               # use work.`hostname`
                   2048:     FAILOVER_FETCH= yes               # insist on the correct checksum
                   2049:     PKG_DEVELOPER?= yes
                   2050:     _ACCEPTABLE=    yes
1.1       grant    2051: </pre>
1.75      rillig   2052: <p>Some options that are especially useful for bulk builds
                   2053:        can be found at the top lines of the file
1.76      rillig   2054:        <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75      rillig   2055:        options of these are briefly described here.</p>
                   2056: <div class="itemizedlist"><ul type="disc">
                   2057: <li><p>If you are on a slow machine, you may want to
                   2058:        set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
                   2059:        &#8220;<span class="quote">no</span>&#8221;.</p></li>
                   2060: <li><p>If you are doing bulk builds from a read-only
                   2061:        copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
                   2062:        to the directory where all log files are created. Otherwise the
                   2063:        log files are created in the pkgsrc directory.</p></li>
                   2064: <li><p>Another important variable is
                   2065:        <code class="varname">BULK_PREREQ</code>, which is a list of packages that
                   2066:        should be always available while building other
                   2067:        packages.</p></li>
                   2068: </ul></div>
                   2069: <p>Some other options are scattered in the pkgsrc
                   2070:        infrastructure:</p>
                   2071: <div class="itemizedlist"><ul type="disc">
                   2072: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
                   2073:        should be set to <code class="literal">yes</code>. The purpose of the bulk
                   2074:        builds is creating binary packages, no matter if they are
                   2075:        vulnerable or not. When uploading the packages to a public
                   2076:        server, the vulnerable packages will be put into a directory of
                   2077:        their own. Leaving this variable unset would prevent the bulk
                   2078:        build system from even trying to build them, so possible
                   2079:        building errors would not show up.</p></li>
                   2080: <li><p><code class="varname">CHECK_FILES</code>
1.76      rillig   2081:        (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75      rillig   2082:        &#8220;<span class="quote">yes</span>&#8221; to check that the installed set of files
1.76      rillig   2083:        matches the <code class="filename">PLIST</code>.</p></li>
1.75      rillig   2084: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.76      rillig   2085:        (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
1.75      rillig   2086:        &#8220;<span class="quote">yes</span>&#8221; to check that the installed
                   2087:        &#8220;<span class="quote">#!</span>&#8221;-scripts will find their
                   2088:        interpreter.</p></li>
                   2089: </ul></div>
                   2090: </div>
                   2091: <div class="sect3" lang="en">
                   2092: <div class="titlepage"><div><div><h4 class="title">
1.76      rillig   2093: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75      rillig   2094: <p>It is possible to configure the bulk build to perform
                   2095:          certain site-specific tasks at the end of the pre-build
                   2096:          stage.  If the file
1.76      rillig   2097:          <code class="filename">pre-build.local</code> exists in
                   2098:          <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
1.75      rillig   2099:          (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
                   2100:          stage.  An example use of
1.76      rillig   2101:          <code class="filename">pre-build.local</code> is to have the line:</p>
1.75      rillig   2102: <pre class="screen">echo "I do not have enough disk space to build this pig." \
                   2103:     &gt; misc/openoffice/$BROKENF</pre>
                   2104: <p>to prevent the system from trying to build a particular package
                   2105:          which requires nearly 3 GB of disk space.</p>
                   2106: </div>
                   2107: </div>
                   2108: <div class="sect2" lang="en">
                   2109: <div class="titlepage"><div><div><h3 class="title">
                   2110: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76      rillig   2111: <p>As <code class="filename">/usr/pkg</code> will be completely
1.75      rillig   2112:        deleted at the start of bulk builds, make sure your login
                   2113:        shell is placed somewhere else. Either drop it into
1.76      rillig   2114:        <code class="filename">/usr/local/bin</code> (and adjust your login
1.75      rillig   2115:        shell in the passwd file), or (re-)install it via
1.76      rillig   2116:        <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   2117:        you can login after a reboot (remember that your current
                   2118:        process won't die if the package is removed, you just can't
                   2119:        start any new instances of the shell any more).  Also, if you
                   2120:        use NetBSD earlier than 1.5, or you still want to use the pkgsrc
                   2121:        version of ssh for some reason, be sure to install ssh before
1.76      rillig   2122:        starting it from <code class="filename">rc.local</code>:</p>
1.75      rillig   2123: <pre class="programlisting">
                   2124:     ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
                   2125:     if [ -f /usr/pkg/etc/rc.d/sshd ]; then
                   2126:         /usr/pkg/etc/rc.d/sshd
                   2127:     fi
1.1       grant    2128: </pre>
1.75      rillig   2129: <p>Not doing so will result in you being not able to log in
                   2130:        via ssh after the bulk build is finished or if the machine
                   2131:        gets rebooted or crashes. You have been warned! :)</p>
                   2132: </div>
                   2133: <div class="sect2" lang="en">
                   2134: <div class="titlepage"><div><div><h3 class="title">
                   2135: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
                   2136: <p>Make sure you don't need any of the packages still
                   2137:        installed.
                   2138:       </p>
                   2139: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
                   2140: <h3 class="title">Warning</h3>
                   2141: <p>During the bulk build, <span class="emphasis"><em>all packages will be
                   2142:            removed!</em></span></p>
                   2143: </div>
                   2144: <p>Be sure to remove all other things that might
                   2145:        interfere with builds, like some libs installed in
1.76      rillig   2146:        <code class="filename">/usr/local</code>, etc. then become root and type:</p>
1.75      rillig   2147: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   2148: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong></pre>
                   2149: <p>If for some reason your last build didn't complete (power
                   2150:        failure, system panic, ...), you can continue it by
                   2151:        running:</p>
                   2152: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
                   2153: <p>
                   2154:         At the end of the bulk build, you will get a summary via mail,
                   2155:        and find build logs in the directory specified by
1.76      rillig   2156:        <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
1.75      rillig   2157:        file.
                   2158:       </p>
                   2159: </div>
                   2160: <div class="sect2" lang="en">
                   2161: <div class="titlepage"><div><div><h3 class="title">
                   2162: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
                   2163: <p>The bulk builds consist of three steps:</p>
                   2164: <div class="variablelist"><dl>
                   2165: <dt><span class="term">1. pre-build</span></dt>
                   2166: <dd><p>
                   2167:              The script updates your pkgsrc tree via (anon)cvs, then
                   2168:              cleans out any broken distfiles, and removes all
                   2169:              packages installed.</p></dd>
                   2170: <dt><span class="term">2. the bulk build</span></dt>
                   2171: <dd><p>
                   2172:              This is basically &#8220;<span class="quote">make bulk-package</span>&#8221; with
                   2173:              an optimised order in which packages will be
                   2174:              built. Packages that don't require other packages will
                   2175:              be built first, and packages with many dependencies will
                   2176:              be built later.
                   2177:            </p></dd>
                   2178: <dt><span class="term">3. post-build</span></dt>
                   2179: <dd><p>
                   2180:              Generates a report that's placed in the directory
1.76      rillig   2181:              specified in the <code class="filename">build.conf</code> file
                   2182:              named <code class="filename">broken.html</code>, a short version
1.75      rillig   2183:              of that report will also be mailed to the build's
                   2184:              admin.</p></dd>
                   2185: </dl></div>
                   2186: <p>
                   2187:         During the build, a list of broken packages will be compiled
1.76      rillig   2188:         in <code class="filename">/usr/pkgsrc/.broken</code> (or
                   2189:         <code class="filename">.../.broken.${MACHINE}</code> if
1.75      rillig   2190:         <code class="varname">OBJMACHINE</code> is set),       individual build logs
                   2191:         of broken builds can be found in the package's
                   2192:         directory. These files are used by the bulk-targets to mark
                   2193:         broken builds  to not waste time trying to rebuild them, and
                   2194:         they can be used to debug      these broken package builds
                   2195:         later.
                   2196:       </p>
                   2197: </div>
                   2198: <div class="sect2" lang="en">
                   2199: <div class="titlepage"><div><div><h3 class="title">
                   2200: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
                   2201: <p>Currently, roughly the following requirements are valid for
                   2202:        NetBSD 2.0/i386:</p>
                   2203: <div class="itemizedlist"><ul type="disc">
                   2204: <li><p>
                   2205:            10 GB - distfiles (NFS ok)
                   2206:          </p></li>
                   2207: <li><p>
                   2208:            8 GB - full set of all binaries (NFS ok)
                   2209:          </p></li>
                   2210: <li><p>
                   2211:            5 GB - temp space for compiling (local disk recommended)
                   2212:          </p></li>
                   2213: </ul></div>
                   2214: <p>
                   2215:         Note that all pkgs will be de-installed as soon as they are
                   2216:         turned into a  binary package, and that sources are removed,
                   2217:         so there is no excessively huge        demand to disk
                   2218:         space. Afterwards, if the package is needed again, it will
                   2219:         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
                   2220:         there are no cycles wasted by recompiling.
                   2221:       </p>
                   2222: </div>
                   2223: <div class="sect2" lang="en">
                   2224: <div class="titlepage"><div><div><h3 class="title">
                   2225: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
                   2226: <p>
                   2227:         If you don't want all the packages nuked from a machine
                   2228:         (rendering it useless for anything but pkg compiling), there
                   2229:         is the possibility of doing the package bulk build inside a
                   2230:         chroot environment.
                   2231:       </p>
                   2232: <p>
                   2233:         The first step is to set up a chroot sandbox,
1.76      rillig   2234:        e.g. <code class="filename">/usr/sandbox</code>.  This can be done by
1.75      rillig   2235:        using null mounts, or manually.
                   2236:       </p>
                   2237: <p>
                   2238:         There is a shell script called
1.76      rillig   2239:         <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
1.75      rillig   2240:         up the sandbox environment using null mounts. It will also
1.76      rillig   2241:         create a script called <code class="filename">sandbox</code> in the
1.75      rillig   2242:         root of the sandbox environment, which will allow the null
                   2243:         mounts to be activated using the <span><strong class="command">sandbox
                   2244:         mount</strong></span> command and deactivated using the
                   2245:         <span><strong class="command">sandbox umount</strong></span> command.
                   2246:       </p>
                   2247: <p>
                   2248:         To set up a sandbox environment by hand, after extracting all
                   2249:         the sets from a NetBSD installation or doing a <span><strong class="command">make
                   2250:         distribution DESTDIR=/usr/sandbox</strong></span> in
1.76      rillig   2251:         <code class="filename">/usr/src/etc</code>, be sure the following items
1.75      rillig   2252:         are present and properly configured:
                   2253:       </p>
                   2254: <div class="procedure"><ol type="1">
                   2255: <li>
                   2256: <p>Kernel</p>
                   2257: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
                   2258: </li>
                   2259: <li>
1.76      rillig   2260: <p><code class="filename">/dev/*</code></p>
1.75      rillig   2261: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
                   2262: </li>
                   2263: <li>
1.76      rillig   2264: <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   2265: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
                   2266: </li>
                   2267: <li>
                   2268: <p>Working(!) mail config (hostname, sendmail.cf):</p>
                   2269: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
                   2270: </li>
                   2271: <li>
1.76      rillig   2272: <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   2273: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
                   2274: </li>
                   2275: <li>
1.76      rillig   2276: <p><code class="filename">/usr/src</code> (system sources,
                   2277:          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   2278: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
                   2279: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
                   2280: </li>
                   2281: <li>
1.76      rillig   2282: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75      rillig   2283: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
                   2284: </li>
                   2285: <li>
1.76      rillig   2286: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75      rillig   2287: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
                   2288: </li>
                   2289: <li>
                   2290: <p>Checkout pkgsrc via cvs into
1.76      rillig   2291:            <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
1.75      rillig   2292: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
                   2293: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong></pre>
                   2294: <p>Do not mount/link this to the copy of your pkgsrc tree
                   2295:            you do development in, as this will likely cause problems!
                   2296:            </p>
                   2297: </li>
                   2298: <li><p>Make
1.76      rillig   2299:            <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
                   2300:            <code class="filename">.../distfiles</code> point somewhere
1.75      rillig   2301:            appropriate. NFS- and/or nullfs-mounts may come in handy!
                   2302:            </p></li>
1.76      rillig   2303: <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>
                   2304: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75      rillig   2305: </ol></div>
                   2306: <p>When the chroot sandbox is set up, you can start
                   2307:        the build with the following steps:</p>
                   2308: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
                   2309: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong></pre>
                   2310: <p>
                   2311:         This will just jump inside the sandbox and start building.  At
                   2312:         the end of the build, mail will be sent with the results of
                   2313:         the build. Created binary pkgs will be in
1.76      rillig   2314:         <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
1.75      rillig   2315:         (wherever that points/mounts to/from).</p>
                   2316: </div>
                   2317: <div class="sect2" lang="en">
                   2318: <div class="titlepage"><div><div><h3 class="title">
                   2319: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
                   2320: <p> In addition to building a complete set of all packages in
1.76      rillig   2321:         pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
1.75      rillig   2322:         may be used to build a subset of the packages contained in
                   2323:         pkgsrc.  By setting <code class="varname">SPECIFIC_PKGS</code>
1.76      rillig   2324:         in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75      rillig   2325: <div class="itemizedlist"><ul type="disc">
                   2326: <li><p>SITE_SPECIFIC_PKGS</p></li>
                   2327: <li><p>HOST_SPECIFIC_PKGS</p></li>
                   2328: <li><p>GROUP_SPECIFIC_PKGS</p></li>
                   2329: <li><p>USER_SPECIFIC_PKGS</p></li>
                   2330: </ul></div>
                   2331: <p> will define the set of packages which should be built.
                   2332:         The bulk build code will also include any packages which are
                   2333:         needed as dependencies for the explicitly listed packages.
                   2334:        </p>
                   2335: <p> One use of this is to do a bulk build with
                   2336:         <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
                   2337:         periodically to have a complete set of the binary packages
                   2338:         needed for your site available without the overhead of
                   2339:         building extra packages that are not needed.  </p>
                   2340: </div>
                   2341: <div class="sect2" lang="en">
                   2342: <div class="titlepage"><div><div><h3 class="title">
                   2343: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
                   2344: <p>
                   2345:         This section describes how pkgsrc developers can upload binary
                   2346:         pkgs built by bulk builds to ftp.NetBSD.org.
                   2347:       </p>
                   2348: <p>
                   2349:        If you would like to automatically create checksum files for the
                   2350:        binary packages you intend to upload, remember to set
                   2351:        <code class="varname">MKSUMS=yes</code> in your
1.76      rillig   2352:        <code class="filename">mk/bulk/build.conf</code>.
1.75      rillig   2353:       </p>
                   2354: <p>
                   2355:        If you would like to PGP sign the checksum files (highly
                   2356:        recommended!), remember to set
                   2357:        <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
1.76      rillig   2358:        <code class="filename">mk/bulk/build.conf</code>.  This will prompt you for
1.75      rillig   2359:        your GPG password to sign the files before uploading everything.
                   2360:       </p>
                   2361: <p>
                   2362:         Then, make sure that you have <code class="varname">RSYNC_DST</code>
1.76      rillig   2363:         set properly in your <code class="filename">mk/bulk/build.conf</code>
1.75      rillig   2364:         file, i.e. adjust it to something like one of the following:
                   2365:       </p>
                   2366: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
                   2367: <p>Please use appropriate values for "pkgsrc-200xQy",
                   2368:         "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
                   2369:        is different from your local login, write your login directly
                   2370:        into the variable, e.g. my local account is "feyrer", but for my
                   2371:        login "hubertf", I use:</p>
                   2372: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
                   2373: <p>
1.76      rillig   2374:         A separate <code class="filename">upload</code> directory is used
1.75      rillig   2375:         here to allow "closing" the directory during upload. To do
                   2376:         so, run the following command on ftp.NetBSD.org next:
                   2377:       </p>
                   2378: <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>
                   2379: <p>
1.76      rillig   2380:         Please note that <code class="filename">/pub/NetBSD/packages</code> is
1.75      rillig   2381:         only appropriate for packages for the NetBSD operating
                   2382:         system. Binary packages for other operating systems should go
1.76      rillig   2383:         into <code class="filename">/pub/pkgsrc</code>.
1.75      rillig   2384:       </p>
                   2385: <p>
                   2386:         Before uploading the binary pkgs, ssh authentication needs to
                   2387:         be set up. This example shows how to set up temporary keys
                   2388:         for the root account <span class="emphasis"><em>inside the sandbox</em></span>
                   2389:         (assuming that no keys should be present there usually):
                   2390:       </p>
                   2391: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
                   2392: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
                   2393: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
                   2394: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong> </pre>
                   2395: <p>
1.76      rillig   2396:         Now take the output of <code class="filename">id-dsa.pub</code> and
                   2397:         append it to your <code class="filename">~/.ssh/authorized_keys</code>
1.75      rillig   2398:         file on ftp.NetBSD.org. You can remove the key after the
                   2399:         upload is done!
                   2400:       </p>
                   2401: <p>
                   2402:         Next, test if your ssh connection really works:
                   2403:       </p>
                   2404: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
                   2405: <p>
                   2406:         Use "-l yourNetBSDlogin" here as appropriate!
                   2407:       </p>
                   2408: <p>
                   2409:         Now after all this works, you can exit the sandbox and start
                   2410:         the upload:
                   2411:       </p>
                   2412: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
                   2413: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
                   2414: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong> </pre>
                   2415: <p>
                   2416:         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
                   2417:         <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
                   2418:         upload. The upload script will take care of not uploading
                   2419:         restricted packages and putting vulnerable packages into the
1.76      rillig   2420:         <code class="filename">vulnerable</code> subdirectory.
1.75      rillig   2421:       </p>
                   2422: <p>
                   2423:         After the upload has ended, first thing is to revoke ssh access:
                   2424:       </p>
                   2425: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
                   2426: Gdd:x! </pre>
                   2427: <p>
                   2428:         Use whatever is needed to remove the key you've entered
                   2429:         before! Last, move the uploaded packages out of the
1.76      rillig   2430:         <code class="filename">upload</code> directory to have them accessible
1.75      rillig   2431:         to everyone:
                   2432:       </p>
                   2433: <pre class="screen">nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
                   2434: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
                   2435: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
                   2436: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong> </pre>
                   2437: </div>
                   2438: </div>
                   2439: <div class="sect1" lang="en">
                   2440: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2441: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
                   2442: <p>
                   2443:       After your pkgsrc bulk-build has completed, you may wish to
                   2444:       create a CD-ROM set of the resulting binary packages to assist
                   2445:       in installing packages on other machines.  The
1.76      rillig   2446:       <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   2447:       a simple tool for creating the ISO 9660 images.
                   2448:       <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
                   2449:       way that keeps all the dependencies for a given package on the same
                   2450:       CD as that package.
                   2451:     </p>
                   2452: <div class="sect2" lang="en">
                   2453: <div class="titlepage"><div><div><h3 class="title">
                   2454: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
                   2455: <p>
                   2456:         Complete documentation for cdpack is found in the cdpack(1)
                   2457:         man page. The following short example assumes that the binary
                   2458:         packages are left in
1.76      rillig   2459:         <code class="filename">/usr/pkgsrc/packages/All</code> and that
                   2460:         sufficient disk space exists in <code class="filename">/u2</code> to
1.75      rillig   2461:         hold the ISO 9660 images.</p>
                   2462: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
                   2463: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
                   2464: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
                   2465: <p>
                   2466:         If you wish to include a common set of files
1.76      rillig   2467:        (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
1.75      rillig   2468:        etc.) on each CD in the collection, then you need to create a
                   2469:        directory which contains these files. e.g.
                   2470:       </p>
                   2471: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
                   2472: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" &gt; /tmp/common/README</code></strong>
                   2473: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" &gt; /tmp/common/COPYING</code></strong>
                   2474: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
                   2475: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" &gt; /tmp/common/bin/myscript</code></strong>
                   2476: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" &gt;&gt; /tmp/common/bin/myscript</code></strong>
                   2477: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong></pre>
                   2478: <p>Now create the images:</p>
                   2479: <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   2480: <p>Each image will contain <code class="filename">README</code>,
                   2481:        <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
1.75      rillig   2482:        in their root directories.</p>
                   2483: </div>
                   2484: </div>
                   2485: </div>
                   2486: <div class="chapter" lang="en">
                   2487: <div class="titlepage"><div><div><h2 class="title">
                   2488: <a name="faq"></a>Chapter 7. Frequently Asked Questions</h2></div></div></div>
                   2489: <div class="toc">
                   2490: <p><b>Table of Contents</b></p>
                   2491: <dl>
                   2492: <dt><span class="sect1"><a href="#mailing-list-pointers">7.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
                   2493: <dt><span class="sect1"><a href="#pkgviews-docs">7.2. Where's the pkgviews documentation?</a></span></dt>
                   2494: <dt><span class="sect1"><a href="#faq-pkgtools">7.3. Utilities for package management (pkgtools)</a></span></dt>
                   2495: <dt><span class="sect1"><a href="#non-root-pkgsrc">7.4. How to use pkgsrc as non-root</a></span></dt>
                   2496: <dt><span class="sect1"><a href="#resume-transfers">7.5. How to resume transfers when fetching distfiles?</a></span></dt>
                   2497: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">7.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
                   2498: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">7.7. How can I install/use X.org from pkgsrc?</a></span></dt>
                   2499: <dt><span class="sect1"><a href="#fetch-behind-firewall">7.8. How to fetch files from behind a firewall</a></span></dt>
                   2500: <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>
                   2501: <dt><span class="sect1"><a href="#fetching-all-distfiles">7.10. How to fetch all distfiles at once</a></span></dt>
                   2502: <dt><span class="sect1"><a href="#tmac.andoc-missing">7.11. What does &#8220;<span class="quote">Don't know how to make
                   2503: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</a></span></dt>
                   2504: <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>
                   2505: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">7.13. Using 'sudo' with pkgsrc</a></span></dt>
                   2506: <dt><span class="sect1"><a href="#faq.conf">7.14. How do I change the location of configuration files?</a></span></dt>
                   2507: <dt><span class="sect1"><a href="#audit-packages">7.15. Automated security checks</a></span></dt>
                   2508: <dt><span class="sect1"><a href="#ufaq-cflags">7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
                   2509: </dl>
                   2510: </div>
                   2511: <p>This section contains hints, tips &amp; tricks on special things in
                   2512: pkgsrc that we didn't find a better place for in the previous chapters, and
                   2513: it contains items for both pkgsrc users and developers.</p>
                   2514: <div class="sect1" lang="en">
                   2515: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2516: <a name="mailing-list-pointers"></a>7.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
                   2517: <p>The following mailing lists may be of interest to pkgsrc users:</p>
                   2518: <div class="itemizedlist"><ul type="disc">
                   2519: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a>:
                   2520:          All bug reports in category "pkg" sent 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> appear
                   2521:          here. Please do not report your bugs here directly; use one
                   2522:          of the other mailing lists.
                   2523:          discussed.</p></li>
                   2524: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
                   2525:          A list where the results of pkgsrc bulk builds are sent and
                   2526:          discussed.</p></li>
                   2527: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
                   2528:          This list is for those who are interested in getting a
                   2529:          commit message for every change committed to pkgsrc. It is
                   2530:          also available in digest form, meaning one daily message
                   2531:          containing all commit messages for changes to the package
                   2532:          source tree in that 24 hour period.</p></li>
                   2533: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">pkgsrc-users</a>:
                   2534:          This is a general purpose list for most issues regarding
                   2535:          pkgsrc, regardless of platform, e.g. soliciting user help
                   2536:          for pkgsrc configuration, unexpected build failures, using
                   2537:          particular packages, upgrading pkgsrc installations,
                   2538:          questions regarding the pkgsrc release branches, etc.  General announcements or
                   2539:          proposals for changes that impact the pkgsrc user community,
                   2540:          e.g. major infrastructure changes, new features, package
                   2541:          removals, etc., may also be posted.</p></li>
                   2542: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a>:
                   2543:          This is a list for technical discussions related to pkgsrc
                   2544:          development, e.g. soliciting feedback for changes to pkgsrc
                   2545:          infrastructure, proposed new features, questions related
                   2546:          to porting pkgsrc to a new platform, advice for maintaining
                   2547:          a package, patches that affect many packages, help requests
                   2548:          moved from pkgsrc-users when an infrastructure bug is found,
                   2549:          etc.</p></li>
                   2550: </ul></div>
                   2551: <p>To subscribe, do:</p>
                   2552: <pre class="programlisting">
                   2553:     <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
                   2554: </pre>
                   2555: <p>Archives for all these mailing lists are available from
                   2556: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
                   2557: </div>
                   2558: <div class="sect1" lang="en">
                   2559: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2560: <a name="pkgviews-docs"></a>7.2. Where's the pkgviews documentation?</h2></div></div></div>
                   2561: <p>Pkgviews is tightly integrated with buildlink.  You can find a
                   2562: pkgviews User's guide in
1.76      rillig   2563: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75      rillig   2564: </div>
                   2565: <div class="sect1" lang="en">
                   2566: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2567: <a name="faq-pkgtools"></a>7.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.76      rillig   2568: <p>The <code class="filename">pkgsrc/pkgtools</code> directory pkgtools contains
1.75      rillig   2569: a number of useful utilities for both users and developers of pkgsrc.  This
                   2570: section attempts only to make the reader aware of the utilities and when
                   2571: they might be useful, and not to duplicate the documentation that comes
                   2572: with each package.</p>
                   2573: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76      rillig   2574: <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   2575:       Symlinks for use by buildlink.</p></li></ul></div>
                   2576: <p>OS tool augmentation (automatically installed when needed):</p>
                   2577: <div class="itemizedlist"><ul type="disc">
1.76      rillig   2578: <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   2579:       Calculates various kinds of checksums (including SHA1).</p></li>
1.76      rillig   2580: <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   2581:       Compatibility library for pkgsrc tools.</p></li>
1.76      rillig   2582: <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   2583:       non-BSD systems due to lack of native mtree.
                   2584:   </p></li>
1.76      rillig   2585: <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   2586:       Up-to-date replacement for
1.76      rillig   2587:       <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75      rillig   2588:       systems where pkg_install is not present.</p></li>
                   2589: </ul></div>
                   2590: <p>Utilities used by pkgsrc (not automatically installed):</p>
                   2591: <div class="itemizedlist"><ul type="disc">
1.76      rillig   2592: <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   2593:       Create a binary package from an
                   2594:       already-installed package.  Used by <span><strong class="command">make replace</strong></span> to
                   2595:       save the old package.</p></li>
1.76      rillig   2596: <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   2597:       Adds extra functionality to pkgsrc, allowing it to fetch distfiles
                   2598:       from multiple locations. It currently supports the following
                   2599:       methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76      rillig   2600: <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   2601:       packages someplace else (enabled by default).</p></li>
1.76      rillig   2602: <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   2603:       best compiler flags to optimise code for your current CPU and
                   2604:       compiler.</p></li>
                   2605: </ul></div>
                   2606: <p>Utilities for keeping track of installed packages, being up to date,
                   2607: etc:</p>
                   2608: <div class="itemizedlist"><ul type="disc">
1.76      rillig   2609: <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   2610:       packages whose installed versions do not match the latest pkgsrc
                   2611:       entries.</p></li>
1.76      rillig   2612: <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   2613:       dependency graphs of packages, to aid in choosing a strategy for
                   2614:       updating.</p></li>
1.76      rillig   2615: <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
                   2616:       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>
                   2617: <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   2618:       pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
                   2619:       does various checks on the complete pkgsrc system.</p></li>
1.76      rillig   2620: <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   2621:       packages you have installed.</p></li>
                   2622: </ul></div>
                   2623: <p>Utilities for people maintaining or creating individual packages:</p>
                   2624: <div class="itemizedlist"><ul type="disc">
1.76      rillig   2625: <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   2626:       making and maintaining patches for a package (includes pkgdiff,
                   2627:       pkgvi, mkpatches, etc.).</p></li>
1.76      rillig   2628: <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>,
                   2629:       <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   2630:       converting to pkgsrc.</p></li>
1.76      rillig   2631: <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   2632:       pkgsrc to a Solaris package.</p></li>
                   2633: </ul></div>
                   2634: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
                   2635: utilities)</p>
                   2636: <div class="itemizedlist"><ul type="disc">
1.76      rillig   2637: <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   2638:       packages in a chrooted area.</p></li>
1.76      rillig   2639: <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   2640:       kernel version for chrooted cross builds.</p></li>
                   2641: </ul></div>
                   2642: </div>
                   2643: <div class="sect1" lang="en">
                   2644: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2645: <a name="non-root-pkgsrc"></a>7.4. How to use pkgsrc as non-root</h2></div></div></div>
                   2646: <p>If you want to use pkgsrc as non-root user, you can set some
                   2647: variables to make pkgsrc work under these conditions.  At the very least,
                   2648: you need to set <code class="varname">UNPRIVILEGED</code> to &#8220;<span class="quote">yes</span>&#8221;; this
                   2649: will turn on unprivileged mode and set multiple related variables to allow
                   2650: installation of packages as non-root.</p>
                   2651: <p>In case the defaults are not enough, you may want to tune some other
                   2652: variables used.  For example, if the automatic user/group detection leads
                   2653: to incorrect values (or not the ones you would like to use), you can change
                   2654: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
                   2655: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
                   2656: <p>As regards bootstrapping, please note that the
                   2657: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
                   2658: given the &#8220;<span class="quote">--ignore-user-check</span>&#8221; flag, as it will choose and
1.76      rillig   2659: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75      rillig   2660: installation targets.  These directories can be overriden by the
                   2661: &#8220;<span class="quote">--prefix</span>&#8221; flag provided by the script, as well as some others
                   2662: that allow finer tuning of the tree layout.</p>
                   2663: </div>
                   2664: <div class="sect1" lang="en">
                   2665: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2666: <a name="resume-transfers"></a>7.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
                   2667: <p>By default, resuming transfers in pkgsrc is disabled, but you can
                   2668: enable this feature by adding the option
                   2669: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76      rillig   2670: <code class="filename">/etc/mk.conf</code>.  If, during a fetch step, an incomplete
1.75      rillig   2671: distfile is found, pkgsrc will try to resume it.</p>
                   2672: <p>You can also
                   2673: 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
                   2674: <code class="varname">FETCH_CMD</code> variable.  Don't forget to set
                   2675: <code class="varname">FETCH_RESUME_ARGS</code> and
                   2676: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
                   2677: values.</p>
                   2678: <p>For example, if you want to use
1.76      rillig   2679: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75      rillig   2680: like:</p>
                   2681: <pre class="programlisting">
                   2682:     FETCH_CMD=             wget
                   2683:     FETCH_BEFORE_ARGS=     --passive-ftp
                   2684:     FETCH_RESUME_ARGS=     -c
                   2685:     FETCH_OUTPUT_ARGS=     -O
1.1       grant    2686: </pre>
1.75      rillig   2687: </div>
                   2688: <div class="sect1" lang="en">
                   2689: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2690: <a name="XFree86-from-pkgsrc"></a>7.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
                   2691: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76      rillig   2692: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75      rillig   2693: ...), you will have to add the following line into
1.76      rillig   2694: <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   2695: <pre class="programlisting">
                   2696:     X11_TYPE=XFree86
1.1       grant    2697: </pre>
1.75      rillig   2698: </div>
                   2699: <div class="sect1" lang="en">
                   2700: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2701: <a name="x.org-from-pkgsrc"></a>7.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
                   2702: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76      rillig   2703: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75      rillig   2704: you will have to add the following line into
1.76      rillig   2705: <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   2706: <pre class="programlisting">
                   2707:     X11_TYPE=xorg
1.1       grant    2708: </pre>
1.75      rillig   2709: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   2710: <h3 class="title">Note</h3>
                   2711: <p>The DragonFly operating system defaults to using
                   2712: this X.org X11 implementation from pkgsrc.
                   2713: </p>
                   2714: </div>
                   2715: </div>
                   2716: <div class="sect1" lang="en">
                   2717: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2718: <a name="fetch-behind-firewall"></a>7.8. How to fetch files from behind a firewall</h2></div></div></div>
                   2719: <p>If you are sitting behind a firewall which does not allow direct
                   2720: connections to Internet hosts (i.e. non-NAT), you may specify the
                   2721: relevant proxy hosts.  This is done using an environment variable in the
                   2722: form of a URL, e.g. in Amdahl, the machine
                   2723: &#8220;<span class="quote">orpheus.amdahl.com</span>&#8221; is one of the firewalls, and it uses
                   2724: port 80 as the proxy port number.  So the proxy environment variables
                   2725: are:</p>
                   2726: <pre class="programlisting">
                   2727:     ftp_proxy=ftp://orpheus.amdahl.com:80/
                   2728:     http_proxy=http://orpheus.amdahl.com:80/
1.1       grant    2729: </pre>
1.75      rillig   2730: </div>
                   2731: <div class="sect1" lang="en">
                   2732: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2733: <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>
                   2734: <p>This depends on which utility is used to retrieve distfiles.  From
1.76      rillig   2735: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75      rillig   2736: the first available command from the following list:</p>
                   2737: <div class="itemizedlist"><ul type="disc">
1.76      rillig   2738: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
                   2739: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75      rillig   2740: </ul></div>
                   2741: <p>On a default NetBSD installation, this will be
1.76      rillig   2742: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75      rillig   2743: connections first, and falls back to active connections if the server
                   2744: refuses to do passive.  For the other tools, add the following to your
1.76      rillig   2745: <code class="filename">/etc/mk.conf</code> file:
1.75      rillig   2746: <code class="varname">PASSIVE_FETCH=1</code>.</p>
                   2747: <p>Having that option present will prevent
1.76      rillig   2748: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75      rillig   2749: transfers.</p>
                   2750: </div>
                   2751: <div class="sect1" lang="en">
                   2752: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2753: <a name="fetching-all-distfiles"></a>7.10. How to fetch all distfiles at once</h2></div></div></div>
                   2754: <p>You would like to download all the distfiles in a single batch from
                   2755: work or university, where you can't run a <span><strong class="command">make fetch</strong></span>.
                   2756: There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
                   2757: but downloading the entire directory may not be appropriate.</p>
                   2758: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76      rillig   2759: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75      rillig   2760: resulting list to your machine at work/school and use it there.  If you
                   2761: 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
                   2762: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
                   2763: URL:</p>
                   2764: <p>At home:</p>
                   2765: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   2766: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles &gt;/tmp/fetch.sh</code></strong>
                   2767: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
                   2768: <p>At work:</p>
                   2769: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76      rillig   2770: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75      rillig   2771: home.</p>
                   2772: <p>If you have a machine running NetBSD, and you want to get
                   2773: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your machine
                   2774: architecture), you can do so by using the above-mentioned <span><strong class="command">make
                   2775: fetch-list</strong></span> approach, or fetch the distfiles directly by
                   2776: running:</p>
                   2777: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
                   2778: <p>If you even decide to ignore
                   2779: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
                   2780: by running:</p>
                   2781: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
                   2782: </div>
                   2783: <div class="sect1" lang="en">
                   2784: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2785: <a name="tmac.andoc-missing"></a>7.11. What does &#8220;<span class="quote">Don't know how to make
                   2786: /usr/share/tmac/tmac.andoc</span>&#8221; mean?</h2></div></div></div>
1.76      rillig   2787: <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   2788: package, you get the error from make that it doesn't know how to make
1.76      rillig   2789: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75      rillig   2790: you don't have installed the &#8220;<span class="quote">text</span>&#8221; set (nroff, ...) from
                   2791: the NetBSD base distribution on your machine.  It is recommended to do
                   2792: that to format man pages.</p>
1.76      rillig   2793: <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   2794: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76      rillig   2795: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75      rillig   2796: </div>
                   2797: <div class="sect1" lang="en">
                   2798: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2799: <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   2800: <p> You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75      rillig   2801: when you installed your NetBSD machine.  Please get and install it, by
1.76      rillig   2802: extracting it in <code class="filename">/</code>:</p>
1.75      rillig   2803: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
                   2804: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76      rillig   2805: <p><code class="filename">comp.tgz</code> is part of every NetBSD release.  Get
1.75      rillig   2806: the one that corresponds to your release (determine via <span><strong class="command">uname
                   2807: -r</strong></span>).</p>
                   2808: </div>
                   2809: <div class="sect1" lang="en">
                   2810: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2811: <a name="using-sudo-with-pkgsrc"></a>7.13. Using 'sudo' with pkgsrc</h2></div></div></div>
                   2812: <p>When installing packages as non-root user and using the just-in-time
                   2813: <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
                   2814: password for each required package installed.  To avoid this, the sudo
                   2815: package can be used, which does password caching over a limited time.  To
                   2816: use it, install sudo (either as binary package or from
1.76      rillig   2817: <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
                   2818: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75      rillig   2819: <pre class="programlisting">
                   2820:     .if exists(${LOCALBASE}/bin/sudo)
                   2821:     SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   2822:     .endif
1.1       grant    2823: </pre>
1.75      rillig   2824: </div>
                   2825: <div class="sect1" lang="en">
                   2826: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2827: <a name="faq.conf"></a>7.14. How do I change the location of configuration files?</h2></div></div></div>
                   2828: <p>As the system administrator, you can choose where configuration files
                   2829: are installed.  The default settings make all these files go into
1.76      rillig   2830: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75      rillig   2831: be suboptimal depending on your expectations (e.g., a read-only,
                   2832: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
                   2833: configuration of the provided packages).</p>
                   2834: <p>In order to change the defaults, you can modify the
                   2835: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76      rillig   2836: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
                   2837: directory; some common examples include <code class="filename">/etc</code> or
                   2838: <code class="filename">/etc/pkg</code>.</p>
1.75      rillig   2839: <p>Furthermore, you can change this value on a per-package basis by
                   2840: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
                   2841: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
                   2842: package you would like to modify, that is, the contents of
                   2843: <code class="varname">PKGBASE</code>.</p>
                   2844: <p>Note that after changing these settings, you must rebuild and
                   2845: reinstall any affected packages.</p>
                   2846: </div>
                   2847: <div class="sect1" lang="en">
                   2848: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2849: <a name="audit-packages"></a>7.15. Automated security checks</h2></div></div></div>
                   2850: <p>Please be aware that there can often be bugs in third-party software,
                   2851: and some of these bugs can leave a machine vulnerable to exploitation by
                   2852: attackers.  In an effort to lessen the exposure, the NetBSD packages team
                   2853: maintains a database of known-exploits to packages which have at one time
                   2854: been included in pkgsrc.  The database can be downloaded automatically, and
                   2855: a security audit of all packages installed on a system can take place.  To
1.76      rillig   2856: 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   2857: components:</p>
                   2858: <div class="orderedlist"><ol type="1">
                   2859: <li>
                   2860: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
                   2861:     download a list of the security vulnerabilities information.  This list
                   2862:     is kept up to date by the NetBSD security officer and the NetBSD
                   2863:     packages team, and is distributed from the NetBSD ftp server:</p>
                   2864: <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>
                   2865: </li>
                   2866: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
                   2867:     current machine, checking each vulnerability which is known.  If a
                   2868:     vulnerable package is installed, it will be shown by output to stdout,
                   2869:     including a description of the type of vulnerability, and a URL
                   2870:     containing more information.</p></li>
                   2871: </ol></div>
1.76      rillig   2872: <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   2873: package is strongly recommended!  After
                   2874: &#8220;<span class="quote">audit-packages</span>&#8221; is installed, please read
                   2875: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
                   2876: audit-packages</code></strong>.</p>
                   2877: <p>If this package is installed, pkgsrc builds will use it to perform
                   2878: a security check before building any package.  See
                   2879: <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.
                   2880: </p>
                   2881: </div>
                   2882: <div class="sect1" lang="en">
                   2883: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   2884: <a name="ufaq-cflags"></a>7.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
                   2885: <p>When you add your own preferences to the
                   2886:        <code class="varname">CFLAGS</code> variable in your
1.76      rillig   2887:        <code class="filename">mk.conf</code>, these flags are passed in
                   2888:        environment variables to the <code class="filename">./configure</code>
1.75      rillig   2889:        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
                   2890:        <code class="varname">CFLAGS</code> from the environment variable by
1.76      rillig   2891:        overriding them in the <code class="filename">Makefile</code>s of their
1.75      rillig   2892:        package.</p>
                   2893: <p>Currently there is no solution to this problem. If you
                   2894:        really need the package to use your <code class="varname">CFLAGS</code>
                   2895:        you should run <span><strong class="command">make patch</strong></span> in the package
1.76      rillig   2896:        directory and then inspect any <code class="filename">Makefile</code> and
                   2897:        <code class="filename">Makefile.in</code> for whether they define
1.75      rillig   2898:        <code class="varname">CFLAGS</code> explicitly. Usually you can remove
                   2899:        these lines. But be aware that some &#8220;<span class="quote">smart</span>&#8221;
                   2900:        programmers write so bad code that it only works for the
                   2901:        specific combination of <code class="varname">CFLAGS</code> they have
                   2902:        chosen.</p>
                   2903: </div>
                   2904: </div>
                   2905: </div>
                   2906: <div class="part" lang="en">
                   2907: <div class="titlepage"><div><div><h1 class="title">
                   2908: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77    ! rillig   2909: <div class="partintro" lang="en">
        !          2910: <div></div>
        !          2911: <p>This part of the book deals with creating and
        !          2912:        modifying packages. It starts with a &#8220;<span class="quote">HOWTO</span>&#8221;-like
        !          2913:        guide on creating a new package. The remaining chapters are more
        !          2914:        like a reference manual for pkgsrc.</p>
1.75      rillig   2915: <div class="toc">
                   2916: <p><b>Table of Contents</b></p>
                   2917: <dl>
1.77    ! rillig   2918: <dt><span class="chapter"><a href="#creating">8. Creating a new pkgsrc package from scratch</a></span></dt>
        !          2919: <dt><span class="chapter"><a href="#components">9. Package components - files, directories and contents</a></span></dt>
1.75      rillig   2920: <dd><dl>
1.77    ! rillig   2921: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
        !          2922: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
        !          2923: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
        !          2924: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
        !          2925: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
        !          2926: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
        !          2927: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
        !          2928: </dl></dd>
        !          2929: <dt><span class="chapter"><a href="#makefile">10. Programming in <code class="filename">Makefile</code>s</a></span></dt>
        !          2930: <dd><dl>
        !          2931: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
        !          2932: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
        !          2933: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
        !          2934: <dd><dl>
        !          2935: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
        !          2936: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
        !          2937: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
        !          2938: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
        !          2939: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">10.2.5. Workaround for a bug in BSD Make</a></span></dt>
        !          2940: </dl></dd>
        !          2941: </dl></dd>
        !          2942: <dt><span class="chapter"><a href="#plist">11. PLIST issues</a></span></dt>
        !          2943: <dd><dl>
        !          2944: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
        !          2945: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
        !          2946: <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>
        !          2947: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
        !          2948: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
        !          2949: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
        !          2950: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
        !          2951: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
        !          2952: </dl></dd>
        !          2953: <dt><span class="chapter"><a href="#buildlink">12. Buildlink methodology</a></span></dt>
        !          2954: <dd><dl>
        !          2955: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
        !          2956: <dt><span class="sect1"><a href="#creating-buildlink3.mk">12.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
        !          2957: <dd><dl>
        !          2958: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
        !          2959: <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>
        !          2960: </dl></dd>
        !          2961: <dt><span class="sect1"><a href="#writing-builtin.mk">12.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
        !          2962: <dd><dl>
        !          2963: <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>
        !          2964: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">12.3.2. Global preferences for native or pkgsrc software</a></span></dt>
        !          2965: </dl></dd>
        !          2966: </dl></dd>
        !          2967: <dt><span class="chapter"><a href="#pkginstall">13. The pkginstall framework</a></span></dt>
        !          2968: <dd><dl>
        !          2969: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">13.1. Files and directories outside the installation prefix</a></span></dt>
        !          2970: <dd><dl>
        !          2971: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
        !          2972: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
        !          2973: </dl></dd>
        !          2974: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
        !          2975: <dd><dl>
        !          2976: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
        !          2977: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
        !          2978: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
        !          2979: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
        !          2980: </dl></dd>
        !          2981: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
        !          2982: <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>
        !          2983: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
        !          2984: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
        !          2985: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
        !          2986: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
        !          2987: <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>
        !          2988: </dl></dd>
        !          2989: <dt><span class="chapter"><a href="#options">14. Options handling</a></span></dt>
        !          2990: <dd><dl>
        !          2991: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
        !          2992: <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>
        !          2993: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
        !          2994: </dl></dd>
        !          2995: <dt><span class="chapter"><a href="#build">15. The build process</a></span></dt>
        !          2996: <dd><dl>
        !          2997: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
        !          2998: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
        !          2999: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
        !          3000: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
        !          3001: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
        !          3002: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
        !          3003: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
        !          3004: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
        !          3005: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
        !          3006: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
        !          3007: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
        !          3008: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
        !          3009: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
        !          3010: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
        !          3011: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
        !          3012: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
        !          3013: </dl></dd>
        !          3014: <dt><span class="chapter"><a href="#tools">16. Tools needed for building or running</a></span></dt>
        !          3015: <dd><dl>
        !          3016: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
        !          3017: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
        !          3018: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
        !          3019: </dl></dd>
        !          3020: <dt><span class="chapter"><a href="#fixes">17. Making your package work</a></span></dt>
        !          3021: <dd><dl>
        !          3022: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
        !          3023: <dd><dl>
        !          3024: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">17.1.1. How to pull in variables from /etc/mk.conf</a></span></dt>
        !          3025: <dt><span class="sect2"><a href="#where-to-install-documentation">17.1.2. Where to install documentation</a></span></dt>
        !          3026: <dt><span class="sect2"><a href="#restricted-packages">17.1.3. Restricted packages</a></span></dt>
        !          3027: <dt><span class="sect2"><a href="#dependencies">17.1.4. Handling dependencies</a></span></dt>
        !          3028: <dt><span class="sect2"><a href="#conflicts">17.1.5. Handling conflicts with other packages</a></span></dt>
        !          3029: <dt><span class="sect2"><a href="#not-building-packages">17.1.6. Packages that cannot or should not be built</a></span></dt>
        !          3030: <dt><span class="sect2"><a href="#undeletable-packages">17.1.7. Packages which should not be deleted, once installed</a></span></dt>
        !          3031: <dt><span class="sect2"><a href="#security-handling">17.1.8. Handling packages with security problems</a></span></dt>
        !          3032: <dt><span class="sect2"><a href="#compiler-bugs">17.1.9. How to handle compiler bugs</a></span></dt>
        !          3033: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.10. How to handle incrementing versions when fixing an existing package</a></span></dt>
        !          3034: <dt><span class="sect2"><a href="#portability-of-packages">17.1.11. Portability of packages</a></span></dt>
        !          3035: </dl></dd>
        !          3036: <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>
        !          3037: <dd><dl>
        !          3038: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
        !          3039: <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>
        !          3040: </dl></dd>
        !          3041: <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>
        !          3042: <dd><dl>
        !          3043: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
        !          3044: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
        !          3045: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
        !          3046: </dl></dd>
        !          3047: <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>
        !          3048: <dd><dl><dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt></dl></dd>
        !          3049: <dt><span class="sect1"><a href="#package-specific-actions">17.5. Package specific actions</a></span></dt>
        !          3050: <dd><dl>
        !          3051: <dt><span class="sect2"><a href="#user-interaction">17.5.1. User interaction</a></span></dt>
        !          3052: <dt><span class="sect2"><a href="#handling-licenses">17.5.2. Handling licenses</a></span></dt>
        !          3053: </dl></dd>
        !          3054: <dt><span class="sect1"><a href="#fixes.install">17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
        !          3055: <dd><dl>
        !          3056: <dt><span class="sect2"><a href="#installing-score-files">17.6.1. Installing score files</a></span></dt>
        !          3057: <dt><span class="sect2"><a href="#perl-scripts">17.6.2. Packages containing perl scripts</a></span></dt>
        !          3058: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.3. Packages with hardcoded paths to other interpreters</a></span></dt>
        !          3059: <dt><span class="sect2"><a href="#perl-modules">17.6.4. Packages installing perl modules</a></span></dt>
        !          3060: <dt><span class="sect2"><a href="#faq.info-files">17.6.5. Packages installing info files</a></span></dt>
        !          3061: <dt><span class="sect2"><a href="#manpages">17.6.6. Packages installing man pages</a></span></dt>
        !          3062: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.7. Packages installing GConf2 data files</a></span></dt>
        !          3063: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.8. Packages installing scrollkeeper data files</a></span></dt>
        !          3064: <dt><span class="sect2"><a href="#x11-fonts">17.6.9. Packages installing X11 fonts</a></span></dt>
        !          3065: <dt><span class="sect2"><a href="#gtk2-modules">17.6.10. Packages installing GTK2 modules</a></span></dt>
        !          3066: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.11. Packages installing SGML or XML data</a></span></dt>
        !          3067: <dt><span class="sect2"><a href="#mime-database">17.6.12. Packages installing extensions to the MIME database</a></span></dt>
        !          3068: <dt><span class="sect2"><a href="#intltool">17.6.13. Packages using intltool</a></span></dt>
        !          3069: <dt><span class="sect2"><a href="#startup-scripts">17.6.14. Packages installing startup scripts</a></span></dt>
        !          3070: <dt><span class="sect2"><a href="#tex-packages">17.6.15. Packages installing TeX modules</a></span></dt>
        !          3071: </dl></dd>
        !          3072: <dt><span class="sect1"><a href="#feedback-to-author">17.7. Feedback to the author</a></span></dt>
        !          3073: </dl></dd>
        !          3074: <dt><span class="chapter"><a href="#debug">18. Debugging</a></span></dt>
        !          3075: <dt><span class="chapter"><a href="#submit">19. Submitting and Committing</a></span></dt>
        !          3076: <dd><dl>
        !          3077: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
        !          3078: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
        !          3079: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
        !          3080: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
        !          3081: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
        !          3082: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig   3083: </dl></dd>
1.77    ! rillig   3084: <dt><span class="chapter"><a href="#devfaq">20. Frequently Asked Questions</a></span></dt>
1.75      rillig   3085: </dl>
                   3086: </div>
1.77    ! rillig   3087: </div>
        !          3088: <div class="chapter" lang="en">
        !          3089: <div class="titlepage"><div><div><h2 class="title">
        !          3090: <a name="creating"></a>Chapter 8. Creating a new pkgsrc package from scratch</h2></div></div></div>
        !          3091: <p>When you find a package that is not yet in pkgsrc, you
        !          3092:        most likely have a URL from where you can download the source
        !          3093:        code. Starting with this URL, creating a package involves only a
        !          3094:        few steps.</p>
        !          3095: <div class="procedure"><ol type="1">
        !          3096: <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>
        !          3097: <li><p>Then, choose one of the top-level directories as the
        !          3098:        category in which you want to place your package. You can also
        !          3099:        create a directory of your own (maybe called
        !          3100:        <code class="filename">local</code>). In that category directory, create
        !          3101:        another directory for your package and change into
        !          3102:        it.</p></li>
        !          3103: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
        !          3104:        will ask you for a URL. Enter the URL of the distribution file
        !          3105:        (in most cases a <code class="filename">.tar.gz</code> file) and watch
        !          3106:        how the basic ingredients of your package are created
        !          3107:        automatically. The distribution file is extracted automatically
        !          3108:        to fill in some details in the <code class="filename">Makefile</code>
        !          3109:        that would otherwise have to be done manually.</p></li>
        !          3110: <li>
        !          3111: <p>Examine the extracted files to determine the
        !          3112:        dependencies of your package. Ideally, this is mentioned in some
        !          3113:        <code class="filename">README</code> file, but things may differ. For
        !          3114:        each of these dependencies, look where it exists in pkgsrc, and
        !          3115:        if there is a file called <code class="filename">buildlink3.mk</code> in
        !          3116:        that directory, add a line to your package
        !          3117:        <code class="filename">Makefile</code> which includes that file just
        !          3118:        before the last line. If the <code class="filename">buildlink3.mk</code>
        !          3119:        file does not exist, add a <code class="varname">DEPENDS</code> line to
        !          3120:        the Makefile, which specifies the version of the dependency and
        !          3121:        where it can be found in pkgsrc. This line should be placed in
        !          3122:        the third paragraph. If the dependency is only needed for
        !          3123:        building the package, but not when using it, use
        !          3124:        <code class="varname">BUILD_DEPENDS</code> instead of
        !          3125:        <code class="varname">DEPENDS</code>. Your package may then look like
        !          3126:        this:</p>
        !          3127: <pre class="programlisting">
        !          3128:     [...]
        !          3129: 
        !          3130:     BUILD_DEPENDS+= lua&gt;=5.0:../../lang/lua
        !          3131:     DEPENDS+=       screen-[0-9]*:../../misc/screen
        !          3132:     DEPENDS+=       screen&gt;=4.0:../../misc/screen
        !          3133: 
        !          3134:     [...]
        !          3135: 
        !          3136:     .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
        !          3137:     .include "../../devel/glib2/buildlink3.mk"
        !          3138:     .include "../../mk/bsd.pkg.mk"
        !          3139: </pre>
        !          3140: </li>
        !          3141: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
        !          3142:        still need to be done to make your package a &#8220;<span class="quote">good</span>&#8221;
        !          3143:        one. If you don't know what pkglint's warnings want to tell you,
        !          3144:        try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
        !          3145:        -e</strong></span>, which outputs additional
        !          3146:        explanations.</p></li>
        !          3147: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
        !          3148:        package. For the various things that can go wrong in this phase,
        !          3149:        consult <a href="#fixes" title="Chapter 17. Making your package work">Chapter 17, <i>Making your package work</i></a>.</p></li>
        !          3150: <li><p>When the package builds fine, the next step is to
        !          3151:        install the package. Run <span><strong class="command">bmake install</strong></span> and
        !          3152:        hope that everything works.</p></li>
        !          3153: <li><p>Up to now, the file <code class="filename">PLIST</code>,
        !          3154:        which contains a list of the files that are installed by the
        !          3155:        package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
        !          3156:        &gt;PLIST</strong></span> to generate a probably correct list. Check
        !          3157:        the file using your preferred text editor to see if the list of
        !          3158:        files looks plausible.</p></li>
        !          3159: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
        !          3160:        generated <code class="filename">PLIST</code> contains garbage or
        !          3161:        not.</p></li>
        !          3162: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
        !          3163:        package has been registered in the database of installed files,
        !          3164:        but with an empty list of files. To fix this, run <span><strong class="command">bmake
        !          3165:        deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
        !          3166:        Now the package is registered with the list of files from
        !          3167:        <code class="filename">PLIST</code>.</p></li>
        !          3168: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
        !          3169:        binary package from the set of installed files.</p></li>
        !          3170: </ol></div>
        !          3171: </div>
1.75      rillig   3172: <div class="chapter" lang="en">
                   3173: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   3174: <a name="components"></a>Chapter 9. Package components - files, directories and contents</h2></div></div></div>
1.75      rillig   3175: <div class="toc">
                   3176: <p><b>Table of Contents</b></p>
                   3177: <dl>
1.77    ! rillig   3178: <dt><span class="sect1"><a href="#components.Makefile">9.1. <code class="filename">Makefile</code></a></span></dt>
        !          3179: <dt><span class="sect1"><a href="#components.distinfo">9.2. <code class="filename">distinfo</code></a></span></dt>
        !          3180: <dt><span class="sect1"><a href="#components.patches">9.3. patches/*</a></span></dt>
        !          3181: <dt><span class="sect1"><a href="#other-mandatory-files">9.4. Other mandatory files</a></span></dt>
        !          3182: <dt><span class="sect1"><a href="#components.optional">9.5. Optional files</a></span></dt>
        !          3183: <dt><span class="sect1"><a href="#work-dir">9.6. <code class="filename">work*</code></a></span></dt>
        !          3184: <dt><span class="sect1"><a href="#files-dir">9.7. <code class="filename">files/*</code></a></span></dt>
1.75      rillig   3185: </dl>
                   3186: </div>
                   3187: <p>  Whenever you're preparing a package, there are a number of
                   3188:     files involved which are described in the following
                   3189:     sections. </p>
                   3190: <div class="sect1" lang="en">
                   3191: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3192: <a name="components.Makefile"></a>9.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75      rillig   3193: <p>Building, installation and creation of a binary package are all
1.76      rillig   3194:       controlled by the package's <code class="filename">Makefile</code>.
                   3195:       The <code class="filename">Makefile</code> describes various things about
1.75      rillig   3196:       a package, for example from where to get it, how to configure,
                   3197:       build, and install it.
                   3198:     </p>
1.76      rillig   3199: <p>A package <code class="filename">Makefile</code> contains several
1.75      rillig   3200:      sections that describe the package.</p>
                   3201: <p>In the first section there are the following variables, which
                   3202:       should appear exactly in the order given here.
                   3203:       </p>
                   3204: <div class="itemizedlist"><ul type="disc">
                   3205: <li><p><code class="varname">DISTNAME</code> is the basename of the
                   3206:       distribution file to be downloaded from the package's
                   3207:       website.</p></li>
                   3208: <li><p><code class="varname">PKGNAME</code> is the name of the
                   3209:       package, as used by pkgsrc. You only need to provide it if it
                   3210:       differs from <code class="varname">DISTNAME</code>. Usually it is the directory name together
                   3211:       with the version number. It must match the regular expression
                   3212:       <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
                   3213:       starts with a letter or digit, and contains only letters, digits,
                   3214:       dashes, underscores, dots and plus signs.</p></li>
                   3215: <li>
                   3216: <p><code class="varname">CATEGORIES</code> is a list of categories
                   3217:            which the package fits in. You can choose any of the top-level
                   3218:            directories of pkgsrc for it.</p>
                   3219: <p>Currently the following values are available for
                   3220:          <code class="varname">CATEGORIES</code>. If more than
                   3221:          one is used, they need to be separated by spaces:</p>
                   3222: <pre class="programlisting">
                   3223:     archivers     cross         geography     meta-pkgs     security
                   3224:     audio         databases     graphics      misc          shells
                   3225:     benchmarks    devel         ham           multimedia    sysutils
                   3226:     biology       editors       inputmethod   net           textproc
                   3227:     cad           emulators     lang          news          time
                   3228:     chat          finance       mail          parallel      wm
                   3229:     comms         fonts         math          pkgtools      www
                   3230:     converters    games         mbone         print         x11
1.1       grant    3231: </pre>
1.75      rillig   3232: </li>
                   3233: <li>
                   3234: <p><code class="varname">MASTER_SITES</code> is a list of URLs where
                   3235:            the distribution files can be downloaded. Each URL must end with a
                   3236:            slash.</p>
                   3237: <p>The <code class="varname">MASTER_SITES</code> may make use of
                   3238:            the following predefined sites:</p>
                   3239: <pre class="programlisting">
                   3240:     ${MASTER_SITE_APACHE}
                   3241:     ${MASTER_SITE_BACKUP}
                   3242:     ${MASTER_SITE_CYGWIN}
                   3243:     ${MASTER_SITE_DEBIAN}
                   3244:     ${MASTER_SITE_FREEBSD}
                   3245:     ${MASTER_SITE_FREEBSD_LOCAL}
                   3246:     ${MASTER_SITE_GNOME}
                   3247:     ${MASTER_SITE_GNU}
                   3248:     ${MASTER_SITE_GNUSTEP}
                   3249:     ${MASTER_SITE_IFARCHIVE}
                   3250:     ${MASTER_SITE_MOZILLA}
                   3251:     ${MASTER_SITE_OPENOFFICE}
                   3252:     ${MASTER_SITE_PERL_CPAN}
                   3253:     ${MASTER_SITE_R_CRAN}
                   3254:     ${MASTER_SITE_SOURCEFORGE}
                   3255:     ${MASTER_SITE_SUNSITE}
                   3256:     ${MASTER_SITE_SUSE}
                   3257:     ${MASTER_SITE_TEX_CTAN}
                   3258:     ${MASTER_SITE_XCONTRIB}
                   3259:     ${MASTER_SITE_XEMACS}
1.74      rillig   3260: </pre>
1.75      rillig   3261: <p>If one of these predefined sites is chosen, you may
                   3262:            want to specify a subdirectory of that
                   3263:            site.  Since these macros may expand to more than one
                   3264:            actual site, you <span class="emphasis"><em>must</em></span> use the
                   3265:            following construct to specify a subdirectory:</p>
                   3266: <pre class="programlisting">
                   3267:     ${MASTER_SITE_GNU:=subdirectory/name/}
                   3268:     ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1       grant    3269: </pre>
1.75      rillig   3270: <p>Note the trailing slash after the subdirectory name.</p>
                   3271: <p>If the package has multiple
                   3272:            <code class="varname">DISTFILES</code> or multiple
                   3273:            <code class="varname">PATCHFILES</code> from different
                   3274:            sites, set <code class="varname">SITES.foo</code> to a list of URIs
                   3275:            where file &#8220;<span class="quote">foo</span>&#8221; may be
                   3276:            found. &#8220;<span class="quote">foo</span>&#8221; includes the suffix, e.g.:</p>
                   3277: <pre class="programlisting">
                   3278:     DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   3279:     DISTFILES+=     foo-file.tar.gz
                   3280:     SITES.foo-file.tar.gz= \
                   3281:             http://www.somewhere.com/somehow/ \
                   3282:             http://www.somewhereelse.com/mirror/somehow/
1.1       grant    3283: </pre>
1.75      rillig   3284: </li>
                   3285: <li>
                   3286: <p><code class="varname">DISTFILES</code>: Name(s)
                   3287:            of archive file(s) containing distribution. The default is
1.76      rillig   3288:            <code class="filename">${DISTNAME}${EXTRACT_SUFX}</code>. Should only
1.75      rillig   3289:            be set if you have more than one distfile.</p>
                   3290: <p>Note that the normal default setting of
                   3291:            <code class="varname">DISTFILES</code> must be made explicit if you
                   3292:            want to add to it (rather than replace it), as you usually
                   3293:            would.</p>
                   3294: </li>
                   3295: <li><p><code class="varname">EXTRACT_SUFX</code>: Suffix of the
                   3296:            distribution file, will be appended to
                   3297:            <code class="varname">DISTNAME</code>. Defaults to
1.76      rillig   3298:            <code class="filename">.tar.gz</code>.
1.75      rillig   3299:          </p></li>
                   3300: </ul></div>
                   3301: <p>
                   3302:     </p>
                   3303: <p>The second section contains information about separately
                   3304:       downloaded patches, if any.
                   3305:       </p>
                   3306: <div class="itemizedlist"><ul type="disc">
                   3307: <li><p><code class="varname">PATCHFILES:</code>
                   3308:          Name(s) of additional files that contain distribution patches.
                   3309:          There is no default. pkgsrc will look for them at
                   3310:          <code class="varname">PATCH_SITES</code>.
                   3311:          They will automatically be uncompressed before patching if
1.76      rillig   3312:          the names end with <code class="filename">.gz</code> or
                   3313:          <code class="filename">.Z</code>.</p></li>
1.75      rillig   3314: <li><p><code class="varname">PATCH_SITES</code>:
                   3315:          Primary location(s) for distribution patch files (see
                   3316:          <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
                   3317: </ul></div>
                   3318: <p>
                   3319:     </p>
                   3320: <p>The third section contains the following variables.
                   3321:       </p>
                   3322: <div class="itemizedlist"><ul type="disc">
                   3323: <li><p><code class="varname">MAINTAINER</code> is the email address
                   3324:       of the person who feels responsible for this package, and who is
                   3325:       most likely to look at problems or questions regarding this
                   3326:       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
                   3327:       developers should contact the <code class="varname">MAINTAINER</code> before
                   3328:       making major changes to the package. When packaging a new program,
                   3329:       set <code class="varname">MAINTAINER</code> to yourself. If you really can't
                   3330:       maintain the package for future updates, set it to
                   3331:       <code class="email">&lt;<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>&gt;</code>.</p></li>
                   3332: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
                   3333:       find more information about the package.</p></li>
                   3334: <li><p><code class="varname">COMMENT</code> is a one-line
                   3335:       description of the package (should not include the package
                   3336:       name).</p></li>
                   3337: </ul></div>
                   3338: <p>
                   3339:     </p>
                   3340: <p>Other variables that affect the build:
                   3341:       </p>
                   3342: <div class="itemizedlist"><ul type="disc"><li>
                   3343: <p><code class="varname">WRKSRC</code>: The directory where the
                   3344:          interesting distribution files of the package are found. The
1.76      rillig   3345:          default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
1.75      rillig   3346:          works for most packages.</p>
                   3347: <p>If a package doesn't create a subdirectory for itself
                   3348:          (most GNU software does, for instance), but extracts itself in
                   3349:          the current directory, you should set <code class="varname">WRKSRC=
                   3350:          ${WRKDIR}</code>.</p>
                   3351: <p>If a package doesn't create a subdirectory with the name
                   3352:          of <code class="varname">DISTNAME</code> but some different name, set
                   3353:          <code class="varname">WRKSRC</code> to point to the proper name in
1.76      rillig   3354:          <code class="filename">${WRKDIR}</code>, for example <code class="varname">WRKSRC=
                   3355:          ${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   3356: <p>The name of the working directory created by pkgsrc is
                   3357:          taken from the <code class="varname">WRKDIR_BASENAME</code> variable. By
1.76      rillig   3358:          default, its value is <code class="filename">work</code>. If you want
1.75      rillig   3359:          to use the same pkgsrc tree for building different kinds of
                   3360:          binary packages, you can change the variable according to your
                   3361:          needs. Two other variables handle common cases of setting
                   3362:          <code class="varname">WRKDIR_BASENAME</code> individually. If
                   3363:          <code class="varname">OBJHOSTNAME</code> is defined in
1.76      rillig   3364:          <code class="filename">/etc/mk.conf</code>, the first component of the
1.75      rillig   3365:          host's name is attached to the directory name. If
                   3366:          <code class="varname">OBJMACHINE</code> is defined, the platform name is
1.76      rillig   3367:          attached, which might look like <code class="filename">work.i386</code>
                   3368:          or <code class="filename">work.sparc</code>.</p>
1.75      rillig   3369: </li></ul></div>
                   3370: <p>
                   3371:     </p>
                   3372: <p>Please pay attention to the following gotchas:</p>
                   3373: <div class="itemizedlist"><ul type="disc">
                   3374: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are installed in
                   3375:           compressed form by the package; see comment in
1.76      rillig   3376:           <code class="filename">bsd.pkg.mk</code>.</p></li>
                   3377: <li><p>Replace <code class="filename">/usr/local</code> with
1.75      rillig   3378:           &#8220;<span class="quote">${PREFIX}</span>&#8221; in all files (see patches, below).</p></li>
                   3379: <li><p>If the package installs any info files, see
1.77    ! rillig   3380:           <a href="#faq.info-files" title="17.6.5. Packages installing info files">Section 17.6.5, &#8220;Packages installing info files&#8221;</a>.</p></li>
1.75      rillig   3381: </ul></div>
                   3382: </div>
                   3383: <div class="sect1" lang="en">
                   3384: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3385: <a name="components.distinfo"></a>9.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76      rillig   3386: <p>The <code class="filename">distinfo</code> file contains the message
1.75      rillig   3387:     digest, or checksum, of each distfile needed for the package. This
                   3388:     ensures that the distfiles retrieved from the Internet have not been
                   3389:     corrupted during transfer or altered by a malign force to introduce
                   3390:     a security hole. Due to recent rumor about weaknesses of digest
                   3391:     algorithms, all distfiles are protected using both SHA1 and RMD160
                   3392:     message digests, as well as the file size.</p>
1.76      rillig   3393: <p>The <code class="filename">distinfo</code> file also contains the
1.75      rillig   3394:     checksums for all the patches found in the
1.77    ! rillig   3395:     <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   3396: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.75      rillig   3397:     <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
                   3398:     command.</p>
                   3399: <p>Some packages have different sets of distfiles depending on
1.76      rillig   3400:     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
                   3401:     <code class="filename">distinfo</code> file and care should be taken when
1.75      rillig   3402:     upgrading such a package to ensure distfile information is not
                   3403:     lost.</p>
                   3404: </div>
                   3405: <div class="sect1" lang="en">
                   3406: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3407: <a name="components.patches"></a>9.3. patches/*</h2></div></div></div>
1.75      rillig   3408: <p>This directory contains files that are used by the
                   3409:       <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
                   3410:       modify the sources as distributed in the distribution file into a form
                   3411:       that will compile and run perfectly on NetBSD. The files are applied
                   3412:       successively in alphabetic order (as returned by a shell
                   3413:       &#8220;<span class="quote">patches/patch-*</span>&#8221; glob expansion), so
1.76      rillig   3414:       <code class="filename">patch-aa</code> is applied before
                   3415:       <code class="filename">patch-ab</code>, etc.</p>
                   3416: <p>The <code class="filename">patch-*</code> files should be in
1.75      rillig   3417:       <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
                   3418:       problems. (To force patches to apply
                   3419:       with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
                   3420:       Furthermore, do not put changes for more than one file into a single
                   3421:       patch file, as this will make future modifications more difficult.</p>
                   3422: <p>Similar, a file should be patched at most once, not several times by
                   3423:       several different patches. If a file needs several patches, they should
                   3424:       be combined into one file.</p>
                   3425: <p>One important thing to mention is to pay attention that no RCS IDs
                   3426:       get stored in the patch files, as these will cause problems when
                   3427:       later checked into the NetBSD CVS tree. Use the
                   3428:       <span><strong class="command">pkgdiff</strong></span> from the
1.76      rillig   3429:       <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   3430:       these problems.</p>
                   3431: <p>For even more automation, we recommend using <span><strong class="command">mkpatches</strong></span> from the same
                   3432:       package to make a whole set of patches. You just have to backup files
1.76      rillig   3433:       before you edit them to <code class="filename">filename.orig</code>, e.g. with
1.75      rillig   3434:       <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by using
                   3435:       <span><strong class="command">pkgvi</strong></span> again from the same package. If you upgrade a package
                   3436:       this way, you can easily compare the new set of patches with the
                   3437:       previously existing one with <span><strong class="command">patchdiff</strong></span>.</p>
                   3438: <p>When you have finished a package, remember to generate the checksums
                   3439:       for the patch files by using the <span><strong class="command">make makepatchsum</strong></span>
1.77    ! rillig   3440:       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   3441: <p>When adding a patch that corrects a problem in the distfile (rather
                   3442:       than e.g. enforcing pkgsrc's view of where man pages should go), send
                   3443:       the patch as a bug report to the maintainer.  This benefits
                   3444:       non-pkgsrc users of the package, and usually enables removing
                   3445:       the patch in future version.</p>
                   3446: <p>Patch files that are distributed by the author or other
                   3447:       maintainers can be listed in
                   3448:       <code class="varname">$PATCHFILES</code>. </p>
                   3449: <p>If it is desired to store any patches that should not be committed into
                   3450:       pkgsrc, they can be kept outside the pkgsrc tree in the
1.76      rillig   3451:       <code class="filename">$LOCALPATCHES</code>
1.75      rillig   3452:       directory. The directory tree there is expected to have the same
                   3453:       &#8220;<span class="quote">category/package</span>&#8221; structure as pkgsrc, and patches are
                   3454:       expected to be stored inside these dirs (also known as
1.76      rillig   3455:       <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
1.75      rillig   3456:       example, if you want to keep a private patch for
1.76      rillig   3457:       <code class="filename">pkgsrc/graphics/png</code>, keep
                   3458:       it in <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
1.75      rillig   3459:       files in the named directory are expected to be patch files, and
                   3460:       <span class="emphasis"><em>they are applied after pkgsrc patches are applied</em></span>.</p>
                   3461: </div>
                   3462: <div class="sect1" lang="en">
                   3463: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3464: <a name="other-mandatory-files"></a>9.4. Other mandatory files</h2></div></div></div>
1.75      rillig   3465: <div class="variablelist"><dl>
1.76      rillig   3466: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75      rillig   3467: <dd><p>A multi-line description of the piece of software.  This should include
                   3468:             any credits where they are due.  Please bear in mind that others do not
                   3469:             share your sense of humour (or spelling idiosyncrasies), and that others
                   3470:             will read everything that you write here.</p></dd>
1.76      rillig   3471: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.75      rillig   3472: <dd><p>
                   3473:             This file governs the files that are installed on your system: all the
                   3474:             binaries, manual pages, etc. There are other directives which may be
                   3475:             entered in this file, to control the creation and deletion of
                   3476:             directories, and the location of inserted files.
1.77    ! rillig   3477:             See <a href="#plist" title="Chapter 11. PLIST issues">Chapter 11, <i>PLIST issues</i></a> for more information. </p></dd>
1.75      rillig   3478: </dl></div>
                   3479: </div>
                   3480: <div class="sect1" lang="en">
                   3481: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3482: <a name="components.optional"></a>9.5. Optional files</h2></div></div></div>
1.75      rillig   3483: <div class="variablelist"><dl>
1.76      rillig   3484: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75      rillig   3485: <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>.
                   3486:             First time after package
                   3487:             extraction and before files are moved in place, the second time after
                   3488:             the files to install are moved in place. This can be used to do any
                   3489:             custom procedures not possible with @exec commands in
1.76      rillig   3490:             <code class="filename">PLIST</code>. See
1.75      rillig   3491:             <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   3492: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75      rillig   3493: <dd><p>This script is executed before and after any files are removed.  It is
                   3494:             this script's responsibility to clean up any additional messy details
                   3495:             around the package's installation, since all pkg_delete knows is how to
                   3496:             delete the files created in the original distribution.
                   3497:             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>
                   3498:             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   3499: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75      rillig   3500: <dd>
                   3501: <p>This file is displayed after installation of the package.
                   3502:             Useful for things like legal notices on almost-free
                   3503:             software and hints for updating config files after
                   3504:             installing modules for apache, PHP etc.
                   3505:             Please note that you can modify variables in it easily by using
                   3506:             <code class="varname">MESSAGE_SUBST</code> in the package's
1.76      rillig   3507:             <code class="filename">Makefile</code>:</p>
1.75      rillig   3508: <pre class="programlisting">
                   3509:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
1.1       grant    3510: </pre>
1.75      rillig   3511: <p>replaces "${SOMEVAR}" with &#8220;<span class="quote">somevalue</span>&#8221; in
1.76      rillig   3512:             <code class="filename">MESSAGE</code>.</p>
1.75      rillig   3513: </dd>
                   3514: </dl></div>
                   3515: </div>
                   3516: <div class="sect1" lang="en">
                   3517: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3518: <a name="work-dir"></a>9.6. <code class="filename">work*</code></h2></div></div></div>
1.75      rillig   3519: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
                   3520:       unpacked into the directory denoted by
                   3521:       <code class="varname">WRKDIR</code>. It can be removed by running
                   3522:       <span><strong class="command">make clean</strong></span>. Besides the sources, this
                   3523:       directory is also used to keep various timestamp files.
                   3524:       The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
1.76      rillig   3525:       The default is <code class="filename">${.CURDIR}/work</code>
                   3526:       or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
1.75      rillig   3527:       if <code class="varname">OBJMACHINE</code> is set.</p>
                   3528: </div>
                   3529: <div class="sect1" lang="en">
                   3530: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3531: <a name="files-dir"></a>9.7. <code class="filename">files/*</code></h2></div></div></div>
1.75      rillig   3532: <p>If you have any files that you wish to be placed in the package prior
                   3533:       to configuration or building, you could place these files here and use
                   3534:       a &#8220;<span class="quote">${CP}</span>&#8221; command in the
                   3535:       &#8220;<span class="quote">pre-configure</span>&#8221; target to achieve
                   3536:       this. Alternatively, you could simply diff the file against
1.76      rillig   3537:       <code class="filename">/dev/null</code> and use the patch mechanism to manage
1.75      rillig   3538:       the creation of this file.</p>
                   3539: </div>
                   3540: </div>
                   3541: <div class="chapter" lang="en">
                   3542: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   3543: <a name="makefile"></a>Chapter 10. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75      rillig   3544: <div class="toc">
                   3545: <p><b>Table of Contents</b></p>
                   3546: <dl>
1.77    ! rillig   3547: <dt><span class="sect1"><a href="#makefile.variables">10.1. <code class="filename">Makefile</code> variables</a></span></dt>
        !          3548: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">10.1.1. Naming conventions</a></span></dt></dl></dd>
        !          3549: <dt><span class="sect1"><a href="#makefile.code">10.2. Code snippets</a></span></dt>
        !          3550: <dd><dl>
        !          3551: <dt><span class="sect2"><a href="#adding-to-list">10.2.1. Adding things to a list</a></span></dt>
        !          3552: <dt><span class="sect2"><a href="#converting-internal-to-external">10.2.2. Converting an internal list into an external list</a></span></dt>
        !          3553: <dt><span class="sect2"><a href="#passing-variable-to-shell">10.2.3. Passing variables to a shell command</a></span></dt>
        !          3554: <dt><span class="sect2"><a href="#quoting-guideline">10.2.4. Quoting guideline</a></span></dt>
        !          3555: <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   3556: </dl></dd>
                   3557: </dl>
                   3558: </div>
1.76      rillig   3559: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75      rillig   3560:   each of which forms a well-defined part of the pkgsrc system. Using
                   3561:   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
                   3562:   like pkgsrc requires some discipline to keep the code correct and
                   3563:   understandable.</p>
1.76      rillig   3564: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75      rillig   3565:   programming are variables (which are actually macros) and shell
                   3566:   commands. Among these shell commands may even be more complex ones
                   3567:   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
                   3568:   as intended it is necessary to quote all variables correctly when they
                   3569:   are used.</p>
                   3570: <p>This chapter describes some patterns, that appear quite often in
1.76      rillig   3571:   <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75      rillig   3572:   with them.</p>
                   3573: <div class="sect1" lang="en">
                   3574: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3575: <a name="makefile.variables"></a>10.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76      rillig   3576: <p><code class="filename">Makefile</code> variables contain strings that
1.75      rillig   3577:     can be processed using the five operators ``='', ``+='', ``?='',
                   3578:     ``:='', 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
                   3579:     page.</p>
                   3580: <p>When a variable's value is parsed from a
1.76      rillig   3581:     <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75      rillig   3582:     backslash character ``\'' are handled specially. If a backslash is
                   3583:     followed by a newline, any whitespace immediately in front of the
                   3584:     backslash, the backslash, the newline, and any whitespace
                   3585:     immediately behind the newline are replaced with a single space. A
                   3586:     backslash character and an immediately following hash character are
                   3587:     replaced with a single hash character. Otherwise, the backslash is
                   3588:     passed as is. In a variable assignment, any hash character that is
                   3589:     not preceded by a backslash starts a comment that continues upto the
                   3590:     end of the logical line.</p>
                   3591: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
                   3592:     the only way to create a variable consisting of a single backslash
                   3593:     is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
                   3594: <p>So far for defining variables. The other thing you can do with
                   3595:     variables is evaluating them. A variable is evaluated when it is
                   3596:     part of the right side of the ``:='' or the ``!='' operator, or
                   3597:     directly before executing a shell command which the variable is part
                   3598:     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
                   3599:     is, variables are not evaluated until there's no other way. The
                   3600:     ``modifiers'' mentioned in the man page also evaluate the
                   3601:     variable.</p>
                   3602: <p>Some of the modifiers split the string into words and then
                   3603:     operate on the words, others operate on the string as a whole. When
                   3604:     a string is split into words, it is split as you would expect
                   3605:     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>
                   3606: <p>No rule without exception&#8212;the <span><strong class="command">.for</strong></span>
                   3607:     loop does not follow the shell quoting rules but splits at sequences
                   3608:     of whitespace.</p>
                   3609: <p>There are several types of variables that should be handled
                   3610:     differently. Strings and two types of lists.</p>
                   3611: <div class="itemizedlist"><ul type="disc">
                   3612: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
                   3613:       characters. Nevertheless, you should restrict yourself to only
                   3614:       using printable characters. Examples are
                   3615:       <code class="varname">PREFIX</code> and
                   3616:       <code class="varname">COMMENT</code>.</p></li>
                   3617: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
                   3618:       are never exported to any shell command. Their elements are
                   3619:       separated by whitespace. Therefore, the elements themselves cannot
                   3620:       have embedded whitespace. Any other characters are allowed.
                   3621:       Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
                   3622:       Examples are <code class="varname">DEPENDS</code> and
                   3623:       <code class="varname">BUILD_DEPENDS</code>.</p></li>
                   3624: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
                   3625:       may be exported to a shell command. Their elements can contain any
                   3626:       characters, including whitespace. That's why they cannot be used
                   3627:       in <span><strong class="command">.for</strong></span> loops. Examples are
                   3628:       <code class="varname">DISTFILES</code> and
                   3629:       <code class="varname">MASTER_SITES</code>.</p></li>
                   3630: </ul></div>
                   3631: <div class="sect2" lang="en">
                   3632: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   3633: <a name="makefile.variables.names"></a>10.1.1. Naming conventions</h3></div></div></div>
1.75      rillig   3634: <div class="itemizedlist"><ul type="disc">
                   3635: <li><p>All variable names starting with an underscore
                   3636:        are reserved for use by the pkgsrc infrastructure. They shall
                   3637:        not be used by package
1.76      rillig   3638:        <code class="filename">Makefile</code>s.</p></li>
1.75      rillig   3639: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
                   3640:        lowercase variable names for the iteration
                   3641:        variables.</p></li>
                   3642: <li><p>All list variables should have a ``plural''
                   3643:        name, e.g. <code class="varname">PKG_OPTIONS</code> or
                   3644:        <code class="varname">DISTFILES</code>.</p></li>
                   3645: </ul></div>
                   3646: </div>
                   3647: </div>
                   3648: <div class="sect1" lang="en">
                   3649: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3650: <a name="makefile.code"></a>10.2. Code snippets</h2></div></div></div>
1.75      rillig   3651: <p>This section presents you with some code snippets you should
                   3652:     use in your own code. If you don't find anything appropriate here,
                   3653:     you should test your code and add it here.</p>
                   3654: <div class="sect2" lang="en">
                   3655: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   3656: <a name="adding-to-list"></a>10.2.1. Adding things to a list</h3></div></div></div>
1.75      rillig   3657: <pre class="programlisting">
                   3658:     STRING=                 foo * bar `date`
                   3659:     INT_LIST=               # empty
                   3660:     ANOTHER_INT_LIST=       apache-[0-9]*:../../www/apache
                   3661:     EXT_LIST=               # empty
                   3662:     ANOTHER_EXT_LIST=       a=b c=d
1.1       grant    3663: 
1.75      rillig   3664:     INT_LIST+=              ${STRING}               # 1
                   3665:     INT_LIST+=              ${ANOTHER_INT_LIST}     # 2
                   3666:     EXT_LIST+=              ${STRING:Q}             # 3
                   3667:     EXT_LIST+=              ${ANOTHER_EXT_LIST}     # 4
1.1       grant    3668: </pre>
1.75      rillig   3669: <p>When you add a string to an external list (example 3), it
                   3670:       must be quoted. In all other cases, you must not add a quoting
                   3671:       level. You must not merge internal and external lists, unless you
                   3672:       are sure that all entries are correctly interpreted in both
                   3673:       lists.</p>
                   3674: </div>
                   3675: <div class="sect2" lang="en">
                   3676: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   3677: <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   3678: <pre class="programlisting">
                   3679:     EXT_LIST=       # empty
                   3680:     .for i in ${INT_LIST}
                   3681:     EXT_LIST+=      ${i:Q}""
                   3682:     .endfor
1.1       grant    3683: </pre>
1.75      rillig   3684: <p>This code converts the internal list
                   3685:       <code class="varname">INT_LIST</code> into the external list
                   3686:       <code class="varname">EXT_LIST</code>. As the elements of an internal list
                   3687:       are unquoted they must be quoted here. The reason for appending
                   3688:       <code class="varname">""</code> is explained below.</p>
                   3689: </div>
                   3690: <div class="sect2" lang="en">
                   3691: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   3692: <a name="passing-variable-to-shell"></a>10.2.3. Passing variables to a shell command</h3></div></div></div>
1.75      rillig   3693: <pre class="programlisting">
                   3694:     STRING=         foo bar &lt;    &gt; * `date` $$HOME ' "
                   3695:     EXT_LIST=       string=${STRING:Q} x=second\ item
1.1       grant    3696: 
1.75      rillig   3697:     all:
                   3698:             echo ${STRING}                  # 1
                   3699:             echo "${STRING}"                # 2
                   3700:             echo "${STRING:Q}"              # 3
                   3701:             echo ${STRING:Q}                # 4
                   3702:             echo x${STRING:Q} | sed 1s,.,,  # 5
                   3703:             env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1       grant    3704: </pre>
1.75      rillig   3705: <p>Example 1 leads to a syntax error in the shell, as the
                   3706:       characters are just copied.</p>
                   3707: <p>Example 2 leads to a syntax error too, and if you leave out
                   3708:       the last " character from <code class="varname">${STRING}</code>,
                   3709:       <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
                   3710:       variable would be evaluated, too.</p>
                   3711: <p>Example 3 outputs each space character preceded by a
                   3712:       backslash (or not), depending on the implementation of the
                   3713:       <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>
                   3714: <p>Example 4 handles correctly every string that does not start
                   3715:       with a dash. In that case, the result depends on the
                   3716:       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
                   3717:       guarantee that your input does not start with a dash, this form is
                   3718:       appropriate.</p>
                   3719: <p>Example 5 handles even the case of a leading dash
                   3720:       correctly.</p>
                   3721: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
                   3722:       because the quoting has already been done when adding elements to
                   3723:       the list.</p>
                   3724: <p>As internal lists shall not be passed to the shell, there is
                   3725:       no example for it.</p>
                   3726: </div>
                   3727: <div class="sect2" lang="en">
                   3728: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   3729: <a name="quoting-guideline"></a>10.2.4. Quoting guideline</h3></div></div></div>
1.75      rillig   3730: <p>There are many possible sources of wrongly quoted variables.
                   3731:       This section lists some of the commonly known ones.</p>
                   3732: <div class="itemizedlist"><ul type="disc">
                   3733: <li>
                   3734: <p>Whenever you use the value of a list, think
                   3735:        about what happens to leading or trailing whitespace. If the
                   3736:        list is a well-formed shell expression, you can apply the
                   3737:        <code class="varname">:M*</code> modifier to strip leading and trailing
                   3738:        whitespace from each word. The <code class="varname">:M</code> operator
                   3739:        first splits its argument according to the rules of the shell,
                   3740:        and then creates a new list consisting of all words that match
                   3741:        the shell glob expression <code class="varname">*</code>, that is: all.
                   3742:        One class of situations where this is needed is when adding a
                   3743:        variable like <code class="varname">CPPFLAGS</code> to
                   3744:        <code class="varname">CONFIGURE_ARGS</code>. If the configure script
                   3745:        invokes other configure scripts, it strips the leading and
                   3746:        trailing whitespace from the variable and then passes it to the
                   3747:        other configure scripts. But these configure scripts expect the
                   3748:        (child) <code class="varname">CPPFLAGS</code> variable to be the same as
                   3749:        the parent <code class="varname">CPPFLAGS</code>. That's why we better
                   3750:        pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
                   3751:        here is how we do it:</p>
                   3752: <pre class="programlisting">
                   3753:     CPPFLAGS=               # empty
                   3754:     CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX:Q}\"
                   3755:     CPPFLAGS+=              ${MY_CPPFLAGS}
1.1       grant    3756: 
1.75      rillig   3757:     CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
1.1       grant    3758: 
1.75      rillig   3759:     all:
                   3760:             echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   3761:             echo x${CONFIGURE_ARGS}x        # properly trimmed
1.1       grant    3762: </pre>
1.75      rillig   3763: </li>
                   3764: <li><p>The example above contains one bug: The
                   3765:        <code class="varname">${PREFIX}</code> is a properly quoted shell
                   3766:        expression, but there is the C compiler after it, which also
                   3767:        expects a properly quoted string (this time in C syntax). The
                   3768:        version above is therefore only correct if
                   3769:        <code class="varname">${PREFIX}</code> does not have embedded backslashes
                   3770:        or double quotes. If you want to allow these, you have to add
                   3771:        another layer of quoting to each variable that is used as a C
                   3772:        string literal. You cannot use the <code class="varname">:Q</code>
                   3773:        operator for it, as this operator only works for the
                   3774:        shell.</p></li>
                   3775: <li>
                   3776: <p>Whenever a variable can be empty, the
                   3777:        <code class="varname">:Q</code> operator can have surprising results. Here
                   3778:        are two completely different cases which can be solved with the
                   3779:        same trick.</p>
                   3780: <pre class="programlisting">
                   3781:     EMPTY=                  # empty
                   3782:     empty_test:
                   3783:             for i in a ${EMPTY:Q} c; do \
                   3784:                     echo "$$i"; \
                   3785:             done
1.1       grant    3786: 
1.75      rillig   3787:     for_test:
                   3788:     .for i in a:\ a:\test.txt
                   3789:             echo ${i:Q}
                   3790:             echo "foo"
                   3791:     .endfor
1.1       grant    3792: </pre>
1.75      rillig   3793: <p>The first example will only print two of the three lines
                   3794:        we might have expected. This is because
                   3795:        <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
                   3796:        the shell cannot see. The workaround is to write
                   3797:        <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
                   3798:        as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
                   3799:        -f ${FNAME:Q}</code> (both of these are wrong).</p>
                   3800: <p>The second example will only print three lines instead of
                   3801:        four. The first line looks like <code class="varname">a:\ echo foo</code>.
                   3802:        This is because the backslash of the value
                   3803:        <code class="varname">a:\</code> is interpreted as a line-continuation by
                   3804:        <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
                   3805:        <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
                   3806:        <code class="varname">${i:Q}""</code>.</p>
                   3807: </li>
                   3808: </ul></div>
                   3809: </div>
                   3810: <div class="sect2" lang="en">
                   3811: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   3812: <a name="bsd-make-bug-workaround"></a>10.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75      rillig   3813: <p>The pkgsrc bmake program does not handle the following
                   3814:       assignment correctly. In case <code class="varname">_othervar_</code>
                   3815:       contains a ``-'' character, one of the closing braces is included
                   3816:       in <code class="varname">${VAR}</code> after this code executes.</p>
                   3817: <pre class="programlisting">
                   3818:     VAR:=   ${VAR:N${_othervar_:C/-//}}
1.1       grant    3819: </pre>
1.75      rillig   3820: <p>For a more complex code snippet and a workaround, see the
1.76      rillig   3821:       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   3822:       <code class="varname">bug1</code>.</p>
                   3823: </div>
                   3824: </div>
                   3825: </div>
                   3826: <div class="chapter" lang="en">
                   3827: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   3828: <a name="plist"></a>Chapter 11. PLIST issues</h2></div></div></div>
1.75      rillig   3829: <div class="toc">
                   3830: <p><b>Table of Contents</b></p>
                   3831: <dl>
1.77    ! rillig   3832: <dt><span class="sect1"><a href="#rcs-id">11.1. RCS ID</a></span></dt>
        !          3833: <dt><span class="sect1"><a href="#automatic-plist-generation">11.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
        !          3834: <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>
        !          3835: <dt><span class="sect1"><a href="#plist.misc">11.4. Variable substitution in PLIST</a></span></dt>
        !          3836: <dt><span class="sect1"><a href="#manpage-compression">11.5. Man page compression</a></span></dt>
        !          3837: <dt><span class="sect1"><a href="#using-PLIST_SRC">11.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
        !          3838: <dt><span class="sect1"><a href="#platform-specific-plist">11.7. Platform-specific and differing PLISTs</a></span></dt>
        !          3839: <dt><span class="sect1"><a href="#faq.common-dirs">11.8. Sharing directories between packages</a></span></dt>
1.75      rillig   3840: </dl>
                   3841: </div>
1.76      rillig   3842: <p> The <code class="filename">PLIST</code> file contains a package's
1.75      rillig   3843:     &#8220;<span class="quote">packing list</span>&#8221;, i.e. a list of files that belong to
1.76      rillig   3844:     the package (relative to the <code class="filename">${PREFIX}</code>
1.75      rillig   3845:     directory it's been installed in) plus some additional statements
                   3846:     - 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.
                   3847:     This chapter addresses some issues that need attention when
1.76      rillig   3848:     dealing with the <code class="filename">PLIST</code> file (or files, see
1.75      rillig   3849:     below!).</p>
                   3850: <div class="sect1" lang="en">
                   3851: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3852: <a name="rcs-id"></a>11.1. RCS ID</h2></div></div></div>
1.75      rillig   3853: <p>
                   3854:       Be sure to add a RCS ID line as the first thing in any
1.76      rillig   3855:       <code class="filename">PLIST</code> file you write:
1.75      rillig   3856:     </p>
                   3857: <pre class="programlisting">
                   3858:     @comment $NetBSD$
1.55      rillig   3859: </pre>
1.75      rillig   3860: </div>
                   3861: <div class="sect1" lang="en">
                   3862: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3863: <a name="automatic-plist-generation"></a>11.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75      rillig   3864: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
                   3865:       to output a PLIST that matches any new files since the package
1.77    ! rillig   3866:       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   3867:       more information on this target.</p>
                   3868: </div>
                   3869: <div class="sect1" lang="en">
                   3870: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3871: <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   3872: <p> If you have used any of the *-dirs packages, as explained in
1.77    ! rillig   3873:       <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   3874:       <span><strong class="command">make print-PLIST</strong></span> outputs a set of
                   3875:       <code class="varname">@comment</code>s instead of real
                   3876:       <code class="varname">@dirrm</code> lines.  You can also do this for
                   3877:       specific directories and files, so that the results of that
                   3878:       command are very close to reality. This helps <span class="emphasis"><em>a
                   3879:       lot</em></span> during the update of packages. </p>
                   3880: <p> The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
                   3881:       of AWK patterns and actions that are used to filter the output of
                   3882:       print-PLIST.  You can <span class="emphasis"><em>append</em></span> any chunk of AWK
                   3883:       scripting you like to it, but be careful with quoting. </p>
                   3884: <p> For example, to get all files inside the
1.76      rillig   3885:       <code class="filename">libdata/foo</code> directory removed from the
1.75      rillig   3886:       resulting PLIST:</p>
                   3887: <pre class="programlisting">
                   3888:     PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
1.55      rillig   3889: </pre>
1.75      rillig   3890: <p> And to get all the <code class="varname">@dirrm</code> lines referring
                   3891:       to a specific (shared) directory converted to
                   3892:       <code class="varname">@comment</code>s: </p>
                   3893: <pre class="programlisting">
                   3894:     PRINT_PLIST_AWK+=       /^@dirrm share\/specific/ { print "@comment " $$0; next; }
1.51      rillig   3895: </pre>
1.75      rillig   3896: </div>
                   3897: <div class="sect1" lang="en">
                   3898: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3899: <a name="plist.misc"></a>11.4. Variable substitution in PLIST</h2></div></div></div>
1.75      rillig   3900: <p>
                   3901:       A number of variables are substituted automatically in PLISTs
                   3902:       when a package is installed on a system. This includes the
                   3903:       following variables: </p>
                   3904: <div class="variablelist"><dl>
                   3905: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
                   3906: <dd>
                   3907: <p>Some packages like emacs and perl embed information
                   3908:             about which architecture they were built on into the
                   3909:             pathnames where they install their files. To handle this
                   3910:             case, PLIST will be preprocessed before actually used, and
                   3911:             the symbol
                   3912:             &#8220;<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>&#8221; will be
                   3913:             replaced by what <span><strong class="command">uname -p</strong></span> gives. The
                   3914:             same is done if the string
                   3915:             <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
                   3916:             PLIST somewhere - use this on packages that have GNU
                   3917:             autoconf-created configure scripts.</p>
                   3918: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   3919: <h3 class="title">Legacy note</h3>
                   3920: <p>There used to be a symbol
                   3921:               &#8220;<span class="quote"><code class="varname">$ARCH</code></span>&#8221; that
                   3922:               was replaced by the output of <span><strong class="command">uname
                   3923:               -m</strong></span>, but that's no longer supported and has
                   3924:               been removed.</p>
                   3925: </div>
                   3926: </dd>
                   3927: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
                   3928: <dd>
                   3929: <p>Some packages want to embed the OS name and version
                   3930:             into some paths.  To do this, use these variables in the
1.76      rillig   3931:             <code class="filename">PLIST</code>:
1.75      rillig   3932:           </p>
                   3933: <div class="itemizedlist"><ul type="disc">
                   3934: <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>
                   3935: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. &#8220;<span class="quote">solaris</span>&#8221;)</p></li>
                   3936: <li><p><code class="varname">${OS_VERSION}</code> - &#8220;<span class="quote"><span><strong class="command">uname -r</strong></span></span>&#8221;</p></li>
                   3937: </ul></div>
                   3938: </dd>
                   3939: </dl></div>
                   3940: <p> For a complete list of values which are replaced by
1.76      rillig   3941:       default, please look in <code class="filename">bsd.pkg.mk</code> (and
1.75      rillig   3942:       search for <span class="emphasis"><em>PLIST_SUBST</em></span>). </p>
                   3943: <p> If you want to change other variables not listed above, you
                   3944:       can add variables and their expansions to this variable in the
1.77    ! rillig   3945:       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   3946: <pre class="programlisting">
                   3947:     PLIST_SUBST+=   SOMEVAR="somevalue"
1.1       grant    3948: </pre>
1.75      rillig   3949: <p>This replaces all occurrences of &#8220;<span class="quote">${SOMEVAR}</span>&#8221;
                   3950:       in the PLIST with &#8220;<span class="quote">somevalue</span>&#8221;.  </p>
                   3951: </div>
                   3952: <div class="sect1" lang="en">
                   3953: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3954: <a name="manpage-compression"></a>11.5. Man page compression</h2></div></div></div>
1.75      rillig   3955: <p>Man pages should be installed in compressed form if
1.76      rillig   3956:       <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
1.75      rillig   3957:       and uncompressed otherwise. To handle this in the
1.76      rillig   3958:       <code class="filename">PLIST</code> file, the suffix &#8220;<span class="quote">.gz</span>&#8221; is
1.75      rillig   3959:       appended/removed automatically for man pages according to
                   3960:       <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
                   3961:       or not, see above for details. This modification of the
1.76      rillig   3962:       <code class="filename">PLIST</code> file is done on a copy of it, not
                   3963:       <code class="filename">PLIST</code> itself.</p>
1.75      rillig   3964: </div>
                   3965: <div class="sect1" lang="en">
                   3966: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3967: <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   3968: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.75      rillig   3969:       in generating the binary package, set the variable
                   3970:       <code class="varname">PLIST_SRC</code> to the names of that file(s).
                   3971:       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
                   3972:       important.</p>
                   3973: </div>
                   3974: <div class="sect1" lang="en">
                   3975: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3976: <a name="platform-specific-plist"></a>11.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75      rillig   3977: <p>Some packages decide to install a different set of files based on
                   3978:       the operating system being used. These differences can be
                   3979:       automatically handled by using the following files:</p>
                   3980: <div class="itemizedlist"><ul type="disc">
1.76      rillig   3981: <li><p><code class="filename">PLIST.common</code></p></li>
                   3982: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
                   3983: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
                   3984: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
                   3985: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75      rillig   3986: </ul></div>
                   3987: </div>
                   3988: <div class="sect1" lang="en">
                   3989: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   3990: <a name="faq.common-dirs"></a>11.8. Sharing directories between packages</h2></div></div></div>
1.75      rillig   3991: <p> A &#8220;<span class="quote">shared directory</span>&#8221; is a directory where
                   3992:       multiple (and unrelated) packages install files.  These
                   3993:       directories are problematic because you have to add special tricks
                   3994:       in the PLIST to conditionally remove them, or have some
                   3995:       centralized package handle them. </p>
                   3996: <p> Within pkgsrc, you'll find both approaches.  If a directory
                   3997:       is shared by a few unrelated packages, it's often not worth to add
                   3998:       an extra package to remove it.  Therefore, one simply does:
                   3999:       </p>
                   4000: <pre class="programlisting">
                   4001:     @unexec ${RMDIR} %D/path/to/shared/directory 2&gt;/dev/null || ${TRUE}
1.1       grant    4002: </pre>
1.75      rillig   4003: <p> in the PLISTs of all affected packages, instead of the
                   4004:       regular "@dirrm" line. </p>
                   4005: <p> However, if the directory is shared across many packages, two
                   4006:       different solutions are available: </p>
                   4007: <div class="orderedlist"><ol type="1">
                   4008: <li><p> If the packages have a common dependency, the directory
                   4009:           can be removed in that.  For example, see
1.76      rillig   4010:           <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   4011:          removes the shared directory
1.76      rillig   4012:          <code class="filename">share/omf</code>. </p></li>
1.75      rillig   4013: <li><p> If the packages using the directory are not related at
                   4014:           all (they have no common dependencies), a *-dirs package is
                   4015:           used. </p></li>
                   4016: </ol></div>
                   4017: <p> From now on, we'll discuss the second solution.  To get an
                   4018:       idea of the *-dirs packages available, issue: </p>
                   4019: <pre class="programlisting">
                   4020:     <code class="prompt">%</code> cd .../pkgsrc
                   4021:     <code class="prompt">%</code> ls -d */*-dirs
1.1       grant    4022: </pre>
1.75      rillig   4023: <p> Their use from other packages is very simple.  The
                   4024:       <code class="varname">USE_DIRS</code> variable takes a list of package names
                   4025:       (without the &#8220;<span class="quote">-dirs</span>&#8221; part) together with the required
                   4026:       version number (always pick the latest one when writing new
                   4027:       packages). </p>
                   4028: <p> For example, if a package installs files under
1.76      rillig   4029:       <code class="filename">share/applications</code>, it should have the
1.75      rillig   4030:       following line in it:
                   4031:       </p>
                   4032: <pre class="programlisting">
                   4033:     USE_DIRS+=      xdg-1.1
1.1       grant    4034: </pre>
1.75      rillig   4035: <p> After regenerating the PLIST using <span><strong class="command">make
                   4036:       print-PLIST</strong></span>, you should get the right (commented out)
                   4037:       lines. </p>
                   4038: <p> Note that even if your package is using
1.76      rillig   4039:       <code class="filename">$X11BASE</code>, it must not depend on the
1.75      rillig   4040:       *-x11-dirs packages.  Just specify the name without that part and
1.76      rillig   4041:       pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
1.75      rillig   4042:       care of it. </p>
                   4043: </div>
                   4044: </div>
                   4045: <div class="chapter" lang="en">
                   4046: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   4047: <a name="buildlink"></a>Chapter 12. Buildlink methodology</h2></div></div></div>
1.75      rillig   4048: <div class="toc">
                   4049: <p><b>Table of Contents</b></p>
                   4050: <dl>
1.77    ! rillig   4051: <dt><span class="sect1"><a href="#converting-to-buildlink3">12.1. Converting packages to use buildlink3</a></span></dt>
        !          4052: <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   4053: <dd><dl>
1.77    ! rillig   4054: <dt><span class="sect2"><a href="#anatomy-of-bl3">12.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
        !          4055: <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   4056: </dl></dd>
1.77    ! rillig   4057: <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   4058: <dd><dl>
1.77    ! rillig   4059: <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>
        !          4060: <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   4061: </dl></dd>
                   4062: </dl>
                   4063: </div>
                   4064: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
                   4065:     are seen by a package's configure and build processes.  This is implemented
                   4066:     in a two step process:</p>
                   4067: <div class="orderedlist"><ol type="1">
                   4068: <li><p>Symlink headers and libraries for dependencies into
                   4069:        <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
                   4070:        of <code class="varname">WRKDIR</code>.</p></li>
                   4071: <li><p>Create wrapper scripts that are used in place of the normal compiler
                   4072:        tools that translate <code class="option">-I${LOCALBASE}/include</code> and
                   4073:        <code class="option">-L${LOCALBASE}/lib</code> into references to
                   4074:        <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
                   4075:         native compiler on some operating systems look like GCC, so that
                   4076:         packages that expect GCC won't require modifications to build with
                   4077:         those native compilers.</p></li>
                   4078: </ol></div>
                   4079: <p>This normalizes the environment in which a package is built so that the
                   4080:     package may be built consistently despite what other software may be
                   4081:     installed. Please note that the normal system header and library paths,
1.76      rillig   4082:     e.g. <code class="filename">/usr/include</code>,
                   4083:     <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
1.75      rillig   4084:     designed to insulate the package build from non-system-supplied
                   4085:     software. </p>
                   4086: <div class="sect1" lang="en">
                   4087: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   4088: <a name="converting-to-buildlink3"></a>12.1. Converting packages to use buildlink3</h2></div></div></div>
1.75      rillig   4089: <p>The process of converting packages to use the buildlink3
                   4090:       framework (&#8220;<span class="quote">bl3ifying</span>&#8221;) is fairly straightforward.
                   4091:       The things to keep in mind are:</p>
                   4092: <div class="orderedlist"><ol type="1">
                   4093: <li><p> Ensure that the build always calls the wrapper scripts
                   4094:           instead of the actual toolchain.  Some packages are tricky,
                   4095:           and the only way to know for sure is the check
1.76      rillig   4096:           <code class="filename">${WRKDIR}/.work.log</code> to see if the
1.75      rillig   4097:           wrappers are being invoked. </p></li>
                   4098: <li><p> Don't override <code class="varname">PREFIX</code> from within
                   4099:           the package Makefile, e.g. Java VMs, standalone shells,
                   4100:           etc., because the code to symlink files into
1.76      rillig   4101:           <code class="filename">${BUILDLINK_DIR}</code> looks for files
1.75      rillig   4102:           relative to &#8220;<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>&#8221;.
                   4103:          </p></li>
                   4104: <li><p> Remember that <span class="emphasis"><em>only</em></span> the
1.76      rillig   4105:           <code class="filename">buildlink3.mk</code> files that you list in a
1.75      rillig   4106:           package's Makefile are added as dependencies for that package.
                   4107:          </p></li>
                   4108: </ol></div>
                   4109: <p> If a dependency on a particular package is required for its libraries and
                   4110:       headers, then we replace: </p>
                   4111: <pre class="programlisting">
                   4112:     DEPENDS+=   foo&gt;=1.1.0:../../category/foo
1.1       grant    4113: </pre>
1.75      rillig   4114: <p>with</p>
                   4115: <pre class="programlisting">
                   4116:     .include "../../category/foo/buildlink3.mk"
1.1       grant    4117: </pre>
1.75      rillig   4118: <p>The buildlink3.mk files usually define the required dependencies.
                   4119:     If you need a newer version of the dependency when using buildlink3.mk
                   4120:     files, then you can define it in your Makefile; for example:
                   4121:     </p>
                   4122: <pre class="programlisting">
                   4123:     BUILDLINK_API_DEPENDS.foo+=   foo&gt;=1.1.0
                   4124:     .include "../../category/foo/buildlink3.mk"
1.1       grant    4125: </pre>
1.76      rillig   4126: <p>There are several <code class="filename">buildlink3.mk</code>
                   4127:       files in <code class="filename">pkgsrc/mk</code>
1.75      rillig   4128:       that handle special package issues:</p>
                   4129: <div class="itemizedlist"><ul type="disc">
1.76      rillig   4130: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.75      rillig   4131:           the native or a pkgsrc Berkeley DB implementation based on
                   4132:           the values of <code class="varname">BDB_ACCEPTED</code> and
                   4133:           <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76      rillig   4134: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.75      rillig   4135:           comes with neither Curses nor NCurses, this will take care
1.76      rillig   4136:          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>
                   4137: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.75      rillig   4138:           of <code class="varname">KRB5_ACCEPTED</code> to choose between
                   4139:          adding a dependency on Heimdal or MIT-krb5 for packages that
                   4140:           require a Kerberos 5 implementation.</p></li>
1.76      rillig   4141: <li><p><code class="filename">motif.buildlink3.mk</code> checks
1.75      rillig   4142:          for a system-provided
1.76      rillig   4143:          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
                   4144:          <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>
                   4145: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.75      rillig   4146:          variables that may be used by packages that use the
                   4147:          Open Sound System (OSS) API.</p></li>
1.76      rillig   4148: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.75      rillig   4149:         either Postgres 7.3 or 7.4, whichever is found installed. See
                   4150:         the file for more information. </p></li>
1.76      rillig   4151: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.75      rillig   4152:          <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
1.76      rillig   4153:          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>
                   4154: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.75      rillig   4155:          <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
                   4156:          library.</p></li>
                   4157: </ul></div>
1.76      rillig   4158: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.75      rillig   4159:       files provide a more complete
                   4160:       description of how to use them properly.</p>
                   4161: </div>
                   4162: <div class="sect1" lang="en">
                   4163: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   4164: <a name="creating-buildlink3.mk"></a>12.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.76      rillig   4165: <p> A package's <code class="filename">buildlink3.mk</code> file is
1.75      rillig   4166:       included by Makefiles to indicate the need to compile and link
                   4167:       against header files and libraries provided by the package.  A
1.76      rillig   4168:       <code class="filename">buildlink3.mk</code> file should always provide
1.75      rillig   4169:       enough information to add the correct type of dependency
                   4170:       relationship and include any other
1.76      rillig   4171:       <code class="filename">buildlink3.mk</code> files that it needs to find
1.75      rillig   4172:       headers and libraries that it needs in turn.</p>
1.76      rillig   4173: <p> To generate an initial <code class="filename">buildlink3.mk</code>
                   4174:       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   4175:       package is highly recommended.  For most packages, the following
                   4176:       command will generate a good starting point for
1.76      rillig   4177:       <code class="filename">buildlink3.mk</code> files:</p>
1.75      rillig   4178: <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>
                   4179: <code class="prompt">%</code> createbuildlink &gt;buildlink3.mk</code></strong></pre>
                   4180: <div class="sect2" lang="en">
                   4181: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4182: <a name="anatomy-of-bl3"></a>12.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75      rillig   4183: <p>The following real-life example
1.76      rillig   4184:         <code class="filename">buildlink3.mk</code> is taken
                   4185:         from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75      rillig   4186: <pre class="programlisting">
                   4187:     # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1       grant    4188: 
1.75      rillig   4189:     BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH}+
                   4190:     TIFF_BUILDLINK3_MK:=    ${TIFF_BUILDLINK3_MK}+
1.1       grant    4191: 
1.75      rillig   4192:     .if !empty(BUILDLINK_DEPTH:M+)
                   4193:     BUILDLINK_DEPENDS+=     tiff
                   4194:     .endif
1.1       grant    4195: 
1.75      rillig   4196:     BUILDLINK_PACKAGES:=    ${BUILDLINK_PACKAGES:Ntiff}
                   4197:     BUILDLINK_PACKAGES+=    tiff
1.1       grant    4198: 
1.75      rillig   4199:     .if !empty(TIFF_BUILDLINK3_MK:M+)
                   4200:     BUILDLINK_API_DEPENDS.tiff+=        tiff&gt;=3.6.1
                   4201:     BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
                   4202:     .endif  # TIFF_BUILDLINK3_MK
1.1       grant    4203: 
1.75      rillig   4204:     .include "../../devel/zlib/buildlink3.mk"
                   4205:     .include "../../graphics/jpeg/buildlink3.mk"
1.1       grant    4206: 
1.75      rillig   4207:     BUILDLINK_DEPTH:=       ${BUILDLINK_DEPTH:S/+$//}
1.1       grant    4208: </pre>
1.75      rillig   4209: <p> The header and footer manipulate
                   4210:         <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
1.76      rillig   4211:         <code class="filename">buildlink3.mk</code> files and is used to track
1.75      rillig   4212:         at what depth we are including
1.76      rillig   4213:         <code class="filename">buildlink3.mk</code> files.</p>
1.75      rillig   4214: <p> The first section controls if the dependency on
                   4215:         <em class="replaceable"><code>pkg</code></em> is added.
                   4216:         <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
                   4217:         packages for which dependencies are added by
                   4218:         buildlink3.</p>
                   4219: <p> The second section advises pkgsrc that the
1.76      rillig   4220:         <code class="filename">buildlink3.mk</code> file for
1.75      rillig   4221:         <em class="replaceable"><code>pkg</code></em> has been included at some point.
                   4222:         <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
1.76      rillig   4223:         packages for which <code class="filename">buildlink3.mk</code> files
1.75      rillig   4224:         have been included.  It must <span class="emphasis"><em>always</em></span> be
1.76      rillig   4225:         appended to within a <code class="filename">buildlink3.mk</code>
1.75      rillig   4226:         file. </p>
                   4227: <p> The third section is protected from multiple inclusion
                   4228:         and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
                   4229:         added.  Several important variables are set in the section:
                   4230:         </p>
                   4231: <div class="itemizedlist"><ul type="disc">
                   4232: <li><p> <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4233:            is the actual dependency recorded in the installed
                   4234:             package; this should always be set using
                   4235:            <span><strong class="command">+=</strong></span> to ensure that
                   4236:             we're appending to any pre-existing list of values.  This
                   4237:             variable should be set to the first version of the
                   4238:             package that had an API change.
                   4239:            </p></li>
                   4240: <li><p> <code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
                   4241:            is the location of the <em class="replaceable"><code>pkg</code></em>
                   4242:            pkgsrc directory.</p></li>
                   4243: <li><p>
                   4244:            <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
                   4245:            (not shown above) controls whether we use
                   4246:            <code class="varname">BUILD_DEPENDS</code> or
                   4247:            <code class="varname">DEPENDS</code> to add the dependency on
                   4248:            <em class="replaceable"><code>pkg</code></em>.
                   4249:            The build dependency is selected by setting
                   4250:            <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
                   4251:            to &#8220;<span class="quote">build</span>&#8221;.  By default, the
                   4252:            full dependency is used.
                   4253:            </p></li>
                   4254: <li><p>
                   4255:            <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
                   4256:            and
                   4257:            <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
                   4258:            (not shown above) are lists of subdirectories of
1.76      rillig   4259:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4260:            to add to the header and library search paths.  These
                   4261:            default to &#8220;<span class="quote">include</span>&#8221; and &#8220;<span class="quote">lib</span>&#8221;
                   4262:            respectively. </p></li>
                   4263: <li><p>
                   4264:            <code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
                   4265:            (not shown above) is the list of preprocessor flags to add
                   4266:            to <code class="varname">CPPFLAGS</code>, which are passed on to the
                   4267:            configure and build phases.  The &#8220;<span class="quote">-I</span>&#8221; option
                   4268:            should be avoided and instead be handled using
                   4269:            <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
                   4270:            above.</p></li>
                   4271: </ul></div>
                   4272: <p> The following variables are all optionally defined within
                   4273:        this second section (protected against multiple inclusion) and
                   4274:        control which package files are symlinked into
1.76      rillig   4275:        <code class="filename">${BUILDLINK_DIR}</code> and how their names are
1.75      rillig   4276:        transformed during the symlinking: </p>
                   4277: <div class="itemizedlist"><ul type="disc">
                   4278: <li><p>
                   4279:            <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
                   4280:            (not shown above) is a shell glob pattern relative to
1.76      rillig   4281:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4282:            to be symlinked into
1.76      rillig   4283:            <code class="filename">${BUILDLINK_DIR}</code>,
                   4284:            e.g. <code class="filename">include/*.h</code>. </p></li>
1.75      rillig   4285: <li><p>
                   4286:            <code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
                   4287:              (not shown above) is a shell pipeline that
                   4288:              outputs to stdout a list of files relative to
1.76      rillig   4289:              <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
1.75      rillig   4290:              The resulting files are to be symlinked
1.76      rillig   4291:              into <code class="filename">${BUILDLINK_DIR}</code>.  By default,
                   4292:              this takes the <code class="filename">+CONTENTS</code> of a
1.75      rillig   4293:              <em class="replaceable"><code>pkg</code></em> and filters it through
                   4294:              <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.
                   4295:            </p></li>
                   4296: <li><p>
                   4297:            <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
                   4298:            (not shown above) is a filter command that filters
1.76      rillig   4299:            <code class="filename">+CONTENTS</code> input into a list of files
1.75      rillig   4300:            relative to
1.76      rillig   4301:            <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75      rillig   4302:            on stdout.  By default for overwrite packages,
                   4303:            <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76      rillig   4304:            outputs the contents of the <code class="filename">include</code>
                   4305:            and <code class="filename">lib</code> directories in the package
                   4306:            <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75      rillig   4307:            it outputs any libtool archives in
1.76      rillig   4308:            <code class="filename">lib</code> directories.
1.75      rillig   4309:            </p></li>
                   4310: <li><p>
                   4311:            <code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
                   4312:            (not shown above) is a list of sed arguments used to
                   4313:            transform the name of the source filename into a
                   4314:            destination filename, e.g. <span><strong class="command">-e
                   4315:            "s|/curses.h|/ncurses.h|g"</strong></span>.
                   4316:            </p></li>
                   4317: </ul></div>
                   4318: <p> The last section includes any
1.76      rillig   4319:            <code class="filename">buildlink3.mk</code> needed for
1.75      rillig   4320:            <em class="replaceable"><code>pkg</code></em>'s library dependencies.
1.76      rillig   4321:            Including these <code class="filename">buildlink3.mk</code> files
1.75      rillig   4322:            means that the headers and libraries for these
                   4323:            dependencies are also symlinked into
1.76      rillig   4324:            <code class="filename">${BUILDLINK_DIR}</code>
1.75      rillig   4325:            whenever the <em class="replaceable"><code>pkg</code></em>
1.76      rillig   4326:            <code class="filename">buildlink3.mk</code>
1.75      rillig   4327:            file is included.
                   4328:            </p>
                   4329: </div>
                   4330: <div class="sect2" lang="en">
                   4331: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4332: <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   4333: <p>
                   4334:         The situation that requires increasing the dependency listed in
                   4335:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4336:        after a package update is when the API or interface to the
                   4337:        header files change.</p>
                   4338: <p> In this case,
                   4339:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4340:        should be adjusted to require at least the new package
                   4341:        version.  In some cases, the packages that depend on this new
                   4342:        version may need their <code class="varname">PKGREVISION</code>s
1.76      rillig   4343:        increased and, if they have <code class="filename">buildlink3.mk</code>
1.75      rillig   4344:        files, their
                   4345:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4346:        adjusted, too.  This is needed so pkgsrc will require the
                   4347:        correct package dependency and not settle for an older one
                   4348:        when building the source.</p>
                   4349: <p>
                   4350:        <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4351:        should be increased when the binary interface or sonames
                   4352:        (major number of the library version) of any installed
                   4353:        shared libraries change.  This is needed so that binary
                   4354:        packages made using it will require the correct package
                   4355:        dependency and not settle for an older one which will not
                   4356:        contain the necessary shared libraries. </p>
                   4357: <p>
1.77    ! rillig   4358:        See <a href="#dependencies" title="17.1.4. Handling dependencies">Section 17.1.4, &#8220;Handling dependencies&#8221;</a> for
1.75      rillig   4359:        more information about dependencies on other packages,
                   4360:        including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
                   4361:        <code class="varname">ABI_DEPENDS</code> definitions. </p>
                   4362: <p> Please take careful consideration before adjusting
                   4363:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4364:        or
                   4365:        <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4366:        as we don't want to cause unneeded package deletions and
                   4367:        rebuilds.  In many cases, new versions of packages work just
                   4368:        fine with older dependencies.</p>
                   4369: <p>
                   4370:        Also it is not needed to set
                   4371:        <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
                   4372:        when it is identical to
                   4373:        <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.       </p>
                   4374: </div>
                   4375: </div>
                   4376: <div class="sect1" lang="en">
                   4377: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   4378: <a name="writing-builtin.mk"></a>12.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.75      rillig   4379: <p>
                   4380:       Some packages in pkgsrc install headers and libraries that
                   4381:       coincide with headers and libraries present in the base system.
1.76      rillig   4382:       Aside from a <code class="filename">buildlink3.mk</code> file, these
                   4383:       packages should also include a <code class="filename">builtin.mk</code>
1.75      rillig   4384:       file that includes the necessary checks to decide whether using
                   4385:       the built-in software or the pkgsrc software is
                   4386:       appropriate. </p>
                   4387: <p> The only requirements of a builtin.mk file for
                   4388:       <em class="replaceable"><code>pkg</code></em> are:
                   4389:       </p>
                   4390: <div class="orderedlist"><ol type="1">
                   4391: <li><p> It should set
                   4392:           <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4393:           to either &#8220;<span class="quote">yes</span>&#8221; or &#8220;<span class="quote">no</span>&#8221;
                   4394:           after it is included.
                   4395:        </p></li>
                   4396: <li><p> It should <span class="emphasis"><em>not</em></span> override any
                   4397:           <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4398:           which is already set before the
1.76      rillig   4399:           <code class="filename">builtin.mk</code> file is included.
1.75      rillig   4400:        </p></li>
                   4401: <li><p> It should be written to allow multiple inclusion.  This
                   4402:           is <span class="emphasis"><em>very</em></span> important and takes careful
1.76      rillig   4403:           attention to <code class="filename">Makefile</code> coding.
1.75      rillig   4404:        </p></li>
                   4405: </ol></div>
                   4406: <div class="sect2" lang="en">
                   4407: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4408: <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   4409: <p>The following is the recommended template for builtin.mk
                   4410:         files: </p>
                   4411: <pre class="programlisting">
                   4412:     .if !defined(IS_BUILTIN.foo)
                   4413:     #
                   4414:     # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   4415:     # genuinely exists in the system or not.
                   4416:     #
                   4417:     IS_BUILTIN.foo?=        no
1.1       grant    4418: 
1.75      rillig   4419:     # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   4420:     # version can be determined.
                   4421:     #
                   4422:     .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   4423:     BUILTIN_PKG.foo?=       foo-1.0
                   4424:     .  endif
                   4425:     .endif  # IS_BUILTIN.foo
1.1       grant    4426: 
1.75      rillig   4427:     .if !defined(USE_BUILTIN.foo)
                   4428:     USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   4429:     .  if defined(BUILTIN_PKG.foo)
                   4430:     .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   4431:     .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   4432:     USE_BUILTIN.foo!=                                                       \
                   4433:           if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then     \
                   4434:                   ${ECHO} "yes";                                            \
                   4435:           else                                                              \
                   4436:                   ${ECHO} "no";                                             \
                   4437:           fi
                   4438:     .      endif
                   4439:     .    endfor
                   4440:     .  endif
                   4441:     .endif  # USE_BUILTIN.foo
1.1       grant    4442: 
1.75      rillig   4443:     CHECK_BUILTIN.foo?=     no
                   4444:     .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   4445:     #
                   4446:     # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   4447:     # "yes" or "no".
                   4448:     #
                   4449:     .endif  # CHECK_BUILTIN.foo
1.1       grant    4450: </pre>
1.75      rillig   4451: <p> The first section sets
                   4452:         <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4453:         depending on if <em class="replaceable"><code>pkg</code></em> really exists
                   4454:         in the base system.  This should not be a base system software
                   4455:         with similar functionality to <em class="replaceable"><code>pkg</code></em>;
                   4456:         it should only be &#8220;<span class="quote">yes</span>&#8221; if the actual package is
                   4457:         included as part of the base system.  This variable is only
1.76      rillig   4458:         used internally within the <code class="filename">builtin.mk</code>
1.75      rillig   4459:         file. </p>
                   4460: <p> The second section sets
                   4461:         <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
                   4462:         to the version of <em class="replaceable"><code>pkg</code></em> in the base
                   4463:         system if it exists (if
                   4464:         <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4465:         is &#8220;<span class="quote">yes</span>&#8221;).  This variable is only used internally
1.76      rillig   4466:         within the <code class="filename">builtin.mk</code> file. </p>
1.75      rillig   4467: <p> The third section sets
                   4468:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4469:         and is <span class="emphasis"><em>required</em></span> in all
1.76      rillig   4470:         <code class="filename">builtin.mk</code> files.  The code in this
1.75      rillig   4471:         section must make the determination whether the built-in
                   4472:         software is adequate to satisfy the dependencies listed in
                   4473:         <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
                   4474:         This is typically done by comparing
                   4475:         <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
                   4476:         against each of the dependencies in
                   4477:         <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
                   4478:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4479:         <span class="emphasis"><em>must</em></span> be set to the correct value by the
1.76      rillig   4480:         end of the <code class="filename">builtin.mk</code> file.  Note that
1.75      rillig   4481:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4482:         may be &#8220;<span class="quote">yes</span>&#8221; even if
                   4483:         <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4484:         is &#8220;<span class="quote">no</span>&#8221; because we may make the determination
                   4485:         that the built-in version of the software is similar enough to
                   4486:         be used as a replacement. </p>
                   4487: <p> The last section is guarded by
                   4488:         <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
                   4489:         and includes code that uses the value of
                   4490:         <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
                   4491:         set in the previous section.  This typically includes, e.g.,
                   4492:         adding additional dependency restrictions and listing
                   4493:         additional files to symlink into
1.76      rillig   4494:         <code class="filename">${BUILDLINK_DIR}</code> (via
1.75      rillig   4495:         <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).
                   4496:         </p>
                   4497: </div>
                   4498: <div class="sect2" lang="en">
                   4499: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4500: <a name="native-or-pkgsrc-preference"></a>12.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.75      rillig   4501: <p>
                   4502:         When building packages, it's possible to choose whether to set
                   4503:         a global preference for using either the built-in (native)
                   4504:         version or the pkgsrc version of software to satisfy a
                   4505:         dependency.  This is controlled by setting
                   4506:         <code class="varname">PREFER_PKGSRC</code> and
                   4507:         <code class="varname">PREFER_NATIVE</code>.  These variables take values
                   4508:         of either &#8220;<span class="quote">yes</span>&#8221;, &#8220;<span class="quote">no</span>&#8221;, or a list of
                   4509:         packages.  <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
                   4510:         use the pkgsrc versions of software, while
                   4511:         <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
                   4512:         built-in versions.  Preferences are determined by the most
                   4513:         specific instance of the package in either
                   4514:         <code class="varname">PREFER_PKGSRC</code> or
                   4515:         <code class="varname">PREFER_NATIVE</code>.  If a package is specified
                   4516:         in neither or in both variables, then
                   4517:         <code class="varname">PREFER_PKGSRC</code> has precedence over
                   4518:         <code class="varname">PREFER_NATIVE</code>.  For example, to require
                   4519:         using pkgsrc versions of software for all but the most basic
                   4520:         bits on a NetBSD system, you can set: </p>
                   4521: <pre class="programlisting">
                   4522:     PREFER_PKGSRC=  yes
                   4523:     PREFER_NATIVE=  getopt skey tcp_wrappers
1.1       grant    4524: </pre>
1.75      rillig   4525: <p> A package <span class="emphasis"><em>must</em></span> have a
1.76      rillig   4526:         <code class="filename">builtin.mk</code>
1.75      rillig   4527:         file to be listed in <code class="varname">PREFER_NATIVE</code>,
                   4528:         otherwise it is simply ignored in that list.
                   4529:        </p>
                   4530: </div>
                   4531: </div>
                   4532: </div>
                   4533: <div class="chapter" lang="en">
                   4534: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   4535: <a name="pkginstall"></a>Chapter 13. The pkginstall framework</h2></div></div></div>
1.75      rillig   4536: <div class="toc">
                   4537: <p><b>Table of Contents</b></p>
                   4538: <dl>
1.77    ! rillig   4539: <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   4540: <dd><dl>
1.77    ! rillig   4541: <dt><span class="sect2"><a href="#dirs-outside-prefix">13.1.1. Directory manipulation</a></span></dt>
        !          4542: <dt><span class="sect2"><a href="#files-outside-prefix">13.1.2. File manipulation</a></span></dt>
1.75      rillig   4543: </dl></dd>
1.77    ! rillig   4544: <dt><span class="sect1"><a href="#conf-files">13.2. Configuration files</a></span></dt>
1.75      rillig   4545: <dd><dl>
1.77    ! rillig   4546: <dt><span class="sect2"><a href="#conf-files-sysconfdir">13.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
        !          4547: <dt><span class="sect2"><a href="#conf-files-configure">13.2.2. Telling the software where configuration files are</a></span></dt>
        !          4548: <dt><span class="sect2"><a href="#conf-files-patching">13.2.3. Patching installations</a></span></dt>
        !          4549: <dt><span class="sect2"><a href="#conf-files-disable">13.2.4. Disabling handling of configuration files</a></span></dt>
        !          4550: </dl></dd>
        !          4551: <dt><span class="sect1"><a href="#rcd-scripts">13.3. System startup scripts</a></span></dt>
        !          4552: <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>
        !          4553: <dt><span class="sect1"><a href="#users-and-groups">13.4. System users and groups</a></span></dt>
        !          4554: <dt><span class="sect1"><a href="#shells">13.5. System shells</a></span></dt>
        !          4555: <dd><dl><dt><span class="sect2"><a href="#shells-disable">13.5.1. Disabling shell registration</a></span></dt></dl></dd>
        !          4556: <dt><span class="sect1"><a href="#fonts">13.6. Fonts</a></span></dt>
        !          4557: <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   4558: </dl>
                   4559: </div>
                   4560: <p>This chapter describes the framework known as
                   4561: <code class="literal">pkginstall</code>, whose key features are:</p>
                   4562: <div class="itemizedlist"><ul type="disc">
                   4563: <li><p>Generic installation and manipulation of directories and files
                   4564:     outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
                   4565: <li><p>Automatic handling of configuration files during installation,
                   4566:     provided that packages are correctly designed.</p></li>
                   4567: <li><p>Generation and installation of system startup scripts.</p></li>
                   4568: <li><p>Registration of system users and groups.</p></li>
                   4569: <li><p>Registration of system shells.</p></li>
                   4570: <li><p>Automatic updating of fonts databases.</p></li>
                   4571: </ul></div>
                   4572: <p>The following sections inspect each of the above points in detail.</p>
                   4573: <p>You may be thinking that many of the things described here could be
                   4574: easily done with simple code in the package's post-installation target
                   4575: (<code class="literal">post-install</code>).  <span class="emphasis"><em>This is incorrect</em></span>,
                   4576: as the code in them is only executed when building from source.  Machines
                   4577: using binary packages could not benefit from it at all (as the code itself
                   4578: could be unavailable).  Therefore, the only way to achieve any of the items
                   4579: described above is by means of the installation scripts, which are
                   4580: automatically generated by pkginstall.</p>
                   4581: <div class="sect1" lang="en">
                   4582: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   4583: <a name="files-and-dirs-outside-prefix"></a>13.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76      rillig   4584: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75      rillig   4585: of files and directories that belong to a package.  The names used in it
1.76      rillig   4586: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75      rillig   4587: which means that it cannot register files outside this directory (absolute
                   4588: path names are not allowed).  Despite this restriction, some packages need
                   4589: to install files outside this location; e.g., under
1.76      rillig   4590: <code class="filename">${VARBASE}</code> or
                   4591: <code class="filename">${PKG_SYSCONFDIR}</code>.</p>
1.75      rillig   4592: <p>The only way to achieve this is to create such files during
                   4593: installation time by using the installation scripts.  These scripts can run
                   4594: arbitrary commands, so they have the potential to create and manage files
                   4595: anywhere in the file system.  Here is where pkginstall comes into play: it
                   4596: provides generic scripts to abstract the manipulation of such files and
                   4597: directories based on variables set in the package's
1.76      rillig   4598: <code class="filename">Makefile</code>.  The rest of this section describes these
1.75      rillig   4599: variables.</p>
                   4600: <div class="sect2" lang="en">
                   4601: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4602: <a name="dirs-outside-prefix"></a>13.1.1. Directory manipulation</h3></div></div></div>
1.75      rillig   4603: <p>The following variables can be set to request the creation of
                   4604: directories anywhere in the file system:</p>
                   4605: <div class="itemizedlist"><ul type="disc">
                   4606: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
                   4607:     contain a list of directories that should be created and should attempt
                   4608:     to be destroyed by the installation scripts.  The difference between
                   4609:     the two is that the latter prompts the administrator to remove any
                   4610:     directories that may be left after deinstallation (because they were
                   4611:     not empty), while the former does not.</p></li>
                   4612: <li>
                   4613: <p><code class="varname">MAKE_DIRS_PERMS</code> and
                   4614:     <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
                   4615:     which directories should be created and should attempt to be destroyed
                   4616:     by the installation scripts.  Each tuple holds the following values,
                   4617:     separated by spaces: the directory name, its owner, its group and its
                   4618:     numerical mode.  For example:</p>
                   4619: <pre class="programlisting">
                   4620:     MAKE_DIRS_PERMS+=         ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1       grant    4621: </pre>
1.75      rillig   4622: <p>The difference between the two is exactly the same as their
                   4623:     non-<code class="varname">PERMS</code> counterparts.</p>
                   4624: </li>
                   4625: </ul></div>
                   4626: </div>
                   4627: <div class="sect2" lang="en">
                   4628: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4629: <a name="files-outside-prefix"></a>13.1.2. File manipulation</h3></div></div></div>
1.75      rillig   4630: <p>Creating non-empty files outside the installation prefix is tricky
1.76      rillig   4631: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75      rillig   4632: To overcome this problem, the only solution is to extract the file in the
                   4633: known place (i.e., inside the installation prefix) and copy it to the
                   4634: appropriate location during installation (done by the installation scripts
                   4635: generated by pkginstall).  We will call the former the <span class="emphasis"><em>master
                   4636: file</em></span> in the following paragraphs, which describe the variables
                   4637: that can be used to automatically and consistently handle files outside the
                   4638: installation prefix:</p>
                   4639: <div class="itemizedlist"><ul type="disc">
                   4640: <li>
                   4641: <p><code class="varname">CONF_FILES</code> and
                   4642:     <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
                   4643:     During installation time, the master file is copied to the target one
                   4644:     if and only if the latter does not exist.  Upon deinstallation, the
                   4645:     target file is removed provided that it was not modified by the
                   4646:     installation.</p>
                   4647: <p>The difference between the two is that the latter prompts the
                   4648:     administrator to remove any files that may be left after
                   4649:     deinstallation (because they were not empty), while the former does
                   4650:     not.</p>
                   4651: </li>
                   4652: <li>
                   4653: <p><code class="varname">CONF_FILES_PERMS</code> and
                   4654:     <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
                   4655:     files as well as their target locations.  For each of them, it also
                   4656:     specifies their owner, their group and their numeric permissions, in
                   4657:     this order.  For example:</p>
                   4658: <pre class="programlisting">
                   4659:     SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1       grant    4660: </pre>
1.75      rillig   4661: <p>The difference between the two is exactly the same as their
                   4662:     non-<code class="varname">PERMS</code> counterparts.</p>
                   4663: </li>
                   4664: </ul></div>
                   4665: </div>
                   4666: </div>
                   4667: <div class="sect1" lang="en">
                   4668: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   4669: <a name="conf-files"></a>13.2. Configuration files</h2></div></div></div>
1.75      rillig   4670: <p>Configuration files are special in the sense that they are installed
                   4671: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
                   4672: need special treatment during installation (most of which is automated by
                   4673: pkginstall).  The main concept you must bear in mind is that files marked
                   4674: as configuration files are automatically copied to the right place (somewhere
                   4675: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
                   4676: and only if</em></span> they didn't exist before.  Similarly, they will not
                   4677: be removed if they have local modifications.  This ensures that
                   4678: administrators never lose any custom changes they may have made.</p>
                   4679: <div class="sect2" lang="en">
                   4680: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4681: <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   4682: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
                   4683: specifies where configuration files shall be installed.  Its contents are
                   4684: set based upon the following variables:</p>
                   4685: <div class="itemizedlist"><ul type="disc">
                   4686: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76      rillig   4687:     directory.  Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75      rillig   4688:     be overridden by the user to point to his preferred location (e.g.,
1.76      rillig   4689:     <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75      rillig   4690:     Packages must not use it directly.</p></li>
                   4691: <li>
                   4692: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
                   4693:     <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
                   4694:     for the package being built shall be installed.  The definition of this
                   4695:     variable only makes sense in the package's
1.76      rillig   4696:     <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75      rillig   4697: <p>As an example, consider the Apache package,
1.76      rillig   4698:     <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   4699:     configuration files under the
1.76      rillig   4700:     <code class="filename">httpd/</code> subdirectory of
1.75      rillig   4701:     <code class="varname">PKG_SYSCONFBASE</code>.  This should be set in the package
                   4702:     Makefile.</p>
                   4703: </li>
                   4704: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
                   4705:     variable that holds this package's configuration directory (if
                   4706:     different from <code class="varname">PKG_SYSCONFBASE</code>).  It defaults to
                   4707:     <code class="varname">PKGBASE</code>'s value, and is always prefixed with
                   4708:     <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
                   4709: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
                   4710:     directory where the configuration files for the package identified by
                   4711:     <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
                   4712: </ul></div>
                   4713: <p>Based on the above variables, pkginstall determines the value of
                   4714: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
                   4715: variable that can be used within a package to refer to its configuration
                   4716: directory.  The algorithm used to set its value is basically the
                   4717: following:</p>
                   4718: <div class="orderedlist"><ol type="1">
                   4719: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
                   4720:     its value is used.</p></li>
                   4721: <li><p>If the previous variable is not defined but
                   4722:     <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76      rillig   4723:     <code class="filename">Makefile</code>, the resulting value is
                   4724:     <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75      rillig   4725: <li><p>Otherwise, it is set to
1.76      rillig   4726:     <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75      rillig   4727: </ol></div>
1.76      rillig   4728: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.77    ! rillig   4729: 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   4730: </div>
                   4731: <div class="sect2" lang="en">
                   4732: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4733: <a name="conf-files-configure"></a>13.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75      rillig   4734: <p>Given that pkgsrc (and users!) expect configuration files to be in a
                   4735: known place, you need to teach each package where it shall install its
                   4736: files.  In some cases you will have to patch the package Makefiles to
                   4737: achieve it.  If you are lucky, though, it may be as easy as passing an
                   4738: extra flag to the configuration script; this is the case of GNU Autoconf-
                   4739: generated files:</p>
                   4740: <pre class="programlisting">
                   4741:     CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1       grant    4742: </pre>
1.75      rillig   4743: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
                   4744: for</em></span> its configuration files, not where they will be originally
                   4745: installed (although the difference is never explicit,
                   4746: unfortunately).</p>
                   4747: </div>
                   4748: <div class="sect2" lang="en">
                   4749: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4750: <a name="conf-files-patching"></a>13.2.3. Patching installations</h3></div></div></div>
1.75      rillig   4751: <p>As said before, pkginstall automatically handles configuration files.
                   4752: This means that <span class="strong"><strong>the packages themselves must not
1.76      rillig   4753: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75      rillig   4754: directly</strong></span>.  Bad news is that many software installation scripts
                   4755: will, out of the box, mess with the contents of that directory.  So what is
                   4756: the correct procedure to fix this issue?</p>
                   4757: <p>You must teach the package (usually by manually patching it) to
                   4758: install any configuration files under the examples hierarchy,
1.76      rillig   4759: <code class="filename">share/examples/${PKGBASE}/</code>.  This way, the
                   4760: <code class="filename">PLIST</code> registers them and the administrator always
1.75      rillig   4761: has the original copies available.</p>
                   4762: <p>Once the required configuration files are in place (i.e., under the
                   4763: examples hierarchy), the pkginstall framework can use them as master copies
                   4764: during the package installation to update what is in
1.76      rillig   4765: <code class="filename">${PKG_SYSCONFDIR}</code>.  To achieve this, the variables
1.75      rillig   4766: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.77    ! rillig   4767: 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   4768: about their syntax and their purpose.  Here is an example, taken from the
1.76      rillig   4769: <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   4770: <pre class="programlisting">
                   4771:     EGDIR=        ${PREFIX}/share/doc/mutt/samples
                   4772:     CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1       grant    4773: </pre>
1.75      rillig   4774: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
                   4775: package and has no meaning outside it.</p>
                   4776: </div>
                   4777: <div class="sect2" lang="en">
                   4778: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4779: <a name="conf-files-disable"></a>13.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75      rillig   4780: <p>The automatic copying of config files can be toggled by setting the
                   4781: environment variable <code class="varname">PKG_CONFIG</code> prior to package
                   4782: installation.</p>
                   4783: </div>
                   4784: </div>
                   4785: <div class="sect1" lang="en">
                   4786: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   4787: <a name="rcd-scripts"></a>13.3. System startup scripts</h2></div></div></div>
1.75      rillig   4788: <p>System startup scripts are special files because they must be
                   4789: installed in a place known by the underlying OS, usually outside the
1.77    ! rillig   4790: 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   4791: can be used.  However, pkginstall provides a special mechanism to handle
                   4792: these files.</p>
                   4793: <p>In order to provide system startup scripts, the package has
                   4794: to:</p>
                   4795: <div class="orderedlist"><ol type="1">
1.76      rillig   4796: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75      rillig   4797:     the <code class="literal">.sh</code> suffix appended.  Considering the
1.76      rillig   4798:     <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
                   4799:     <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75      rillig   4800: <li>
                   4801: <p>Tell pkginstall to handle it, appending the name of the script,
                   4802:     without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
                   4803:     Continuing the previous example:</p>
                   4804: <pre class="programlisting">
                   4805:     RCD_SCRIPTS+=   cupsd
1.1       grant    4806: </pre>
1.75      rillig   4807: </li>
                   4808: </ol></div>
                   4809: <p>Once this is done, pkginstall will do the following steps for each
                   4810: script in an automated fashion:</p>
                   4811: <div class="orderedlist"><ol type="1">
                   4812: <li><p>Process the file found in the files directory applying all the
1.76      rillig   4813:     substitutions described in the <code class="filename">FILES_SUBST</code>
1.75      rillig   4814:     variable.</p></li>
                   4815: <li><p>Copy the script from the files directory to the examples
1.76      rillig   4816:     hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>.  Note
1.75      rillig   4817:     that this master file must be explicitly registered in the
1.76      rillig   4818:     <code class="filename">PLIST</code>.</p></li>
1.75      rillig   4819: <li><p>Add code to the installation scripts to copy the startup script
                   4820:     from the examples hierarchy into the system-wide startup scripts
                   4821:     directory.</p></li>
                   4822: </ol></div>
                   4823: <div class="sect2" lang="en">
                   4824: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4825: <a name="rcd-scripts-disable"></a>13.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75      rillig   4826: <p>The automatic copying of config files can be toggled by setting the
                   4827: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
                   4828: installation.  Note that the scripts will be always copied inside the
1.76      rillig   4829: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75      rillig   4830: matter what the value of this variable is.</p>
                   4831: </div>
                   4832: </div>
                   4833: <div class="sect1" lang="en">
                   4834: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   4835: <a name="users-and-groups"></a>13.4. System users and groups</h2></div></div></div>
1.75      rillig   4836: <p>If a package needs to create special users and/or groups during
                   4837: installation, it can do so by using the pkginstall framework.</p>
                   4838: <p>Users can be created by adding entries to the
                   4839: <code class="varname">PKG_USERS</code> variable.  Each entry has the following
                   4840: syntax:</p>
                   4841: <pre class="programlisting">
                   4842:     user:group
1.1       grant    4843: </pre>
1.75      rillig   4844: <p>Further specification of user details may be done by setting per-user
                   4845: variables.
                   4846: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the numeric
                   4847: UID for the user.
                   4848: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the user's
                   4849: description or comment.
                   4850: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the user's
1.76      rillig   4851: home directory, and defaults to <code class="filename">/nonexistent</code> if not
1.75      rillig   4852: specified.
                   4853: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the user's
1.76      rillig   4854: shell, and defaults to <code class="filename">/sbinno/login</code> if not specified.
1.75      rillig   4855: </p>
                   4856: <p>Similarly, groups can be created by adding entries to the
                   4857: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
                   4858: <pre class="programlisting">
                   4859:     group
1.1       grant    4860: </pre>
1.75      rillig   4861: <p>The numeric GID of the group may be set by defining 
                   4862: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
                   4863: <p>If a package needs to create the users and groups at an earlier
                   4864: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
                   4865: either <code class="literal">configure</code> or <code class="literal">build</code> to
                   4866: indicate the phase before which the users and groups are created.  In
                   4867: this case, the numeric UIDs and GIDs of the created users and groups
                   4868: are automatically hardcoded into the final installation scripts.</p>
                   4869: </div>
                   4870: <div class="sect1" lang="en">
                   4871: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   4872: <a name="shells"></a>13.5. System shells</h2></div></div></div>
1.75      rillig   4873: <p>Packages that install system shells should register them in the shell
1.76      rillig   4874: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75      rillig   4875: administrator.  This must be done from the installation scripts to keep
                   4876: binary packages working on any system.  pkginstall provides an easy way to
                   4877: accomplish this task.</p>
                   4878: <p>When a package provides a shell interpreter, it has to set the
                   4879: <code class="varname">PKG_SHELL</code> variable to its absolute file name.  This will
                   4880: add some hooks to the installation scripts to handle it.  Consider the
1.76      rillig   4881: 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   4882: <pre class="programlisting">
                   4883:     PKG_SHELL=      ${PREFIX}/bin/zsh
1.1       grant    4884: </pre>
1.75      rillig   4885: <div class="sect2" lang="en">
                   4886: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4887: <a name="shells-disable"></a>13.5.1. Disabling shell registration</h3></div></div></div>
1.75      rillig   4888: <p>The automatic registration of shell interpreters can be disabled by
1.76      rillig   4889: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75      rillig   4890: environment variable to <code class="literal">NO</code>.</p>
                   4891: </div>
                   4892: </div>
                   4893: <div class="sect1" lang="en">
                   4894: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   4895: <a name="fonts"></a>13.6. Fonts</h2></div></div></div>
1.75      rillig   4896: <p>Packages that install X11 fonts should update the database files
                   4897: that index the fonts within each fonts directory.  This can easily be
                   4898: accomplished within the pkginstall framework.</p>
                   4899: <p>When a package installs X11 fonts, it must list the directories in
                   4900: which fonts are installed in the
                   4901: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
                   4902: where <em class="replaceable"><code>type</code></em> can be one of &#8220;<span class="quote">ttf</span>&#8221;,
                   4903: &#8220;<span class="quote">type1</span>&#8221; or &#8220;<span class="quote">x11</span>&#8221;.  This will add hooks to the
                   4904: installation scripts to run the appropriate commands to update the fonts
                   4905: database files within each of those directories.  For convenience, if the
                   4906: directory path is relative, it is taken to be relative to the package's
1.76      rillig   4907: 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   4908: <pre class="programlisting">
                   4909:     FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1       grant    4910: </pre>
1.75      rillig   4911: <div class="sect2" lang="en">
                   4912: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   4913: <a name="fonts-disable"></a>13.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75      rillig   4914: <p>The automatic update of fonts databases can be disabled by
1.76      rillig   4915: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75      rillig   4916: environment variable to <code class="literal">NO</code>.</p>
                   4917: </div>
                   4918: </div>
                   4919: </div>
                   4920: <div class="chapter" lang="en">
                   4921: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   4922: <a name="options"></a>Chapter 14. Options handling</h2></div></div></div>
1.75      rillig   4923: <div class="toc">
                   4924: <p><b>Table of Contents</b></p>
                   4925: <dl>
1.77    ! rillig   4926: <dt><span class="sect1"><a href="#global-default-options">14.1. Global default options</a></span></dt>
        !          4927: <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>
        !          4928: <dt><span class="sect1"><a href="#option-names">14.3. Option Names</a></span></dt>
1.75      rillig   4929: </dl>
                   4930: </div>
                   4931: <p>Many packages have the ability to be built to support different
1.76      rillig   4932: sets of features.  <code class="filename">bsd.options.mk</code> is a framework
1.75      rillig   4933: in pkgsrc that provides generic handling of those options that
                   4934: determine different ways in which the packages can be built.  It's
                   4935: possible for the user to specify exactly which sets of options will be
                   4936: built into a package or to allow a set of global default options
                   4937: apply.</p>
                   4938: <div class="sect1" lang="en">
                   4939: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   4940: <a name="global-default-options"></a>14.1. Global default options</h2></div></div></div>
1.75      rillig   4941: <p>Global default options are listed in
                   4942: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
                   4943: that should be built into every package if that option is supported.
1.76      rillig   4944: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75      rillig   4945: </div>
                   4946: <div class="sect1" lang="en">
                   4947: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   4948: <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   4949: <p>The following example shows how
1.76      rillig   4950: <code class="filename">bsd.options.mk</code> should be used
1.75      rillig   4951: by the hypothetical ``wibble'' package, either in the package
1.76      rillig   4952: <code class="filename">Makefile</code>, or in a file,
                   4953: e.g. <code class="filename">options.mk</code>, that is included by the
                   4954: main package <code class="filename">Makefile</code>.</p>
1.75      rillig   4955: <pre class="programlisting">
                   4956:     PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   4957:     PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   4958:     PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   4959:     PKG_OPTIONS_GROUP.database=     mysql pgsql
                   4960:     PKG_SUGGESTED_OPTIONS=          wibble-foo
                   4961:     PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   4962:     PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
1.1       grant    4963: 
1.75      rillig   4964:     .include "../../mk/bsd.prefs.mk"
1.69      rillig   4965: 
1.75      rillig   4966:     # this package was previously named wibble2
                   4967:     .if defined(PKG_OPTIONS.wibble2)
                   4968:     PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   4969:     PKG_OPTIONS_DEPRECATED_WARNINGS+= \
                   4970:             "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR instead."
                   4971:     .endif
1.69      rillig   4972: 
1.75      rillig   4973:     .include "../../mk/bsd.options.mk"
1.69      rillig   4974: 
1.75      rillig   4975:     # Package-specific option-handling
1.69      rillig   4976: 
1.75      rillig   4977:     ###
                   4978:     ### FOO support
                   4979:     ###
                   4980:     .if !empty(PKG_OPTIONS:Mwibble-foo)
                   4981:     CONFIGURE_ARGS+=    --enable-foo
                   4982:     .endif
1.69      rillig   4983: 
1.75      rillig   4984:     ###
                   4985:     ### LDAP support
                   4986:     ###
                   4987:     .if !empty(PKG_OPTIONS:Mldap)
1.77    ! rillig   4988:     .  include "../../databases/openldap-client/buildlink3.mk"
        !          4989:     CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75      rillig   4990:     .endif
1.69      rillig   4991: 
1.75      rillig   4992:     ###
                   4993:     ### database support
                   4994:     ###
                   4995:     .if !empty(PKG_OPTIONS:Mmysql)
                   4996:     .  include "../../mk/mysql.buildlink3.mk"
                   4997:     .endif
                   4998:     .if !empty(PKG_OPTIONS:Mpgsql)
                   4999:     .  include "../../mk/pgsql.buildlink3.mk"
                   5000:     .endif
                   5001: </pre>
                   5002: <p>The first section contains the information about which build
                   5003: options are supported by the package, and any default options settings
                   5004: if needed.</p>
                   5005: <div class="orderedlist"><ol type="1">
                   5006: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
                   5007: <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
                   5008: options.  It should be set to
                   5009: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>.  Do not set it to
                   5010: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is set after
                   5011: <code class="varname">PKG_OPTIONS_VAR</code> is used.</p></li>
                   5012: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
                   5013: build options supported by the package.</p></li>
                   5014: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
                   5015: list of names of groups of mutually exclusive options.  The options in
                   5016: each group are listed in
                   5017: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
                   5018: The most specific setting of any option from the group takes
                   5019: precedence over all other options in the group.  Options from the
                   5020: groups will be automatically added to
                   5021: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
                   5022: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
                   5023: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
                   5024: packages will fail if no option from the group is
                   5025: selected.</p></li>
                   5026: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
                   5027: of names of sets of options.  At least one option from each set must
                   5028: be selected.  The options in each set are listed in
                   5029: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
                   5030: Options from the sets will be automatically added to
                   5031: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.  Building the package will
                   5032: fail if no option from the set is selected.</p></li>
                   5033: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
                   5034: build options which are enabled by default.</p></li>
                   5035: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
                   5036: of
                   5037: &#8220;<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>&#8221;
1.76      rillig   5038: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75      rillig   5039: their option counterparts.  Pairs should be added with
                   5040: &#8220;<span class="quote">+=</span>&#8221; to keep the listing of global legacy variables.  A
                   5041: warning will be issued if the user uses a legacy
                   5042: variable.</p></li>
                   5043: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
                   5044: of
                   5045: &#8220;<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>&#8221;
                   5046: pairs that map options that have been renamed to their new
                   5047: counterparts.  Pairs should be added with &#8220;<span class="quote">+=</span>&#8221; to keep
                   5048: the listing of global legacy options.  A warning will be issued if
                   5049: the user uses a legacy option.</p></li>
                   5050: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
                   5051: options implied by deprecated variables used.  This can be used for
                   5052: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
                   5053: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
                   5054: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
                   5055: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
                   5056: a list of warnings about deprecated variables or options used, and
                   5057: what to use instead.</p></li>
                   5058: </ol></div>
                   5059: <p>A package should never modify
                   5060: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
                   5061: <code class="varname">PKG_OPTIONS_VAR</code>.  These are strictly user-settable.
                   5062: To suggest a default set of options, use
                   5063: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
                   5064: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76      rillig   5065: including <code class="filename">bsd.options.mk</code>.  If none of
1.75      rillig   5066: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
                   5067: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
                   5068: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
                   5069: happen with platform-specific options if none of them is supported on
                   5070: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
                   5071: empty list and the package is otherwise treated as not using the
                   5072: options framework.</p>
1.76      rillig   5073: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75      rillig   5074: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
                   5075: build options, properly filtered to remove unsupported and duplicate
                   5076: options.</p>
                   5077: <p>The remaining sections contain the logic that is specific to
                   5078: each option.  The correct way to check for an option is to check
                   5079: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
                   5080: <pre class="programlisting">
                   5081:     .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
                   5082: </pre>
                   5083: </div>
                   5084: <div class="sect1" lang="en">
                   5085: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5086: <a name="option-names"></a>14.3. Option Names</h2></div></div></div>
1.75      rillig   5087: <p>Options that enable similar features in different packages (like
                   5088: optional support for a library) should use a common name in all
                   5089: packages that support it (like the name of the library).  If another
                   5090: package already has an option with the same meaning, use the same
                   5091: name.</p>
                   5092: <p>Options that enable features specific to one package, where it's
                   5093: unlikely that another (unrelated) package has the same (or a similar)
                   5094: optional feature, should use a name prefixed with
                   5095: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
                   5096: <p>If a group of related packages share an optional feature
                   5097: specific to that group, prefix it with the name of the
                   5098: &#8220;<span class="quote">main</span>&#8221; package
                   5099: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
                   5100: <p>For new options, add a line to
1.76      rillig   5101: <code class="filename">mk/defaults/options.description</code>.  Lines have two
1.75      rillig   5102: fields, separated by tab.  The first field is the option name, the
                   5103: second its description.  The description should be a whole sentence
                   5104: (starting with an uppercase letter and ending with a period) that
                   5105: describes what enabling the option does.  E. g. &#8220;<span class="quote">Enable ispell
                   5106: support.</span>&#8221; The file is sorted by option names.</p>
                   5107: </div>
                   5108: </div>
                   5109: <div class="chapter" lang="en">
                   5110: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   5111: <a name="build"></a>Chapter 15. The build process</h2></div></div></div>
1.75      rillig   5112: <div class="toc">
                   5113: <p><b>Table of Contents</b></p>
                   5114: <dl>
1.77    ! rillig   5115: <dt><span class="sect1"><a href="#build.intro">15.1. Introduction</a></span></dt>
        !          5116: <dt><span class="sect1"><a href="#build.prefix">15.2. Program location</a></span></dt>
        !          5117: <dt><span class="sect1"><a href="#build.builddirs">15.3. Directories used during the build process</a></span></dt>
        !          5118: <dt><span class="sect1"><a href="#build.running">15.4. Running a phase</a></span></dt>
        !          5119: <dt><span class="sect1"><a href="#build.fetch">15.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
        !          5120: <dt><span class="sect1"><a href="#build.checksum">15.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
        !          5121: <dt><span class="sect1"><a href="#build.extract">15.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
        !          5122: <dt><span class="sect1"><a href="#build.patch">15.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
        !          5123: <dt><span class="sect1"><a href="#build.tools">15.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
        !          5124: <dt><span class="sect1"><a href="#build.wrapper">15.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
        !          5125: <dt><span class="sect1"><a href="#build.configure">15.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
        !          5126: <dt><span class="sect1"><a href="#build.build">15.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
        !          5127: <dt><span class="sect1"><a href="#build.test">15.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
        !          5128: <dt><span class="sect1"><a href="#build.install">15.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
        !          5129: <dt><span class="sect1"><a href="#build.package">15.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
        !          5130: <dt><span class="sect1"><a href="#build.helpful-targets">15.16. Other helpful targets</a></span></dt>
1.75      rillig   5131: </dl>
                   5132: </div>
                   5133: <div class="sect1" lang="en">
                   5134: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5135: <a name="build.intro"></a>15.1. Introduction</h2></div></div></div>
1.75      rillig   5136: <p>This chapter gives a detailed description on how a package is
                   5137: built. Building a package is separated into different
                   5138: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
                   5139: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
                   5140: described in the following sections. Each phase is splitted into
                   5141: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
                   5142: containing phase, prefixed by one of <code class="varname">pre-</code>,
                   5143: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
                   5144: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
                   5145: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
                   5146: <p>The basic steps for building a program are always the same.  First
                   5147: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
                   5148: the local system and then extracted. After any pkgsrc-specific patches
                   5149: to compile properly are applied, the software can be configured, then
                   5150: built (usually by compiling), and finally the generated binaries, etc.
                   5151: can be put into place on the system.</p>
                   5152: </div>
                   5153: <div class="sect1" lang="en">
                   5154: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5155: <a name="build.prefix"></a>15.2. Program location</h2></div></div></div>
1.75      rillig   5156: <p>Before outlining the process performed by the NetBSD package system in
                   5157:       the next section, here's a brief discussion on where programs are
                   5158:       installed, and which variables influence this.</p>
                   5159: <p>The automatic variable <code class="varname">PREFIX</code> indicates
                   5160:       where all files of the final program shall be installed. It is
                   5161:       usually set to <code class="varname">LOCALBASE</code>
1.76      rillig   5162:       (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.75      rillig   5163:       for pkgs in the &#8220;<span class="quote">cross</span>&#8221; category.  The value of
                   5164:       <code class="varname">PREFIX</code> needs to be put
                   5165:       into the various places in the program's source where paths to
1.77    ! rillig   5166:       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   5167: <p>When choosing which of these variables to use,
                   5168:       follow the following rules:</p>
                   5169: <div class="itemizedlist"><ul type="disc">
                   5170: <li><p><code class="varname">PREFIX</code> always points to the location where the current
                   5171:          pkg will be installed.  When referring to a pkg's own installation path,
                   5172:          use &#8220;<span class="quote">${PREFIX}</span>&#8221;.</p></li>
                   5173: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs are installed.
                   5174:          If you need to construct a -I or -L argument to the compiler to find
                   5175:          includes and libraries installed by another non-X11 pkg, use
                   5176:          &#8220;<span class="quote">${LOCALBASE}</span>&#8221;.</p></li>
                   5177: <li><p><code class="varname">X11BASE</code> is where the actual X11 distribution (from
                   5178:          xsrc, etc.) is installed. When looking for
                   5179:          <span class="emphasis"><em>standard</em></span> X11 includes (not
                   5180:          those installed by a pkg), use &#8220;<span class="quote">${X11BASE}</span>&#8221;.</p></li>
                   5181: <li>
                   5182: <p>X11-based packages are special in that they may be installed in
                   5183:          either <code class="varname">X11BASE</code> or <code class="varname">LOCALBASE</code>.</p>
                   5184: <p>Usually, X11 packages should be installed under
                   5185:          <code class="varname">LOCALBASE</code> whenever possible.  Note that you will
1.76      rillig   5186:          need to include <code class="filename">../../mk/x11.buildlink3.mk</code>
1.75      rillig   5187:          in them to request the
                   5188:          presence of X11 and to get the right compilation flags.</p>
                   5189: <p>Even though, there are some packages that cannot be installed
                   5190:          under <code class="varname">LOCALBASE</code>: those that come with app-defaults
                   5191:          files. These packages are special and they must be placed under
                   5192:          <code class="varname">X11BASE</code>. To accomplish this, set either
                   5193:          <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
                   5194:          your package.</p>
                   5195: <p>Some notes: If you need
                   5196:          to find includes or libraries installed by a pkg that has
                   5197:          <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
1.76      rillig   5198:          its pkg <code class="filename">Makefile</code>, you need to look in
                   5199:          <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
                   5200:          <code class="filename">${LOCALBASE}</code>. To force installation of
1.75      rillig   5201:          all X11 packages in <code class="varname">LOCALBASE</code>, the
1.76      rillig   5202:          <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   5203:          is enabled by default.</p>
                   5204: </li>
                   5205: <li><p><code class="varname">X11PREFIX</code> should be used to refer to the installed
                   5206:          location of an X11 package. <code class="varname">X11PREFIX</code> will be set to
                   5207:          <code class="varname">X11BASE</code> if xpkgwedge is not installed,
                   5208:          and to <code class="varname">LOCALBASE</code> if xpkgwedge is installed.</p></li>
                   5209: <li>
                   5210: <p>If xpkgwedge is installed, it is possible to have some packages installed
                   5211:          in <code class="varname">X11BASE</code> and some in <code class="varname">LOCALBASE</code>.
                   5212:          To determine the prefix of an installed package, the
                   5213:          <code class="varname">EVAL_PREFIX</code> definition can be used. It takes pairs in the
                   5214:          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
                   5215:          <code class="varname">DIRNAME</code> will be set to the prefix of the installed
                   5216:          package &lt;package&gt;, or &#8220;<span class="quote">${X11PREFIX}</span>&#8221; if the package is
                   5217:          not installed.</p>
                   5218: <p>This is best illustrated by example.</p>
                   5219: <p>The following lines are taken from
1.76      rillig   5220:          <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75      rillig   5221: <pre class="programlisting">
                   5222:     EVAL_PREFIX+=           GTKDIR=gtk+
                   5223:     CONFIGURE_ARGS+=        --with-guile-prefix=${LOCALBASE:Q}
                   5224:     CONFIGURE_ARGS+=        --with-gtk-prefix=${GTKDIR:Q}
                   5225:     CONFIGURE_ARGS+=        --enable-multibyte
                   5226: </pre>
                   5227: <p>Specific defaults can be defined for the packages evaluated using
                   5228:          <code class="varname">EVAL_PREFIX</code>, by using a definition of the form:</p>
                   5229: <pre class="programlisting">
                   5230:     GTKDIR_DEFAULT= ${LOCALBASE}
                   5231: </pre>
                   5232: <p>where <code class="varname">GTKDIR</code> corresponds
                   5233:          to the first definition in
                   5234:          the <code class="varname">EVAL_PREFIX</code> pair.</p>
                   5235: </li>
1.76      rillig   5236: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.75      rillig   5237:           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   5238:           manual pages go into <code class="filename">${PREFIX}/man</code>, not
                   5239:           <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75      rillig   5240: </ul></div>
                   5241: </div>
                   5242: <div class="sect1" lang="en">
                   5243: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5244: <a name="build.builddirs"></a>15.3. Directories used during the build process</h2></div></div></div>
1.75      rillig   5245: <p>When building a package, a number of directories is used to store
                   5246: source files, temporary files, pkgsrc-internal files, and so on. These
                   5247: directories are explained here.</p>
                   5248: <p>Some of the directory variables contain relative pathnames. There
                   5249: are two common base directories for these relative directories:
                   5250: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
                   5251: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
                   5252: inside the package itself.</p>
                   5253: <div class="variablelist"><dl>
                   5254: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
                   5255: <dd><p>This is an absolute pathname that points to the pkgsrc
                   5256: root directory. Generally, you don't need
                   5257: it.</p></dd>
                   5258: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
                   5259: <dd><p>This is a pathname relative to
                   5260: <code class="varname">PKGSRCDIR</code> that points to the current
                   5261: package.</p></dd>
                   5262: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
                   5263: <dd><p>This is an absolute pathname pointing to the directory
                   5264: where all work takes place. The distfiles are extraced to this
                   5265: directory. It also contains temporary directories and log files used by
                   5266: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
                   5267: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
                   5268: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
                   5269: <dd><p>This is an absolute pathname pointing to the directory
                   5270: where the distfiles are extracted. It is usually a direct subdirectory
                   5271: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
                   5272: that isn't hidden. This variable may be changed by a package
1.76      rillig   5273: <code class="filename">Makefile</code>.</p></dd>
1.75      rillig   5274: </dl></div>
                   5275: </div>
                   5276: <div class="sect1" lang="en">
                   5277: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5278: <a name="build.running"></a>15.4. Running a phase</h2></div></div></div>
1.75      rillig   5279: <p>You can run a particular phase by typing <span><strong class="command">make
                   5280: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
                   5281: phase. This will automatically run all phases that are required for this
                   5282: phase. The default phase is <code class="varname">build</code>, that is, when you
                   5283: run <span><strong class="command">make</strong></span> without parameters in a package directory,
                   5284: the package will be built, but not installed.</p>
                   5285: </div>
                   5286: <div class="sect1" lang="en">
                   5287: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5288: <a name="build.fetch"></a>15.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.75      rillig   5289: <p>This will check if the file(s) given in the variables
                   5290:            <code class="varname">DISTFILES</code> and <code class="varname">PATCHFILES</code> (as
                   5291:            defined in the package's Makefile) are present on the
1.76      rillig   5292:            local system in <code class="filename">/usr/pkgsrc/distfiles</code>. If they
1.75      rillig   5293:            are not present, an attempt will be made to fetch them using commands
                   5294:            of the form:</p>
                   5295: <pre class="programlisting">
                   5296:     ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
                   5297: </pre>
                   5298: <p>where ${site} varies through several possibilities in turn: first,
                   5299:            <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the sites
                   5300:            specified in either <code class="varname">SITES.file</code> if defined, else
                   5301:            <code class="varname">MASTER_SITES</code> or <code class="varname">PATCH_SITES</code>, as
                   5302:            applies, then finally the value of
                   5303:            <code class="varname">MASTER_SITE_BACKUP</code>. The order of all except the
                   5304:            first can be optionally sorted by the user, via setting either
                   5305:            <code class="varname">MASTER_SORT_AWK</code> or
                   5306:            <code class="varname">MASTER_SORT_REGEX</code>.</p>
                   5307: </div>
                   5308: <div class="sect1" lang="en">
                   5309: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5310: <a name="build.checksum"></a>15.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.75      rillig   5311: <p>After the distfile(s) are fetched, their checksum is generated and
                   5312:            compared with the checksums stored in the distinfo file. If the
                   5313:            checksums don't match, the build is aborted. This is to ensure the same
                   5314:            distfile is used for building, and that the distfile wasn't changed,
                   5315:            e.g. by some malign force, deliberately changed distfiles on the master
                   5316:            distribution site or network lossage.</p>
                   5317: </div>
                   5318: <div class="sect1" lang="en">
                   5319: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5320: <a name="build.extract"></a>15.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75      rillig   5321: <p>When the distfiles are present on the local system, they
                   5322:        need to be extracted, as they usually come in the form of some
                   5323:        compressed archive format.</p>
                   5324: <p>By default, all <code class="varname">DISTFILES</code> are
                   5325:        extracted. If you only need some of them, you can set the
                   5326:        <code class="varname">EXTRACT_ONLY</code> variable to the list of those
                   5327:        files.</p>
                   5328: <p>Extracting the files is usually done by a little program,
1.76      rillig   5329:        <code class="filename">mk/scripts/extract</code>, which already knows how
1.75      rillig   5330:        to extract various archive formats, so most likely you will not
                   5331:        need to change anything here. But if you need, the following
                   5332:        variables may help you:</p>
                   5333: <div class="variablelist"><dl>
                   5334: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
                   5335: <dd><p>Use these variables to override the default
                   5336:        options for an extract command, which are defined in
1.76      rillig   5337:        <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75      rillig   5338: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
                   5339: <dd><p>This variable can be set to
                   5340:        <code class="literal">pax</code>, <code class="literal">tar</code> or an absolute
                   5341:        pathname pointing to the command with which tar archives should
                   5342:        be extracted.</p></dd>
                   5343: </dl></div>
1.76      rillig   5344: <p>If the <code class="filename">extract</code> program doesn't serve
1.75      rillig   5345:        your needs, you can also override the
                   5346:        <code class="varname">EXTRACT_CMD</code> variable, which holds the command
                   5347:        used for extracting the files. This command is executed in the
1.76      rillig   5348:        <code class="filename">${WRKSRC}</code> directory. During execution of
1.75      rillig   5349:        this command, the shell variable <code class="varname">extract_file</code>
                   5350:        holds the absolute pathname of the file that is going to be
                   5351:        extracted.</p>
                   5352: <p>And if that still does not suffice, you can override the
                   5353:        <code class="varname">do-extract</code> target in the package
                   5354:        Makefile.</p>
                   5355: </div>
                   5356: <div class="sect1" lang="en">
                   5357: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5358: <a name="build.patch"></a>15.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75      rillig   5359: <p>After extraction, all the patches named by the
                   5360:            <code class="varname">PATCHFILES</code>, those present in the patches
                   5361:            subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
1.76      rillig   5362:            <code class="filename">/usr/local/patches/graphics/png</code>) are applied.
                   5363:            Patchfiles ending in <code class="filename">.Z</code> or
                   5364:            <code class="filename">.gz</code> are uncompressed before they are applied,
                   5365:            files ending in <code class="filename">.orig</code> or
                   5366:            <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   5367:            can be handed in <code class="varname">PATCH_DIST_ARGS</code>.
1.77    ! rillig   5368:            See <a href="#components.patches" title="9.3. patches/*">Section 9.3, &#8220;patches/*&#8221;</a> for more details.</p>
1.75      rillig   5369: <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
                   5370:            patches apply with some lines of fuzz. Please fix (regen) the patches
                   5371:            so that they apply cleanly. The rationale behind this is that
                   5372:            patches that don't apply cleanly may end up being applied in the wrong
                   5373:            place, and cause severe harm there.</p>
                   5374: </div>
                   5375: <div class="sect1" lang="en">
                   5376: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5377: <a name="build.tools"></a>15.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.75      rillig   5378: <p>This is covered in
1.77    ! rillig   5379: <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   5380: </p>
                   5381: </div>
                   5382: <div class="sect1" lang="en">
                   5383: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5384: <a name="build.wrapper"></a>15.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75      rillig   5385: <p>This phase creates wrapper programs for the compilers and
                   5386:        linkers. The following variables can be used to tweak the
                   5387:        wrappers.</p>
                   5388: <div class="variablelist"><dl>
                   5389: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
                   5390: <dd><p>The command used to print progress
                   5391:                messages. Does nothing by default. Set to
                   5392:                <code class="literal">${ECHO}</code> to see the progress
                   5393:                messages.</p></dd>
                   5394: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
                   5395: <dd><p>This variable can be set to
                   5396:                <code class="literal">yes</code> (default) or
                   5397:                <code class="literal">no</code>, depending on whether you want
                   5398:                additional information in the wrapper log
                   5399:                file.</p></dd>
                   5400: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
                   5401: <dd><p>This variable can be set to
                   5402:                <code class="literal">yes</code> or <code class="literal">no</code>,
                   5403:                depending on whether the wrapper should use its cache,
                   5404:                which will improve the speed. The default value is
                   5405:                <code class="literal">yes</code>, but is forced to
                   5406:                <code class="literal">no</code> if the platform does not support
                   5407:                it.</p></dd>
                   5408: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
                   5409: <dd><p>A list of reordering commands. A
                   5410:                reordering command has the form
                   5411:                <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
                   5412:                It ensures that that
                   5413:                <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code>
                   5414:                occurs before
                   5415:                <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
                   5416:                </p></dd>
                   5417: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
                   5418: <dd><p>A list of transformation commands. [TODO:
                   5419:                investigate further]</p></dd>
                   5420: </dl></div>
                   5421: </div>
                   5422: <div class="sect1" lang="en">
                   5423: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5424: <a name="build.configure"></a>15.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75      rillig   5425: <p>Most pieces of software need information on the header files,
                   5426: system calls, and library routines which are available on the platform
                   5427: they run on. The process of determining this information is known as
                   5428: configuration, and is usually automated. In most cases, a script is
                   5429: supplied with the distfiles, and its invocation results in generation of
                   5430: header files, Makefiles, etc.</p>
                   5431: <p>If the package contains a configure script, this can be invoked by
                   5432: setting <code class="varname">HAS_CONFIGURE</code> to &#8220;<span class="quote">yes</span>&#8221;. If the
                   5433: configure script is a GNU autoconf script, you should set
                   5434: <code class="varname">GNU_CONFIGURE</code> to &#8220;<span class="quote">yes</span>&#8221; instead. What
                   5435: happens in the <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
                   5436: <pre class="programlisting">
                   5437:     .for d in ${CONFIGURE_DIRS}
                   5438:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${CONFIGURE_ENV} \
                   5439:                 ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
                   5440:     .endfor
                   5441: </pre>
                   5442: <p><code class="varname">CONFIGURE_DIRS</code> (default: &#8220;<span class="quote">.</span>&#8221;) is a
                   5443: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
                   5444: these directories, the configure script is run with the environment
                   5445: <code class="varname">CONFIGURE_ENV</code> and arguments
                   5446: <code class="varname">CONFIGURE_ARGS</code>. The variables
                   5447: <code class="varname">CONFIGURE_ENV</code>, <code class="varname">CONFIGURE_SCRIPT</code>
                   5448: (default: &#8220;<span class="quote">./configure</span>&#8221;) and
                   5449: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
                   5450: package.</p>
1.76      rillig   5451: <p>If the program uses an <code class="filename">Imakefile</code> for
1.75      rillig   5452: configuration, the appropriate steps can be invoked by setting
                   5453: <code class="varname">USE_IMAKE</code> to &#8220;<span class="quote">yes</span>&#8221;. (If you only want
                   5454: the package installed in <code class="varname">${X11PREFIX}</code> but xmkmf not
                   5455: being run, set <code class="varname">USE_X11BASE</code> instead.)</p>
                   5456: </div>
                   5457: <div class="sect1" lang="en">
                   5458: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5459: <a name="build.build"></a>15.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.75      rillig   5460: <p>For building a package, a rough equivalent of the following code
                   5461: is executed.</p>
                   5462: <pre class="programlisting">
                   5463:     .for d in ${BUILD_DIRS}
                   5464:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${MAKE_ENV} \
                   5465:                 ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
                   5466:                     -f ${MAKEFILE} ${BUILD_TARGET}
                   5467:     .endfor
                   5468: </pre>
                   5469: <p><code class="varname">BUILD_DIRS</code> (default: &#8220;<span class="quote">.</span>&#8221;) is a
                   5470: list of pathnames relative to <code class="varname">WRKSRC</code>. In each of
                   5471: these directories, <code class="varname">MAKE_PROGRAM</code> is run with the
                   5472: environment <code class="varname">MAKE_ENV</code> and arguments
                   5473: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
                   5474: <code class="varname">MAKE_ENV</code>, <code class="varname">BUILD_MAKE_FLAGS</code>,
                   5475: <code class="varname">MAKEFILE</code> and <code class="varname">BUILD_TARGET</code> may all
                   5476: be changed by the package.</p>
                   5477: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
                   5478: &#8220;<span class="quote">gmake</span>&#8221; if <code class="varname">USE_TOOLS</code> contains
                   5479: &#8220;<span class="quote">gmake</span>&#8221;, &#8220;<span class="quote">make</span>&#8221; otherwise. The default value
                   5480: of <code class="varname">MAKEFILE</code> is &#8220;<span class="quote">Makefile</span>&#8221;, and
                   5481: <code class="varname">BUILD_TARGET</code> defaults to &#8220;<span class="quote">all</span>&#8221;.</p>
                   5482: </div>
                   5483: <div class="sect1" lang="en">
                   5484: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5485: <a name="build.test"></a>15.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75      rillig   5486: <p>[TODO]</p>
                   5487: </div>
                   5488: <div class="sect1" lang="en">
                   5489: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5490: <a name="build.install"></a>15.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75      rillig   5491: <p>Once the build stage has completed, the final step is to
                   5492:        install the software in public directories, so users can access
                   5493:        the programs and files.</p>
                   5494: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
                   5495:        equivalent of the following code is executed. Additionally,
                   5496:        before and after this code, much magic is performed to do
                   5497:        consistency checks, registering the package, and so on.</p>
                   5498: <pre class="programlisting">
                   5499:     .for d in ${INSTALL_DIRS}
                   5500:             cd ${WRKSRC} &amp;&amp; cd ${d} &amp;&amp; env ${MAKE_ENV} \
                   5501:                 ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
                   5502:                     -f ${MAKEFILE} ${BUILD_TARGET}
                   5503:     .endfor
                   5504: </pre>
                   5505: <p>The variable's meanings are analogous to the ones in the
                   5506:        <span class="emphasis"><em>build</em></span> phase.
                   5507:        <code class="varname">INSTALL_DIRS</code> defaults to
                   5508:        <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
                   5509:        is &#8220;<span class="quote">install</span>&#8221; by default, plus
                   5510:        &#8220;<span class="quote">install.man</span>&#8221; if <code class="varname">USE_IMAKE</code> is
                   5511:        defined.</p>
                   5512: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
                   5513:        variables are useful. They are all variations of the
                   5514:        <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
                   5515:        permissions preset. <code class="varname">INSTALL</code> is the plain
                   5516:        install command. The specialized variants, together with their
                   5517:        intended use, are:</p>
                   5518: <div class="variablelist"><dl>
                   5519: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
                   5520: <dd><p>directories that contain binaries</p></dd>
                   5521: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
                   5522: <dd><p>directories that contain scripts</p></dd>
                   5523: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
                   5524: <dd><p>directories that contain shared and static libraries</p></dd>
                   5525: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
                   5526: <dd><p>directories that contain data files</p></dd>
                   5527: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
                   5528: <dd><p>directories that contain man pages</p></dd>
                   5529: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
                   5530: <dd><p>binaries that can be stripped from debugging symbols</p></dd>
                   5531: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
                   5532: <dd><p>binaries that cannot be stripped</p></dd>
                   5533: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
                   5534: <dd><p>game binaries</p></dd>
                   5535: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
                   5536: <dd><p>shared and static libraries</p></dd>
                   5537: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
                   5538: <dd><p>data files</p></dd>
                   5539: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
                   5540: <dd><p>data files for games</p></dd>
                   5541: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
                   5542: <dd><p>man pages</p></dd>
                   5543: </dl></div>
                   5544: <p>Some other variables are:</p>
                   5545: <div class="variablelist"><dl>
                   5546: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
                   5547: <dd><p>A list of directories relative to
                   5548:                <code class="varname">PREFIX</code> that are created by pkgsrc at
                   5549:                the beginning of the <span class="emphasis"><em>install</em></span> phase. If
                   5550:                this variable is set,
                   5551:                <code class="varname">NO_MTREE</code>=&#8220;<span class="quote">yes</span>&#8221; is
                   5552:                assumed, which means that the package claims to create
                   5553:                all needed directories itself before installing files to
                   5554:                it. Therefore this variable should only be set in
1.76      rillig   5555:                <code class="filename">Makefile</code>s that are under control of
1.75      rillig   5556:                the package's author.</p></dd>
                   5557: </dl></div>
                   5558: </div>
                   5559: <div class="sect1" lang="en">
                   5560: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5561: <a name="build.package"></a>15.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.75      rillig   5562: <p>[TODO]</p>
                   5563: </div>
                   5564: <div class="sect1" lang="en">
                   5565: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5566: <a name="build.helpful-targets"></a>15.16. Other helpful targets</h2></div></div></div>
1.75      rillig   5567: <div class="variablelist"><dl>
                   5568: <dt><span class="term">pre/post-*</span></dt>
                   5569: <dd><p>For any of the main targets described in the previous section, two
                   5570:            auxiliary targets exist with &#8220;<span class="quote">pre-</span>&#8221; and
                   5571:            &#8220;<span class="quote">post-</span>&#8221; used as a prefix
                   5572:            for the main target's name.  These targets are invoked before and
                   5573:            after the main target is called, allowing extra configuration or
                   5574:            installation steps be performed from a package's Makefile, for
                   5575:            example, which a program's configure script
                   5576:            or install target omitted.</p></dd>
                   5577: <dt><span class="term">do-*</span></dt>
                   5578: <dd><p>Should one of the main targets do the wrong thing, and should there
                   5579:            be no variable to fix this, you can redefine it with the do-*
                   5580:            target.  (Note that redefining the target itself instead of the
                   5581:            do-* target is a bad idea, as the pre-* and post-* targets won't be
                   5582:            called anymore, etc.) You will not usually need to do this.</p></dd>
                   5583: <dt><span class="term">reinstall</span></dt>
                   5584: <dd><p>If you did a <span><strong class="command">make install</strong></span> and you noticed some file
                   5585:            was not installed properly, you can repeat the installation with this
                   5586:            target, which will ignore the &#8220;<span class="quote">already installed</span>&#8221; flag.</p></dd>
                   5587: <dt><span class="term">deinstall</span></dt>
                   5588: <dd>
                   5589: <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,
                   5590:            effectively de-installing the package. The following variables can
                   5591:            be used to tune the behaviour:</p>
                   5592: <div class="variablelist"><dl>
                   5593: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
                   5594: <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>
                   5595: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
                   5596: <dd><p>Remove all packages that require (depend on) the given package.
                   5597:                  This can be used to remove any packages that may have been pulled in
                   5598:                  by a given package, e.g. if <span><strong class="command">make deinstall
                   5599:                    DEINSTALLDEPENDS=1</strong></span> is done in
1.76      rillig   5600:                  <code class="filename">pkgsrc/x11/kde</code>, this is likely to remove whole
1.75      rillig   5601:                  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>
                   5602: </dl></div>
                   5603: </dd>
                   5604: <dt><span class="term">update</span></dt>
                   5605: <dd>
                   5606: <p>This target causes the current package to be updated to the latest
                   5607:            version.  The package and all depending packages first get de-installed,
                   5608:            then current versions of the corresponding packages get compiled and
                   5609:            installed.  This is similar to manually noting which packages are
                   5610:            currently installed, then performing a series of <span><strong class="command">make
                   5611:              deinstall</strong></span> and <span><strong class="command">make install</strong></span> (or whatever
                   5612:            <code class="varname">UPDATE_TARGET</code> is set to) for these packages.</p>
                   5613: <p>You can use the &#8220;<span class="quote">update</span>&#8221; target to resume package
                   5614:            updating in case a previous <span><strong class="command">make update</strong></span> was interrupted
                   5615:            for some reason.  However, in this case, make sure you don't call
                   5616:            <span><strong class="command">make clean</strong></span> or otherwise remove the list of dependent
                   5617:            packages in <code class="varname">WRKDIR</code>.  Otherwise, you lose the
                   5618:            ability to automatically update the current package along with the
                   5619:            dependent packages you have installed.</p>
                   5620: <p>Resuming an interrupted <span><strong class="command">make update</strong></span> will only work as
                   5621:            long as the package tree remains unchanged.  If the source code for
                   5622:            one of the packages to be updated has been changed, resuming
                   5623:            <span><strong class="command">make update</strong></span> will most certainly fail!</p>
                   5624: <p>The following variables can be used either on the command line or in
1.76      rillig   5625:            <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75      rillig   5626:            <span><strong class="command">make update</strong></span>:</p>
                   5627: <div class="variablelist"><dl>
                   5628: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
                   5629: <dd><p>Install target to recursively use for the updated package and the
                   5630:                  dependent packages.  Defaults to <code class="varname">DEPENDS_TARGET</code> if set,
                   5631:                  &#8220;<span class="quote">install</span>&#8221; otherwise for <span><strong class="command">make update</strong></span>.
                   5632:                  e.g. <span><strong class="command">make update UPDATE_TARGET=package</strong></span></p></dd>
                   5633: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
                   5634: <dd><p>Don't clean up after updating.  Useful if you want to leave the
                   5635:                  work sources of the updated packages around for inspection or
                   5636:                  other purposes.  Be sure you eventually clean up the source
                   5637:                  tree (see the &#8220;<span class="quote">clean-update</span>&#8221; target below) or you may
                   5638:                  run into troubles with old source code still lying around on your
                   5639:                  next <span><strong class="command">make</strong></span> or <span><strong class="command">make update</strong></span>.</p></dd>
                   5640: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
                   5641: <dd><p>Deinstall each package before installing (making
                   5642:                  <code class="varname">DEPENDS_TARGET</code>). This may be necessary if the
                   5643:                  &#8220;<span class="quote">clean-update</span>&#8221; target (see below) was called after
                   5644:                  interrupting a running <span><strong class="command">make update</strong></span>.</p></dd>
                   5645: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
                   5646: <dd><p>Allows you to disable recursion and hardcode the target for
                   5647:                  packages.  The default is &#8220;<span class="quote">update</span>&#8221; for the update target,
                   5648:                  facilitating a recursive update of prerequisite packages.
                   5649:                  Only set <code class="varname">DEPENDS_TARGET</code> if you want to disable
                   5650:                  recursive updates. Use <code class="varname">UPDATE_TARGET</code> instead to just
                   5651:                  set a specific target for each package to be installed during
                   5652:                  <span><strong class="command">make update</strong></span> (see above).</p></dd>
                   5653: </dl></div>
                   5654: </dd>
                   5655: <dt><span class="term">clean-update</span></dt>
                   5656: <dd>
                   5657: <p>Clean the source tree for all packages that would get updated if
                   5658:            <span><strong class="command">make update</strong></span> was called from the current directory.
                   5659:            This target should not be used if the current package (or any of its
                   5660:            depending packages) have already been de-installed (e.g., after calling
                   5661:            <span><strong class="command">make update</strong></span>) or you may lose some packages you intended
                   5662:            to update. As a rule of thumb: only use this target
                   5663:            <span class="emphasis"><em>before</em></span> the first time you run
                   5664:            <span><strong class="command">make update</strong></span> and only if you have a dirty package tree
                   5665:            (e.g., if you used <code class="varname">NOCLEAN</code>).</p>
                   5666: <p>If you are unsure about whether your tree is clean, you can either
                   5667:            perform a <span><strong class="command">make clean</strong></span> at the top of the tree, or use
                   5668:            the following sequence of commands from the directory of the package
                   5669:            you want to update (<span class="emphasis"><em>before</em></span> running
                   5670:            <span><strong class="command">make update</strong></span> for the first time, otherwise you lose
                   5671:            all the packages you wanted to update!):</p>
                   5672: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
                   5673: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
                   5674: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong></pre>
                   5675: <p>The following variables can be used either on the command line or in
1.76      rillig   5676:            <code class="filename">/etc/mk.conf</code> to alter the behaviour of
1.75      rillig   5677:            <span><strong class="command">make clean-update</strong></span>:</p>
                   5678: <div class="variablelist"><dl>
                   5679: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
                   5680: <dd><p>After <span><strong class="command">make clean</strong></span>, do not reconstruct the list of
                   5681:                  directories to update for this package.  Only use this if <span><strong class="command">make
                   5682:                    update</strong></span> successfully installed all packages you wanted to
                   5683:                  update.  Normally, this is done automatically on <span><strong class="command">make
                   5684:                    update</strong></span>, but may have been suppressed by the
                   5685:                  <code class="varname">NOCLEAN</code> variable (see above).</p></dd>
                   5686: </dl></div>
                   5687: </dd>
                   5688: <dt><span class="term">info</span></dt>
                   5689: <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
                   5690:            package. You can use this to check which version of a package is
                   5691:            installed.</p></dd>
                   5692: <dt><span class="term">readme</span></dt>
1.76      rillig   5693: <dd><p>This target generates a <code class="filename">README.html</code> file, which
1.75      rillig   5694:            can be viewed using a browser such as
1.76      rillig   5695:            <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/mozilla/README.html" target="_top"><code class="filename">www/mozilla</code></a> or
                   5696:            <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   5697:            The generated files contain references to any
                   5698:            packages which are in the <code class="varname">PACKAGES</code> directory on
                   5699:            the local host. The generated files can be made to refer to URLs based on
                   5700:            <code class="varname">FTP_PKG_URL_HOST</code> and
                   5701:            <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I wanted to generate
1.76      rillig   5702:            <code class="filename">README.html</code> files which pointed to binary packages
1.75      rillig   5703:            on the local machine, in the directory
1.76      rillig   5704:            <code class="filename">/usr/packages</code>, set
1.75      rillig   5705:            <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
                   5706:            <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
                   5707:            <code class="varname">${PACKAGES}</code> directory and its subdirectories will be
                   5708:            searched for all the binary packages.</p></dd>
                   5709: <dt><span class="term">readme-all</span></dt>
1.76      rillig   5710: <dd><p>Use this target to create a file <code class="filename">README-all.html</code>
1.75      rillig   5711:            which contains a list of all packages currently available in the NetBSD
                   5712:            Packages Collection, together with the category they belong to and a
                   5713:            short description. This file is compiled from the
1.76      rillig   5714:            <code class="filename">pkgsrc/*/README.html</code> files, so be sure to run
1.75      rillig   5715:            this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make readme</strong></span>.</p></dd>
                   5716: <dt><span class="term">cdrom-readme</span></dt>
                   5717: <dd><p>This is very much the same as the &#8220;<span class="quote">readme</span>&#8221; target (see
                   5718:            above), but is to be used when generating a pkgsrc tree to be written
                   5719:            to a CD-ROM.  This target also produces
1.76      rillig   5720:            <code class="filename">README.html</code> files, and can be made to refer
1.75      rillig   5721:            to URLs based on <code class="varname">CDROM_PKG_URL_HOST</code> and
                   5722:            <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
                   5723: <dt><span class="term">show-distfiles</span></dt>
                   5724: <dd><p>This target shows which distfiles and patchfiles are needed to build
                   5725:            the package. (<code class="varname">DISTFILES</code> and
1.76      rillig   5726:            <code class="varname">PATCHFILES</code>, but not <code class="filename">patches/*</code>)</p></dd>
1.75      rillig   5727: <dt><span class="term">show-downlevel</span></dt>
                   5728: <dd><p>This target shows nothing if the package is not installed. If a version
                   5729:            of this package is installed, but is not the version provided in this
                   5730:            version of pkgsrc, then a warning message is displayed. This target can
                   5731:            be used to show which of your installed packages are downlevel, and so
                   5732:            the old versions can be deleted, and the current ones added.</p></dd>
                   5733: <dt><span class="term">show-pkgsrc-dir</span></dt>
                   5734: <dd><p>This target shows the directory in the pkgsrc hierarchy from which the
                   5735:            package can be built and installed. This may not be the same directory
                   5736:            as the one from which the package was installed. This target is intended
                   5737:            to be used by people who may wish to upgrade many packages on a single
                   5738:            host, and can be invoked from the top-level pkgsrc Makefile by using the
                   5739:            &#8220;<span class="quote">show-host-specific-pkgs</span>&#8221; target.</p></dd>
                   5740: <dt><span class="term">show-installed-depends</span></dt>
                   5741: <dd><p>This target shows which installed packages match the current package's
                   5742:            <code class="varname">DEPENDS</code>. Useful if out of date dependencies are
                   5743:            causing build problems.</p></dd>
                   5744: <dt><span class="term">check-shlibs</span></dt>
                   5745: <dd><p>After a package is installed, check all its binaries and (on ELF
                   5746:            platforms) shared libraries to see if they find the shared libs they need.
                   5747:            Run by default if <code class="varname">PKG_DEVELOPER</code> is set in
1.76      rillig   5748:            <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75      rillig   5749: <dt><span class="term">print-PLIST</span></dt>
                   5750: <dd>
                   5751: <p>After a &#8220;<span class="quote">make install</span>&#8221; from a new or
                   5752:            upgraded pkg, this prints out an attempt to generate a new
1.76      rillig   5753:            <code class="filename">PLIST</code> from a <span><strong class="command">find -newer
1.75      rillig   5754:            work/.extract_done</strong></span>.  An attempt is made to care
                   5755:            for shared libs etc., but it is
                   5756:            <span class="emphasis"><em>strongly</em></span> recommended to review the
                   5757:            result before putting it into
1.76      rillig   5758:            <code class="filename">PLIST</code>. On upgrades, it's useful to
1.75      rillig   5759:            diff the output of this command against an already
1.76      rillig   5760:            existing <code class="filename">PLIST</code> file.</p>
1.75      rillig   5761: <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
                   5762:            methods that don't update file access times, be sure to
                   5763:            add these files manually to your
1.76      rillig   5764:            <code class="filename">PLIST</code>, as the &#8220;<span class="quote">find
1.75      rillig   5765:            -newer</span>&#8221; command used by this target won't catch
                   5766:            them!</p>
1.77    ! rillig   5767: <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   5768:            information on this target.</p>
                   5769: </dd>
                   5770: <dt><span class="term">bulk-package</span></dt>
                   5771: <dd>
                   5772: <p>Used to do bulk builds. If an appropriate binary package already exists,
                   5773:            no action is taken. If not, this target will compile, install and
                   5774:            package it (and its depends, if <code class="varname">PKG_DEPENDS</code> is
                   5775:            set properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, &#8220;Configuration&#8221;</a>).
                   5776:            After creating the binary
                   5777:            package, the sources, the just-installed package and its required
                   5778:            packages are removed, preserving free disk space.</p>
                   5779: <p><span class="emphasis"><em>Beware that this target may deinstall all
                   5780:            packages installed on a system!</em></span></p>
                   5781: </dd>
                   5782: <dt><span class="term">bulk-install</span></dt>
                   5783: <dd>
                   5784: <p>Used during bulk-installs to install required packages. If an
                   5785:            up-to-date binary package is available, it will be installed via
                   5786:            <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,
                   5787:            but the installed binary won't be removed. </p>
                   5788: <p> A binary package is considered &#8220;<span class="quote">up-to-date</span>&#8221; to be
                   5789:            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>
                   5790: <div class="itemizedlist"><ul type="disc">
1.76      rillig   5791: <li><p>None of the package's files (<code class="filename">Makefile</code>,
1.75      rillig   5792:                ...) were modified since it was built.</p></li>
                   5793: <li><p>None of the package's required (binary) packages were
                   5794:                modified since it was built.</p></li>
                   5795: </ul></div>
                   5796: <p><span class="emphasis"><em>Beware that this target may deinstall all
                   5797:            packages installed on a system!</em></span></p>
                   5798: </dd>
                   5799: </dl></div>
                   5800: </div>
                   5801: </div>
                   5802: <div class="chapter" lang="en">
                   5803: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   5804: <a name="tools"></a>Chapter 16. Tools needed for building or running</h2></div></div></div>
1.75      rillig   5805: <div class="toc">
                   5806: <p><b>Table of Contents</b></p>
                   5807: <dl>
1.77    ! rillig   5808: <dt><span class="sect1"><a href="#pkgsrc-tools">16.1. Tools for pkgsrc builds</a></span></dt>
        !          5809: <dt><span class="sect1"><a href="#package-tools">16.2. Tools needed by packages</a></span></dt>
        !          5810: <dt><span class="sect1"><a href="#platform-tools">16.3. Tools provided by platforms</a></span></dt>
1.75      rillig   5811: </dl>
                   5812: </div>
                   5813: <p>
                   5814: The <code class="varname">USE_TOOLS</code> definition is used both internally
                   5815: by pkgsrc and also for individual packages to define what commands
                   5816: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
                   5817: or for later run-time of an installed packaged (such as
                   5818: <code class="varname">DEPENDS</code>).
                   5819: If the native system provides an adequate tool, then in many cases, a pkgsrc
                   5820: package will not be used.
                   5821: </p>
                   5822: <p>
                   5823: When building a package, the replacement tools are
                   5824: made available in a directory (as symlinks or wrapper scripts)
                   5825: that is early in the executable search path. Just like the buildlink
                   5826: system, this helps with consistent builds.
                   5827: </p>
                   5828: <p>
                   5829: A tool may be needed to help build a specific package. For example,
                   5830: perl, GNU make (gmake) or yacc may be needed.
                   5831: </p>
                   5832: <p>
                   5833: Also a tool may be needed, for example, because the native system's supplied
                   5834: tool may be inefficient for building a package with pkgsrc.
                   5835: For example, a package may need GNU awk, bison (instead of
                   5836: yacc) or a better sed.
                   5837: </p>
                   5838: <p>
                   5839: The tools used by a package can be listed by running
                   5840: <span><strong class="command">make show-tools</strong></span>.
                   5841: </p>
                   5842: <div class="sect1" lang="en">
                   5843: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5844: <a name="pkgsrc-tools"></a>16.1. Tools for pkgsrc builds</h2></div></div></div>
1.75      rillig   5845: <p>
                   5846: The default set of tools used by pkgsrc is defined in
1.76      rillig   5847: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75      rillig   5848: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
                   5849: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
                   5850: These can be seen by running:
                   5851: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.
                   5852: </p>
                   5853: <p>
                   5854: If a package needs a specific program to build
                   5855: then the <code class="varname">USE_TOOLS</code> variable can be used
                   5856: to define the tools needed.
                   5857: </p>
                   5858: </div>
                   5859: <div class="sect1" lang="en">
                   5860: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5861: <a name="package-tools"></a>16.2. Tools needed by packages</h2></div></div></div>
1.75      rillig   5862: <p>
                   5863: In the following examples, the :pkgsrc means to use the pkgsrc version
                   5864: and not the native version for a build dependency.
                   5865: And the :run means that it is used for a
                   5866: run-time dependencies also (and becomes a DEPENDS).
                   5867: The default is a build dependency which can be set with
                   5868: :build. (So in this example, it is the same as gmake:build
                   5869: and pkg-config:build.)
                   5870: </p>
                   5871: <pre class="programlisting">
                   5872: USE_TOOLS+=     mktemp:pkgsrc
                   5873: USE_TOOLS+=     gmake perl:run pkg-config
                   5874: </pre>
                   5875: <p>
                   5876: When using the tools framework, a
                   5877: <code class="varname">TOOLS_PATH.foo</code> variable is defined
                   5878: which contains the full path to the appropriate tool. For example,
                   5879: <code class="varname">TOOLS_PATH.bash</code> could be &#8220;<span class="quote">/bin/bash</span>&#8221;
                   5880: on Linux systems.
                   5881: </p>
                   5882: <p>
                   5883: If you always need a pkgsrc version of the
                   5884: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
                   5885: 
                   5886: </p>
                   5887: </div>
                   5888: <div class="sect1" lang="en">
                   5889: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5890: <a name="platform-tools"></a>16.3. Tools provided by platforms</h2></div></div></div>
1.75      rillig   5891: <p>
                   5892: When improving or porting pkgsrc to a new platform, have a look
                   5893: at (or create) the corresponding platform specific make file fragment under
1.76      rillig   5894: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75      rillig   5895: the name of the common tools. For example:</p>
                   5896: <pre class="programlisting">
                   5897: .if exists(/usr/bin/bzcat)
                   5898: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   5899: .elif exists(/usr/bin/bzip2)
                   5900: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   5901: .endif
1.69      rillig   5902: 
1.75      rillig   5903: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   5904: </pre>
                   5905: </div>
                   5906: </div>
                   5907: <div class="chapter" lang="en">
                   5908: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   5909: <a name="fixes"></a>Chapter 17. Making your package work</h2></div></div></div>
1.75      rillig   5910: <div class="toc">
                   5911: <p><b>Table of Contents</b></p>
                   5912: <dl>
1.77    ! rillig   5913: <dt><span class="sect1"><a href="#general-operation">17.1. General operation</a></span></dt>
1.75      rillig   5914: <dd><dl>
1.77    ! rillig   5915: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">17.1.1. How to pull in variables from /etc/mk.conf</a></span></dt>
        !          5916: <dt><span class="sect2"><a href="#where-to-install-documentation">17.1.2. Where to install documentation</a></span></dt>
        !          5917: <dt><span class="sect2"><a href="#restricted-packages">17.1.3. Restricted packages</a></span></dt>
        !          5918: <dt><span class="sect2"><a href="#dependencies">17.1.4. Handling dependencies</a></span></dt>
        !          5919: <dt><span class="sect2"><a href="#conflicts">17.1.5. Handling conflicts with other packages</a></span></dt>
        !          5920: <dt><span class="sect2"><a href="#not-building-packages">17.1.6. Packages that cannot or should not be built</a></span></dt>
        !          5921: <dt><span class="sect2"><a href="#undeletable-packages">17.1.7. Packages which should not be deleted, once installed</a></span></dt>
        !          5922: <dt><span class="sect2"><a href="#security-handling">17.1.8. Handling packages with security problems</a></span></dt>
        !          5923: <dt><span class="sect2"><a href="#compiler-bugs">17.1.9. How to handle compiler bugs</a></span></dt>
        !          5924: <dt><span class="sect2"><a href="#bumping-pkgrevision">17.1.10. How to handle incrementing versions when fixing an existing package</a></span></dt>
        !          5925: <dt><span class="sect2"><a href="#portability-of-packages">17.1.11. Portability of packages</a></span></dt>
        !          5926: </dl></dd>
        !          5927: <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>
        !          5928: <dd><dl>
        !          5929: <dt><span class="sect2"><a href="#no-plain-download">17.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
        !          5930: <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>
        !          5931: </dl></dd>
        !          5932: <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>
        !          5933: <dd><dl>
        !          5934: <dt><span class="sect2"><a href="#fixes.libtool">17.3.1. Shared libraries - libtool</a></span></dt>
        !          5935: <dt><span class="sect2"><a href="#using-libtool">17.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
        !          5936: <dt><span class="sect2"><a href="#autoconf-automake">17.3.3. GNU Autoconf/Automake</a></span></dt>
        !          5937: </dl></dd>
        !          5938: <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>
        !          5939: <dd><dl><dt><span class="sect2"><a href="#fixes.build.cpp">17.4.1. Compiling C and C++ code conditionally</a></span></dt></dl></dd>
        !          5940: <dt><span class="sect1"><a href="#package-specific-actions">17.5. Package specific actions</a></span></dt>
        !          5941: <dd><dl>
        !          5942: <dt><span class="sect2"><a href="#user-interaction">17.5.1. User interaction</a></span></dt>
        !          5943: <dt><span class="sect2"><a href="#handling-licenses">17.5.2. Handling licenses</a></span></dt>
        !          5944: </dl></dd>
        !          5945: <dt><span class="sect1"><a href="#fixes.install">17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
        !          5946: <dd><dl>
        !          5947: <dt><span class="sect2"><a href="#installing-score-files">17.6.1. Installing score files</a></span></dt>
        !          5948: <dt><span class="sect2"><a href="#perl-scripts">17.6.2. Packages containing perl scripts</a></span></dt>
        !          5949: <dt><span class="sect2"><a href="#hardcoded-paths">17.6.3. Packages with hardcoded paths to other interpreters</a></span></dt>
        !          5950: <dt><span class="sect2"><a href="#perl-modules">17.6.4. Packages installing perl modules</a></span></dt>
        !          5951: <dt><span class="sect2"><a href="#faq.info-files">17.6.5. Packages installing info files</a></span></dt>
        !          5952: <dt><span class="sect2"><a href="#manpages">17.6.6. Packages installing man pages</a></span></dt>
        !          5953: <dt><span class="sect2"><a href="#gconf2-data-files">17.6.7. Packages installing GConf2 data files</a></span></dt>
        !          5954: <dt><span class="sect2"><a href="#scrollkeeper-data-files">17.6.8. Packages installing scrollkeeper data files</a></span></dt>
        !          5955: <dt><span class="sect2"><a href="#x11-fonts">17.6.9. Packages installing X11 fonts</a></span></dt>
        !          5956: <dt><span class="sect2"><a href="#gtk2-modules">17.6.10. Packages installing GTK2 modules</a></span></dt>
        !          5957: <dt><span class="sect2"><a href="#sgml-xml-data">17.6.11. Packages installing SGML or XML data</a></span></dt>
        !          5958: <dt><span class="sect2"><a href="#mime-database">17.6.12. Packages installing extensions to the MIME database</a></span></dt>
        !          5959: <dt><span class="sect2"><a href="#intltool">17.6.13. Packages using intltool</a></span></dt>
        !          5960: <dt><span class="sect2"><a href="#startup-scripts">17.6.14. Packages installing startup scripts</a></span></dt>
        !          5961: <dt><span class="sect2"><a href="#tex-packages">17.6.15. Packages installing TeX modules</a></span></dt>
1.75      rillig   5962: </dl></dd>
1.77    ! rillig   5963: <dt><span class="sect1"><a href="#feedback-to-author">17.7. Feedback to the author</a></span></dt>
1.75      rillig   5964: </dl>
                   5965: </div>
                   5966: <div class="sect1" lang="en">
                   5967: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   5968: <a name="general-operation"></a>17.1. General operation</h2></div></div></div>
1.75      rillig   5969: <div class="sect2" lang="en">
                   5970: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   5971: <a name="pulling-vars-from-etc-mk.conf"></a>17.1.1. How to pull in variables from /etc/mk.conf</h3></div></div></div>
1.75      rillig   5972: <p>The problem with package-defined variables that can be
                   5973:         overridden via <code class="varname">MAKECONF</code> or
1.76      rillig   5974:         <code class="filename">/etc/mk.conf</code> is that <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> expands a
1.75      rillig   5975:         variable as it is used, but evaluates preprocessor-like
                   5976:         statements (.if, .ifdef and .ifndef) as they are read.  So, to
                   5977:         use any variable (which may be set in
1.76      rillig   5978:         <code class="filename">/etc/mk.conf</code>) in one of the .if*
                   5979:         statements, the file <code class="filename">/etc/mk.conf</code> must be
1.75      rillig   5980:         included before that .if* statement.</p>
                   5981: <p>Rather than having a number of ad-hoc ways of including
1.76      rillig   5982:         <code class="filename">/etc/mk.conf</code>, should it exist, or
1.75      rillig   5983:         <code class="varname">MAKECONF</code>, should it exist, include the
1.76      rillig   5984:         <code class="filename">pkgsrc/mk/bsd.prefs.mk</code> file in the package
1.75      rillig   5985:         Makefile before any preprocessor-like .if, .ifdef, or .ifndef
                   5986:         statements:</p>
                   5987: <pre class="programlisting">
                   5988:     .include "../../mk/bsd.prefs.mk"
1.69      rillig   5989: 
1.75      rillig   5990:     .if defined(USE_MENUS)
                   5991:     # ...
                   5992:     .endif
                   5993: </pre>
                   5994: <p>If you wish to set the <code class="varname">CFLAGS</code> variable
1.76      rillig   5995:         in <code class="filename">/etc/mk.conf</code>, please make sure to use:
1.69      rillig   5996: 
1.75      rillig   5997: </p>
                   5998: <pre class="programlisting">
                   5999:     CFLAGS+=  -your -flags
                   6000: </pre>
                   6001: <p>
1.69      rillig   6002: 
1.75      rillig   6003:         Using <code class="varname">CFLAGS=</code> (i.e. without the
                   6004:         &#8220;<span class="quote">+</span>&#8221;) may lead to problems with packages that need
                   6005:         to add their own flags.  Also, you may want to take a look at
1.76      rillig   6006:         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
1.75      rillig   6007:        you're interested in optimization for the current CPU.</p>
                   6008: </div>
                   6009: <div class="sect2" lang="en">
                   6010: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6011: <a name="where-to-install-documentation"></a>17.1.2. Where to install documentation</h3></div></div></div>
1.75      rillig   6012: <p>Documentation should be installed into
1.76      rillig   6013:       <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
                   6014:       <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the
1.75      rillig   6015:       latter includes the version number of the package).</p>
                   6016: </div>
                   6017: <div class="sect2" lang="en">
                   6018: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6019: <a name="restricted-packages"></a>17.1.3. Restricted packages</h3></div></div></div>
1.75      rillig   6020: <p>Some licenses restrict how software may be re-distributed.
                   6021:         In order to satisfy these restrictions, the package system
                   6022:         defines five make variables that can be set to note these
                   6023:         restrictions:</p>
                   6024: <div class="itemizedlist"><ul type="disc">
                   6025: <li>
                   6026: <p><code class="varname">RESTRICTED</code></p>
                   6027: <p>This variable should be set whenever a restriction
                   6028:             exists (regardless of its kind).  Set this variable to a
                   6029:             string containing the reason for the restriction.</p>
                   6030: </li>
                   6031: <li>
                   6032: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
                   6033: <p>Binaries may not be placed on CD-ROM.  Set this
                   6034:             variable to <code class="varname">${RESTRICTED}</code> whenever a
                   6035:             binary package may not be included on a CD-ROM.</p>
                   6036: </li>
                   6037: <li>
                   6038: <p><code class="varname">NO_BIN_ON_FTP</code></p>
                   6039: <p>Binaries may not be placed on an FTP server.  Set
                   6040:             this variable to <code class="varname">${RESTRICTED}</code>
                   6041:             whenever a binary package may not not be made available
                   6042:             on the Internet.</p>
                   6043: </li>
                   6044: <li>
                   6045: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
                   6046: <p>Distfiles may not be placed on CD-ROM.  Set this
                   6047:             variable to <code class="varname">${RESTRICTED}</code> if
                   6048:             re-distribution of the source code or other distfile(s) is
                   6049:             not allowed on CD-ROMs.</p>
                   6050: </li>
                   6051: <li>
                   6052: <p><code class="varname">NO_SRC_ON_FTP</code></p>
                   6053: <p>Distfiles may not be placed on FTP.  Set this variable
                   6054:             to <code class="varname">${RESTRICTED}</code> if re-distribution of
                   6055:             the source code or other distfile(s) via the Internet is not
                   6056:             allowed.</p>
                   6057: </li>
                   6058: </ul></div>
                   6059: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
                   6060:         <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
                   6061:         generic make variables to denote restrictions is deprecated,
                   6062:         because they unconditionally prevent users from generating
                   6063:         binary packages!</p>
                   6064: </div>
                   6065: <div class="sect2" lang="en">
                   6066: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6067: <a name="dependencies"></a>17.1.4. Handling dependencies</h3></div></div></div>
1.75      rillig   6068: <p>Your package may depend on some other package being present
                   6069:         - and there are various ways of expressing this
                   6070:         dependency. pkgsrc supports the <code class="varname">BUILD_DEPENDS</code>
                   6071:         and <code class="varname">DEPENDS</code> definitions, the
                   6072:         <code class="varname">USE_TOOLS</code> definition, as well as
1.76      rillig   6073:         dependencies via <code class="filename">buildlink3.mk</code>, which is
1.75      rillig   6074:         the preferred way to handle dependencies, and which uses the
1.77    ! rillig   6075:         variables named above. See <a href="#buildlink" title="Chapter 12. Buildlink methodology">Chapter 12, <i>Buildlink methodology</i></a> for more
1.75      rillig   6076:         information.</p>
                   6077: <p>The basic difference between the two variables is as
                   6078:         follows: The <code class="varname">DEPENDS</code> definition registers
                   6079:         that pre-requisite in the binary package so it will be pulled in
                   6080:         when the binary package is later installed, whilst the
                   6081:         <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
                   6082:         dependency that is only needed for building the package.
                   6083: </p>
                   6084: <p>This means that if you only need a package present whilst
                   6085:         you are building, it should be noted as a
                   6086:         <code class="varname">BUILD_DEPENDS</code>.</p>
                   6087: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
                   6088:         <code class="varname">DEPENDS</code> definition is:</p>
                   6089: <pre class="programlisting">
                   6090:     &lt;pre-req-package-name&gt;:../../&lt;category&gt;/&lt;pre-req-package&gt;
                   6091: </pre>
                   6092: <p>Please note that the &#8220;<span class="quote">pre-req-package-name</span>&#8221;
                   6093:         may include any of the wildcard version numbers recognized by
                   6094:         <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>
                   6095: <div class="orderedlist"><ol type="1">
                   6096: <li>
                   6097: <p>If your package needs another package's binaries or
                   6098:             libraries to build or run, and if that package has a
1.76      rillig   6099:             <code class="filename">buildlink3.mk</code> file available, use it:
1.75      rillig   6100: </p>
                   6101: <pre class="programlisting">
                   6102:     .include "../../graphics/jpeg/buildlink3.mk"
                   6103: </pre>
                   6104: </li>
                   6105: <li>
                   6106: <p>If your package needs to use another package to build
1.76      rillig   6107:             itself and there is no <code class="filename">buildlink3.mk</code>
1.75      rillig   6108:             file available, use the <code class="varname">BUILD_DEPENDS</code>
                   6109:             definition:</p>
                   6110: <pre class="programlisting">
                   6111:     BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
                   6112: </pre>
                   6113: </li>
                   6114: <li>
                   6115: <p>If your package needs a library with which to link and
1.76      rillig   6116:        again there is no <code class="filename">buildlink3.mk</code> file
1.75      rillig   6117:         available, this is specified using the
                   6118:         <code class="varname">DEPENDS</code> definition. For example:</p>
                   6119: <pre class="programlisting">
                   6120:     DEPENDS+=       xpm-3.4j:../../graphics/xpm
                   6121: </pre>
                   6122: <p>You can also use wildcards in package dependences:</p>
                   6123: <pre class="programlisting">
                   6124:     DEPENDS+=       xpm-[0-9]*:../../graphics/xpm
                   6125: </pre>
                   6126: <p>Note that such wildcard dependencies are retained when
                   6127:             creating binary packages.  The dependency is checked when
                   6128:             installing the binary package and any package which matches
                   6129:             the pattern will be used.  Wildcard dependencies should be
                   6130:             used with care.</p>
                   6131: <p>The &#8220;<span class="quote">-[0-9]*</span>&#8221; should be used instead of
                   6132:             &#8220;<span class="quote">-*</span>&#8221; to avoid potentially ambiguous matches
                   6133:             such as &#8220;<span class="quote">tk-postgresql</span>&#8221; matching a
                   6134:             &#8220;<span class="quote">tk-*</span>&#8221; <code class="varname">DEPENDS</code>.</p>
                   6135: <p>Wildcards can also be used to specify that a package
                   6136:             will only  build against a certain minimum version of a
                   6137:             pre-requisite:</p>
                   6138: <pre class="programlisting">
                   6139:     DEPENDS+=       tiff&gt;=3.5.4:../../graphics/tiff
                   6140: </pre>
                   6141: <p>This means that the package will build against version
                   6142:             3.5.4 of the tiff library or newer.  Such a dependency may
                   6143:             be warranted if, for example, the API of the library has
                   6144:             changed with version 3.5.4 and a package would not compile
                   6145:             against an earlier version of tiff.</p>
                   6146: <p>Please note that such dependencies should only be
                   6147:             updated if a package requires  a newer pre-requisite, but
                   6148:             not to denote recommendations such as 
                   6149:             ABI changes that do not prevent a package from building
                   6150:             correctly.  Such recommendations can be expressed using
                   6151:             <code class="varname">ABI_DEPENDS</code>:</p>
                   6152: <pre class="programlisting">
                   6153:     ABI_DEPENDS+=   tiff&gt;=3.6.1:../../graphics/tiff
                   6154: </pre>
                   6155: <p>In addition to the above <code class="varname">DEPENDS</code>
                   6156:             line, this denotes that while a package will build against
                   6157:             tiff&gt;=3.5.4, at least version 3.6.1 is recommended.
                   6158:             <code class="varname">ABI_DEPENDS</code> entries will be turned into
                   6159:             dependencies unless explicitly ignored (in which case a
                   6160:             warning will be printed).</p>
                   6161: <p>To ignore these ABI dependency recommendations and just
                   6162:             use the required <code class="varname">DEPENDS</code>, set
                   6163:             <code class="varname">USE_ABI_DEPENDS=NO</code>.   This may make
                   6164:             it easier and faster to update packages built using pkgsrc,
                   6165:             since older compatible dependencies can continue to be
                   6166:             used. This is useful for people who watch their rebuilds
                   6167:             very carefully; it is not very good as a general-purpose
                   6168:             hammer.  If you use it, you need to be mindful of possible
                   6169:             ABI changes, including those from the underlying OS.
                   6170: </p>
                   6171: <p>Packages that are built with recommendations ignored
                   6172:             may not be uploaded to ftp.NetBSD.org by developers and
                   6173:             should not be used across different systems that may have
                   6174:             different versions of binary packages installed.</p>
                   6175: <p>For security fixes, please update the package
1.77    ! rillig   6176:             vulnerabilities file. See <a href="#security-handling" title="17.1.8. Handling packages with security problems">Section 17.1.8, &#8220;Handling packages with security problems&#8221;</a> for more
1.75      rillig   6177:             information.</p>
                   6178: </li>
                   6179: <li>
                   6180: <p>If your package needs some executable to be able to run
                   6181:             correctly and if there's no
1.76      rillig   6182:             <code class="filename">buildlink3.mk</code> file, this is specified
1.75      rillig   6183:             using the <code class="varname">DEPENDS</code> variable. The
1.76      rillig   6184:             <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   6185:            be able to execute the latex binary from the teTeX package
                   6186:            when it runs, and that is specified:</p>
                   6187: <pre class="programlisting">
                   6188:     DEPENDS+=        teTeX-[0-9]*:../../print/teTeX
                   6189: </pre>
                   6190: <p>The comment about wildcard dependencies from previous
                   6191:             paragraph  applies here, too.</p>
                   6192: </li>
                   6193: </ol></div>
                   6194: <p>If your package needs files from another package to build,
                   6195:        add the relevant distribution files to
                   6196:        <code class="varname">DISTFILES</code>, so they will be extracted
1.76      rillig   6197:        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   6198:        (It relies on the jpeg sources being present in source form
                   6199:        during the build.)</p>
                   6200: <p>Please also note the <code class="varname">BUILD_USES_MSGFMT</code>
                   6201:         and <code class="varname">BUILD_USES_GETTEXT_M4</code> definitions, which
                   6202:         are provided as convenience definitions.  The former works out
                   6203:         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   6204:         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   6205:        The latter adds a build dependency on either an installed
                   6206:        version of an older gettext package, or if it isn't, installs the
1.76      rillig   6207:         <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   6208: </div>
                   6209: <div class="sect2" lang="en">
                   6210: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6211: <a name="conflicts"></a>17.1.5. Handling conflicts with other packages</h3></div></div></div>
1.75      rillig   6212: <p>Your package may conflict with other packages a user might
                   6213:         already have installed on his system, e.g. if your package
                   6214:         installs the same set of files like another package in our
                   6215:         pkgsrc tree.</p>
                   6216: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
                   6217:         space-separated list of packages (including version string) your
                   6218:         package conflicts with.</p>
1.76      rillig   6219: <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>
                   6220:         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   6221:         install the same shared library, thus you set in
1.76      rillig   6222:         <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
1.75      rillig   6223: <pre class="programlisting">
                   6224:     CONFLICTS=      Xaw-Xpm-[0-9]*
                   6225: </pre>
1.76      rillig   6226: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:
1.75      rillig   6227: </p>
                   6228: <pre class="programlisting">
                   6229:     CONFLICTS=      Xaw3d-[0-9]*
                   6230: </pre>
                   6231: <p>Packages will automatically conflict with other packages
                   6232:         with the name prefix  and a different version
                   6233:         string. &#8220;<span class="quote">Xaw3d-1.5</span>&#8221; e.g. will automatically
                   6234:         conflict  with the older version &#8220;<span class="quote">Xaw3d-1.3</span>&#8221;.
                   6235: </p>
                   6236: </div>
                   6237: <div class="sect2" lang="en">
                   6238: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6239: <a name="not-building-packages"></a>17.1.6. Packages that cannot or should not be built</h3></div></div></div>
1.75      rillig   6240: <p>There are several reasons why a package might be
                   6241:         instructed to not build under certain circumstances. If the
                   6242:         package builds and runs on most platforms, the exceptions
                   6243:         should be noted with <code class="varname">NOT_FOR_PLATFORM</code>.  If
                   6244:         the package builds and runs on a small handful of platforms,
                   6245:         set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
                   6246:        Both <code class="varname">ONLY_FOR_PLATFORM</code> and
                   6247:         <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
                   6248:         (OS-version-platform) that can use glob-style
                   6249:         wildcards.</p>
                   6250: <p>If the package should be skipped (for example, because it
                   6251:         provides functionality already provided by the system), set
                   6252:         <code class="varname">PKG_SKIP_REASON</code> to a descriptive message.
                   6253:         If the package should fail because some preconditions are not
                   6254:         met, set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
                   6255:         message.</p>
                   6256: </div>
                   6257: <div class="sect2" lang="en">
                   6258: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6259: <a name="undeletable-packages"></a>17.1.7. Packages which should not be deleted, once installed</h3></div></div></div>
1.75      rillig   6260: <p>To ensure that a package may not be deleted, once it has been
                   6261:         installed, the <code class="varname">PKG_PRESERVE</code> definition should
                   6262:         be set in the package Makefile. This will be carried into any
                   6263:         binary package that is made from this pkgsrc entry. A
                   6264:         &#8220;<span class="quote">preserved</span>&#8221; package will
                   6265:         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
                   6266:         &#8220;<span class="quote">-f</span>&#8221; option is used.</p>
                   6267: </div>
                   6268: <div class="sect2" lang="en">
                   6269: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6270: <a name="security-handling"></a>17.1.8. Handling packages with security problems</h3></div></div></div>
1.75      rillig   6271: <p>When a vulnerability is found, this should be noted in
1.76      rillig   6272:         <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
1.75      rillig   6273:         and after committing that file, use <span><strong class="command">make upload</strong></span>
                   6274:        in the same directory to update the file on ftp.NetBSD.org.</p>
                   6275: <p>After fixing the vulnerability by a patch, its
                   6276:        <code class="varname">PKGREVISION</code> should be increased (this
                   6277:        is of course not necessary if the problem is fixed by using
                   6278:        a newer release of the software).</p>
                   6279: <p>Also, if the fix should be applied to the stable pkgsrc
                   6280:         branch, be sure to submit a pullup request!</p>
                   6281: <p>Binary packages already on ftp.NetBSD.org will be handled
                   6282:        semi-automatically by a weekly cron job.</p>
                   6283: </div>
                   6284: <div class="sect2" lang="en">
                   6285: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6286: <a name="compiler-bugs"></a>17.1.9. How to handle compiler bugs</h3></div></div></div>
1.75      rillig   6287: <p>Some source files trigger bugs in the compiler, based on
                   6288:         combinations  of compiler version and architecture and almost
                   6289:         always relation to  optimisation being enabled.  Common symptoms
                   6290:         are gcc internal errors  or never finishing compiling a file.
                   6291: </p>
                   6292: <p>Typically, a workaround involves testing the
                   6293:         <code class="varname">MACHINE_ARCH</code>  and compiler version, disabling
                   6294:         optimisation for that
                   6295:         file/<code class="varname">MACHINE_ARCH</code>/compiler  combination, and
1.76      rillig   6296:         documenting it in  <code class="filename">pkgsrc/doc/HACKS</code>.  See
1.75      rillig   6297:         that file for a number of examples!</p>
                   6298: </div>
                   6299: <div class="sect2" lang="en">
                   6300: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6301: <a name="bumping-pkgrevision"></a>17.1.10. How to handle incrementing versions when fixing an existing package</h3></div></div></div>
1.75      rillig   6302: <p>When making fixes to an existing package it can be useful
                   6303:         to change the version number in <code class="varname">PKGNAME</code>. To
                   6304:         avoid conflicting with future versions by the original author, a
                   6305:         &#8220;<span class="quote">nb1</span>&#8221;, &#8220;<span class="quote">nb2</span>&#8221;, ... suffix can be used
                   6306:         on package versions by setting <code class="varname">PKGREVISION=1</code>
                   6307:         (2, ...). The &#8220;<span class="quote">nb</span>&#8221; is treated like a
                   6308:         &#8220;<span class="quote">.</span>&#8221; by the pkg tools. e.g.</p>
                   6309: <pre class="programlisting">
                   6310:     DISTNAME=       foo-17.42
                   6311:     PKGREVISION=    9
                   6312: </pre>
                   6313: <p>will result in a <code class="varname">PKGNAME</code> of
                   6314:         &#8220;<span class="quote">foo-17.42nb9</span>&#8221;.</p>
                   6315: <p>When a new release of the package is released, the
                   6316:         <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
                   6317:         minor release of the above package, things should be like:</p>
                   6318: <pre class="programlisting">
                   6319:     DISTNAME=       foo-17.43
                   6320: </pre>
                   6321: </div>
                   6322: <div class="sect2" lang="en">
                   6323: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6324: <a name="portability-of-packages"></a>17.1.11. Portability of packages</h3></div></div></div>
1.75      rillig   6325: <p>One appealing feature of pkgsrc is that it runs on many different
                   6326:         platforms. As a result, it is important to ensure, where possible,
                   6327:         that packages in pkgsrc are portable. There are some particular
                   6328:         details you should pay attention to while working on pkgsrc.</p>
                   6329: <div class="sect3" lang="en">
                   6330: <div class="titlepage"><div><div><h4 class="title">
1.77    ! rillig   6331: <a name="install-scripts"></a>17.1.11.1. ${INSTALL}, ${INSTALL_DATA_DIR}, ...</h4></div></div></div>
1.75      rillig   6332: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied with some
                   6333:           operating systems will not perform more than one operation at a time.
                   6334:           As such, you should call &#8220;<span class="quote">${INSTALL}</span>&#8221;, etc. like this:</p>
                   6335: <pre class="programlisting">
                   6336:     ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   6337:     ${INSTALL_DATA_DIR} ${PREFIX}/dir2
                   6338: </pre>
                   6339: </div>
                   6340: </div>
                   6341: </div>
                   6342: <div class="sect1" lang="en">
                   6343: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   6344: <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   6345: <div class="sect2" lang="en">
                   6346: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6347: <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   6348: <p>If you need to download from a dynamic URL you can set
                   6349:         <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
1.76      rillig   6350:         fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
1.75      rillig   6351:         with the name of each file to download as an argument, expecting
                   6352:         it to output the URL of the directory from which to download
1.76      rillig   6353:         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.75      rillig   6354:        example of this usage.
                   6355: </p>
                   6356: <p>If the download can't be automated, because the user must
                   6357:        submit personal information to apply for a password, or must pay
                   6358:        for the source, or whatever, you can set
                   6359:        <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
                   6360:        displayed to the user before aborting the build. Example:</p>
                   6361: <pre class="programlisting">
                   6362:     FETCH_MESSAGE=  "Please download the files"
                   6363:     FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   6364:     FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   6365: </pre>
                   6366: </div>
                   6367: <div class="sect2" lang="en">
                   6368: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6369: <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   6370: <p>Sometimes authors of a software package make some
                   6371:         modifications after the software was released, and they put up a
                   6372:         new distfile without changing the package's version number. If a
                   6373:         package is already in pkgsrc at that time, the checksum will
                   6374:         no longer match. The contents of the new distfile should be
                   6375:        compared against the old one before changing anything, to make
                   6376:        sure the distfile was really updated on purpose, and that
                   6377:         no trojan horse or so crept in.
                   6378:        Then, the correct way to work around this is to
                   6379:        set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
                   6380:        usually based on <code class="varname">PKGNAME_NOREV</code>. In case this
                   6381:        happens more often, <code class="varname">PKGNAME</code> can be used (thus
1.76      rillig   6382:        including the <code class="filename">nbX</code> suffix) or a date stamp
1.75      rillig   6383:        can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
1.76      rillig   6384:        Do not forget regenerating the <code class="filename">distinfo</code> file
1.75      rillig   6385:        after that, since it contains the <code class="varname">DIST_SUBDIR</code>
                   6386:        path in the filenames.
                   6387:         Furthermore, a mail to the package's authors seems appropriate
                   6388:        telling them that changing distfiles after releases without
                   6389:        changing the file names is not good practice.</p>
                   6390: </div>
                   6391: </div>
                   6392: <div class="sect1" lang="en">
                   6393: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   6394: <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   6395: <div class="sect2" lang="en">
                   6396: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6397: <a name="fixes.libtool"></a>17.3.1. Shared libraries - libtool</h3></div></div></div>
1.75      rillig   6398: <p>pkgsrc supports many different machines, with different
                   6399:         object formats like a.out and ELF, and varying abilities to do
                   6400:         shared library and dynamic loading at all. To accompany this,
                   6401:         varying commands and options have to be passed to the
                   6402:         compiler, linker, etc. to get the Right Thing, which can be
                   6403:         pretty annoying especially if you don't have all the machines
                   6404:         at your hand to test things.  The
1.76      rillig   6405:        <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   6406:         can help here, as it just &#8220;<span class="quote">knows</span>&#8221; how to build
                   6407:         both static and dynamic libraries from a set of source files,
                   6408:         thus being platform-independent.</p>
                   6409: <p>Here's how to use libtool in a pkg in seven simple
                   6410:         steps:</p>
                   6411: <div class="orderedlist"><ol type="1">
                   6412: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
                   6413:             Makefile.</p></li>
                   6414: <li><p>For library objects, use &#8220;<span class="quote">${LIBTOOL} --mode=compile
                   6415:             ${CC}</span>&#8221; in place of &#8220;<span class="quote">${CC}</span>&#8221;. You could even
                   6416:             add it to the definition of <code class="varname">CC</code>, if only
                   6417:             libraries are being built in a given Makefile. This one command
                   6418:             will build both PIC and non-PIC library objects, so you need not
                   6419:             have separate shared and non-shared library rules.</p></li>
                   6420: <li>
                   6421: <p>For the linking of the library, remove any
                   6422:             &#8220;<span class="quote">ar</span>&#8221;, &#8220;<span class="quote">ranlib</span>&#8221;, and &#8220;<span class="quote">ld
                   6423:             -Bshareable</span>&#8221; commands, and instead use:</p>
                   6424: <pre class="programlisting">
                   6425:     ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
                   6426:         -rpath ${PREFIX}/lib -version-info major:minor
                   6427: </pre>
                   6428: <p>Note that the library is changed to have a
1.76      rillig   6429:             <code class="filename">.la</code> extension, and the objects are
                   6430:             changed to have a <code class="filename">.lo</code>
1.75      rillig   6431:             extension. Change <code class="varname">OBJS</code> as
                   6432:             necessary. This automatically creates all of the
1.76      rillig   6433:             <code class="filename">.a</code>,
                   6434:             <code class="filename">.so.major.minor</code>, and ELF symlinks (if
1.75      rillig   6435:             necessary) in the build directory. Be sure to include
                   6436:             &#8220;<span class="quote">-version-info</span>&#8221;, especially when major and
                   6437:             minor are zero, as libtool will otherwise strip off the
                   6438:             shared library version.</p>
                   6439: <p>From the libtool manual:</p>
                   6440: <pre class="programlisting">
                   6441:     So, libtool library versions are described by three integers:
1.69      rillig   6442: 
1.75      rillig   6443:     CURRENT
                   6444:         The most recent interface number that this library implements.
1.69      rillig   6445: 
1.75      rillig   6446:     REVISION
                   6447:         The implementation number of the CURRENT interface.
1.69      rillig   6448: 
1.75      rillig   6449:     AGE
                   6450:         The difference between the newest and oldest interfaces that
                   6451:         this library implements.  In other words, the library implements
                   6452:         all the interface numbers in the range from number `CURRENT -
                   6453:         AGE' to `CURRENT'.
1.1       grant    6454: 
1.75      rillig   6455:     If two libraries have identical CURRENT and AGE numbers, then the
                   6456:     dynamic linker chooses the library with the greater REVISION number.
                   6457: </pre>
                   6458: <p>The &#8220;<span class="quote">-release</span>&#8221; option will produce
                   6459:             different results for a.out and ELF (excluding symlinks)
                   6460:             in only one case. An ELF library of the form
                   6461:             &#8220;<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;
                   6462:             will have a symlink of
                   6463:             &#8220;<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>&#8221;
                   6464:             on an a.out platform. This is handled
                   6465:             automatically.</p>
                   6466: <p>The &#8220;<span class="quote">-rpath argument</span>&#8221; is the install
                   6467:             directory of the library being built.</p>
1.76      rillig   6468: <p>In the <code class="filename">PLIST</code>, include only the
                   6469:             <code class="filename">.la</code> file, the other files will be
1.75      rillig   6470:            added automatically.</p>
                   6471: </li>
                   6472: <li>
1.76      rillig   6473: <p>When linking shared object (<code class="filename">.so</code>)
1.75      rillig   6474:             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
                   6475:             shared libraries, use &#8220;<span class="quote">-module
                   6476:             -avoid-version</span>&#8221; to prevent them getting version
                   6477:             tacked on.</p>
1.76      rillig   6478: <p>The <code class="filename">PLIST</code> file gets the
                   6479:             <code class="filename">foo.so</code> entry.</p>
1.75      rillig   6480: </li>
                   6481: <li>
                   6482: <p>When linking programs that depend on these libraries
                   6483:             <span class="emphasis"><em>before</em></span> they are installed, preface
                   6484:             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}
                   6485:             --mode=link</span>&#8221;, and it will find the correct
                   6486:             libraries (static or shared), but please be aware that
                   6487:             libtool will not allow you to specify a relative path in
                   6488:             -L (such as &#8220;<span class="quote">-L../somelib</span>&#8221;), because it
                   6489:             expects you to change that argument to be the
1.76      rillig   6490:             <code class="filename">.la</code> file. e.g.</p>
1.75      rillig   6491: <pre class="programlisting">
                   6492:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   6493: </pre>
                   6494: <p>should be changed to:</p>
                   6495: <pre class="programlisting">
                   6496:     ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
                   6497: </pre>
                   6498: <p>and it will do the right thing with the libraries.</p>
                   6499: </li>
                   6500: <li>
                   6501: <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>
                   6502:             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}
                   6503:             --mode=install</span>&#8221;, and change the library name to
1.76      rillig   6504:             <code class="filename">.la</code>. e.g.</p>
1.75      rillig   6505: <pre class="programlisting">
                   6506:     ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
                   6507: </pre>
1.76      rillig   6508: <p>This will install the static <code class="filename">.a</code>,
1.75      rillig   6509:             shared library, any needed symlinks, and run
                   6510:             <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>
                   6511: </li>
1.76      rillig   6512: <li><p>In your <code class="filename">PLIST</code>, include only
                   6513:             the <code class="filename">.la</code>
1.75      rillig   6514:             file (this is a change from previous behaviour).</p></li>
                   6515: </ol></div>
                   6516: </div>
                   6517: <div class="sect2" lang="en">
                   6518: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6519: <a name="using-libtool"></a>17.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75      rillig   6520: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
                   6521:         package Makefile. This will override the package's own libtool
                   6522:         in most cases.  For older libtool using packages,  libtool is
                   6523:         made by ltconfig script during the do-configure step; you can
                   6524:         check the libtool script location by doing <span><strong class="command">make
                   6525:         configure; find work*/ -name libtool</strong></span>.</p>
                   6526: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
                   6527:         scripts, relative to <code class="varname">WRKSRC</code>, to override.  By
                   6528:         default, it is set to &#8220;<span class="quote">libtool */libtool
                   6529:         */*/libtool</span>&#8221;.  If this does not match the location of the
                   6530:         package's libtool script(s), set it as appropriate.</p>
1.76      rillig   6531: <p>If you do not need <code class="filename">*.a</code> static
1.75      rillig   6532:         libraries built and installed, then use
                   6533:         <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
                   6534: <p>If your package makes use of the platform-independent library
                   6535:         for loading dynamic shared objects, that comes with libtool
                   6536:         (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
                   6537: <p>Some packages use libtool incorrectly so that the package may not work or
                   6538:         build in some circumstances. Some of the more common errors are:</p>
                   6539: <div class="itemizedlist"><ul type="disc">
                   6540: <li>
                   6541: <p>The inclusion of a shared object (-module) as a dependent library in an
                   6542:             executable or library. This in itself isn't a problem if one of two things
                   6543:             has been done:</p>
                   6544: <div class="orderedlist"><ol type="1">
                   6545: <li><p>The shared object is named correctly, i.e.
1.76      rillig   6546:                 <code class="filename">libfoo.la</code>, not
                   6547:                 <code class="filename">foo.la</code></p></li>
1.75      rillig   6548: <li><p>The -dlopen option is used when linking an executable.</p></li>
                   6549: </ol></div>
                   6550: </li>
                   6551: <li><p>The use of libltdl without the correct calls to initialisation routines.
                   6552:             The function lt_dlinit() should be called and the macro
                   6553:             <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
                   6554:             executables.</p></li>
                   6555: </ul></div>
                   6556: </div>
                   6557: <div class="sect2" lang="en">
                   6558: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6559: <a name="autoconf-automake"></a>17.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75      rillig   6560: <p>If a package needs GNU autoconf or automake to be executed
                   6561:         to regenerate the configure script and Makefile.in makefile
                   6562:         templates, then they should be executed in a pre-configure
                   6563:         target.</p>
                   6564: <p>For packages that need only autoconf:</p>
                   6565: <pre class="programlisting">
                   6566:     AUTOCONF_REQD=  2.50            # if default version is not good enough
                   6567:     USE_TOOLS+=     autoconf        # use "autoconf213" for autoconf-2.13
                   6568:     ...
1.1       grant    6569: 
1.75      rillig   6570:     pre-configure:
                   6571:             cd ${WRKSRC}; autoconf
1.1       grant    6572: 
1.75      rillig   6573:     ...
                   6574: </pre>
                   6575: <p>and for packages that need automake and autoconf:</p>
                   6576: <pre class="programlisting">
                   6577:     AUTOMAKE_REQD=  1.7.1           # if default version is not good enough
                   6578:     USE_TOOLS+=     automake        # use "automake14" for automake-1.4
                   6579:     ...
1.1       grant    6580: 
1.75      rillig   6581:     pre-configure:
                   6582:             cd ${WRKSRC};                          \
                   6583:             aclocal; autoheader;                   \
                   6584:             automake -a --foreign -i; autoconf
1.1       grant    6585: 
1.75      rillig   6586:     ...
                   6587: </pre>
                   6588: <p>Packages which use GNU Automake will almost certainly
                   6589:           require GNU Make.</p>
                   6590: <p>There are times when the configure process makes
                   6591:           additional  changes to the generated files, which then causes
                   6592:           the build  process to try to re-execute the automake sequence.
                   6593:           This is  prevented by touching various files in the configure
                   6594:           stage. If  this causes problems with your package you can set
                   6595:           <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
                   6596:           Makefile.</p>
                   6597: </div>
                   6598: </div>
                   6599: <div class="sect1" lang="en">
                   6600: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   6601: <a name="fixes.build"></a>17.4. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
        !          6602: <p>The most common failures when building a package are that
        !          6603:        some platforms do not provide certain header files, functions or
        !          6604:        libraries, or they provide the functions in a library that the
        !          6605:        original package author didn't know. To work around this, you
        !          6606:        can rewrite the source code in most cases so that it does not
        !          6607:        use the missing functions or provides a replacement function.</p>
        !          6608: <div class="sect2" lang="en">
        !          6609: <div class="titlepage"><div><div><h3 class="title">
        !          6610: <a name="fixes.build.cpp"></a>17.4.1. Compiling C and C++ code conditionally</h3></div></div></div>
        !          6611: <p>If a package already comes with a GNU configure script, the
        !          6612:        preferred way to fix the build failure is to change the
        !          6613:        configure script, not the code. In the other cases, you can
        !          6614:        utilize the C preprocessor, which defines certain macros
        !          6615:        depending on the operating system and hardware architecture it
        !          6616:        compiles for. These macros can be queried using for example
        !          6617:        <code class="varname">#if defined(__i386)</code>. Almost every operating
        !          6618:        system, hardware architecture and compiler has its own macro.
        !          6619:        For example, if the macros <code class="varname">__GNUC__</code>,
        !          6620:        <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
        !          6621:        are all defined, you know that you are using NetBSD on an i386
        !          6622:        compatible CPU, and your compiler is GCC.</p>
        !          6623: <p>The list of the following macros for hardware and
        !          6624:        operating system depends on the compiler that is used. For
        !          6625:        example, if you want to conditionally compile code on Solaris,
        !          6626:        don't use <code class="varname">__sun__</code>, as the SunPro compiler
        !          6627:        does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75      rillig   6628: <div class="sect3" lang="en">
                   6629: <div class="titlepage"><div><div><h4 class="title">
1.77    ! rillig   6630: <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   6631: <p>To distinguish between 4.4 BSD-derived systems and the
                   6632:         rest of the world, you should use the following code.</p>
                   6633: <pre class="programlisting">
                   6634:     #include &lt;sys/param.h&gt;
                   6635:     #if (defined(BSD) &amp;&amp; BSD &gt;= 199306)
                   6636:       /* BSD-specific code goes here */
                   6637:     #else
                   6638:       /* non-BSD-specific code goes here */
                   6639:     #endif
                   6640: </pre>
1.77    ! rillig   6641: <p>If this distinction is not fine enough, you can also test
        !          6642:        for the following macros.</p>
1.75      rillig   6643: <pre class="programlisting">
                   6644:     FreeBSD     __FreeBSD__
                   6645:     DragonFly   __DragonFly__
                   6646:     Interix     __INTERIX
                   6647:     Linux       linux, __linux, __linux__
                   6648:     NetBSD      __NetBSD__
                   6649:     OpenBSD     __OpenBSD__
                   6650:     Solaris     sun, __sun
                   6651: </pre>
                   6652: </div>
                   6653: <div class="sect3" lang="en">
                   6654: <div class="titlepage"><div><div><h4 class="title">
1.77    ! rillig   6655: <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   6656: <pre class="programlisting">
                   6657:     i386        i386, __i386, __i386__
                   6658:     MIPS        __mips
                   6659:     SPARC       sparc, __sparc
                   6660: </pre>
                   6661: </div>
                   6662: <div class="sect3" lang="en">
                   6663: <div class="titlepage"><div><div><h4 class="title">
1.77    ! rillig   6664: <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   6665: <pre class="programlisting">
                   6666:     GCC         __GNUC__ (major version), __GNUC_MINOR__
                   6667:     SunPro      __SUNPRO_C (0x570 for version 5.7)
                   6668: </pre>
                   6669: </div>
                   6670: </div>
                   6671: </div>
                   6672: <div class="sect1" lang="en">
                   6673: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   6674: <a name="package-specific-actions"></a>17.5. Package specific actions</h2></div></div></div>
1.75      rillig   6675: <div class="sect2" lang="en">
                   6676: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6677: <a name="user-interaction"></a>17.5.1. User interaction</h3></div></div></div>
1.75      rillig   6678: <p>Occasionally, packages require interaction from the user, and this can be
                   6679:         in a number of ways:</p>
                   6680: <div class="itemizedlist"><ul type="disc">
                   6681: <li><p>help in fetching the distfiles</p></li>
                   6682: <li><p>help to configure the package before it is built</p></li>
                   6683: <li><p>help during the build process</p></li>
                   6684: <li><p>help during the installation of a package</p></li>
                   6685: </ul></div>
                   6686: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is provided to notify
                   6687:         the pkgsrc mechanism of an interactive stage which will be needed, and
1.76      rillig   6688:         this should be set in the package's <code class="filename">Makefile</code>, e.g.:</p>
1.75      rillig   6689: <pre class="programlisting">
                   6690:     INTERACTIVE_STAGE=      build
                   6691: </pre>
                   6692: <p>Multiple interactive stages can be specified:</p>
                   6693: <pre class="programlisting">
                   6694:     INTERACTIVE_STAGE=      configure install
                   6695: </pre>
                   6696: </div>
                   6697: <div class="sect2" lang="en">
                   6698: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6699: <a name="handling-licenses"></a>17.5.2. Handling licenses</h3></div></div></div>
1.75      rillig   6700: <p>A package may be covered by a license which the user has
                   6701:         or has not agreed to accept.  For these cases, pkgsrc contains
                   6702:         a mechanism to note that a package is covered by a particular
                   6703:         license, and the package cannot be built unless the user has
                   6704:         accepted the license.  (Installation of binary packages are
                   6705:         not currently subject to this mechanism.)  Packages with
                   6706:         licenses that are either Open Source according to the Open
                   6707:         Source Initiative or Free according to the Free Software
                   6708:         Foundation will not be marked with a license tag.  Packages
                   6709:         with licenses that have not been determined to meet either
                   6710:         definition will be marked with a license tag referring to the
                   6711:         license.  This will prevent building unless pkgsrc is informed
                   6712:         that the license is acceptable, and enables displaying the
                   6713:         license.</p>
                   6714: <p>The license tag mechanism is intended to address
                   6715:        copyright-related issues surrounding building, installing and
                   6716:        using a package, and not to address redistribution issues (see
                   6717:        <code class="varname">RESTRICTED</code> and
                   6718:        <code class="varname">NO_SRC_ON_FTP</code>, etc.).  However, the above
                   6719:        definition of licenses for which tags are not needed implies
                   6720:        that packages with redistribution restrictions should have
                   6721:        tags.</p>
                   6722: <p>
                   6723:         Denoting that a package is covered by a particular license is
                   6724:         done by placing the license in
1.76      rillig   6725:         <code class="filename">pkgsrc/licenses</code> and setting the
1.75      rillig   6726:         <code class="varname">LICENSE</code> variable to a string identifying
                   6727:         the license, e.g. in
1.76      rillig   6728:        <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>: </p>
1.75      rillig   6729: <pre class="programlisting">
                   6730:     LICENSE=        xv-license
                   6731: </pre>
                   6732: <p>
                   6733:        When trying to build, the user will get a notice that the
                   6734:         package is covered by a license which has not been
                   6735:         accepted:</p>
                   6736: <pre class="programlisting">
                   6737:     <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
                   6738:     ===&gt; xv-3.10anb9 has an unacceptable license: xv-license.
                   6739:     ===&gt;     To view the license, enter "/usr/bin/make show-license".
                   6740:     ===&gt;     To indicate acceptance, add this line to your /etc/mk.conf:
                   6741:     ===&gt;     ACCEPTABLE_LICENSES+=xv-license
                   6742:     *** Error code 1
                   6743: </pre>
                   6744: <p>The license can be viewed with <span><strong class="command">make
                   6745:           show-license</strong></span>, and if it is considered appropriate,
                   6746:           the line printed above can be added to
1.76      rillig   6747:           <code class="filename">/etc/mk.conf</code> to indicate acceptance of
1.75      rillig   6748:           the particular license:</p>
                   6749: <pre class="programlisting">
                   6750:     ACCEPTABLE_LICENSES+=xv-license
                   6751: </pre>
                   6752: <p>When adding a package with a new license, the license
1.76      rillig   6753:           text should be added to <code class="filename">pkgsrc/licenses</code>
1.75      rillig   6754:           for displaying. A list of known licenses can be seen in this
                   6755:           directory as well as by looking at the list of (commented
                   6756:           out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
                   6757:           settings in
1.76      rillig   6758:           <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
1.75      rillig   6759: <p>The use of <code class="varname">LICENSE=shareware</code>,
                   6760:          <code class="varname">LICENSE=no-commercial-use</code>, and similar
                   6761:          language is deprecated because it does not crisply refer to
                   6762:          a particular license text.  Another problem with such usage
                   6763:          is that it does not enable a user to denote acceptance of
                   6764:          the license for a single package without accepting the same
                   6765:          license text for another package.  In particular, this can
                   6766:          be inappropriate when e.g. one accepts a particular license to
                   6767:          indicate to pkgsrc that a fee has been paid.</p>
                   6768: </div>
1.77    ! rillig   6769: </div>
        !          6770: <div class="sect1" lang="en">
        !          6771: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
        !          6772: <a name="fixes.install"></a>17.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75      rillig   6773: <div class="sect2" lang="en">
                   6774: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6775: <a name="installing-score-files"></a>17.6.1. Installing score files</h3></div></div></div>
1.75      rillig   6776: <p>Certain packages, most of them in the games category, install
                   6777:         a score file that allows all users on the system to record their
                   6778:         highscores.  In order for this to work, the binaries need to be
                   6779:         installed setgid and the score files owned by the appropriate
                   6780:         group and/or owner (traditionally the "games" user/group).  The
                   6781:         following variables, documented in more detail in
1.76      rillig   6782:         <code class="filename">mk/defaults/mk.conf</code>, control this
1.75      rillig   6783:         behaviour: <code class="varname">SETGIDGAME</code>,
                   6784:         <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
                   6785:         <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
                   6786: <p>Note that per default, setgid installation of games is
                   6787:         disabled;  setting <code class="varname">SETGIDGAME=YES</code> will set all
                   6788:         the other variables accordingly.</p>
                   6789: <p>A package should therefor never hard code file ownership or
                   6790:         access permissions but rely on <code class="varname">INSTALL_GAME</code> and
                   6791:         <code class="varname">INSTALL_GAME_DATA</code> to set these
                   6792:         correctly.</p>
                   6793: </div>
                   6794: <div class="sect2" lang="en">
                   6795: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6796: <a name="perl-scripts"></a>17.6.2. Packages containing perl scripts</h3></div></div></div>
1.75      rillig   6797: <p>
                   6798:         If your package contains interpreted perl scripts, set
                   6799:         <code class="varname">REPLACE_PERL</code> to ensure that the proper
                   6800:         interpreter path is set. <code class="varname">REPLACE_PERL</code> should
                   6801:         contain a list of scripts, relative to
                   6802:         <code class="varname">WRKSRC</code>, that you want adjusted.</p>
                   6803: </div>
                   6804: <div class="sect2" lang="en">
                   6805: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6806: <a name="hardcoded-paths"></a>17.6.3. Packages with hardcoded paths to other interpreters</h3></div></div></div>
1.75      rillig   6807: <p>
                   6808:         Your package may also contain scripts with hardcoded paths to
                   6809:         other interpreters besides (or as well as) perl.  To correct the
                   6810:         full pathname to the script interpreter, you need to set the
1.76      rillig   6811:         following definitions in your <code class="filename">Makefile</code> (we
1.75      rillig   6812:         shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
                   6813: <pre class="programlisting">
                   6814:     REPLACE_INTERPRETER+=   tcl
                   6815:     REPLACE.tcl.old=        .*/bin/tclsh
                   6816:     REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   6817:     REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   6818:                             # relative to ${WRKSRC}, just as in REPLACE_PERL
                   6819: </pre>
                   6820: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   6821: <h3 class="title">Note</h3>
                   6822: <p>Before March 2006, these variables were called
                   6823:        <code class="varname">_REPLACE.*</code> and
                   6824:        <code class="varname">_REPLACE_FILES.*</code>.</p>
                   6825: </div>
                   6826: </div>
                   6827: <div class="sect2" lang="en">
                   6828: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6829: <a name="perl-modules"></a>17.6.4. Packages installing perl modules</h3></div></div></div>
1.75      rillig   6830: <p>Makefiles of packages providing perl5 modules should include
                   6831:         the Makefile fragment
1.76      rillig   6832:         <code class="filename">../../lang/perl5/module.mk</code>.  It provides a
1.75      rillig   6833:         <span><strong class="command">do-configure</strong></span> target for the standard perl
                   6834:         configuration for such modules as well as various hooks to tune
                   6835:         this configuration.  See comments in this file for
                   6836:         details.</p>
                   6837: <p>Perl5 modules will install into different places depending
                   6838:         on the version of perl used during the build process.  To
                   6839:         address this, pkgsrc will append lines to the
1.76      rillig   6840:         <code class="filename">PLIST</code> corresponding to the files listed in
                   6841:         the installed <code class="filename">.packlist</code> file generated by
1.75      rillig   6842:         most perl5 modules.  This is invoked by defining
                   6843:         <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
                   6844:         paths to packlist files, e.g.:</p>
                   6845: <pre class="programlisting">
                   6846:     PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
                   6847: </pre>
                   6848: <p>The variables <code class="varname">PERL5_SITELIB</code>,
                   6849:         <code class="varname">PERL5_SITEARCH</code>, and
                   6850:         <code class="varname">PERL5_ARCHLIB</code> represent the three locations
                   6851:         in which perl5 modules may be installed, and may be used by
                   6852:         perl5 packages that don't have a packlist.  These three
                   6853:         variables are also substituted for in the
1.76      rillig   6854:         <code class="filename">PLIST</code>.</p>
1.75      rillig   6855: </div>
                   6856: <div class="sect2" lang="en">
                   6857: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6858: <a name="faq.info-files"></a>17.6.5. Packages installing info files</h3></div></div></div>
1.75      rillig   6859: <p>Some packages install info files or use the
                   6860:         &#8220;<span class="quote">makeinfo</span>&#8221;  or &#8220;<span class="quote">install-info</span>&#8221;
                   6861:        commands.  <code class="varname">INFO_FILES</code> should be defined in
1.76      rillig   6862:        the package Makefile so that <code class="filename">INSTALL</code> and
                   6863:         <code class="filename">DEINSTALL</code> scripts will be generated to
1.75      rillig   6864:         handle registration of the info files in the Info directory
                   6865:         file. The &#8220;<span class="quote">install-info</span>&#8221; command used for the info
                   6866:         files registration is either provided by the system, or by a
                   6867:         special purpose package automatically added as dependency if
                   6868:         needed.</p>
                   6869: <p><code class="varname">PKGINFODIR</code> is the directory under
1.76      rillig   6870:        <code class="filename">${PREFIX}</code> where info files are primarily
1.75      rillig   6871:        located. <code class="varname">PKGINFODIR</code> defaults to
                   6872:        &#8220;<span class="quote">info</span>&#8221; and can be overridden by the user.</p>
                   6873: <p>The info files for the package should be listed in the
1.76      rillig   6874:        package <code class="filename">PLIST</code>; however any split info files
1.75      rillig   6875:        need not be listed.</p>
                   6876: <p>A package which needs the &#8220;<span class="quote">makeinfo</span>&#8221; command
                   6877:         at build time must add &#8220;<span class="quote">makeinfo</span>&#8221; to
                   6878:         <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
                   6879:         version of the &#8220;<span class="quote">makeinfo</span>&#8221; command is needed it
                   6880:         should be noted with the <code class="varname">TEXINFO_REQD</code>
1.76      rillig   6881:         variable in the package <code class="filename">Makefile</code>. By
1.75      rillig   6882:         default, a minimum version of 3.12 is required. If the system
                   6883:         does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
                   6884:         does not match the required minimum, a build dependency on the
1.76      rillig   6885:         <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   6886:        be added automatically.</p>
                   6887: <p>The build and installation process of the software provided
                   6888:         by the package should not use the
                   6889:         <span><strong class="command">install-info</strong></span> command as the registration of
                   6890:         info files is the task of the package
1.76      rillig   6891:         <code class="filename">INSTALL</code> script, and it must use the
1.75      rillig   6892:         appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
                   6893: <p>To achieve this goal, the pkgsrc infrastructure creates
                   6894:         overriding scripts for the <span><strong class="command">install-info</strong></span> and
                   6895:         <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
                   6896:         in <code class="varname">PATH</code>.</p>
                   6897: <p>The script overriding <span><strong class="command">install-info</strong></span> has
                   6898:         no effect except the logging of a message. The script overriding
                   6899:         <span><strong class="command">makeinfo</strong></span> logs a message and according to the
                   6900:         value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
                   6901:        <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
                   6902: </div>
                   6903: <div class="sect2" lang="en">
                   6904: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6905: <a name="manpages"></a>17.6.6. Packages installing man pages</h3></div></div></div>
1.75      rillig   6906: <p>Many packages install manual pages. The man pages
                   6907:        are installed under <code class="varname">${PREFIX}/${PKGMANDIR}</code>
1.76      rillig   6908:        which is <code class="filename">/usr/pkg/man</code> by default.
1.75      rillig   6909:        <code class="varname">PKGMANDIR</code> defaults to &#8220;<span class="quote">man</span>&#8221;.
                   6910:        For example, you can set <code class="varname">PKGMANDIR</code> to
                   6911:        &#8220;<span class="quote">share/man</span>&#8221; to have man pages install under
1.76      rillig   6912:        <code class="filename">/usr/pkg/share/man/</code> by default.
1.75      rillig   6913:       </p>
                   6914: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   6915: <h3 class="title">Note</h3>
                   6916: <p>The support for a custom <code class="varname">PKGMANDIR</code>
                   6917:        is not complete.
                   6918:       </p>
                   6919: </div>
1.76      rillig   6920: <p>The <code class="filename">PLIST</code> files can just
                   6921:        use <code class="filename">man/</code> as the top level directory
1.75      rillig   6922:        for the man page file entries
                   6923:        and the pkgsrc framework will convert as needed.
                   6924:       </p>
                   6925: <p> Packages that are
                   6926:        configured with <code class="varname">GNU_CONFIGURE</code> set as
                   6927:        &#8220;<span class="quote">yes</span>&#8221;, by default will use the
1.76      rillig   6928:        <code class="filename">./configure</code>
1.75      rillig   6929:        --mandir switch to set where the man pages should be installed.
                   6930:        The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
                   6931:        to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.
                   6932:       </p>
                   6933: <p>
                   6934:        Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
                   6935:        use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
                   6936:        to &#8220;<span class="quote">no</span>&#8221;.
1.76      rillig   6937:        Or if the <code class="filename">./configure</code> script uses
1.75      rillig   6938:        a non-standard use of --mandir, you can set
                   6939:        <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.
                   6940:       </p>
1.77    ! rillig   6941: <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   6942:        information on installation of compressed manual pages.
                   6943:       </p>
                   6944: </div>
                   6945: <div class="sect2" lang="en">
                   6946: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6947: <a name="gconf2-data-files"></a>17.6.7. Packages installing GConf2 data files</h3></div></div></div>
1.75      rillig   6948: <p>
1.76      rillig   6949:         If a package installs <code class="filename">.schemas</code> or
                   6950:         <code class="filename">.entries</code> files, used by GConf2,
1.75      rillig   6951:         you need to take some extra steps to make sure they get registered
                   6952:         in the database:
                   6953: </p>
                   6954: <div class="orderedlist"><ol type="1">
1.76      rillig   6955: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
                   6956:           instead of its <code class="filename">buildlink3.mk</code> file.  This
1.75      rillig   6957:           takes care of rebuilding the GConf2 database at installation and
                   6958:           deinstallation time, and tells the package where to install
                   6959:           GConf2 data files using some standard configure arguments.  It
                   6960:           also disallows any access to the database directly from the
                   6961:           package.</p></li>
                   6962: <li><p>Ensure that the package installs its
1.76      rillig   6963:           <code class="filename">.schemas</code> files under
                   6964:           <code class="filename">${PREFIX}/share/gconf/schemas</code>.  If they get
                   6965:           installed under <code class="filename">${PREFIX}/etc</code>, you will
1.75      rillig   6966:           need to manually patch the package.</p></li>
                   6967: <li><p>Check the PLIST and remove any entries under the etc/gconf
                   6968:           directory, as they will be handled automatically.  See
                   6969:           <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>
                   6970: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.76      rillig   6971:           your <code class="filename">Makefile</code> with a list of all
                   6972:           <code class="filename">.schemas</code> files installed by the package, if
1.75      rillig   6973:           any.  Names must not contain any directories in them.</p></li>
                   6974: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.76      rillig   6975:           your <code class="filename">Makefile</code> with a
                   6976:           list of all <code class="filename">.entries</code> files installed by the
1.75      rillig   6977:           package, if any. Names must not contain any directories in
                   6978:           them.</p></li>
                   6979: </ol></div>
                   6980: </div>
                   6981: <div class="sect2" lang="en">
                   6982: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   6983: <a name="scrollkeeper-data-files"></a>17.6.8. Packages installing scrollkeeper data files</h3></div></div></div>
1.75      rillig   6984: <p>
1.76      rillig   6985:         If a package installs <code class="filename">.omf</code> files, used by
1.75      rillig   6986:         scrollkeeper, you need to take some extra steps to make sure they
                   6987:         get registered in the database:
                   6988: </p>
                   6989: <div class="orderedlist"><ol type="1">
                   6990: <li><p>Include
1.76      rillig   6991:             <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
                   6992:             instead of its <code class="filename">buildlink3.mk</code> file.  This
1.75      rillig   6993:             takes care of rebuilding the scrollkeeper database at
                   6994:             installation and deinstallation time, and disallows any access
                   6995:             to it directly from the package.
                   6996: </p></li>
                   6997: <li><p>Check the PLIST and remove any entries under the
1.76      rillig   6998:             <code class="filename">libdata/scrollkeeper</code> directory, as they
1.75      rillig   6999:             will be handled automatically.</p></li>
1.76      rillig   7000: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.75      rillig   7001:             the PLIST.  It will be handled by scrollkeeper.</p></li>
                   7002: </ol></div>
                   7003: </div>
                   7004: <div class="sect2" lang="en">
                   7005: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7006: <a name="x11-fonts"></a>17.6.9. Packages installing X11 fonts</h3></div></div></div>
1.75      rillig   7007: <p>If a package installs font files, you will need to rebuild
                   7008:         the fonts database in the directory where they get installed at
                   7009:         installation and deinstallation time.  This can be automatically
                   7010:         done by using the pkginstall framework.</p>
                   7011: <p>You can list the directories where fonts are installed in the
                   7012:         <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
                   7013:         variables, where <em class="replaceable"><code>type</code></em> can be one of
                   7014:         &#8220;<span class="quote">ttf</span>&#8221;, &#8220;<span class="quote">type1</span>&#8221; or &#8220;<span class="quote">x11</span>&#8221;.
                   7015:         Also make sure that the database file
1.76      rillig   7016:         <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75      rillig   7017: <p>Note that you should not create new directories for fonts;
                   7018:         instead use the standard ones to avoid that the user needs to
                   7019:         manually configure his X server to find them.</p>
                   7020: </div>
                   7021: <div class="sect2" lang="en">
                   7022: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7023: <a name="gtk2-modules"></a>17.6.10. Packages installing GTK2 modules</h3></div></div></div>
1.75      rillig   7024: <p>If a package installs GTK2 immodules or loaders, you need to
                   7025:         take some extra steps to get them registered in the GTK2 database
                   7026:         properly:</p>
                   7027: <div class="orderedlist"><ol type="1">
                   7028: <li><p>Include
1.76      rillig   7029:         <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
                   7030:         <code class="filename">buildlink3.mk</code> file.  This takes care of
1.75      rillig   7031:         rebuilding the database at installation and deinstallation time.
                   7032: </p></li>
                   7033: <li><p>
                   7034:         Set <code class="varname">GTK2_IMMODULES=YES</code> if
                   7035:             your package installs GTK2 immodules.</p></li>
                   7036: <li><p>
                   7037:         Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
                   7038:             GTK2 loaders.</p></li>
                   7039: <li>
                   7040: <p>
                   7041:         Patch the package to not touch any of the GTK2 databases directly.
                   7042:         These are:
                   7043: 
                   7044:         </p>
                   7045: <div class="itemizedlist"><ul type="disc">
1.76      rillig   7046: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
                   7047: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75      rillig   7048: </ul></div>
                   7049: <p>
                   7050: </p>
                   7051: </li>
                   7052: <li><p>
                   7053:         Check the PLIST and remove any entries under the
1.76      rillig   7054:         <code class="filename">libdata/gtk-2.0</code> directory, as they will be
1.75      rillig   7055:         handled automatically.</p></li>
                   7056: </ol></div>
                   7057: </div>
                   7058: <div class="sect2" lang="en">
                   7059: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7060: <a name="sgml-xml-data"></a>17.6.11. Packages installing SGML or XML data</h3></div></div></div>
1.75      rillig   7061: <p>If a package installs SGML or XML data files that need to be
                   7062:         registered in system-wide catalogs (like DTDs, sub-catalogs,
                   7063:         etc.), you need to take some extra steps:
                   7064: </p>
                   7065: <div class="orderedlist"><ol type="1">
                   7066: <li><p>Include
1.76      rillig   7067:             <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
                   7068:             your <code class="filename">Makefile</code>, which takes care of
1.75      rillig   7069:             registering those files in system-wide catalogs at
                   7070:             installation and deinstallation time.</p></li>
                   7071: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
                   7072:             any SGML catalogs installed by the package.</p></li>
                   7073: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
                   7074:             any XML catalogs installed by the package.</p></li>
                   7075: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
                   7076:             to be added to the SGML catalog.  These come in groups of
                   7077:             three strings; see xmlcatmgr(1) for more information
                   7078:             (specifically, arguments recognized by the 'add' action).
                   7079:             Note that you will normally not use this variable.</p></li>
                   7080: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
                   7081:             to be added to the XML catalog.  These come in groups of three
                   7082:             strings; see xmlcatmgr(1) for more information (specifically,
                   7083:             arguments recognized by the 'add' action).  Note that you will
                   7084:             normally not use this variable.
                   7085: </p></li>
                   7086: </ol></div>
                   7087: </div>
                   7088: <div class="sect2" lang="en">
                   7089: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7090: <a name="mime-database"></a>17.6.12. Packages installing extensions to the MIME database</h3></div></div></div>
1.75      rillig   7091: <p>If a package provides extensions to the MIME database by
1.76      rillig   7092:         installing <code class="filename">.xml</code> files inside
                   7093:         <code class="filename">${PREFIX}/share/mime/packages</code>, you
1.75      rillig   7094:         need to take some extra steps to ensure that the database is kept
                   7095:         consistent with respect to these new files:
                   7096: </p>
                   7097: <div class="orderedlist"><ol type="1">
                   7098: <li><p>Include
1.76      rillig   7099:             <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
                   7100:             (avoid using the <code class="filename">buildlink3.mk</code> file from
1.75      rillig   7101:             this same directory, which is reserved for inclusion from
1.76      rillig   7102:             other <code class="filename">buildlink3.mk</code> files).  It takes
1.75      rillig   7103:             care of rebuilding the MIME database at installation and
                   7104:             deinstallation time, and disallows any access to it directly
                   7105:             from the package.</p></li>
                   7106: <li><p>Check the PLIST and remove any entries under the
1.76      rillig   7107:             <code class="filename">share/mime</code> directory,
1.75      rillig   7108:             <span class="emphasis"><em>except</em></span> for files saved under
1.76      rillig   7109:             <code class="filename">share/mime/packages</code>.  The former are
1.75      rillig   7110:             handled automatically by
                   7111:             the update-mime-database program, but the latter are
                   7112:             package-dependent and must be removed by the package that
                   7113:             installed them in the first place.</p></li>
1.76      rillig   7114: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.75      rillig   7115:             from the PLIST.  They will be handled by the shared-mime-info
                   7116:             package.</p></li>
                   7117: </ol></div>
                   7118: </div>
                   7119: <div class="sect2" lang="en">
                   7120: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7121: <a name="intltool"></a>17.6.13. Packages using intltool</h3></div></div></div>
1.75      rillig   7122: <p>If a package uses intltool during its build, include the
1.76      rillig   7123:         <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
1.75      rillig   7124:         which forces it to use the intltool package provided by pkgsrc,
                   7125:         instead of the one bundled with the distribution file.
                   7126: </p>
                   7127: <p>This tracks intltool's build-time dependencies and uses the
                   7128:         latest available version; this way, the package benefits of any
                   7129:         bug fixes that may have appeared since it was released.
                   7130: </p>
                   7131: </div>
                   7132: <div class="sect2" lang="en">
                   7133: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7134: <a name="startup-scripts"></a>17.6.14. Packages installing startup scripts</h3></div></div></div>
1.75      rillig   7135: <p>If a package contains a rc.d script, it won't be copied into
                   7136:         the startup directory by default, but you can enable it, by adding
                   7137:         the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
1.76      rillig   7138:         <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
                   7139:         into <code class="filename">/etc/rc.d</code> when a package is installed, and
1.75      rillig   7140:         it will automatically remove the scripts when the package is
                   7141:         deinstalled.</p>
                   7142: </div>
                   7143: <div class="sect2" lang="en">
                   7144: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7145: <a name="tex-packages"></a>17.6.15. Packages installing TeX modules</h3></div></div></div>
1.75      rillig   7146: <p>If a package installs TeX packages into the texmf tree,
1.76      rillig   7147:         the <code class="filename">ls-R</code> database of the tree needs to be
1.75      rillig   7148:         updated.</p>
                   7149: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                   7150: <h3 class="title">Note</h3>
                   7151: <p>Except the main TeX packages such as teTeX-texmf,
                   7152:          packages should install files
                   7153:          into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
                   7154:          not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
                   7155: </div>
                   7156: <div class="orderedlist"><ol type="1">
                   7157: <li><p>Include
1.76      rillig   7158:             <code class="filename">../../print/teTeX/module.mk</code> instead
                   7159:             of <code class="filename">../../mk/tex.buildlink3.mk</code>.  This
                   7160:             takes care of rebuilding the <code class="filename">ls-R</code>
1.75      rillig   7161:             database at installation and deinstallation time.</p></li>
                   7162: <li>
                   7163: <p>If your package installs files into a texmf
                   7164:             tree other than the one
                   7165:             at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
                   7166:             set <code class="varname">TEXMFDIRS</code> to the list of all texmf
                   7167:             trees that need database update.</p>
                   7168: <p>If your package also installs font map files that need
                   7169:            to be registered using <span><strong class="command">updmap</strong></span>,
                   7170:            set <code class="varname">TEX_FONTMAPS</code> to the list of all
                   7171:            such font map files.  Then <span><strong class="command">updmap</strong></span> will
                   7172:            be run automatically at installation/deinstallation to
                   7173:            enable/disable font map files for TeX output
                   7174:            drivers.</p>
                   7175: </li>
1.76      rillig   7176: <li><p>Make sure that none of <code class="filename">ls-R</code>
                   7177:             databases are included in <code class="filename">PLIST</code>, as
1.75      rillig   7178:             they will be removed only by the teTeX-bin package.</p></li>
                   7179: </ol></div>
                   7180: </div>
                   7181: </div>
                   7182: <div class="sect1" lang="en">
                   7183: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7184: <a name="feedback-to-author"></a>17.7. Feedback to the author</h2></div></div></div>
1.75      rillig   7185: <p>If you have found any bugs in the package you make available,
                   7186:       if you had to do special steps to make it run under NetBSD or
                   7187:       if you enhanced the software in various other ways, be sure
                   7188:       to report these changes back to the original author of the
                   7189:       program! With that kind of support, the next release of the
                   7190:       program can incorporate these fixes, and people not using the
                   7191:       NetBSD packages system can win from your efforts.</p>
                   7192: <p>Support the idea of free software!</p>
                   7193: </div>
                   7194: </div>
                   7195: <div class="chapter" lang="en">
                   7196: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   7197: <a name="debug"></a>Chapter 18. Debugging</h2></div></div></div>
1.75      rillig   7198: <p>To check out all the gotchas when building a package, here are the steps
                   7199:     that I do in order to get a package working. Please note this is basically
                   7200:     the same as what was explained in the previous sections, only with some
                   7201:     debugging aids.</p>
                   7202: <div class="itemizedlist"><ul type="disc">
                   7203: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code>
1.76      rillig   7204:        in <code class="filename">/etc/mk.conf</code></p></li>
1.75      rillig   7205: <li>
1.76      rillig   7206: <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   7207:         create a directory for a new package, change into it, then run
                   7208:         <span><strong class="command">url2pkg</strong></span>:</p>
                   7209: <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>
                   7210: <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>
                   7211: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
                   7212: </li>
1.76      rillig   7213: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
                   7214: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.75      rillig   7215: <li><p>Run <span><strong class="command">make configure</strong></span>
                   7216:       </p></li>
                   7217: <li><p>Add any dependencies glimpsed from documentation and the
                   7218:        configure step to the package's
1.76      rillig   7219:        <code class="filename">Makefile</code>.</p></li>
1.75      rillig   7220: <li>
                   7221: <p>Make the package compile, doing multiple rounds of</p>
                   7222: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
                   7223: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
                   7224: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
                   7225: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
                   7226: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
                   7227: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
                   7228: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
                   7229: <p>Doing as non-root user will ensure that no files are modified that
                   7230:        shouldn't be, especially during the build
                   7231:        phase. <span><strong class="command">mkpatches</strong></span>,
                   7232:        <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
1.76      rillig   7233:        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   7234:        package. </p>
                   7235: </li>
1.76      rillig   7236: <li><p>Look at the <code class="filename">Makefile</code>, fix if necessary;
1.77    ! rillig   7237:        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   7238: <li>
1.76      rillig   7239: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75      rillig   7240: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
                   7241: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST &gt;PLIST</code></strong>
                   7242: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
                   7243: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
                   7244: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.76      rillig   7245: <p>You usually need to be <code class="username">root</code> to do this.
1.75      rillig   7246:        Look if there are any files left:</p>
                   7247: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
                   7248: <p>If this reveals any files that are missing in
1.76      rillig   7249:        <code class="filename">PLIST</code>, add them.</p>
1.75      rillig   7250: </li>
                   7251: <li>
1.76      rillig   7252: <p>Now that the <code class="filename">PLIST</code> is OK,
1.75      rillig   7253:        install the package again and make a binary package:</p>
                   7254: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
                   7255: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
                   7256: </li>
                   7257: <li>
                   7258: <p>Delete the installed package:</p>
                   7259: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete blub</code></strong></pre>
                   7260: </li>
                   7261: <li>
                   7262: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span> command,
                   7263:        which shouldn't find anything now:</p>
                   7264: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
                   7265: </li>
                   7266: <li>
                   7267: <p>Reinstall the binary package:</p>
                   7268: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../blub.tgz</code></strong></pre>
                   7269: </li>
                   7270: <li><p>Play with it. Make sure everything works.</p></li>
                   7271: <li>
                   7272: <p>Run <span><strong class="command">pkglint</strong></span> from
1.76      rillig   7273:         <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   7274:        and fix the problems it reports:</p>
                   7275: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
                   7276: </li>
                   7277: <li><p>Submit (or commit, if you have cvs access);
1.77    ! rillig   7278:        see <a href="#submit" title="Chapter 19. Submitting and Committing">Chapter 19, <i>Submitting and Committing</i></a>.</p></li>
1.75      rillig   7279: </ul></div>
                   7280: </div>
                   7281: <div class="chapter" lang="en">
                   7282: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   7283: <a name="submit"></a>Chapter 19. Submitting and Committing</h2></div></div></div>
1.75      rillig   7284: <div class="toc">
                   7285: <p><b>Table of Contents</b></p>
                   7286: <dl>
1.77    ! rillig   7287: <dt><span class="sect1"><a href="#submitting-binary-packages">19.1. Submitting binary packages</a></span></dt>
        !          7288: <dt><span class="sect1"><a href="#submitting-your-package">19.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
        !          7289: <dt><span class="sect1"><a href="#general-notes-for-changes">19.3. General notes when adding, updating, or removing packages</a></span></dt>
        !          7290: <dt><span class="sect1"><a href="#committing-importing">19.4. Committing: Importing a package into CVS</a></span></dt>
        !          7291: <dt><span class="sect1"><a href="#updating-package">19.5. Updating a package to a newer version</a></span></dt>
        !          7292: <dt><span class="sect1"><a href="#moving-package">19.6. Moving a package in pkgsrc</a></span></dt>
1.75      rillig   7293: </dl>
                   7294: </div>
                   7295: <div class="sect1" lang="en">
                   7296: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7297: <a name="submitting-binary-packages"></a>19.1. Submitting binary packages</h2></div></div></div>
1.75      rillig   7298: <p>Our policy is that we accept binaries only from pkgsrc
                   7299:        developers to guarantee that the packages don't contain any
                   7300:        trojan horses etc. This is not to annoy anyone but rather to
                   7301:        protect our users! You're still free to put up your home-made
                   7302:        binary packages and tell the world where to get them. NetBSD
                   7303:        developers doing bulk builds and wanting to upload them please
                   7304:        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>
                   7305: </div>
                   7306: <div class="sect1" lang="en">
                   7307: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7308: <a name="submitting-your-package"></a>19.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75      rillig   7309: <p>First, check that your package is complete, compiles and
1.77    ! rillig   7310:        runs well; see <a href="#debug" title="Chapter 18. Debugging">Chapter 18, <i>Debugging</i></a> and the rest of this
1.75      rillig   7311:        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>
                   7312:        archive, preferably with all files in a single directory.
                   7313:        Finally, <span><strong class="command">send-pr</strong></span> with category
                   7314:        &#8220;<span class="quote">pkg</span>&#8221;, a synopsis which includes the package name
                   7315:        and version number, a short description of your package
                   7316:        (contents of the COMMENT variable or DESCR file are OK) and
                   7317:        attach the archive to your PR.</p>
                   7318: <p>If you want to submit several packages, please send a
                   7319:        separate PR for each one, it's easier for us to track things
                   7320:        that way.</p>
                   7321: <p>Alternatively, you can also import new packages into
                   7322:        pkgsrc-wip (&#8220;<span class="quote">pkgsrc work-in-progress</span>&#8221;); see the
                   7323:        homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
                   7324:        for details.</p>
                   7325: </div>
                   7326: <div class="sect1" lang="en">
                   7327: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7328: <a name="general-notes-for-changes"></a>19.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75      rillig   7329: <p>Please note all package additions, updates, moves, and
1.76      rillig   7330:        removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75      rillig   7331:        important to keep this file up to date and conforming to the
                   7332:        existing format, because it will be used by scripts to
                   7333:        automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
                   7334:        sites. Additionally, check the
1.76      rillig   7335:        <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75      rillig   7336:        for the package you updated or removed, in case it was mentioned
                   7337:        there.</p>
                   7338: <p>When the <code class="varname">PKGREVISION</code> of a package is
                   7339:        bumped, the change should appear in
1.76      rillig   7340:        <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75      rillig   7341:        related or otherwise relevant. Mass bumps that result from a
                   7342:        dependency being updated should not be mentioned. In all other
                   7343:        cases it's the developer's decision.</p>
                   7344: <p>There is a make target that helps in creating proper
1.76      rillig   7345:   <code class="filename">CHANGES</code> entries:  <span><strong class="command">make
1.75      rillig   7346:   changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
                   7347:   and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76      rillig   7348:   usage is to first make sure that your <code class="filename">CHANGES</code>
1.75      rillig   7349:   file is up-to-date (to avoid having to resolve conflicts later-on)
                   7350:   and then to <span><strong class="command">cd</strong></span> to the package directory.  For
                   7351:   package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
                   7352:   For new packages, or package moves or removals, set the
                   7353:   <code class="varname">CTYPE</code> variable on the command line to "Added",
                   7354:   "Moved", or "Removed".  You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76      rillig   7355:   in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75      rillig   7356:   not the same as your NetBSD login name. Don't forget to commit
1.76      rillig   7357:   the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75      rillig   7358: </div>
                   7359: <div class="sect1" lang="en">
                   7360: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7361: <a name="committing-importing"></a>19.4. Committing: Importing a package into CVS</h2></div></div></div>
1.75      rillig   7362: <p>
                   7363:   This section is only of interest for pkgsrc developers with write
                   7364:   access to the pkgsrc repository. Please remember that cvs
                   7365:   imports files relative to the current working directory, and that
                   7366:   the pathname that you
                   7367:   give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
                   7368:   to place the files in the repository.  Newly created packages should be
                   7369:   imported with a vendor tag of &#8220;<span class="quote">TNF</span>&#8221; and a release tag of
                   7370:   &#8220;<span class="quote">pkgsrc-base</span>&#8221;, e.g:
                   7371: </p>
                   7372: <pre class="programlisting">
                   7373:     <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
                   7374:     <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
                   7375: </pre>
                   7376: <p>
                   7377:   Remember to move the directory from which you imported out of
                   7378:   the way, or cvs will complain the next time you &#8220;<span class="quote">cvs
                   7379:   update</span>&#8221; your source tree.  Also don't forget to add the new
1.76      rillig   7380:   package to the category's <code class="filename">Makefile</code>.
1.75      rillig   7381: </p>
                   7382: <p>
                   7383:   The commit message of the initial import should include part of the
1.76      rillig   7384:   <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.75      rillig   7385:   what the package is/does.
                   7386: </p>
                   7387: <p>
                   7388:   For new packages, &#8220;<span class="quote">cvs import</span>&#8221; is preferred to &#8220;<span class="quote">cvs
                   7389:   add</span>&#8221; because the former gets everything with a single command,
                   7390:   and provides a consistent tag.
                   7391: </p>
                   7392: </div>
                   7393: <div class="sect1" lang="en">
                   7394: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7395: <a name="updating-package"></a>19.5. Updating a package to a newer version</h2></div></div></div>
1.75      rillig   7396: <p>
                   7397:   Please always put a concise, appropriate and relevant summary of the
                   7398:   changes between old and new versions into the commit log when updating
                   7399:   a package. There are various reasons for this:
                   7400: </p>
                   7401: <div class="itemizedlist"><ul type="disc">
                   7402: <li><p>
                   7403:   A URL is volatile, and can change over time. It may go away completely
                   7404:   or its information may be overwritten by newer information.
                   7405: </p></li>
                   7406: <li><p>
                   7407:   Having the change information between old and new versions in our CVS
                   7408:   repository is very useful for people who use either cvs or anoncvs.
                   7409: </p></li>
                   7410: <li><p>
                   7411:   Having the change information between old and new versions in our CVS
                   7412:   repository is very useful for people who read the pkgsrc-changes mailing
                   7413:   list, so that they can make tactical decisions about when to upgrade
                   7414:   the package.
                   7415: </p></li>
                   7416: </ul></div>
                   7417: <p>
                   7418:   Please also recognize that, just because a new version of a package
                   7419:   has been released, it should not automatically be upgraded in the CVS
                   7420:   repository.  We prefer to be conservative in the packages that are
                   7421:   included in pkgsrc - development or beta packages are not really the
                   7422:   best thing for most places in which pkgsrc is used. Please use your
                   7423:   judgement about what should go into pkgsrc, and bear in mind that
                   7424:   stability is to be preferred above new and possibly untested features.
                   7425: </p>
                   7426: </div>
                   7427: <div class="sect1" lang="en">
                   7428: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7429: <a name="moving-package"></a>19.6. Moving a package in pkgsrc</h2></div></div></div>
1.75      rillig   7430: <div class="orderedlist"><ol type="1">
                   7431: <li><p>Make a copy of the directory somewhere else.</p></li>
                   7432: <li>
                   7433: <p>Remove all CVS dirs.</p>
                   7434: <p>
                   7435:   Alternatively to the first two steps you can also do:
                   7436: </p>
                   7437: <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>
                   7438: <p>
                   7439:   and use that for further work.
                   7440: </p>
                   7441: </li>
                   7442: <li><p>Fix <code class="varname">CATEGORIES</code> and any
                   7443: <code class="varname">DEPENDS</code> paths that just did &#8220;<span class="quote">../package</span>&#8221;
                   7444: instead of &#8220;<span class="quote">../../category/package</span>&#8221;.</p></li>
                   7445: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
                   7446: place.</p></li>
                   7447: <li>
                   7448: <p>Check if any package depends on it:
                   7449: </p>
                   7450: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
                   7451: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
                   7452: <p>
                   7453: </p>
                   7454: </li>
                   7455: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
                   7456: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76      rillig   7457: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
                   7458: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75      rillig   7459: <li>
                   7460: <p>Commit the changed and removed files:</p>
                   7461: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
                   7462: <p>
                   7463:   (and any packages from step 5, of course).
                   7464: </p>
                   7465: </li>
                   7466: </ol></div>
                   7467: </div>
                   7468: </div>
                   7469: <div class="chapter" lang="en">
                   7470: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   7471: <a name="devfaq"></a>Chapter 20. Frequently Asked Questions</h2></div></div></div>
1.75      rillig   7472: <p>This section contains the answers to questions that may
                   7473:        arise when you are writing a package. If you don't find your
                   7474:        question answered here, first have a look in the other chapters,
                   7475:        and if you still don't have the answer, ask on the
                   7476:        <code class="literal">pkgsrc-users</code> mailing list.</p>
                   7477: <div class="qandaset">
                   7478: <dl>
1.77    ! rillig   7479: <dt>20.1. <a href="#id2655161">What is the difference between
1.75      rillig   7480:        MAKEFLAGS, .MAKEFLAGS and
                   7481:        MAKE_FLAGS?</a>
                   7482: </dt>
1.77    ! rillig   7483: <dt>20.2. <a href="#id2655197">What is the difference between
1.75      rillig   7484:        MAKE, GMAKE and
                   7485:        MAKE_PROGRAM?</a>
                   7486: </dt>
1.77    ! rillig   7487: <dt>20.3. <a href="#id2655236">What is the difference between
1.75      rillig   7488:        CC, PKG_CC and
                   7489:        PKGSRC_COMPILER?</a>
                   7490: </dt>
1.77    ! rillig   7491: <dt>20.4. <a href="#id2655273">What is the difference between
1.75      rillig   7492:        BUILDLINK_LDFLAGS,
                   7493:        BUILDLINK_LDADD and
                   7494:        BUILDLINK_LIBS?</a>
                   7495: </dt>
1.77    ! rillig   7496: <dt>20.5. <a href="#id2655291">Why does make show-var
1.75      rillig   7497:        VARNAME=BUILDLINK_PREFIX.foo
                   7498:        say it's empty?</a>
                   7499: </dt>
                   7500: </dl>
                   7501: <table border="0" summary="Q and A Set">
                   7502: <col align="left" width="1%">
                   7503: <tbody>
                   7504: <tr class="question">
                   7505: <td align="left" valign="top">
1.77    ! rillig   7506: <a name="id2655161"></a><a name="id2655162"></a><b>20.1.</b>
1.75      rillig   7507: </td>
                   7508: <td align="left" valign="top"><p>What is the difference between
                   7509:        <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
                   7510:        <code class="varname">MAKE_FLAGS</code>?</p></td>
                   7511: </tr>
                   7512: <tr class="answer">
                   7513: <td align="left" valign="top"><b></b></td>
                   7514: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
                   7515:        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
                   7516:        <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
                   7517:        the <code class="varname">MAKE_PROGRAM</code> when building the
                   7518:        package. [FIXME: What is .MAKEFLAGS for?]</p></td>
                   7519: </tr>
                   7520: <tr class="question">
                   7521: <td align="left" valign="top">
1.77    ! rillig   7522: <a name="id2655197"></a><a name="id2655198"></a><b>20.2.</b>
1.75      rillig   7523: </td>
                   7524: <td align="left" valign="top"><p>What is the difference between
                   7525:        <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
                   7526:        <code class="varname">MAKE_PROGRAM</code>?</p></td>
                   7527: </tr>
                   7528: <tr class="answer">
                   7529: <td align="left" valign="top"><b></b></td>
                   7530: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
                   7531:        <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
                   7532:        infrastructure. <code class="varname">GMAKE</code> is the path to GNU
                   7533:        Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
                   7534:        use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
                   7535:        Make program that is used for building the
                   7536:        package.</p></td>
                   7537: </tr>
                   7538: <tr class="question">
                   7539: <td align="left" valign="top">
1.77    ! rillig   7540: <a name="id2655236"></a><a name="id2655237"></a><b>20.3.</b>
1.75      rillig   7541: </td>
                   7542: <td align="left" valign="top"><p>What is the difference between
                   7543:        <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
                   7544:        <code class="varname">PKGSRC_COMPILER</code>?</p></td>
                   7545: </tr>
                   7546: <tr class="answer">
                   7547: <td align="left" valign="top"><b></b></td>
                   7548: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
                   7549:        compiler, which can be configured by the pkgsrc user.
                   7550:        <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
                   7551:        <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
                   7552:        path to a compiler, but the type of compiler that should be
1.76      rillig   7553:        used. See <code class="filename">mk/compiler.mk</code> for more
1.75      rillig   7554:        information about the latter variable.</p></td>
                   7555: </tr>
                   7556: <tr class="question">
                   7557: <td align="left" valign="top">
1.77    ! rillig   7558: <a name="id2655273"></a><a name="id2655274"></a><b>20.4.</b>
1.75      rillig   7559: </td>
                   7560: <td align="left" valign="top"><p>What is the difference between
                   7561:        <code class="varname">BUILDLINK_LDFLAGS</code>,
                   7562:        <code class="varname">BUILDLINK_LDADD</code> and
                   7563:        <code class="varname">BUILDLINK_LIBS</code>?</p></td>
                   7564: </tr>
                   7565: <tr class="answer">
                   7566: <td align="left" valign="top"><b></b></td>
                   7567: <td align="left" valign="top"><p>[FIXME]</p></td>
                   7568: </tr>
                   7569: <tr class="question">
                   7570: <td align="left" valign="top">
1.77    ! rillig   7571: <a name="id2655291"></a><a name="id2655292"></a><b>20.5.</b>
1.75      rillig   7572: </td>
                   7573: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
                   7574:        VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
                   7575:        say it's empty?</p></td>
                   7576: </tr>
                   7577: <tr class="answer">
                   7578: <td align="left" valign="top"><b></b></td>
                   7579: <td align="left" valign="top"><p>For optimization reasons, some variables are only
                   7580:        available in the &#8220;<span class="quote">wrapper</span>&#8221; phase and later. To
                   7581:        &#8220;<span class="quote">simulate</span>&#8221; the wrapper phase, append
                   7582:        <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
                   7583:        command.</p></td>
                   7584: </tr>
                   7585: </tbody>
                   7586: </table>
                   7587: </div>
                   7588: </div>
                   7589: </div>
                   7590: <div class="part" lang="en">
                   7591: <div class="titlepage"><div><div><h1 class="title">
                   7592: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
                   7593: <div class="partintro" lang="en">
                   7594: <div></div>
                   7595: <p>This part of the guide deals with everything
                   7596:        from the infrastructure that is behind the interfaces described
                   7597:        in the developer's guide. A casual package maintainer should not
                   7598:        need anything from this part.</p>
                   7599: <div class="toc">
                   7600: <p><b>Table of Contents</b></p>
                   7601: <dl>
1.77    ! rillig   7602: <dt><span class="chapter"><a href="#infr.design">21. Design of the pkgsrc infrastructure</a></span></dt>
1.75      rillig   7603: <dd><dl>
1.77    ! rillig   7604: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75      rillig   7605: <dd><dl>
1.77    ! rillig   7606: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
        !          7607: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75      rillig   7608: </dl></dd>
1.77    ! rillig   7609: <dt><span class="sect1"><a href="#infr.design.intf">21.2. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig   7610: <dd><dl>
1.77    ! rillig   7611: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.2.1. Procedures with parameters</a></span></dt>
        !          7612: <dt><span class="sect2"><a href="#infr.design.intf.action">21.2.2. Actions taken on behalf of parameters</a></span></dt>
1.75      rillig   7613: </dl></dd>
                   7614: </dl></dd>
1.77    ! rillig   7615: <dt><span class="chapter"><a href="#regression">22. Regression tests</a></span></dt>
1.75      rillig   7616: <dd><dl>
1.77    ! rillig   7617: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
        !          7618: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
        !          7619: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75      rillig   7620: <dd><dl>
1.77    ! rillig   7621: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
        !          7622: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75      rillig   7623: </dl></dd>
                   7624: </dl></dd>
1.77    ! rillig   7625: <dt><span class="chapter"><a href="#porting">23. Porting pkgsrc</a></span></dt>
1.75      rillig   7626: <dd><dl>
1.77    ! rillig   7627: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
        !          7628: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75      rillig   7629: </dl></dd>
                   7630: </dl>
                   7631: </div>
                   7632: </div>
                   7633: <div class="chapter" lang="en">
                   7634: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   7635: <a name="infr.design"></a>Chapter 21. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75      rillig   7636: <div class="toc">
                   7637: <p><b>Table of Contents</b></p>
                   7638: <dl>
1.77    ! rillig   7639: <dt><span class="sect1"><a href="#infr.var">21.1. Variable evaluation</a></span></dt>
1.75      rillig   7640: <dd><dl>
1.77    ! rillig   7641: <dt><span class="sect2"><a href="#infr.var.load">21.1.1. At load time</a></span></dt>
        !          7642: <dt><span class="sect2"><a href="#infr.var.run">21.1.2. At runtime</a></span></dt>
1.75      rillig   7643: </dl></dd>
1.77    ! rillig   7644: <dt><span class="sect1"><a href="#infr.design.intf">21.2. Designing interfaces for Makefile fragments</a></span></dt>
1.75      rillig   7645: <dd><dl>
1.77    ! rillig   7646: <dt><span class="sect2"><a href="#infr.design.intf.proc">21.2.1. Procedures with parameters</a></span></dt>
        !          7647: <dt><span class="sect2"><a href="#infr.design.intf.action">21.2.2. Actions taken on behalf of parameters</a></span></dt>
1.75      rillig   7648: </dl></dd>
                   7649: </dl>
                   7650: </div>
                   7651: <p>The pkgsrc infrastructure consists of many small Makefile
                   7652:        fragments. Each such fragment needs a properly specified
                   7653:        interface. This chapter explains how such an interface looks
                   7654:        like.</p>
                   7655: <div class="sect1" lang="en">
                   7656: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7657: <a name="infr.var"></a>21.1. Variable evaluation</h2></div></div></div>
1.75      rillig   7658: <div class="sect2" lang="en">
                   7659: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7660: <a name="infr.var.load"></a>21.1.1. At load time</h3></div></div></div>
1.75      rillig   7661: <p>Variable evaluation takes place either at load time or at
                   7662:        runtime, depending on the context in which they occur. The
                   7663:        contexts where variables are evaluated at load time are:</p>
                   7664: <div class="itemizedlist"><ul type="disc">
                   7665: <li><p>The right hand side of the <code class="literal">:=</code>
                   7666:        and <code class="literal">!=</code> operators,</p></li>
                   7667: <li><p>Make directives like <code class="literal">.if</code> or
                   7668:        <code class="literal">.for</code>,</p></li>
                   7669: <li><p>Dependency lines.</p></li>
                   7670: </ul></div>
                   7671: <p>A special exception are references to the iteration
                   7672:        variables of <code class="literal">.for</code> loops, which are expanded
                   7673:        inline, no matter in which context they appear.</p>
                   7674: <p>As the values of variables may change during load time,
                   7675:        care must be taken not to evaluate them by accident. Typical
                   7676:        examples for variables that should not be evaluated at load time
                   7677:        are <code class="varname">DEPENDS</code> and
                   7678:        <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
                   7679:        clear, here is an example:</p>
                   7680: <pre class="programlisting">
                   7681:     CONFIGURE_ARGS=         # none
                   7682:     CFLAGS=                 -O
                   7683:     CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
1.1       grant    7684: 
1.75      rillig   7685:     CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
1.1       grant    7686: 
1.75      rillig   7687:     CFLAGS+=                -Wall
                   7688:        </pre>
                   7689: <p>This code shows how the use of the <code class="literal">:=</code>
                   7690:        operator can quickly lead to unexpected results. The first
                   7691:        paragraph is fairly common code. The second paragraph evaluates
                   7692:        the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
                   7693:        <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
                   7694:        <code class="literal">-Wall</code> is appended to the
                   7695:        <code class="varname">CFLAGS</code>, but this addition will not appear in
                   7696:        <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
                   7697:        paragraphs from above typically occur in completely unrelated
                   7698:        files.</p>
                   7699: </div>
                   7700: <div class="sect2" lang="en">
                   7701: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7702: <a name="infr.var.run"></a>21.1.2. At runtime</h3></div></div></div>
1.75      rillig   7703: <p>After all the files have been loaded, the values of the
                   7704:        variables cannot be changed anymore. Variables that are used in
                   7705:        the shell commands are expanded at this point.</p>
                   7706: </div>
                   7707: </div>
                   7708: <div class="sect1" lang="en">
                   7709: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7710: <a name="infr.design.intf"></a>21.2. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76      rillig   7711: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75      rillig   7712:        of the following classes. Cases where a file falls into more
                   7713:        than one class should be avoided as it often leads to subtle
                   7714:        bugs.</p>
                   7715: <div class="sect2" lang="en">
                   7716: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7717: <a name="infr.design.intf.proc"></a>21.2.1. Procedures with parameters</h3></div></div></div>
1.75      rillig   7718: <p>In a traditional imperative programming language some of
1.76      rillig   7719:        the <code class="filename">.mk</code> files could be described as
1.75      rillig   7720:        procedures. They take some input parameters and&#8212;after
                   7721:        inclusion&#8212;provide a result in output parameters. Since all
1.76      rillig   7722:        variables in <code class="filename">Makefile</code>s have global scope
1.75      rillig   7723:        care must be taken not to use parameter names that have already
                   7724:        another meaning. For example, <code class="varname">PKGNAME</code> is a
                   7725:        bad choice for a parameter name.</p>
                   7726: <p>Procedures are completely evaluated at preprocessing time.
                   7727:        That is, when calling a procedure all input parameters must be
                   7728:        completely resolvable. For example,
                   7729:        <code class="varname">CONFIGURE_ARGS</code> should never be an input
                   7730:        parameter since it is very likely that further text will be
                   7731:        added after calling the procedure, which would effectively apply
                   7732:        the procedure to only a part of the variable. Also, references
                   7733:        to other variables wit will be modified after calling the
                   7734:        procedure.</p>
                   7735: <p>A procedure can declare its output parameters either as
                   7736:        suitable for use in preprocessing directives or as only
                   7737:        available at runtime. The latter alternative is for variables
                   7738:        that contain references to other runtime variables.</p>
                   7739: <p>Procedures shall be written such that it is possible to
                   7740:        call the procedure more than once. That is, the file must not
                   7741:        contain multiple-inclusion guards.</p>
                   7742: <p>Examples for procedures are
1.76      rillig   7743:        <code class="filename">mk/bsd.options.mk</code> and
                   7744:        <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75      rillig   7745:        that the parameters are evaluated at load time, they should be
                   7746:        assigned using the <code class="literal">:=</code> operator, which should
                   7747:        be used only for this purpose.</p>
                   7748: </div>
                   7749: <div class="sect2" lang="en">
                   7750: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7751: <a name="infr.design.intf.action"></a>21.2.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75      rillig   7752: <p>Action files take some input parameters and may define
                   7753:        runtime variables. They shall not define loadtime variables.
                   7754:        There are action files that are included implicitly by the
                   7755:        pkgsrc infrastructure, while other must be included
                   7756:        explicitly.</p>
                   7757: <p>An example for action files is
1.76      rillig   7758:        <code class="filename">mk/subst.mk</code>.</p>
1.75      rillig   7759: </div>
                   7760: </div>
                   7761: </div>
                   7762: <div class="chapter" lang="en">
                   7763: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   7764: <a name="regression"></a>Chapter 22. Regression tests</h2></div></div></div>
1.75      rillig   7765: <div class="toc">
                   7766: <p><b>Table of Contents</b></p>
                   7767: <dl>
1.77    ! rillig   7768: <dt><span class="sect1"><a href="#regression.descr">22.1. The regression tests framework</a></span></dt>
        !          7769: <dt><span class="sect1"><a href="#regression.run">22.2. Running the regression tests</a></span></dt>
        !          7770: <dt><span class="sect1"><a href="#regression.new">22.3. Adding a new regression test</a></span></dt>
1.75      rillig   7771: <dd><dl>
1.77    ! rillig   7772: <dt><span class="sect2"><a href="#regression.fun.override">22.3.1. Overridable functions</a></span></dt>
        !          7773: <dt><span class="sect2"><a href="#regression.fun.helper">22.3.2. Helper functions</a></span></dt>
1.75      rillig   7774: </dl></dd>
                   7775: </dl>
                   7776: </div>
                   7777: <p>The pkgsrc infrastructure consists of a large codebase,
                   7778:        and there are many corners where every little bit of a file is
                   7779:        well thought out, making pkgsrc likely to fail as soon as
                   7780:        anything is changed near those parts. To prevent most changes
                   7781:        from breaking anything, a suite of regression tests should go
                   7782:        along with every important part of the pkgsrc infrastructure.
                   7783:        This chapter describes how regression tests work in pkgsrc and
                   7784:        how you can add new tests.</p>
                   7785: <div class="sect1" lang="en">
                   7786: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7787: <a name="regression.descr"></a>22.1. The regression tests framework</h2></div></div></div>
1.75      rillig   7788: <p></p>
                   7789: </div>
                   7790: <div class="sect1" lang="en">
                   7791: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7792: <a name="regression.run"></a>22.2. Running the regression tests</h2></div></div></div>
1.76      rillig   7793: <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   7794:        provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
                   7795:        can simply run that command, which will run all tests in the
1.76      rillig   7796:        <code class="filename">regress</code> category.</p>
1.75      rillig   7797: </div>
                   7798: <div class="sect1" lang="en">
                   7799: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7800: <a name="regression.new"></a>22.3. Adding a new regression test</h2></div></div></div>
1.76      rillig   7801: <p>Every directory in the <code class="filename">regress</code>
                   7802:        category that contains a file called <code class="filename">spec</code>
1.75      rillig   7803:        is considered a regression test. This file is a shell program
                   7804:        that is included by the <span><strong class="command">pkg_regress</strong></span> command.
                   7805:        The following functions can be overridden to suit your
                   7806:        needs.</p>
                   7807: <div class="sect2" lang="en">
                   7808: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7809: <a name="regression.fun.override"></a>22.3.1. Overridable functions</h3></div></div></div>
1.75      rillig   7810: <p>These functions do not take any parameters. They are all
                   7811:        called in &#8220;<span class="quote">set -e</span>&#8221; mode, so you should be careful
                   7812:        to check the exitcodes of any commands you run in the
                   7813:        test.</p>
                   7814: <div class="variablelist"><dl>
                   7815: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
                   7816: <dd><p>This function prepares the environment for the
                   7817:        test. By default it does nothing.</p></dd>
                   7818: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
                   7819: <dd><p>This function runs the actual test. By default,
                   7820:        it calls <code class="varname">TEST_MAKE</code> with the arguments
                   7821:        <code class="varname">MAKEARGS_TEST</code> and writes its output including
                   7822:        error messages into the file
                   7823:        <code class="varname">TEST_OUTFILE</code>.</p></dd>
                   7824: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
                   7825: <dd><p>This function is run after the test and is
                   7826:        typically used to compare the actual output from the one that is
                   7827:        expected. It can make use of the various helper functions from
                   7828:        the next section.</p></dd>
                   7829: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
                   7830: <dd><p>This function cleans everything up after the
                   7831:        test has been run. By default it does nothing.</p></dd>
                   7832: </dl></div>
                   7833: </div>
                   7834: <div class="sect2" lang="en">
                   7835: <div class="titlepage"><div><div><h3 class="title">
1.77    ! rillig   7836: <a name="regression.fun.helper"></a>22.3.2. Helper functions</h3></div></div></div>
1.75      rillig   7837: <div class="variablelist"><dl>
                   7838: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
                   7839: <dd><p>This function compares the exitcode of the
                   7840:        <span><strong class="command">do_test()</strong></span> function with its first parameter.
                   7841:        If they differ, the test will fail.</p></dd>
                   7842: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
                   7843: <dd><p>This function checks for each of its parameters
                   7844:        if the output from <span><strong class="command">do_test()</strong></span> matches the
                   7845:        extended regular expression. If it does not, the test will
                   7846:        fail.</p></dd>
                   7847: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
                   7848: <dd><p>This function checks for each of its parameters
                   7849:        if the output from <span><strong class="command">do_test()</strong></span> does
                   7850:        <span class="emphasis"><em>not</em></span> match the extended regular expression.
                   7851:        If any of the regular expressions matches, the test will
                   7852:        fail.</p></dd>
                   7853: </dl></div>
                   7854: </div>
                   7855: </div>
                   7856: </div>
                   7857: <div class="chapter" lang="en">
                   7858: <div class="titlepage"><div><div><h2 class="title">
1.77    ! rillig   7859: <a name="porting"></a>Chapter 23. Porting pkgsrc</h2></div></div></div>
1.75      rillig   7860: <div class="toc">
                   7861: <p><b>Table of Contents</b></p>
                   7862: <dl>
1.77    ! rillig   7863: <dt><span class="sect1"><a href="#porting.opsys">23.1. Porting pkgsrc to a new operating system</a></span></dt>
        !          7864: <dt><span class="sect1"><a href="#porting.compiler">23.2. Adding support for a new compiler</a></span></dt>
1.75      rillig   7865: </dl>
                   7866: </div>
                   7867: <p>The pkgsrc system has already been ported to many
                   7868:        operating systems, hardware architectures and compilers. This
                   7869:        chapter explains the necessary steps to make pkgsrc even more
                   7870:        portable.</p>
                   7871: <div class="sect1" lang="en">
                   7872: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7873: <a name="porting.opsys"></a>23.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75      rillig   7874: <p>To port pkgsrc to a new operating system (called
                   7875:        <code class="literal">MyOS</code> in this example), you need to touch the
                   7876:        following files:</p>
                   7877: <div class="variablelist"><dl>
1.76      rillig   7878: <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   7879: <dd><p>This file contains some basic definitions, for
                   7880:        example the name of the C
                   7881:        compiler.</p></dd>
1.76      rillig   7882: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75      rillig   7883: <dd><p>Insert code that defines the variables
                   7884:        <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
                   7885:        <code class="varname">LOWER_OS_VERSION</code>,
                   7886:        <code class="varname">LOWER_VENDOR</code>,
                   7887:        <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
                   7888:        <code class="varname">APPEND_ELF</code>, and the other variables that
                   7889:        appear in this file.</p></dd>
1.76      rillig   7890: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75      rillig   7891: <dd><p>This file contains the platform-specific
                   7892:        definitions that are used by pkgsrc. Start by copying one of the
                   7893:        other files and edit it to your
                   7894:        needs.</p></dd>
1.76      rillig   7895: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75      rillig   7896: <dd><p>This file contains a list of directories,
                   7897:        together with their permission bits and ownership. These
                   7898:        directories will be created automatically with every package
                   7899:        that does not explicitly set <code class="varname">NO_MTREE</code>. There
                   7900:        have been some discussions about whether this file is needed at
                   7901:        all, but with no result.</p></dd>
1.76      rillig   7902: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75      rillig   7903: <dd><p>Just copy one of the pre-existing x11.dist files
                   7904:        to your
1.76      rillig   7905:        <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
                   7906: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75      rillig   7907: <dd><p>On some operating systems, the tools that are
                   7908:        provided with the base system are not good enough for pkgsrc.
                   7909:        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
                   7910:        narrow limit on the line length they can process. Therefore
                   7911:        pkgsrc brings its own tools, which can be enabled
                   7912:        here.</p></dd>
1.76      rillig   7913: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75      rillig   7914: <dd><p>This file defines the paths to all the tools
                   7915:        that are needed by one or the other package in pkgsrc, as well
                   7916:        as by pkgsrc itself. Find out where these tools are on your
                   7917:        platform and add them.</p></dd>
                   7918: </dl></div>
                   7919: <p>Now, you should be able to build some basic packages, like
1.76      rillig   7920:        <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   7921: </div>
                   7922: <div class="sect1" lang="en">
                   7923: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.77    ! rillig   7924: <a name="porting.compiler"></a>23.2. Adding support for a new compiler</h2></div></div></div>
1.75      rillig   7925: <p>TODO</p>
                   7926: </div>
                   7927: </div>
                   7928: </div>
                   7929: <div class="appendix" lang="en">
                   7930: <div class="titlepage"><div><div><h2 class="title">
                   7931: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
                   7932: <div class="toc">
                   7933: <p><b>Table of Contents</b></p>
                   7934: <dl>
                   7935: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
                   7936: <dd><dl>
                   7937: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
                   7938: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
                   7939: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
                   7940: <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>
                   7941: </dl></dd>
                   7942: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
                   7943: </dl>
                   7944: </div>
                   7945: <p>We checked to find a piece of software that wasn't in the packages
                   7946:     collection, and picked GNU bison. Quite why someone would want to have
                   7947:     <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
                   7948:     present in the tree is beyond us, but it's useful for the purposes of
                   7949:     this exercise.</p>
                   7950: <div class="sect1" lang="en">
                   7951: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   7952: <a name="example-files"></a>A.1. files</h2></div></div></div>
                   7953: <div class="sect2" lang="en">
                   7954: <div class="titlepage"><div><div><h3 class="title">
                   7955: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
                   7956: <pre class="programlisting">
1.51      rillig   7957:     # $NetBSD$
                   7958:     #
1.1       grant    7959: 
1.51      rillig   7960:     DISTNAME=       bison-1.25
                   7961:     CATEGORIES=     devel
                   7962:     MASTER_SITES=   ${MASTER_SITE_GNU}
1.1       grant    7963: 
1.51      rillig   7964:     MAINTAINER=     thorpej@NetBSD.org
                   7965:     HOMEPAGE=       http://www.gnu.org/software/bison/bison.html
                   7966:     COMMENT=        GNU yacc clone
1.1       grant    7967: 
1.51      rillig   7968:     GNU_CONFIGURE=  yes
                   7969:     INFO_FILES=     bison.info
1.1       grant    7970: 
1.51      rillig   7971:     .include "../../mk/bsd.pkg.mk"
1.1       grant    7972: </pre>
1.75      rillig   7973: </div>
                   7974: <div class="sect2" lang="en">
                   7975: <div class="titlepage"><div><div><h3 class="title">
                   7976: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
                   7977: <pre class="programlisting">
1.51      rillig   7978:     GNU version of yacc.  Can make re-entrant parsers, and numerous other
1.75      rillig   7979:     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   7980:     of the NetBSD source tree is beyond me.
1.1       grant    7981: </pre>
1.75      rillig   7982: </div>
                   7983: <div class="sect2" lang="en">
                   7984: <div class="titlepage"><div><div><h3 class="title">
                   7985: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
                   7986: <pre class="programlisting">
1.51      rillig   7987:     @comment $NetBSD$
                   7988:     bin/bison
                   7989:     man/man1/bison.1.gz
                   7990:     share/bison.simple
                   7991:     share/bison.hairy
1.1       grant    7992: </pre>
1.75      rillig   7993: </div>
                   7994: <div class="sect2" lang="en">
                   7995: <div class="titlepage"><div><div><h3 class="title">
                   7996: <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>
                   7997: <p>The NetBSD package system comes with
1.76      rillig   7998:         <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   7999:        which helps to check the contents of these
                   8000:        files. After installation it is quite easy to use, just change to the
                   8001:        directory of the package you wish to examine and execute
                   8002:        <span><strong class="command">pkglint</strong></span>:</p>
                   8003: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
                   8004: looks fine.</pre>
                   8005: <p>Depending on the supplied command line arguments (see pkglint(1)),
                   8006:        more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
                   8007:        -Wall</strong></span> for a very thorough check.</p>
                   8008: </div>
                   8009: </div>
                   8010: <div class="sect1" lang="en">
                   8011: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8012: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
                   8013: <p>Create the directory where the package lives,
                   8014:       plus any auxiliary directories:</p>
                   8015: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
                   8016: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
                   8017: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
                   8018: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76      rillig   8019: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.77    ! rillig   8020:       <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   8021:       then continue with fetching the distfile:</p>
                   8022: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1       grant    8023: &gt;&gt; bison-1.25.tar.gz doesn't seem to exist on this system.
                   8024: &gt;&gt; Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   8025: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8026: ftp: Error retrieving file: 500 Internal error
                   8027: 
                   8028: &gt;&gt; Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   8029: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8030: ftp: Error retrieving file: 500 Internal error
                   8031: 
                   8032: &gt;&gt; Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   8033: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75      rillig   8034: Successfully retrieved file.</pre>
                   8035: <p>Generate the checksum of the distfile into
1.76      rillig   8036:       <code class="filename">distinfo</code>:</p>
1.75      rillig   8037: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makesum</code></strong></pre>
                   8038: <p>Now compile:</p>
                   8039: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1       grant    8040: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   8041: ===&gt;  Extracting for bison-1.25
                   8042: ===&gt;  Patching for bison-1.25
                   8043: ===&gt;   Ignoring empty patch directory
                   8044: ===&gt;  Configuring for bison-1.25
                   8045: creating cache ./config.cache
                   8046: checking for gcc... cc
                   8047: checking whether we are using GNU C... yes
                   8048: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   8049: checking how to run the C preprocessor... cc -E
                   8050: checking for minix/config.h... no
                   8051: checking for POSIXized ISC... no
                   8052: checking whether cross-compiling... no
                   8053: checking for ANSI C header files... yes
                   8054: checking for string.h... yes
                   8055: checking for stdlib.h... yes
                   8056: checking for memory.h... yes
                   8057: checking for working const... yes
                   8058: checking for working alloca.h... no
                   8059: checking for alloca... yes
                   8060: checking for strerror... yes
                   8061: updating cache ./config.cache
                   8062: creating ./config.status
                   8063: creating Makefile
                   8064: ===&gt;  Building for bison-1.25
                   8065: 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
                   8066: 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
                   8067: 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
                   8068: 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
                   8069: 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   8070: 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    8071: 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
                   8072: 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
                   8073: 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
                   8074: 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
                   8075: 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
                   8076: 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
                   8077: 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
                   8078: 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
                   8079: 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
                   8080: 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
                   8081: 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
                   8082: 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
                   8083: 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
                   8084: 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
                   8085: 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
                   8086: 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
                   8087: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   8088: rm -f bison.s1
1.75      rillig   8089: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" &lt; ./bison.simple &gt; bison.s1</pre>
                   8090: <p>Everything seems OK, so install the files:</p>
                   8091: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1       grant    8092: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   8093: ===&gt;  Installing for bison-1.25
                   8094: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   8095: rm -f /usr/pkg/bin/bison
                   8096: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   8097: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   8098: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   8099: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   8100: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   8101: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   8102: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75      rillig   8103: ===&gt;  Registering installation for bison-1.25</pre>
                   8104: <p>You can now use bison, and also - if you decide so - remove it with
                   8105:       <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
                   8106:       binary package, do this now:</p>
                   8107: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1       grant    8108: &gt;&gt; Checksum OK for bison-1.25.tar.gz.
                   8109: ===&gt;  Building package for bison-1.25
                   8110: Creating package bison-1.25.tgz
                   8111: Registering depends:.
1.75      rillig   8112: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
                   8113: <p>Now that you don't need the source and object files
                   8114:       any more, clean up:</p>
                   8115: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
                   8116: ===&gt;  Cleaning for bison-1.25</pre>
                   8117: </div>
                   8118: </div>
                   8119: <div class="appendix" lang="en">
                   8120: <div class="titlepage"><div><div><h2 class="title">
                   8121: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
                   8122: <div class="toc">
                   8123: <p><b>Table of Contents</b></p>
                   8124: <dl>
                   8125: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
                   8126: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
                   8127: </dl>
                   8128: </div>
                   8129: <div class="sect1" lang="en">
                   8130: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8131: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
                   8132: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1       grant    8133: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   8134: =&gt; figlet221.tar.gz doesn't seem to exist on this system.
                   8135: =&gt; Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   8136: =&gt; [172219 bytes]
                   8137: Connected to ftp.plig.net.
                   8138: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   8139: 331 Guest login ok, send your complete e-mail address as password.
                   8140: 230-You are user #5 of 500 simultaneous users allowed.
                   8141: 230-
1.68      rillig   8142: 230-  ___ _             _ _
                   8143: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
1.1       grant    8144: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   8145: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   8146: 230-         |_|   |_|     |___|         |___|
                   8147: 230-
                   8148: 230-** Welcome to ftp.plig.org **
                   8149: 230-
                   8150: 230-Please note that all transfers from this FTP site are logged. If you
                   8151: 230-do not like this, please disconnect now.
                   8152: 230-
                   8153: 230-This arhive is available via
                   8154: 230-
                   8155: 230-HTTP:  http://ftp.plig.org/
                   8156: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   8157: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   8158: 230-
                   8159: 230-Please email comments, bug reports and requests for packages to be
1.68      rillig   8160: 230-mirrored to ftp-admin@plig.org.
1.1       grant    8161: 230-
                   8162: 230-
                   8163: 230 Logged in anonymously.
                   8164: Remote system type is UNIX.
                   8165: Using binary mode to transfer files.
                   8166: 200 Type okay.
                   8167: 250 "/pub" is new cwd.
                   8168: 250-"/pub/figlet" is new cwd.
                   8169: 250-
                   8170: 250-Welcome to the figlet archive at ftp.figlet.org
1.68      rillig   8171: 250-
1.75      rillig   8172: 250-   ftp://ftp.figlet.org/pub/figlet/
1.1       grant    8173: 250-
                   8174: 250-The official FIGlet web page is:
1.75      rillig   8175: 250-   http://www.figlet.org/
1.1       grant    8176: 250-
                   8177: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   8178: 250-contribute a font or something else, you can email us.
1.68      rillig   8179: 250
1.1       grant    8180: 250 "/pub/figlet/program" is new cwd.
                   8181: 250 "/pub/figlet/program/unix" is new cwd.
                   8182: local: figlet221.tar.gz remote: figlet221.tar.gz
                   8183: 502 Unimplemented command.
                   8184: 227 Entering Passive Mode (195,40,6,41,246,104)
                   8185: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   8186: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   8187: 226 Transfer completed.
                   8188: 172219 bytes received in 00:02 (75.99 KB/s)
                   8189: 221 Goodbye.
                   8190: =&gt; Checksum OK for figlet221.tar.gz.
                   8191: ===&gt; Extracting for figlet-2.2.1nb2
                   8192: ===&gt; Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   8193: ===&gt; Patching for figlet-2.2.1nb2
                   8194: ===&gt; Applying pkgsrc patches for figlet-2.2.1nb2
                   8195: ===&gt; Overriding tools for figlet-2.2.1nb2
                   8196: ===&gt; Creating toolchain wrappers for figlet-2.2.1nb2
                   8197: ===&gt; Configuring for figlet-2.2.1nb2
                   8198: ===&gt; Building for figlet-2.2.1nb2
                   8199: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   8200: chmod a+x figlet
                   8201: gcc -O2 -o chkfont chkfont.c
                   8202: =&gt; Unwrapping files-to-be-installed.
1.14      xtraeme  8203: <code class="prompt">#</code>
1.75      rillig   8204: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1       grant    8205: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   8206: ===&gt; Installing for figlet-2.2.1nb2
                   8207: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   8208: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   8209: mkdir -p /usr/pkg/share/figlet
                   8210: cp figlet /usr/pkg/bin
                   8211: cp chkfont /usr/pkg/bin
                   8212: chmod 555 figlist showfigfonts
                   8213: cp figlist /usr/pkg/bin
                   8214: cp showfigfonts /usr/pkg/bin
                   8215: cp fonts/*.flf /usr/pkg/share/figlet
                   8216: cp fonts/*.flc /usr/pkg/share/figlet
                   8217: cp figlet.6 /usr/pkg/man/man6
                   8218: ===&gt; Registering installation for figlet-2.2.1nb2
1.75      rillig   8219: <code class="prompt">#</code></pre>
                   8220: </div>
                   8221: <div class="sect1" lang="en">
                   8222: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8223: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
                   8224: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1       grant    8225: ===&gt; Checking for vulnerabilities in figlet-2.2.1nb2
                   8226: ===&gt; Packaging figlet-2.2.1nb2
                   8227: ===&gt; Building binary package for figlet-2.2.1nb2
                   8228: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   8229: Using SrcDir value of /usr/pkg
1.68      rillig   8230: Registering depends:.
1.75      rillig   8231: <code class="prompt">#</code></pre>
                   8232: </div>
                   8233: </div>
                   8234: <div class="appendix" lang="en">
                   8235: <div class="titlepage"><div><div><h2 class="title">
1.76      rillig   8236: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
                   8237: <div class="toc">
                   8238: <p><b>Table of Contents</b></p>
                   8239: <dl>
                   8240: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
                   8241: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
                   8242: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
                   8243: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
                   8244: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
                   8245: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
                   8246: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                   8247: source packages</a></span></dt>
                   8248: </dl>
                   8249: </div>
                   8250: <p>As in other big projects, the directory layout of pkgsrc
                   8251:        is quite complex for newbies. This chapter explains where you
                   8252:        find things on the FTP server. The base directory on
                   8253:        <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>.
                   8254:        This directory contains some subdirectories, which are explained
                   8255:        below.</p>
                   8256: <div class="sect1" lang="en">
                   8257: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8258: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
                   8259: <p>For those who only want to manage binary packages on
                   8260:        systems other than NetBSD, we provide the package management
                   8261:        tools in a separate, small tar file.</p>
                   8262: </div>
                   8263: <div class="sect1" lang="en">
                   8264: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8265: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
                   8266: <p>The directory <code class="filename">distfiles</code> contains lots
                   8267:        of archive files from all pkgsrc packages, which are mirrored
                   8268:        here. The subdirectories are called after their package names
                   8269:        and are used when the distributed files have names that don't
                   8270:        explicitly contain a version number or are otherwise too generic
                   8271:        (for example <code class="filename">release.tar.gz</code>).</p>
                   8272: </div>
                   8273: <div class="sect1" lang="en">
                   8274: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8275: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
                   8276: <p>This directory is currently not in use.</p>
                   8277: </div>
                   8278: <div class="sect1" lang="en">
                   8279: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8280: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
                   8281: <p>This directory contains things that individual pkgsrc
                   8282:        developers find worth publishing.</p>
                   8283: </div>
                   8284: <div class="sect1" lang="en">
                   8285: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8286: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
                   8287: <p>These directories contain binary packages. Those
                   8288:        directories that have a branch name
                   8289:        (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
                   8290:        contain packages from that particular branch. The directory
                   8291:        <code class="filename">packages</code> contains binary packages from
                   8292:        pkgsrc-current. (However, this does not necessarily mean that
                   8293:        the packages are still current anymore.)</p>
                   8294: <p>Below the <code class="filename">packages*</code> directories are
                   8295:        directories that distinguish the packages by operating system
                   8296:        and version, the next directory level specifies the hardware
                   8297:        architecture.</p>
                   8298: <p>In each of the platform-specific directories, there is a
                   8299:        whole binary packages collection. It has a directory called
                   8300:        <code class="filename">All</code> which contains all binary packages.
                   8301:        Besides that, there are various category directories that
                   8302:        contain symbolic links to the real binary packages.</p>
                   8303: </div>
                   8304: <div class="sect1" lang="en">
                   8305: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8306: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
                   8307: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
                   8308: source packages</h2></div></div></div>
                   8309: <p>These directories contain the &#8220;<span class="quote">real</span>&#8221; pkgsrc,
                   8310:        that is the files that define how to create binary packages from
                   8311:        source archives.</p>
                   8312: <p>The directory <code class="filename">pkgsrc</code> contains a
                   8313:        snapshot of the CVS repository, which is updated on a regularly
                   8314:        basis. The file <code class="filename">pkgsrc.tar.gz</code> contains the
                   8315:        same as the directory, ready to be downloaded as a whole.</p>
                   8316: <p>In the directories for the quarterly branches, there is an
                   8317:        additional file called
                   8318:        <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
                   8319:        which contains the state of pkgsrc when it was branched.</p>
                   8320: </div>
1.75      rillig   8321: </div>
                   8322: <div class="appendix" lang="en">
                   8323: <div class="titlepage"><div><div><h2 class="title">
                   8324: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
                   8325: <div class="toc">
                   8326: <p><b>Table of Contents</b></p>
                   8327: <dl>
                   8328: <dt><span class="sect1"><a href="#targets">D.1. Targets</a></span></dt>
                   8329: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
                   8330: </dl>
                   8331: </div>
                   8332: <p>
                   8333:     This section contains information on editing the pkgsrc guide
                   8334:     itself.
                   8335:   </p>
                   8336: <div class="sect1" lang="en">
                   8337: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8338: <a name="targets"></a>D.1. Targets</h2></div></div></div>
                   8339: <p>
                   8340:       The pkgsrc guide's source code is stored in
1.76      rillig   8341:       <code class="filename">pkgsrc/doc/guide/files</code>, and several files are
1.75      rillig   8342:       created from it:
                   8343:     </p>
                   8344: <div class="itemizedlist"><ul type="disc">
                   8345: <li><p>
1.76      rillig   8346:           <code class="filename">pkgsrc/doc/pkgsrc.txt</code>
1.75      rillig   8347:         </p></li>
                   8348: <li><p>
1.76      rillig   8349:           <code class="filename">pkgsrc/doc/pkgsrc.html</code>
1.75      rillig   8350:         </p></li>
                   8351: <li><p>
1.76      rillig   8352:           <code class="filename">http://www.NetBSD.org/Documentation/pkgsrc/</code>:
1.75      rillig   8353:        the documentation on the NetBSD website will be built from
                   8354:        pkgsrc and kept up to date on the web server itself. This
                   8355:        means you <span class="emphasis"><em>must</em></span> make sure that your
                   8356:        changes haven't broken the build!
                   8357:         </p></li>
                   8358: <li><p>
1.76      rillig   8359:           <code class="filename">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</code>:
1.75      rillig   8360:          PDF version of the pkgsrc guide.
                   8361:         </p></li>
                   8362: <li><p>
1.76      rillig   8363:           <code class="filename">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</code>:
1.75      rillig   8364:          PostScript version of the pkgsrc guide.
                   8365:         </p></li>
                   8366: </ul></div>
                   8367: </div>
                   8368: <div class="sect1" lang="en">
                   8369: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                   8370: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
                   8371: <p>
                   8372:       The procedure to edit the pkgsrc guide is:
                   8373:     </p>
                   8374: <div class="itemizedlist"><ul type="disc">
                   8375: <li><p>
                   8376:           Make sure you have the packages needed to re-generate the
                   8377:           pkgsrc guide (and other XML-based NetBSD documentation)
                   8378:           installed. These are &#8220;<span class="quote">netbsd-doc</span>&#8221; for creating the
                   8379:           ASCII and HTML versions, and
                   8380:           &#8220;<span class="quote">netbsd-doc-print</span>&#8221; for the PostScript and PDF
                   8381:           versions. You will need both packages installed, to make sure
                   8382:           documentation is consistent across all formats. The packages
                   8383:           can be found in
1.76      rillig   8384:           <code class="filename">pkgsrc/meta-pkgs/netbsd-doc</code> and
                   8385:           <code class="filename">pkgsrc/meta-pkgs/netbsd-doc-print</code>.
1.75      rillig   8386:         </p></li>
                   8387: <li><p>
                   8388:           Edit the XML file(s) in
1.76      rillig   8389:           <code class="filename">pkgsrc/doc/guide/files</code>.
1.75      rillig   8390:         </p></li>
                   8391: <li><p>
                   8392:           Run <span><strong class="command">make extract &amp;&amp; make do-lint</strong></span> in
1.76      rillig   8393:           <code class="filename">pkgsrc/doc/guide</code> to check the XML
1.75      rillig   8394:           syntax, and fix it if needed.
                   8395:         </p></li>
                   8396: <li><p>
                   8397:           Run <span><strong class="command">make</strong></span> in
1.76      rillig   8398:           <code class="filename">pkgsrc/doc/guide</code> to build the HTML and
1.75      rillig   8399:           ASCII version.
                   8400:         </p></li>
                   8401: <li><p>
                   8402:           If all is well, run <span><strong class="command">make install-doc</strong></span> to put
1.76      rillig   8403:           the generated files into <code class="filename">pkgsrc/doc</code>.
1.75      rillig   8404:         </p></li>
                   8405: <li><p>
                   8406:           <span><strong class="command">cvs commit pkgsrc/doc/guide/files</strong></span>
                   8407:         </p></li>
                   8408: <li><p>
                   8409:           <span><strong class="command">cvs commit -m re-generate pkgsrc/doc/pkgsrc.{html,txt}</strong></span>
                   8410:         </p></li>
                   8411: <li><p>
                   8412:           Until the webserver on www.NetBSD.org is really updated
                   8413:           automatically to pick up changes to the pkgsrc guide
                   8414:           automatically, also run <span><strong class="command">make install-htdocs
                   8415:           HTDOCSDIR=../../../htdocs</strong></span> (or similar, adjust
                   8416:           <code class="varname">HTDOCSDIR</code>!).
                   8417:         </p></li>
                   8418: <li><p>
                   8419:           <span><strong class="command">cvs commit htdocs/Documentation/pkgsrc</strong></span>
                   8420:         </p></li>
                   8421: </ul></div>
                   8422: </div>
                   8423: </div>
                   8424: </div></body>
1.1       grant    8425: </html>

CVSweb <webmaster@jp.NetBSD.org>