Annotation of htdocs/docs/pkgsrc/pkgsrc.txt, revision 1.262

1.1       dsieger     1: The pkgsrc guide
                      2: 
                      3: Documentation on the NetBSD packages system
                      4: 
                      5: Alistair Crooks
                      6: 
                      7: <agc@NetBSD.org>
                      8: 
                      9: Hubert Feyrer
                     10: 
                     11: <hubertf@NetBSD.org>
                     12: 
                     13: The pkgsrc Developers
                     14: 
1.259     leot       15: Copyright   1994-2025 The NetBSD Foundation, Inc
1.1       dsieger    16: 
1.259     leot       17: $NetBSD: pkgsrc.xml,v 1.44 2025/01/01 01:39:11 jnemeth Exp $
1.1       dsieger    18: 
                     19: Abstract
                     20: 
                     21: pkgsrc is a centralized package management system for Unix-like operating
                     22: systems. This guide provides information for users and developers of pkgsrc. It
                     23: covers installation of binary and source packages, creation of binary and
                     24: source packages and a high-level overview about the infrastructure.
                     25: 
                     26: -------------------------------------------------------------------------------
                     27: 
                     28: Table of Contents
                     29: 
                     30: 1. What is pkgsrc?
                     31:     1.1. Introduction
                     32:         1.1.1. Why pkgsrc?
                     33:         1.1.2. Supported platforms
                     34:     1.2. Overview
                     35:     1.3. Terminology
                     36:         1.3.1. Roles involved in pkgsrc
                     37:     1.4. Typography
                     38: I. The pkgsrc user's guide
1.154     rillig     39:     2. Getting help
                     40:     3. Where to get pkgsrc and how to keep it up-to-date
                     41:         3.1. Getting pkgsrc for the first time
                     42:             3.1.1. As tar archive
                     43:             3.1.2. Via anonymous CVS
                     44:         3.2. Keeping pkgsrc up-to-date
                     45:             3.2.1. Via tar files
                     46:             3.2.2. Via CVS
                     47:     4. Using pkgsrc on systems other than NetBSD
                     48:         4.1. Binary distribution
                     49:         4.2. Bootstrapping pkgsrc
                     50:     5. Using pkgsrc
                     51:         5.1. Using binary packages
                     52:             5.1.1. Finding binary packages
                     53:             5.1.2. Installing binary packages
1.202     nia        54:             5.1.3. Updating packages
                     55:             5.1.4. Deinstalling packages
                     56:             5.1.5. Getting information about installed packages
                     57:             5.1.6. Checking for security vulnerabilities in installed packages
                     58:             5.1.7. Finding if newer versions of your installed packages are in
1.259     leot       59:                 pkgsrc
1.202     nia        60:             5.1.8. Other administrative functions
1.154     rillig     61:         5.2. Building packages from source
                     62:             5.2.1. Requirements
                     63:             5.2.2. Fetching distfiles
                     64:             5.2.3. How to build and install
                     65:     6. Configuring pkgsrc
                     66:         6.1. General configuration
                     67:         6.2. Variables affecting the build process
1.241     rillig     68:         6.3. Preferences for native or pkgsrc software
                     69:         6.4. Variables affecting the installation process
                     70:         6.5. Selecting and configuring the compiler
                     71:             6.5.1. Selecting the compiler
                     72:             6.5.2. Additional flags to the compiler (CFLAGS)
                     73:             6.5.3. Additional flags to the linker (LDFLAGS)
                     74:         6.6. Developer/advanced settings
                     75:         6.7. Selecting Build Options
1.154     rillig     76:     7. Creating binary packages
                     77:         7.1. Building a single binary package
                     78:         7.2. Settings for creation of binary packages
                     79:     8. Creating binary packages for everything in pkgsrc (bulk builds)
                     80:         8.1. Preparations
1.180     rillig     81:         8.2. Running a bulk build
1.154     rillig     82:             8.2.1. Configuration
                     83:         8.3. Requirements of a full bulk build
1.178     rillig     84:         8.4. Bulk build variants
1.179     rillig     85:             8.4.1. Detect unknown configure options
                     86:             8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig     87:             8.4.3. Force compiler options only in the build phase
                     88:             8.4.4. Use custom directories
                     89:             8.4.5. Turn warnings into errors
                     90:             8.4.6. Reject packages for which pkglint reports errors
                     91:             8.4.7. Reject packages that contain forbidden strings
                     92:             8.4.8. Reject packages whose self-test fails
                     93:             8.4.9. Reject packages that use undefined shell variables
                     94:             8.4.10. Turn off verbose logging
1.178     rillig     95:         8.5. Creating a multiple CD-ROM packages collection
                     96:             8.5.1. Example of cdpack
1.154     rillig     97:     9. Directory layout of the installed files
                     98:         9.1. File system layout in ${LOCALBASE}
                     99:         9.2. File system layout in ${VARBASE}
                    100:     10. Frequently Asked Questions
                    101:         10.1. Are there any mailing lists for pkg-related discussion?
                    102:         10.2. Utilities for package management (pkgtools)
                    103:         10.3. How to use pkgsrc as non-root
                    104:         10.4. How to resume transfers when fetching distfiles?
                    105:         10.5. How can I install/use modular X.org from pkgsrc?
                    106:         10.6. How to fetch files from behind a firewall
                    107:         10.7. How to fetch files from HTTPS sites
                    108:         10.8. How do I tell make fetch to do passive FTP?
                    109:         10.9. How to fetch all distfiles at once
                    110:         10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.259     leot      111:             mean?
1.154     rillig    112:         10.11. What does "Could not find bsd.own.mk" mean?
1.221     nia       113:         10.12. Using 'sudo' or `priv` with pkgsrc
1.154     rillig    114:         10.13. How do I change the location of configuration files?
                    115:         10.14. Automated security checks
                    116:         10.15. Why do some packages ignore my CFLAGS?
                    117:         10.16. A package does not build. What shall I do?
                    118:         10.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.259     leot      119:             merge conflicts" mean?
1.1       dsieger   120: II. The pkgsrc developer's guide
1.154     rillig    121:     11. Getting help
1.184     rillig    122:     12. Package components - files, directories and contents
                    123:         12.1. Makefile
                    124:         12.2. distinfo
                    125:         12.3. patches/*
                    126:             12.3.1. Structure of a single patch file
                    127:             12.3.2. Creating patch files
                    128:             12.3.3. Sources where the patch files come from
                    129:             12.3.4. Patching guidelines
                    130:             12.3.5. Feedback to the author
                    131:         12.4. Other mandatory files
                    132:         12.5. Optional files
                    133:             12.5.1. Files affecting the binary package
                    134:             12.5.2. Files affecting the build process
                    135:             12.5.3. Files affecting nothing at all
                    136:         12.6. work*
                    137:         12.7. files/*
                    138:     13. The build process
                    139:         13.1. Introduction
                    140:         13.2. Program location
                    141:         13.3. Directories used during the build process
                    142:         13.4. Running a phase
                    143:         13.5. The fetch phase
                    144:             13.5.1. What to fetch and where to get it from
                    145:             13.5.2. How are the files fetched?
                    146:         13.6. The checksum phase
                    147:         13.7. The extract phase
                    148:         13.8. The patch phase
                    149:         13.9. The tools phase
                    150:         13.10. The wrapper phase
                    151:         13.11. The configure phase
                    152:         13.12. The build phase
                    153:         13.13. The test phase
                    154:         13.14. The install phase
                    155:         13.15. The package phase
                    156:         13.16. Cleaning up
                    157:         13.17. Other helpful targets
                    158:     14. Creating a new pkgsrc package from scratch
                    159:         14.1. Common types of packages
1.219     nia       160:             14.1.1. Python modules and programs
                    161:             14.1.2. R packages
                    162:             14.1.3. TeXlive packages
1.184     rillig    163:         14.2. Examples
                    164:             14.2.1. How the www/nvu package came into pkgsrc
                    165:     15. Programming in Makefiles
                    166:         15.1. Caveats
                    167:         15.2. Makefile variables
                    168:             15.2.1. Naming conventions
                    169:         15.3. Code snippets
                    170:             15.3.1. Adding things to a list
                    171:             15.3.2. Echoing a string exactly as-is
                    172:             15.3.3. Passing CFLAGS to GNU configure scripts
                    173:             15.3.4. Handling possibly empty variables
1.229     gutterid  174:             15.3.5. Testing yes/no variables in conditions
1.184     rillig    175:     16. Options handling
                    176:         16.1. Global default options
                    177:         16.2. Converting packages to use bsd.options.mk
                    178:         16.3. Option Names
                    179:         16.4. Determining the options of dependencies
                    180:     17. Tools needed for building or running
                    181:         17.1. Tools for pkgsrc builds
                    182:         17.2. Tools needed by packages
                    183:         17.3. Tools provided by platforms
                    184:     18. Buildlink methodology
                    185:         18.1. Converting packages to use buildlink3
                    186:         18.2. Writing buildlink3.mk files
                    187:             18.2.1. Anatomy of a buildlink3.mk file
                    188:             18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
1.259     leot      189:                 BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.184     rillig    190:         18.3. Writing builtin.mk files
                    191:             18.3.1. Anatomy of a builtin.mk file
                    192:     19. PLIST issues
                    193:         19.1. RCS ID
                    194:         19.2. Semi-automatic PLIST generation
                    195:         19.3. Tweaking output of make print-PLIST
                    196:         19.4. Variable substitution in PLIST
                    197:         19.5. Man page compression
                    198:         19.6. Changing PLIST source with PLIST_SRC
                    199:         19.7. Platform-specific and differing PLISTs
                    200:         19.8. Build-specific PLISTs
                    201:         19.9. Sharing directories between packages
                    202:     20. The pkginstall framework
                    203:         20.1. Files and directories outside the installation prefix
                    204:             20.1.1. Directory manipulation
                    205:             20.1.2. File manipulation
                    206:         20.2. Configuration files
                    207:             20.2.1. How PKG_SYSCONFDIR is set
                    208:             20.2.2. Telling the software where configuration files are
1.239     dholland  209:             20.2.3. Patching installation
                    210:             20.2.4. Declaring configuration files
                    211:             20.2.5. Disabling handling of configuration files
1.184     rillig    212:         20.3. System startup scripts
                    213:             20.3.1. Disabling handling of system startup scripts
                    214:         20.4. System users and groups
                    215:         20.5. System shells
                    216:             20.5.1. Disabling shell registration
                    217:         20.6. Fonts
                    218:             20.6.1. Disabling automatic update of the fonts databases
1.154     rillig    219:     21. Making your package work
                    220:         21.1. General operation
                    221:             21.1.1. How to pull in user-settable variables from mk.conf
                    222:             21.1.2. User interaction
                    223:             21.1.3. Handling licenses
                    224:             21.1.4. Restricted packages
                    225:             21.1.5. Handling dependencies
                    226:             21.1.6. Handling conflicts with other packages
                    227:             21.1.7. Packages that cannot or should not be built
                    228:             21.1.8. Packages which should not be deleted, once installed
                    229:             21.1.9. Handling packages with security problems
                    230:             21.1.10. How to handle incrementing versions when fixing an
1.259     leot      231:                 existing package
1.154     rillig    232:             21.1.11. Substituting variable text in the package files (the SUBST
1.259     leot      233:                 framework)
1.154     rillig    234:         21.2. The fetch phase
                    235:             21.2.1. Packages whose distfiles aren't available for plain
1.259     leot      236:                 downloading
1.154     rillig    237:             21.2.2. How to handle modified distfiles with the 'old' name
                    238:             21.2.3. Packages hosted on github.com
                    239:         21.3. The configure phase
                    240:             21.3.1. Shared libraries - libtool
                    241:             21.3.2. Using libtool on GNU packages that already support libtool
                    242:             21.3.3. GNU Autoconf/Automake
1.223     nia       243:             21.3.4. Meson / ninja
1.260     wiz       244:             21.3.5. Determining the endianness
1.154     rillig    245:         21.4. Programming languages
                    246:             21.4.1. C, C++, and Fortran
                    247:             21.4.2. Java
1.205     wiz       248:             21.4.3. Go
1.223     nia       249:             21.4.4. Rust
                    250:             21.4.5. Packages containing Perl scripts
                    251:             21.4.6. Packages containing shell scripts
                    252:             21.4.7. Other programming languages
1.154     rillig    253:         21.5. The build phase
                    254:             21.5.1. Compiling C and C++ code conditionally
                    255:             21.5.2. How to handle compiler bugs
1.172     rillig    256:             21.5.3. No such file or directory
                    257:             21.5.4. Undefined reference to "..."
                    258:             21.5.5. Running out of memory
1.154     rillig    259:         21.6. The install phase
                    260:             21.6.1. Creating needed directories
                    261:             21.6.2. Where to install documentation
                    262:             21.6.3. Installing highscore files
                    263:             21.6.4. Adding DESTDIR support to packages
                    264:             21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia       265:             21.6.6. Packages installing Perl modules
1.254     wiz       266:             21.6.7. Packages installing pkg-config files
                    267:             21.6.8. Packages installing info files
                    268:             21.6.9. Packages installing man pages
                    269:             21.6.10. Packages installing X11 fonts
                    270:             21.6.11. Packages installing SGML or XML data
                    271:             21.6.12. Packages installing extensions to the MIME database
                    272:             21.6.13. Packages using intltool
                    273:             21.6.14. Packages installing startup scripts
                    274:             21.6.15. Packages installing TeX modules
                    275:             21.6.16. Packages supporting running binaries in emulation
                    276:             21.6.17. Packages installing hicolor icons
                    277:             21.6.18. Packages installing desktop files
1.154     rillig    278:         21.7. Marking packages as having problems
1.184     rillig    279:     22. GNOME packaging and porting
                    280:         22.1. Meta packages
                    281:         22.2. Packaging a GNOME application
                    282:         22.3. Updating GNOME to a newer version
                    283:         22.4. Patching guidelines
1.154     rillig    284:     23. Submitting and Committing
                    285:         23.1. Submitting binary packages
                    286:         23.2. Submitting source packages (for non-NetBSD-developers)
                    287:         23.3. General notes when adding, updating, or removing packages
                    288:         23.4. Commit Messages
                    289:         23.5. Committing: Adding a package to CVS
                    290:         23.6. Updating a package to a newer version
                    291:         23.7. Renaming a package in pkgsrc
                    292:         23.8. Moving a package in pkgsrc
                    293:     24. Frequently Asked Questions
1.1       dsieger   294: III. The pkgsrc infrastructure internals
1.184     rillig    295:     25. Design of the pkgsrc infrastructure
                    296:         25.1. The meaning of variable definitions
                    297:         25.2. Avoiding problems before they arise
                    298:         25.3. Variable evaluation
                    299:             25.3.1. At load time
                    300:             25.3.2. At runtime
                    301:         25.4. How can variables be specified?
                    302:         25.5. Designing interfaces for Makefile fragments
                    303:             25.5.1. Procedures with parameters
                    304:             25.5.2. Actions taken on behalf of parameters
                    305:         25.6. The order in which files are loaded
                    306:             25.6.1. The order in bsd.prefs.mk
                    307:             25.6.2. The order in bsd.pkg.mk
                    308:     26. Regression tests
                    309:         26.1. Running the regression tests
                    310:         26.2. Adding a new regression test
                    311:             26.2.1. Overridable functions
                    312:             26.2.2. Helper functions
                    313:     27. Porting pkgsrc
                    314:         27.1. Porting pkgsrc to a new operating system
1.1       dsieger   315: A. A simple example package: bison
                    316:     A.1. files
                    317:         A.1.1. Makefile
                    318:         A.1.2. DESCR
                    319:         A.1.3. PLIST
                    320:         A.1.4. Checking a package with pkglint
                    321:     A.2. Steps for building, installing, packaging
1.207     leot      322: B. Security hardening
                    323:     B.1. Mechanisms
                    324:         B.1.1. Enabled by default
                    325:         B.1.2. Not enabled by default
                    326:     B.2. Caveats
                    327:         B.2.1. Problems with PKGSRC_MKPIE
                    328:         B.2.2. Problems with PKGSRC_USE_FORTIFY
                    329:         B.2.3. Problems with PKGSRC_USE_RELRO
                    330:         B.2.4. Problems with PKGSRC_USE_SSP
                    331:     B.3. Auditing the system
                    332:         B.3.1. Checking for PIE
                    333:         B.3.2. Checking for partial RELRO
                    334:         B.3.3. Checking for full RELRO
                    335:         B.3.4. Checking for SSP
                    336: C. Build logs
                    337:     C.1. Building figlet
                    338:     C.2. Packaging figlet
                    339: D. Directory layout of the pkgsrc FTP server
                    340:     D.1. distfiles: The distributed source files
                    341:     D.2. misc: Miscellaneous things
                    342:     D.3. packages: Binary packages
                    343:     D.4. reports: Bulk build reports
                    344:     D.5. current, stable, pkgsrc-20xxQy: source packages
                    345: E. Help topics
                    346: F. Editing guidelines for the pkgsrc guide
                    347:     F.1. Make targets
                    348:     F.2. Procedure
1.1       dsieger   349: 
                    350: List of Tables
                    351: 
                    352: 1.1. Platforms supported by pkgsrc
1.184     rillig    353: 12.1. Patching examples
                    354: 22.1. PLIST handling for GNOME packages
1.1       dsieger   355: 
                    356: Chapter 1. What is pkgsrc?
                    357: 
                    358: Table of Contents
                    359: 
                    360: 1.1. Introduction
                    361:     1.1.1. Why pkgsrc?
                    362:     1.1.2. Supported platforms
                    363: 1.2. Overview
                    364: 1.3. Terminology
                    365:     1.3.1. Roles involved in pkgsrc
                    366: 1.4. Typography
                    367: 
                    368: 1.1. Introduction
                    369: 
                    370: There is a lot of software freely available for Unix-based systems, which is
                    371: usually available in form of the source code. Before such software can be used,
                    372: it needs to be configured to the local system, compiled and installed, and this
                    373: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
                    374: some basic commands to handle binary packages, so that not every user has to
                    375: build the packages for himself, which is a time-costly task.
                    376: 
                    377: pkgsrc currently contains several thousand packages, including:
                    378: 
1.104     sevan     379:   * www/apache24 - The Apache web server
1.1       dsieger   380: 
                    381:   * www/firefox - The Firefox web browser
                    382: 
                    383:   * meta-pkgs/gnome - The GNOME Desktop Environment
                    384: 
1.102     ryoon     385:   * meta-pkgs/kde4 - The K Desktop Environment
1.1       dsieger   386: 
1.108     rillig    387: ? just to name a few.
1.1       dsieger   388: 
                    389: pkgsrc has built-in support for handling varying dependencies, such as pthreads
                    390: and X11, and extended features such as IPv6 support on a range of platforms.
                    391: 
                    392: 1.1.1. Why pkgsrc?
                    393: 
                    394: pkgsrc provides the following key features:
                    395: 
                    396:   * Easy building of software from source as well as the creation and
                    397:     installation of binary packages. The source and latest patches are
                    398:     retrieved from a master or mirror download site, checksum verified, then
                    399:     built on your system. Support for binary-only distributions is available
                    400:     for both native platforms and NetBSD emulated platforms.
                    401: 
                    402:   * All packages are installed in a consistent directory tree, including
                    403:     binaries, libraries, man pages and other documentation.
                    404: 
1.104     sevan     405:   * Tracking of package dependencies automatically, including when performing
                    406:     updates, to ensure required packages are installed. The configuration files
                    407:     of various packages are handled automatically during updates, so local
                    408:     changes are preserved.
1.1       dsieger   409: 
                    410:   * Like NetBSD, pkgsrc is designed with portability in mind and consists of
                    411:     highly portable code. This allows the greatest speed of development when
1.26      spz       412:     porting to a new platform. This portability also ensures that pkgsrc is 
1.1       dsieger   413:     consistent across all platforms.
                    414: 
                    415:   * The installation prefix, acceptable software licenses, international
                    416:     encryption requirements and build-time options for a large number of
                    417:     packages are all set in a simple, central configuration file.
                    418: 
                    419:   * The entire source (not including the distribution files) is freely
                    420:     available under a BSD license, so you may extend and adapt pkgsrc to your
                    421:     needs. Support for local packages and patches is available right out of the
                    422:     box, so you can configure it specifically for your environment.
                    423: 
                    424: The following principles are basic to pkgsrc:
                    425: 
1.198     leot      426:   * "It should only work if it's right." -- That means, if a package contains
1.1       dsieger   427:     bugs, it's better to find them and to complain about them rather than to
                    428:     just install the package and hope that it works. There are numerous checks
1.175     gutterid  429:     in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1       dsieger   430:     pkglint), build-time checks (portability of shell scripts), and
                    431:     post-installation checks (installed files, references to shared libraries,
                    432:     script interpreters).
                    433: 
1.198     leot      434:   * "If it works, it should work everywhere" -- Like NetBSD has been ported to
1.1       dsieger   435:     many hardware architectures, pkgsrc has been ported to many operating
                    436:     systems. Care is taken that packages behave the same on all platforms.
                    437: 
                    438: 1.1.2. Supported platforms
                    439: 
                    440: pkgsrc consists of both a source distribution and a binary distribution for
                    441: these operating systems. After retrieving the required source or binaries, you
                    442: can be up and running with pkgsrc in just minutes!
                    443: 
                    444: pkgsrc was derived from FreeBSD's ports system, and initially developed for
                    445: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
                    446: platforms:
                    447: 
                    448: Table 1.1. Platforms supported by pkgsrc
                    449: 
1.92      sevan     450: +-----------------------------------------------------------------------------+
1.229     gutterid  451: |              Platform               | Date Support  |         Notes         |
                    452: |                                     |     Added     |                       |
                    453: |-------------------------------------+---------------+-----------------------|
                    454: |NetBSD                               |   Aug 1997    |                       |
                    455: |-------------------------------------+---------------+-----------------------|
                    456: |Solaris                              |   Mar 1999    |README.Solaris         |
                    457: |-------------------------------------+---------------+-----------------------|
                    458: |Linux                                |   Jun 1999    |README.Linux           |
                    459: |-------------------------------------+---------------+-----------------------|
                    460: |Darwin / Mac OS X / OS X / macOS     |   Oct 2001    |README.macOS           |
                    461: |-------------------------------------+---------------+-----------------------|
                    462: |FreeBSD                              |   Nov 2002    |README.FreeBSD         |
                    463: |-------------------------------------+---------------+-----------------------|
                    464: |OpenBSD                              |   Nov 2002    |README.OpenBSD         |
                    465: |-------------------------------------+---------------+-----------------------|
                    466: |IRIX                                 |   Dec 2002    |README.IRIX            |
                    467: |-------------------------------------+---------------+-----------------------|
1.262   ! dholland  468: |BSD/OS                               |   Dec 2003    |Removed from pkgsrc Mar|
        !           469: |                                     |               |         2025          |
1.229     gutterid  470: |-------------------------------------+---------------+-----------------------|
                    471: |AIX                                  |   Dec 2003    |README.AIX             |
                    472: |-------------------------------------+---------------+-----------------------|
                    473: |Interix (Microsoft Windows Services  |   Mar 2004    |README.Interix         |
                    474: |for Unix)                            |               |                       |
                    475: |-------------------------------------+---------------+-----------------------|
                    476: |DragonFlyBSD                         |   Oct 2004    |                       |
                    477: |-------------------------------------+---------------+-----------------------|
                    478: |OSF/1                                |   Nov 2004    |README.OSF1            |
                    479: |-------------------------------------+---------------+-----------------------|
                    480: |HP-UX                                |   Apr 2007    |README.HPUX            |
                    481: |-------------------------------------+---------------+-----------------------|
                    482: |Haiku                                |   Sep 2010    |README.Haiku           |
                    483: |-------------------------------------+---------------+-----------------------|
1.262   ! dholland  484: |MirBSD                               |   Jan 2011    |Removed from pkgsrc Mar|
        !           485: |                                     |               |         2025          |
1.229     gutterid  486: |-------------------------------------+---------------+-----------------------|
                    487: |Minix3                               |   Nov 2011    |README.Minix3          |
                    488: |-------------------------------------+---------------+-----------------------|
                    489: |Cygwin                               |   Mar 2013    |README.Cygwin          |
                    490: |-------------------------------------+---------------+-----------------------|
1.261     maya      491: |GNU/kFreeBSD                         |   Jul 2013    |Removed from pkgsrc Mar|
                    492: |                                     |               |2025                   |
1.229     gutterid  493: |-------------------------------------+---------------+-----------------------|
                    494: |Bitrig                               |   Jun 2014    |Removed from pkgsrc Sep|
                    495: |                                     |               |2022                   |
1.92      sevan     496: +-----------------------------------------------------------------------------+
1.1       dsieger   497: 
                    498: 
                    499: 1.2. Overview
                    500: 
                    501: This document is divided into three parts. The first, The pkgsrc user's guide,
                    502: describes how one can use one of the packages in the Package Collection, either
                    503: by installing a precompiled binary package, or by building one's own copy using
                    504: the NetBSD package system. The second part, The pkgsrc developer's guide,
                    505: explains how to prepare a package so it can be easily built by other NetBSD
                    506: users without knowing about the package's building details. The third part, The
                    507: pkgsrc infrastructure internals is intended for those who want to understand
                    508: how pkgsrc is implemented.
                    509: 
                    510: This document is available in various formats: HTML, PDF, PS, TXT.
                    511: 
                    512: 1.3. Terminology
                    513: 
                    514: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
                    515: description of all the terminology used within this document.
                    516: 
                    517: Package
                    518: 
                    519:     A set of files and building instructions that describe what's necessary to
                    520:     build a certain piece of software using pkgsrc. Packages are traditionally
1.123     wiz       521:     stored under /usr/pkgsrc, but may be stored in any location, referred to as
                    522:     PKGSRCDIR.
1.1       dsieger   523: 
                    524: The NetBSD package system
                    525: 
                    526:     This is the former name of "pkgsrc". It is part of the NetBSD operating
                    527:     system and can be bootstrapped to run on non-NetBSD operating systems as
                    528:     well. It handles building (compiling), installing, and removing of
                    529:     packages.
                    530: 
                    531: Distfile
                    532: 
                    533:     This term describes the file or files that are provided by the author of
                    534:     the piece of software to distribute his work. All the changes necessary to
                    535:     build on NetBSD are reflected in the corresponding package. Usually the
                    536:     distfile is in the form of a compressed tar-archive, but other types are
                    537:     possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
                    538: 
                    539: Port
                    540: 
                    541:     This is the term used by FreeBSD and OpenBSD people for what we call a
                    542:     package. In NetBSD terminology, "port" refers to a different architecture.
                    543: 
                    544: Precompiled/binary package
                    545: 
                    546:     A set of binaries built with pkgsrc from a distfile and stuffed together in
                    547:     a single .tgz file so it can be installed on machines of the same machine
                    548:     architecture without the need to recompile. Packages are usually generated
                    549:     in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
                    550: 
                    551:     Sometimes, this is referred to by the term "package" too, especially in the
                    552:     context of precompiled packages.
                    553: 
                    554: Program
                    555: 
                    556:     The piece of software to be installed which will be constructed from all
                    557:     the files in the distfile by the actions defined in the corresponding
                    558:     package.
                    559: 
                    560: 1.3.1. Roles involved in pkgsrc
                    561: 
                    562: pkgsrc users
                    563: 
                    564:     The pkgsrc users are people who use the packages provided by pkgsrc.
                    565:     Typically they are system administrators. The people using the software
                    566:     that is inside the packages (maybe called "end users") are not covered by
                    567:     the pkgsrc guide.
                    568: 
                    569:     There are two kinds of pkgsrc users: Some only want to install pre-built
                    570:     binary packages. Others build the pkgsrc packages from source, either for
                    571:     installing them directly or for building binary packages themselves. For
                    572:     pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
                    573:     documentation.
                    574: 
                    575: package maintainers
                    576: 
                    577:     A package maintainer creates packages as described in Part II, "The pkgsrc
                    578:     developer's guide".
                    579: 
                    580: infrastructure developers
                    581: 
                    582:     These people are involved in all those files that live in the mk/ directory
                    583:     and below. Only these people should need to read through Part III, "The
                    584:     pkgsrc infrastructure internals", though others might be curious, too.
                    585: 
                    586: 1.4. Typography
                    587: 
                    588: When giving examples for commands, shell prompts are used to show if the
                    589: command should/can be issued as root, or if "normal" user privileges are
1.115     sevan     590: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
1.229     gutterid  591: assuming they use the C-shell or tcsh and a $ for Bourne shell and derivatives.
1.1       dsieger   592: 
                    593: Part I. The pkgsrc user's guide
                    594: 
                    595: Table of Contents
                    596: 
1.154     rillig    597: 2. Getting help
                    598: 3. Where to get pkgsrc and how to keep it up-to-date
                    599:     3.1. Getting pkgsrc for the first time
                    600:         3.1.1. As tar archive
                    601:         3.1.2. Via anonymous CVS
                    602:     3.2. Keeping pkgsrc up-to-date
                    603:         3.2.1. Via tar files
                    604:         3.2.2. Via CVS
                    605: 4. Using pkgsrc on systems other than NetBSD
                    606:     4.1. Binary distribution
                    607:     4.2. Bootstrapping pkgsrc
                    608: 5. Using pkgsrc
                    609:     5.1. Using binary packages
                    610:         5.1.1. Finding binary packages
                    611:         5.1.2. Installing binary packages
1.202     nia       612:         5.1.3. Updating packages
                    613:         5.1.4. Deinstalling packages
                    614:         5.1.5. Getting information about installed packages
                    615:         5.1.6. Checking for security vulnerabilities in installed packages
                    616:         5.1.7. Finding if newer versions of your installed packages are in
1.259     leot      617:             pkgsrc
1.202     nia       618:         5.1.8. Other administrative functions
1.154     rillig    619:     5.2. Building packages from source
                    620:         5.2.1. Requirements
                    621:         5.2.2. Fetching distfiles
                    622:         5.2.3. How to build and install
                    623: 6. Configuring pkgsrc
                    624:     6.1. General configuration
                    625:     6.2. Variables affecting the build process
1.241     rillig    626:     6.3. Preferences for native or pkgsrc software
                    627:     6.4. Variables affecting the installation process
                    628:     6.5. Selecting and configuring the compiler
                    629:         6.5.1. Selecting the compiler
                    630:         6.5.2. Additional flags to the compiler (CFLAGS)
                    631:         6.5.3. Additional flags to the linker (LDFLAGS)
                    632:     6.6. Developer/advanced settings
                    633:     6.7. Selecting Build Options
1.154     rillig    634: 7. Creating binary packages
                    635:     7.1. Building a single binary package
                    636:     7.2. Settings for creation of binary packages
                    637: 8. Creating binary packages for everything in pkgsrc (bulk builds)
                    638:     8.1. Preparations
1.180     rillig    639:     8.2. Running a bulk build
1.154     rillig    640:         8.2.1. Configuration
                    641:     8.3. Requirements of a full bulk build
1.178     rillig    642:     8.4. Bulk build variants
1.179     rillig    643:         8.4.1. Detect unknown configure options
                    644:         8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig    645:         8.4.3. Force compiler options only in the build phase
                    646:         8.4.4. Use custom directories
                    647:         8.4.5. Turn warnings into errors
                    648:         8.4.6. Reject packages for which pkglint reports errors
                    649:         8.4.7. Reject packages that contain forbidden strings
                    650:         8.4.8. Reject packages whose self-test fails
                    651:         8.4.9. Reject packages that use undefined shell variables
                    652:         8.4.10. Turn off verbose logging
1.178     rillig    653:     8.5. Creating a multiple CD-ROM packages collection
                    654:         8.5.1. Example of cdpack
1.154     rillig    655: 9. Directory layout of the installed files
                    656:     9.1. File system layout in ${LOCALBASE}
                    657:     9.2. File system layout in ${VARBASE}
                    658: 10. Frequently Asked Questions
                    659:     10.1. Are there any mailing lists for pkg-related discussion?
                    660:     10.2. Utilities for package management (pkgtools)
                    661:     10.3. How to use pkgsrc as non-root
                    662:     10.4. How to resume transfers when fetching distfiles?
                    663:     10.5. How can I install/use modular X.org from pkgsrc?
                    664:     10.6. How to fetch files from behind a firewall
                    665:     10.7. How to fetch files from HTTPS sites
                    666:     10.8. How do I tell make fetch to do passive FTP?
                    667:     10.9. How to fetch all distfiles at once
                    668:     10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                    669:     10.11. What does "Could not find bsd.own.mk" mean?
1.221     nia       670:     10.12. Using 'sudo' or `priv` with pkgsrc
1.154     rillig    671:     10.13. How do I change the location of configuration files?
                    672:     10.14. Automated security checks
                    673:     10.15. Why do some packages ignore my CFLAGS?
                    674:     10.16. A package does not build. What shall I do?
                    675:     10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.259     leot      676:         conflicts" mean?
1.1       dsieger   677: 
1.154     rillig    678: Chapter 2. Getting help
                    679: 
                    680: To get help when using pkgsrc, the definitive source is this document, the
                    681: pkgsrc guide. If you don't find anything here, there are alternatives:
                    682: 
                    683:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                    684:     Run bmake help topic=? to get help for any topic, such as a variable name
                    685:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                    686:     like strcasecmp or any other topic.
                    687: 
1.207     leot      688:     The available help topics are listed in Appendix E, Help topics.
1.154     rillig    689: 
1.163     rillig    690:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                    691: 
                    692:   * To see the values of the most common variables, run bmake show-all. These
                    693:     variables are grouped by topic. To see the variables for a single topic,
                    694:     run bmake show-all-topic, for example bmake show-all-fetch.
                    695: 
1.154     rillig    696:   * The pkgsrc-users mailing list, to which you can subscribe and then ask your
                    697:     questions.
                    698: 
                    699:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                    700:     a specialized chat program such as XChat. Pick any user name and join the
                    701:     channel #pkgsrc.
                    702: 
                    703: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   704: 
                    705: Table of Contents
                    706: 
1.154     rillig    707: 3.1. Getting pkgsrc for the first time
                    708:     3.1.1. As tar archive
                    709:     3.1.2. Via anonymous CVS
                    710: 3.2. Keeping pkgsrc up-to-date
                    711:     3.2.1. Via tar files
                    712:     3.2.2. Via CVS
1.1       dsieger   713: 
                    714: Before you download and extract the files, you need to decide where you want to
                    715: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
                    716: usr/pkgsrc. You are though free to install the sources and binary packages
                    717: wherever you want in your filesystem, provided that the pathname does not
                    718: contain white-space or other characters that are interpreted specially by the
                    719: shell and some other programs. A safe bet is to use only letters, digits,
                    720: underscores and dashes.
                    721: 
1.154     rillig    722: 3.1. Getting pkgsrc for the first time
1.1       dsieger   723: 
1.25      wiz       724: Before you download any pkgsrc files, you should decide whether you want the 
1.1       dsieger   725: current branch or the stable branch. The latter is forked on a quarterly basis
                    726: from the current branch and only gets modified for security updates. The names
                    727: of the stable branches are built from the year and the quarter, for example
1.259     leot      728: 2024Q4.
1.1       dsieger   729: 
                    730: The second step is to decide how you want to download pkgsrc. You can get it as
1.24      wiz       731: a tar file or via CVS. Both ways are described here.
1.1       dsieger   732: 
1.52      asau      733: Note that tar archive contains CVS working copy. Thus you can switch to using
                    734: CVS at any later time.
1.1       dsieger   735: 
1.154     rillig    736: 3.1.1. As tar archive
1.52      asau      737: 
1.151     sevan     738: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
                    739: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
                    740: location). There are a number of subdirectories for different purposes, which
1.207     leot      741: are described in detail in Appendix D, Directory layout of the pkgsrc FTP
1.151     sevan     742: server.
1.1       dsieger   743: 
1.52      asau      744: The tar archive for the current branch is in the directory current and is
1.118     sevan     745: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52      asau      746: 
                    747: To save download time we provide bzip2- and xz-compressed archives which are
                    748: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
                    749: 
                    750: You can fetch the same files using FTP.
1.1       dsieger   751: 
1.259     leot      752: The tar file for the stable branch 2024Q4 is in the directory pkgsrc-2024Q4 and
1.59      jnemeth   753: is also called pkgsrc.tar.gz.
1.1       dsieger   754: 
1.136     leot      755: To download the latest pkgsrc stable tarball, run:
1.12      weinem    756: 
1.259     leot      757: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2024Q4/pkgsrc.tar.gz
1.12      weinem    758: 
1.78      snj       759: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52      asau      760: 
1.12      weinem    761: Then, extract it with:
                    762: 
1.78      snj       763: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12      weinem    764: 
                    765: This will create the directory pkgsrc/ in /usr/ and all the package source will
                    766: be stored under /usr/pkgsrc/.
                    767: 
                    768: To download pkgsrc-current, run:
                    769: 
                    770: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1       dsieger   771: 
1.154     rillig    772: 3.1.2. Via anonymous CVS
1.1       dsieger   773: 
1.24      wiz       774: To fetch a specific pkgsrc stable branch, run:
1.1       dsieger   775: 
1.259     leot      776: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2024Q4 -P pkgsrc
1.13      weinem    777: 
1.24      wiz       778: This will create the directory pkgsrc/ in your /usr/ directory and all the
                    779: package source will be stored under /usr/pkgsrc/.
                    780: 
                    781: To fetch the pkgsrc current branch, run:
1.1       dsieger   782: 
1.40      wiz       783: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   784: 
1.30      dholland  785: Refer to the list of available mirrors to choose a faster CVS mirror, if
                    786: needed.
1.1       dsieger   787: 
1.24      wiz       788: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1       dsieger   789: 
1.40      wiz       790: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   791: 
1.24      wiz       792: Refer to documentation on your command shell how to set CVS_RSH=ssh
                    793: permanently. For Bourne shells, you can set it in your .profile or better
                    794: globally in /etc/profile:
                    795: 
                    796: # set CVS remote shell command
                    797: CVS_RSH=ssh
                    798: export CVS_RSH
1.12      weinem    799: 
1.13      weinem    800: By default, CVS doesn't do things like most people would expect it to do. But
                    801: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12      weinem    802: directory and saving the following lines to it. This file will save you lots of
                    803: headache and some bug reports, so we strongly recommend it. You can find an
                    804: explanation of this file in the CVS documentation.
1.2       rillig    805: 
                    806: # recommended CVS configuration file from the pkgsrc guide
1.155     sevan     807: cvs -q
1.2       rillig    808: checkout -P
1.4       rillig    809: update -dP
                    810: diff -upN
1.2       rillig    811: rdiff -u
1.24      wiz       812: release -d
1.1       dsieger   813: 
1.154     rillig    814: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   815: 
                    816: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
                    817: have first installed it via a tar file). It saves bandwidth and hard disk
                    818: activity, compared to downloading the tar file again.
                    819: 
1.154     rillig    820: 3.2.1. Via tar files
1.1       dsieger   821: 
                    822: Warning
                    823: 
                    824: When updating from a tar file, you first need to completely remove the old
                    825: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
                    826: the mean time will not be removed on your local disk, resulting in
                    827: inconsistencies. When removing the old files, any changes that you have done to
                    828: the pkgsrc files will be lost after updating. Therefore updating via CVS is
                    829: strongly recommended.
                    830: 
                    831: Note that by default the distfiles and the binary packages are saved in the
                    832: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78      snj       833: configure pkgsrc to store distfiles and packages in directories outside the
1.154     rillig    834: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6, 
1.78      snj       835: Configuring pkgsrc for the details.
1.1       dsieger   836: 
                    837: To update pkgsrc from a tar file, download the tar file as explained above.
                    838: Then, make sure that you have not made any changes to the files in the pkgsrc
                    839: directory. Remove the pkgsrc directory and extract the new tar file. Done.
                    840: 
1.154     rillig    841: 3.2.2. Via CVS
1.1       dsieger   842: 
1.26      spz       843: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12      weinem    844: 
1.26      spz       845: $ cd /usr/pkgsrc && cvs update -dP
                    846: 
                    847: If you get error messages from rsh, you need to set CVS_RSH variable as
                    848: described above. E.g.:
                    849: 
                    850: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1       dsieger   851: 
1.154     rillig    852: 3.2.2.1. Switching between different pkgsrc branches
1.1       dsieger   853: 
                    854: When updating pkgsrc, the CVS program keeps track of the branch you selected.
                    855: But if you, for whatever reason, want to switch from the stable branch to the
                    856: current one, you can do it by adding the option "-A" after the "update"
1.25      wiz       857: keyword. To switch from the current branch back to the stable branch, add the "
1.259     leot      858: -rpkgsrc-2024Q4" option.
1.1       dsieger   859: 
1.154     rillig    860: 3.2.2.2. What happens to my changes when updating?
1.1       dsieger   861: 
                    862: When you update pkgsrc, the CVS program will only touch those files that are
                    863: registered in the CVS repository. That means that any packages that you created
                    864: on your own will stay unmodified. If you change files that are managed by CVS,
                    865: later updates will try to merge your changes with those that have been done by
                    866: others. See the CVS manual, chapter "update" for details.
                    867: 
1.154     rillig    868: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger   869: 
                    870: Table of Contents
                    871: 
1.154     rillig    872: 4.1. Binary distribution
                    873: 4.2. Bootstrapping pkgsrc
1.1       dsieger   874: 
1.154     rillig    875: 4.1. Binary distribution
1.1       dsieger   876: 
1.154     rillig    877: See Section 5.1, "Using binary packages".
1.1       dsieger   878: 
1.154     rillig    879: 4.2. Bootstrapping pkgsrc
1.1       dsieger   880: 
1.44      asau      881: pkgsrc can be bootstrapped for use in two different modes: privileged and
                    882: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45      asau      883: programs are installed under one particular user and cannot utilise privileged
1.44      asau      884: operations (packages don't create special users and all special file
                    885: permissions like setuid are ignored).
                    886: 
1.1       dsieger   887: Installing the bootstrap kit from source should be as simple as:
                    888: 
1.60      asau      889: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   890: # cd pkgsrc/bootstrap
                    891: # ./bootstrap
                    892: 
                    893: 
1.44      asau      894: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
                    895: 
                    896: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118     sevan     897: will be installed in, and /usr/pkg/pkgdb for the package database directory
                    898: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44      asau      899: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118     sevan     900: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44      asau      901: 
                    902: You can change default layout using command-line arguments. Run "./bootstrap
                    903: --help" to get details.
1.1       dsieger   904: 
                    905: Note
                    906: 
                    907: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
                    908: For examples in this guide, use bmake instead of "make".
                    909: 
1.44      asau      910: Note
                    911: 
                    912: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
                    913: directories. Use bmake corresponding to the installation you're working with to
                    914: build and install packages.
                    915: 
1.154     rillig    916: Chapter 5. Using pkgsrc
1.1       dsieger   917: 
                    918: Table of Contents
                    919: 
1.154     rillig    920: 5.1. Using binary packages
                    921:     5.1.1. Finding binary packages
                    922:     5.1.2. Installing binary packages
1.202     nia       923:     5.1.3. Updating packages
                    924:     5.1.4. Deinstalling packages
                    925:     5.1.5. Getting information about installed packages
                    926:     5.1.6. Checking for security vulnerabilities in installed packages
                    927:     5.1.7. Finding if newer versions of your installed packages are in pkgsrc
                    928:     5.1.8. Other administrative functions
1.154     rillig    929: 5.2. Building packages from source
                    930:     5.2.1. Requirements
                    931:     5.2.2. Fetching distfiles
                    932:     5.2.3. How to build and install
1.1       dsieger   933: 
                    934: Basically, there are two ways of using pkgsrc. The first is to only install the
                    935: package tools and to use binary packages that someone else has prepared. This
                    936: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
                    937: Then you are able to build your own packages, and you can still use binary
                    938: packages from someone else.
                    939: 
1.154     rillig    940: 5.1. Using binary packages
1.1       dsieger   941: 
1.151     sevan     942: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9       rillig    943: packages, ready to be installed. These binary packages have been built using
                    944: the default settings for the directories, that is:
                    945: 
                    946:   * /usr/pkg for LOCALBASE, where most of the files are installed,
                    947: 
                    948:   * /usr/pkg/etc for configuration files,
                    949: 
                    950:   * /var for VARBASE, where those files are installed that may change after
                    951:     installation.
                    952: 
                    953: If you cannot use these directories for whatever reasons (maybe because you're
                    954: not root), you cannot use these binary packages, but have to build the packages
1.154     rillig    955: yourself, which is explained in Section 4.2, "Bootstrapping pkgsrc".
1.1       dsieger   956: 
1.154     rillig    957: 5.1.1. Finding binary packages
1.1       dsieger   958: 
1.5       weinem    959: To install binary packages, you first need to know from where to get them. The
1.202     nia       960: first place where you should look is on the main pkgsrc CDN in the directory /
                    961: pub/pkgsrc/packages.
1.5       weinem    962: 
                    963: This directory contains binary packages for multiple platforms. First, select
1.226     gutterid  964: your operating system. Then, select your hardware architecture, and in the
                    965: third step, the OS version and the "version" of pkgsrc.
1.9       rillig    966: 
1.226     gutterid  967: In this directory, you may find a file called bootstrap.tar.gz which contains
1.9       rillig    968: the package management tools. If the file is missing, it is likely that your
                    969: operating system already provides those tools. Download the file and extract it
                    970: in the / directory. It will create the directories /usr/pkg (containing the
1.118     sevan     971: tools for managing binary packages and the database of installed packages).
1.1       dsieger   972: 
1.154     rillig    973: 5.1.2. Installing binary packages
1.1       dsieger   974: 
1.85      wiz       975: In the directory from the last section, there is a subdirectory called All/,
1.9       rillig    976: which contains all the binary packages that are available for the platform,
1.202     nia       977: excluding those that may not be distributed via HTTP or FTP.
1.9       rillig    978: 
                    979: To install packages directly from an FTP or HTTP server, run the following
                    980: commands in a Bourne-compatible shell (be sure to su to root first):
                    981: 
1.202     nia       982: # PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
                    983: # PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169     rillig    984: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9       rillig    985: # export PATH PKG_PATH
1.202     nia       986: # pkg_add pkgin
1.9       rillig    987: 
                    988: Instead of URLs, you can also use local paths, for example if you are
                    989: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
                    990: to install packages from multiple sources, you can separate them by a semicolon
                    991: in PKG_PATH.
                    992: 
                    993: After these preparations, installing a package is very easy:
                    994: 
1.202     nia       995: # pkgin search nginx
                    996: nginx-1.19.6         Lightweight HTTP server and mail proxy server
                    997: nginx-1.18.0nb8      Lightweight HTTP server and mail proxy server
                    998: # pkgin install zsh nginx-1.19.6 vim
1.1       dsieger   999: 
1.202     nia      1000: Note that pkgin is a user-friendly frontend to the pkg_* tools.
1.1       dsieger  1001: 
1.202     nia      1002: Any prerequisite packages needed to run the package in question will be
                   1003: installed, too, assuming they are present in the repository.
1.1       dsieger  1004: 
                   1005: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
                   1006: in your PATH so you can actually start the just installed program.
                   1007: 
1.202     nia      1008: 5.1.3. Updating packages
1.1       dsieger  1009: 
1.202     nia      1010: To update binary packages, it is recommended that you use pkgin upgrade. This
                   1011: will compare the remote package repository to your locally installed packages
                   1012: and safely replace any older packages.
1.1       dsieger  1013: 
1.202     nia      1014: Note that pkgsrc is released as quarterly branches. If you are updating to a
                   1015: newer quarterly branch of pkgsrc, you may need to adjust the repository in /usr
                   1016: /pkg/etc/pkgin/repositories.conf.
1.1       dsieger  1017: 
1.202     nia      1018: 5.1.4. Deinstalling packages
1.1       dsieger  1019: 
1.202     nia      1020: To deinstall a package, it does not matter whether it was installed from source
                   1021: code or from a binary package. Neither the pkgin or the pkg_delete command need
                   1022: to know.
1.1       dsieger  1023: 
1.202     nia      1024: To delete a package, you can just run pkgin remove package-name. The package
                   1025: name can be given with or without version number.
1.1       dsieger  1026: 
1.202     nia      1027: 5.1.5. Getting information about installed packages
1.1       dsieger  1028: 
                   1029: The pkg_info shows information about installed packages or binary package
1.202     nia      1030: files. As with other management tools, it works with packages installed from
                   1031: source or binaries.
1.1       dsieger  1032: 
1.202     nia      1033: 5.1.6. Checking for security vulnerabilities in installed packages
1.1       dsieger  1034: 
1.202     nia      1035: The pkgsrc Security Team and Packages Groups maintain a list of known
1.164     leot     1036: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.202     nia      1037: list is available from the NetBSD CDN at https://cdn.NetBSD.org/pub/NetBSD/
1.179     rillig   1038: packages/vulns/pkg-vulnerabilities.
1.1       dsieger  1039: 
1.202     nia      1040: Please note that not every "vulnerability" with a CVE assignment is exploitable
                   1041: in every configuration. Some bugs are marked as active simply because an fix
                   1042: was not marked as such. Operating system specific hardening and mitigation
                   1043: features may also reduce the impact of bugs.
                   1044: 
1.23      jakllsch 1045: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
                   1046: automatically, and a security audit of all packages installed on a system can
                   1047: take place.
                   1048: 
                   1049: There are two components to auditing. The first step, pkg_admin
                   1050: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
                   1051: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
                   1052: your installed packages are vulnerable. If a package is vulnerable, you will
                   1053: see output similar to the following:
1.1       dsieger  1054: 
                   1055: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174     leot     1056:     https://www.samba.org/samba/whatsnew/macroexploit.html
1.1       dsieger  1057: 
1.23      jakllsch 1058: You may wish to have the vulnerabilities file downloaded daily so that it
                   1059: remains current. This may be done by adding an appropriate entry to the root
                   1060: users crontab(5) entry. For example the entry
                   1061: 
1.121     sevan    1062: # Download vulnerabilities file
1.118     sevan    1063: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121     sevan    1064: # Audit the installed packages and email results to root
                   1065: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
                   1066:             root >/dev/null 2>&1
1.118     sevan    1067: 
                   1068: 
                   1069: will update the vulnerability list every day at 3AM, followed by an audit at
                   1070: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
                   1071: accomplished instead by adding the following line to /etc/daily.conf:
                   1072: 
                   1073: fetch_pkg_vulnerabilities=YES
                   1074: 
1.23      jakllsch 1075: 
1.118     sevan    1076: to fetch the vulnerability list from the daily security script. The system is
                   1077: set to audit the packages by default but can be set explicitly, if desired (not
1.123     wiz      1078: required), by adding the following line to /etc/security.conf:
1.23      jakllsch 1079: 
1.118     sevan    1080: check_pkg_vulnerabilities=YES
1.23      jakllsch 1081: 
                   1082: 
1.118     sevan    1083: see daily.conf(5) and security.conf(5) for more details.
1.1       dsieger  1084: 
1.202     nia      1085: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
1.1       dsieger  1086: 
1.12      weinem   1087: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
1.202     nia      1088: if any packages are stale, e.g.
1.1       dsieger  1089: 
                   1090: % lintpkgsrc -i
                   1091: ...
                   1092: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
                   1093: 
                   1094: 
1.202     nia      1095: 5.1.8. Other administrative functions
1.1       dsieger  1096: 
                   1097: The pkg_admin executes various administrative functions on the package system.
                   1098: 
1.154     rillig   1099: 5.2. Building packages from source
1.1       dsieger  1100: 
                   1101: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25      wiz      1102: organized into categories. You can browse the online index of packages, or run 
1.1       dsieger  1103: make readme from the pkgsrc directory to build local README.html files for all
                   1104: packages, viewable with any web browser such as www/lynx or www/firefox.
                   1105: 
                   1106: The default prefix for installed packages is /usr/pkg. If you wish to change
                   1107: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
                   1108: use multiple different LOCALBASE definitions on the same system (inside a
                   1109: chroot is an exception).
                   1110: 
                   1111: The rest of this chapter assumes that the package is already in pkgsrc. If it
                   1112: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
                   1113: create your own packages.
                   1114: 
1.154     rillig   1115: 5.2.1. Requirements
1.1       dsieger  1116: 
                   1117: To build packages from source, you need a working C compiler. On NetBSD, you
                   1118: need to install the "comp" and the "text" distribution sets. If you want to
                   1119: build X11-related packages, the "xbase" and "xcomp" distribution sets are
                   1120: required, too.
                   1121: 
1.154     rillig   1122: 5.2.2. Fetching distfiles
1.1       dsieger  1123: 
                   1124: The first step for building a package is downloading the distfiles (i.e. the
                   1125: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
                   1126: them automatically.
                   1127: 
                   1128: If you have all files that you need in the distfiles directory, you don't need
                   1129: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
                   1130: and add:
                   1131: 
                   1132: DISTDIR=/cdrom/pkgsrc/distfiles
                   1133: 
                   1134: to your mk.conf.
                   1135: 
                   1136: By default a list of distribution sites will be randomly intermixed to prevent
                   1137: huge load on servers which holding popular packages (for example,
                   1138: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
                   1139: distfile all the mirrors will be tried in new (random) order. You can turn this
                   1140: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
                   1141: disabled).
                   1142: 
                   1143: You can overwrite some of the major distribution sites to fit to sites that are
                   1144: close to your own. By setting one or two variables you can modify the order in
                   1145: which the master sites are accessed. MASTER_SORT contains a whitespace
                   1146: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
                   1147: contains a whitespace delimited list of regular expressions. It has higher
                   1148: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
                   1149: some examples. This may save some of your bandwidth and time.
                   1150: 
                   1151: You can change these settings either in your shell's environment, or, if you
1.4       rillig   1152: want to keep the settings, by editing the mk.conf file, and adding the
1.1       dsieger  1153: definitions there.
                   1154: 
1.132     wiz      1155: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1       dsieger  1156: process may alternate between periods of downloading source, and compiling. To
                   1157: ensure you have all the source downloaded initially you can run the command:
                   1158: 
                   1159: % make fetch-list | sh
                   1160: 
                   1161: which will output and run a set of shell commands to fetch the necessary files
                   1162: into the distfiles directory. You can also choose to download the files
                   1163: manually.
                   1164: 
1.154     rillig   1165: 5.2.3. How to build and install
1.1       dsieger  1166: 
                   1167: Once the software has downloaded, any patches will be applied, then it will be
                   1168: compiled for you. This may take some time depending on your computer, and how
                   1169: many other packages the software depends on and their compile time.
                   1170: 
                   1171: Note
                   1172: 
                   1173: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
                   1174: command instead of "make" in the examples in this guide.
                   1175: 
                   1176: For example, type
                   1177: 
                   1178: % cd misc/figlet
                   1179: % make
                   1180: 
                   1181: 
                   1182: at the shell prompt to build the various components of the package.
                   1183: 
                   1184: The next stage is to actually install the newly compiled program onto your
                   1185: system. Do this by entering:
                   1186: 
                   1187: % make install
                   1188: 
                   1189: 
                   1190: while you are still in the directory for whatever package you are installing.
                   1191: 
                   1192: Installing the package on your system may require you to be root. However,
                   1193: pkgsrc has a just-in-time-su feature, which allows you to only become root for
                   1194: the actual installation step.
                   1195: 
                   1196: That's it, the software should now be installed and setup for use. You can now
                   1197: enter:
                   1198: 
                   1199: % make clean
                   1200: 
                   1201: 
                   1202: to remove the compiled files in the work directory, as you shouldn't need them
                   1203: any more. If other packages were also added to your system (dependencies) to
                   1204: allow your program to compile, you can tidy these up also with the command:
                   1205: 
                   1206: % make clean-depends
                   1207: 
                   1208: 
                   1209: Taking the figlet utility as an example, we can install it on our system by
1.207     leot     1210: building as shown in Appendix C, Build logs.
1.1       dsieger  1211: 
                   1212: The program is installed under the default root of the packages tree - /usr/
                   1213: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
                   1214: environment, and it will use that value as the root of your packages tree. So,
                   1215: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
                   1216: that you should use a directory which is dedicated to packages and not shared
                   1217: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
                   1218: not try to add any of your own files or directories (such as src/, obj/, or
                   1219: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
                   1220: between programs and other files installed by the package system and whatever
                   1221: else may have been installed there.
                   1222: 
1.4       rillig   1223: Some packages look in mk.conf to alter some configuration options at build
1.1       dsieger  1224: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
                   1225: be set there by default. Environment variables such as LOCALBASE can be set in
1.4       rillig   1226: mk.conf to save having to remember to set them each time you want to use
1.1       dsieger  1227: pkgsrc.
                   1228: 
                   1229: Occasionally, people want to "look under the covers" to see what is going on
                   1230: when a package is building or being installed. This may be for debugging
                   1231: purposes, or out of simple curiosity. A number of utility values have been
                   1232: added to help with this.
                   1233: 
                   1234:  1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
                   1235:     amount of information will be displayed. For example,
                   1236: 
                   1237:     make patch PKG_DEBUG_LEVEL=2
                   1238: 
1.25      wiz      1239:     will show all the commands that are invoked, up to and including the "patch
                   1240:     " stage.
1.1       dsieger  1241: 
                   1242:  2. If you want to know the value of a certain make(1) definition, then the
                   1243:     VARNAME definition should be used, in conjunction with the show-var target.
                   1244:     e.g. to show the expansion of the make(1) variable LOCALBASE:
                   1245: 
                   1246:     % make show-var VARNAME=LOCALBASE
                   1247:     /usr/pkg
                   1248:     %
                   1249: 
                   1250: 
                   1251: If you want to install a binary package that you've either created yourself
                   1252: (see next section), that you put into pkgsrc/packages manually or that is
                   1253: located on a remote FTP server, you can use the "bin-install" target. This
                   1254: target will install a binary package - if available - via pkg_add(1), else do a
                   1255: make package. The list of remote FTP sites searched is kept in the variable
                   1256: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
                   1257: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
                   1258: for more details.
                   1259: 
                   1260: A final word of warning: If you set up a system that has a non-standard setting
                   1261: for LOCALBASE, be sure to set that before any packages are installed, as you
                   1262: cannot use several directories for the same purpose. Doing so will result in
                   1263: pkgsrc not being able to properly detect your installed packages, and fail
                   1264: miserably. Note also that precompiled binary packages are usually built with
                   1265: the default LOCALBASE of /usr/pkg, and that you should not install any if you
                   1266: use a non-standard LOCALBASE.
                   1267: 
1.154     rillig   1268: Chapter 6. Configuring pkgsrc
1.1       dsieger  1269: 
                   1270: Table of Contents
                   1271: 
1.154     rillig   1272: 6.1. General configuration
                   1273: 6.2. Variables affecting the build process
1.241     rillig   1274: 6.3. Preferences for native or pkgsrc software
                   1275: 6.4. Variables affecting the installation process
                   1276: 6.5. Selecting and configuring the compiler
                   1277:     6.5.1. Selecting the compiler
                   1278:     6.5.2. Additional flags to the compiler (CFLAGS)
                   1279:     6.5.3. Additional flags to the linker (LDFLAGS)
                   1280: 6.6. Developer/advanced settings
                   1281: 6.7. Selecting Build Options
1.1       dsieger  1282: 
                   1283: The whole pkgsrc system is configured in a single file, usually called mk.conf.
                   1284: In which directory pkgsrc looks for that file depends on the installation. On
                   1285: NetBSD, when you use make(1) from the base system, it is in the directory /etc
                   1286: /. In all other cases the default location is ${PREFIX}/etc/, depending on
                   1287: where you told the bootstrap program to install the binary packages.
                   1288: 
                   1289: The format of the configuration file is that of the usual BSD-style Makefiles.
                   1290: The whole pkgsrc configuration is done by setting variables in this file. Note
                   1291: that you can define all kinds of variables, and no special error checking (for
1.112     rillig   1292: example for spelling mistakes) takes place.
1.1       dsieger  1293: 
1.154     rillig   1294: 6.1. General configuration
1.1       dsieger  1295: 
1.112     rillig   1296: The following variables apply to all pkgsrc packages. A complete list of the
                   1297: variables that can be configured by the user is available in mk/defaults/
                   1298: mk.conf, together with some comments that describe each variable's intent.
1.1       dsieger  1299: 
                   1300:   * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
                   1301:     not mix binary packages with different LOCALBASEs!
                   1302: 
                   1303:   * CROSSBASE: Where "cross" category packages will be installed. The default
                   1304:     is ${LOCALBASE}/cross.
                   1305: 
1.84      wiz      1306:   * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1       dsieger  1307: 
                   1308:   * DISTDIR: Where to store the downloaded copies of the original source
                   1309:     distributions used for building pkgsrc packages. The default is $
                   1310:     {PKGSRCDIR}/distfiles.
                   1311: 
                   1312:   * PKG_DBDIR: Where the database about installed packages is stored. The
1.118     sevan    1313:     default is /usr/pkg/pkgdb.
1.1       dsieger  1314: 
                   1315:   * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
                   1316:     value.
                   1317: 
                   1318:   * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
                   1319:     files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118     sevan    1320:     respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1       dsieger  1321:     {DIST_SUBDIR}/.
                   1322: 
                   1323:   * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
                   1324:     with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
                   1325: 
1.23      jakllsch 1326:   * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
                   1327:     case-sensitive. Whenever you try to build a package whose license is not in
                   1328:     this list, you will get an error message. If the license condition is
                   1329:     simple enough, the error message will include specific instructions on how
                   1330:     to change this variable.
1.1       dsieger  1331: 
1.154     rillig   1332: 6.2. Variables affecting the build process
1.1       dsieger  1333: 
                   1334:   * PACKAGES: The top level directory for the binary packages. The default is $
                   1335:     {PKGSRCDIR}/packages.
                   1336: 
                   1337:   * WRKOBJDIR: The top level directory where, if defined, the separate working
                   1338:     directories will get created, and symbolically linked to from ${WRKDIR}
                   1339:     (see below). This is useful for building packages on several architectures,
                   1340:     then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
                   1341:     architecture. (It should be noted that PKGSRCDIR should not be set by the
1.198     leot     1342:     user -- it is an internal definition which refers to the root of the pkgsrc
1.1       dsieger  1343:     tree. It is possible to have many pkgsrc tree instances.)
                   1344: 
                   1345:   * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.184     rillig   1346:     Section 12.3, "patches/*" for more information.
1.1       dsieger  1347: 
                   1348:   * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
                   1349:     Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
                   1350:     up settings used by builds in /usr/src.
                   1351: 
1.241     rillig   1352: 6.3. Preferences for native or pkgsrc software
                   1353: 
                   1354: Whenever a package depends on a package that has a builtin.mk file, the
                   1355: dependent package can either use the built-in (native) version from the base
                   1356: system or the pkgsrc-provided version. This only affects dependencies, so it is
                   1357: still possible to build the pkgsrc package devel/pcre++ even when other
                   1358: packages depend on the native pcre++ version instead.
                   1359: 
                   1360: To force using the pkgsrc-provided version for a particular package, define "
                   1361: PREFER_PKGSRC = package-ID" in mk.conf. To force using the native package,
                   1362: define "PREFER_NATIVE = package-ID". In both cases, the package-ID is the one
                   1363: from the buildlink3.mk of the package. In most cases, this ID is the same as
                   1364: the directory name of the package, but for example, devel/pcre++ has the
                   1365: package ID "pcrexx".
                   1366: 
                   1367: For the packages that are not listed by their package ID, pkgsrc uses the
                   1368: pkgsrc-provided version if PREFER_PKGSRC contains the word "yes". Otherwise, if
                   1369: PREFER_NATIVE contains the word "yes", pkgsrc uses the native version. For
                   1370: example, to require using the pkgsrc-provided versions for all but the most
                   1371: basic bits on a NetBSD system, you can set:
                   1372: 
                   1373: PREFER_PKGSRC=  yes
                   1374: PREFER_NATIVE=  getopt skey tcp_wrappers
                   1375: 
                   1376: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
                   1377: it is simply ignored in that list.
                   1378: 
                   1379: PREFER_PKGSRC and PREFER_NATIVE should be set during bootstrap to ensure that
                   1380: the bootstrap process does not use inapropriate native tools as dependencies
                   1381: for core packages.
                   1382: 
                   1383: # ./bootstrap --prefer-pkgsrc yes --prefer-native openssl
                   1384: 
                   1385: Switching between settings globally at a later date can introduce complications
                   1386: with dependency resolution. This is caused by packages built with the opposite
                   1387: preference being installed alongside each other. Hence, when changing any of
                   1388: these variables after bootstrap, you need to rebuild all packages depending on
                   1389: those whose preference has been changed. This is not trivial and should be
                   1390: avoided.
                   1391: 
                   1392: When using pkgsrc on Linux systems, there is high risk of "leakage", where
                   1393: programs installed by pkgsrc may inadvertently use a command or library not
                   1394: installed by pkgsrc, e.g. those installed by yum or apt. Such foreign
                   1395: dependencies may be installed, removed, or upgraded to a version incompatible
                   1396: with the pkgsrc package at any time, causing pkgsrc packages to subsequently
                   1397: malfunction. Pkgsrc cannot prevent this, as it has no control over other
                   1398: package managers. Another potential problem is that under Redhat Enterprise and
                   1399: related Linux systems, yum packages are only patched and never upgraded, so
                   1400: eventually they may become too outdated for use by pkgsrc. Even intentionally
                   1401: using foreign dependencies, not considered leakage, can lead to these problems,
                   1402: so it is generally discouraged. In order to minimize such problems,
                   1403: PREFER_PKGSRC defaults to "yes" on Linux systems. This ensures that pkgsrc is
                   1404: aware of any changes to dependency packages and can rebuild or upgrade the
                   1405: entire dependency tree as needed. This default can be overridden by setting
                   1406: --prefer-pkgsrc to a list of packages and --prefer-native to "yes".
                   1407: 
                   1408: 6.4. Variables affecting the installation process
1.1       dsieger  1409: 
1.198     leot     1410:   * PKGSRC_KEEP_BIN_PKGS: By default, binary packages of built packages are
1.150     leot     1411:     preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1       dsieger  1412: 
1.107     jnemeth  1413: Packages have to support installation into a subdirectory of WRKDIR. This
                   1414: allows a package to be built, before the actual filesystem is touched. DESTDIR
                   1415: support exists in two variations:
1.4       rillig   1416: 
                   1417:   * Basic DESTDIR support means that the package installation and packaging is
                   1418:     still run as root.
                   1419: 
                   1420:   * Full DESTDIR support can run the complete build, installation and packaging
                   1421:     as normal user. Root privileges are only needed to add packages.
                   1422: 
                   1423: With basic DESTDIR support, make clean needs to be run as root.
                   1424: 
1.17      imil     1425: Considering the foo/bar package, DESTDIR full support can be tested using the
                   1426: following commands
                   1427: 
                   1428: $ id
                   1429: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
                   1430: $ mkdir $HOME/packages
                   1431: $ cd $PKGSRCDIR/foo/bar
                   1432: 
                   1433: Verify DESTDIR full support, no root privileges should be needed
                   1434: 
1.66      asau     1435: $ make stage-install
1.17      imil     1436: 
                   1437: Create a package without root privileges
                   1438: 
1.66      asau     1439: $ make PACKAGES=$HOME/packages package
1.17      imil     1440: 
                   1441: For the following command, you must be able to gain root privileges using su(1)
                   1442: 
1.66      asau     1443: $ make PACKAGES=$HOME/packages install
1.17      imil     1444: 
                   1445: Then, as a simple user
                   1446: 
                   1447: $ make clean
                   1448: 
1.241     rillig   1449: 6.5. Selecting and configuring the compiler
1.4       rillig   1450: 
1.241     rillig   1451: 6.5.1. Selecting the compiler
1.1       dsieger  1452: 
                   1453: By default, pkgsrc will use GCC to build packages. This may be overridden by
                   1454: setting the following variables in /etc/mk.conf:
                   1455: 
                   1456: PKGSRC_COMPILER:
                   1457: 
                   1458:     This is a list of values specifying the chain of compilers to invoke when
                   1459:     building packages. Valid values are:
                   1460: 
1.259     leot     1461:       + ccc: Compaq C Compilers (Tru64)
1.66      asau     1462: 
1.259     leot     1463:       + ccache: compiler cache (chainable)
1.66      asau     1464: 
1.259     leot     1465:       + clang: Clang C and Objective-C compiler
1.66      asau     1466: 
1.259     leot     1467:       + distcc: distributed C/C++ (chainable)
1.1       dsieger  1468: 
1.259     leot     1469:       + f2c: Fortran 77 to C compiler (chainable)
1.66      asau     1470: 
1.259     leot     1471:       + icc: Intel C++ Compiler (Linux)
1.66      asau     1472: 
1.259     leot     1473:       + ido: SGI IRIS Development Option cc (IRIX 5)
1.1       dsieger  1474: 
1.259     leot     1475:       + gcc: GNU C/C++ Compiler
1.1       dsieger  1476: 
1.259     leot     1477:       + hp: HP-UX C/aC++ compilers
1.66      asau     1478: 
1.259     leot     1479:       + mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1       dsieger  1480: 
1.259     leot     1481:       + mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1       dsieger  1482: 
1.259     leot     1483:       + sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1       dsieger  1484: 
1.259     leot     1485:       + xlc: IBM's XL C/C++ compiler suite
1.66      asau     1486: 
1.1       dsieger  1487:     The default is "gcc". You can use ccache and/or distcc with an appropriate
                   1488:     PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
                   1489:     terminated with a value for a real compiler. Note that only one real
                   1490:     compiler should be listed (e.g. "sunpro gcc" is not allowed).
                   1491: 
                   1492: GCC_REQD:
                   1493: 
                   1494:     This specifies the minimum version of GCC to use when building packages. If
                   1495:     the system GCC doesn't satisfy this requirement, then pkgsrc will build and
                   1496:     install one of the GCC packages to use instead.
                   1497: 
1.153     leot     1498: PYTHON_VERSION_DEFAULT:
1.114     maya     1499: 
                   1500:     Specifies which version of python to use when several options are
                   1501:     available.
                   1502: 
                   1503: PKGSRC_FORTRAN:
                   1504: 
1.176     gutterid 1505:     Specifies the Fortran compiler to use. The default is gfortran.
1.114     maya     1506: 
                   1507: GFORTRAN_VERSION:
                   1508: 
                   1509:     If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
                   1510:     use.
                   1511: 
1.241     rillig   1512: 6.5.2. Additional flags to the compiler (CFLAGS)
1.1       dsieger  1513: 
                   1514: If you wish to set the CFLAGS variable, please make sure to use the += operator
                   1515: instead of the = operator:
                   1516: 
                   1517: CFLAGS+=        -your -flags
                   1518: 
                   1519: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16      jnemeth  1520: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24      wiz      1521: package if you're interested in optimization specifically for the current CPU.
1.1       dsieger  1522: 
1.241     rillig   1523: 6.5.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1524: 
                   1525: If you want to pass flags to the linker, both in the configure step and the
                   1526: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
                   1527: difference between the two is that LIBS will be appended to the command line,
                   1528: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
                   1529: machines depending on the setting of USE_IMAKE or the inclusion of mk/
                   1530: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
                   1531: settings, use the += operator:
                   1532: 
                   1533: LDFLAGS+=        -your -linkerflags
                   1534: 
1.241     rillig   1535: 6.6. Developer/advanced settings
1.1       dsieger  1536: 
                   1537:   * PKG_DEVELOPER: Run some sanity checks that package developers want:
                   1538: 
1.42      asau     1539:       + make sure patches apply with zero fuzz
1.1       dsieger  1540: 
1.42      asau     1541:       + run check-shlibs to see that all binaries will find their shared libs.
1.1       dsieger  1542: 
1.232     gutterid 1543:   * CHECK_FILES_STRICT: Also check VARBASE and PKG_SYSCONFDIR values in PLIST
                   1544:     entries.
                   1545: 
1.1       dsieger  1546:   * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
                   1547:     making and installing the package. The default value for this is 0, which
                   1548:     will not display the commands as they are executed (normal, default, quiet
                   1549:     operation); the value 1 will display all shell commands before their
                   1550:     invocation, and the value 2 will display both the shell commands before
1.112     rillig   1551:     their invocation, as well as their actual execution progress with set -x.
1.1       dsieger  1552: 
1.241     rillig   1553: 6.7. Selecting Build Options
1.1       dsieger  1554: 
                   1555: Some packages have build time options, usually to select between different
                   1556: dependencies, enable optional support for big dependencies or enable
                   1557: experimental features.
                   1558: 
                   1559: To see which options, if any, a package supports, and which options are
                   1560: mutually exclusive, run make show-options, for example:
                   1561: 
                   1562:     The following options are supported by this package:
                   1563:         ssl      Enable SSL support.
                   1564:     Exactly one of the following gecko options is required:
                   1565:         firefox  Use firefox as gecko rendering engine.
                   1566:         mozilla  Use mozilla as gecko rendering engine.
                   1567:     At most one of the following database options may be selected:
                   1568:         mysql    Enable support for MySQL database.
                   1569:         pgsql    Enable support for PostgreSQL database.
                   1570: 
                   1571:     These options are enabled by default: firefox
                   1572:     These options are currently enabled: mozilla ssl
                   1573: 
1.4       rillig   1574: The following variables can be defined in mk.conf to select which options to
                   1575: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1       dsieger  1576: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
                   1577: which can be used to select or disable options specifically for package pkgbase
                   1578: . Options listed in these variables are selected, options preceded by "-" are
                   1579: disabled. A few examples:
                   1580: 
1.4       rillig   1581: $ grep "PKG.*OPTION" mk.conf
1.1       dsieger  1582: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   1583: PKG_OPTIONS.kdebase=    debug -sasl
                   1584: PKG_OPTIONS.apache=     suexec
                   1585: 
1.11      rillig   1586: It is important to note that options that were specifically suggested by the
1.19      snj      1587: package maintainer must be explicitly removed if you do not wish to include the
                   1588: option. If you are unsure you can view the current state with make show-options
                   1589: .
1.11      rillig   1590: 
1.1       dsieger  1591: The following settings are consulted in the order given, and the last setting
                   1592: that selects or disables an option is used:
                   1593: 
                   1594:  1. the default options as suggested by the package maintainer
                   1595: 
                   1596:  2. the options implied by the settings of legacy variables (see below)
                   1597: 
                   1598:  3. PKG_DEFAULT_OPTIONS
                   1599: 
                   1600:  4. PKG_OPTIONS.pkgbase
                   1601: 
                   1602: For groups of mutually exclusive options, the last option selected is used, all
                   1603: others are automatically disabled. If an option of the group is explicitly
                   1604: disabled, the previously selected option, if any, is used. It is an error if no
                   1605: option from a required group of options is selected, and building the package
                   1606: will fail.
                   1607: 
                   1608: Before the options framework was introduced, build options were selected by
1.4       rillig   1609: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
                   1610: transition to the options framework for the user, these legacy variables are
                   1611: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
                   1612: automatically. A warning is issued to prompt the user to update mk.conf to use
                   1613: the options framework directly. Support for the legacy variables will be
1.1       dsieger  1614: removed eventually.
                   1615: 
1.154     rillig   1616: Chapter 7. Creating binary packages
1.1       dsieger  1617: 
                   1618: Table of Contents
                   1619: 
1.154     rillig   1620: 7.1. Building a single binary package
                   1621: 7.2. Settings for creation of binary packages
1.1       dsieger  1622: 
1.154     rillig   1623: 7.1. Building a single binary package
1.1       dsieger  1624: 
                   1625: Once you have built and installed a package, you can create a binary package
                   1626: which can be installed on another system with pkg_add(1). This saves having to
                   1627: build the same package on a group of hosts and wasting CPU time. It also
                   1628: provides a simple means for others to install your package, should you
                   1629: distribute it.
                   1630: 
                   1631: To create a binary package, change into the appropriate directory in pkgsrc,
                   1632: and run make package:
                   1633: 
1.112     rillig   1634: $ cd misc/figlet
                   1635: $ make package
1.1       dsieger  1636: 
1.242     gutterid 1637: This will build your package (if not already done) and package it into a binary
                   1638: package. You can then use the pkg_* tools to manipulate it. Binary packages are
                   1639: created in PACKAGES, which defaults to /usr/pkgsrc/packages, in the form of a
                   1640: compressed tar file. See Section C.2, "Packaging figlet" for a continuation of
                   1641: the above misc/figlet example.
1.1       dsieger  1642: 
1.154     rillig   1643: See Chapter 23, Submitting and Committing for information on how to submit such
1.1       dsieger  1644: a binary package.
                   1645: 
1.154     rillig   1646: 7.2. Settings for creation of binary packages
1.1       dsieger  1647: 
1.184     rillig   1648: See Section 13.17, "Other helpful targets".
1.6       rillig   1649: 
1.154     rillig   1650: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig   1651: 
                   1652: Table of Contents
                   1653: 
1.154     rillig   1654: 8.1. Preparations
1.180     rillig   1655: 8.2. Running a bulk build
1.154     rillig   1656:     8.2.1. Configuration
                   1657: 8.3. Requirements of a full bulk build
1.178     rillig   1658: 8.4. Bulk build variants
1.179     rillig   1659:     8.4.1. Detect unknown configure options
                   1660:     8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig   1661:     8.4.3. Force compiler options only in the build phase
                   1662:     8.4.4. Use custom directories
                   1663:     8.4.5. Turn warnings into errors
                   1664:     8.4.6. Reject packages for which pkglint reports errors
                   1665:     8.4.7. Reject packages that contain forbidden strings
                   1666:     8.4.8. Reject packages whose self-test fails
                   1667:     8.4.9. Reject packages that use undefined shell variables
                   1668:     8.4.10. Turn off verbose logging
1.178     rillig   1669: 8.5. Creating a multiple CD-ROM packages collection
                   1670:     8.5.1. Example of cdpack
1.6       rillig   1671: 
1.175     gutterid 1672: For a number of reasons, you may want to build binary packages for a large
                   1673: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71      wiz      1674: instance, when you have multiple machines that should run the same software, it
                   1675: is wasted time if they all build their packages themselves from source. Or you
                   1676: may want to build a list of packages you want and check them before deploying
1.175     gutterid 1677: onto production systems. There is a way of getting a set of binary packages:
                   1678: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
                   1679: describes how to set it up.
1.71      wiz      1680: 
1.154     rillig   1681: 8.1. Preparations
1.71      wiz      1682: 
                   1683: First of all, you have to decide whether you build all packages or a limited
                   1684: set of them. Full bulk builds usually consume a lot more resources, both space
1.175     gutterid 1685: and time, than builds for some practical sets of packages. A number of
                   1686: particularly heavy packages exist that are not actually interesting to a wide
                   1687: audience. (The approximate resource consumption for a full bulk build is given
                   1688: in section Section 8.3, "Requirements of a full bulk build".) For limited bulk
                   1689: builds you need to make a list of packages you want to build. Note that all
                   1690: their dependencies will be built, so you don't need to track them manually.
1.71      wiz      1691: 
                   1692: During bulk builds various packages are installed and deinstalled in /usr/pkg
                   1693: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112     rillig   1694: the builds. Essentially, you should provide a fresh system, either a chroot
1.71      wiz      1695: environment or something even more restrictive, depending on what the operating
                   1696: system provides, or dedicate the whole physical machine. As a useful side
                   1697: effect this makes sure that bulk builds cannot break anything in your system.
                   1698: There have been numerous cases where certain packages tried to install files
                   1699: outside the LOCALBASE or wanted to edit some files in /etc.
1.6       rillig   1700: 
1.180     rillig   1701: 8.2. Running a bulk build
1.6       rillig   1702: 
1.180     rillig   1703: Running a bulk build works roughly as follows:
1.15      rillig   1704: 
                   1705:   * First, build the pbulk infrastructure in a fresh pkgsrc location.
                   1706: 
                   1707:   * Then, build each of the packages from a clean installation directory using
                   1708:     the infrastructure.
                   1709: 
1.154     rillig   1710: 8.2.1. Configuration
1.6       rillig   1711: 
1.112     rillig   1712: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6       rillig   1713: 
1.68      asau     1714: In order to use it, prepare a clear system (real one, chroot environment, jail,
                   1715: zone, virtual machine). Configure network access to fetch distribution files.
1.112     rillig   1716: Create a user with name "pbulk".
1.68      asau     1717: 
                   1718: Fetch and extract pkgsrc. Use a command like one of these:
                   1719: 
1.151     sevan    1720: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
                   1721: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72      wiz      1722: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68      asau     1723: 
                   1724: Or any other way that fits (e.g., curl, wget).
                   1725: 
                   1726: Deploy and configure pbulk tools, e.g.:
                   1727: 
1.118     sevan    1728: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68      asau     1729: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
                   1730: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
                   1731: 
                   1732: Note
                   1733: 
                   1734: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
                   1735: to packages you build. For instance,
                   1736: 
1.112     rillig   1737: PKG_DEVELOPER=          yes     # perform more checks
                   1738: X11_TYPE=               modular # use pkgsrc X11
                   1739: SKIP_LICENSE_CHECK=     yes     # accept all licences (useful
                   1740:                                 # when building all packages)
1.68      asau     1741: 
                   1742: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112     rillig   1743: with your list of packages, one per line without empty lines or comments. E.g.:
1.68      asau     1744: 
                   1745: www/firefox
                   1746: mail/thunderbird
                   1747: misc/libreoffice4
                   1748: 
1.69      asau     1749: At this point you can also review configuration in /usr/pbulk/etc and make
                   1750: final amendments, if wanted.
                   1751: 
1.68      asau     1752: Start it:
                   1753: 
                   1754: # /usr/pbulk/bin/bulkbuild
                   1755: 
                   1756: After it finishes, you'll have /mnt filled with distribution files, binary
                   1757: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
                   1758: 
                   1759: Note
                   1760: 
                   1761: The pbulk.sh script does not cover all possible use cases. While being ready to
                   1762: run, it serves as a good starting point to understand and build more complex
                   1763: setups. The script is kept small enough for better understanding.
                   1764: 
                   1765: Note
                   1766: 
                   1767: The pbulk.sh script supports running unprivileged bulk build and helps
1.205     wiz      1768: configuring distributed bulk builds. Distributed bulk builds support either
                   1769: building in worker chroots (each node is a path to a different chroot) that
                   1770: replicate the target system, including the pbulk prefix, or remote machines
                   1771: (each node is an IP address that must be accessible over SSH without a
                   1772: password).
1.15      rillig   1773: 
1.154     rillig   1774: 8.3. Requirements of a full bulk build
1.71      wiz      1775: 
                   1776: A complete bulk build requires lots of disk space. Some of the disk space can
                   1777: be read-only, some other must be writable. Some can be on remote filesystems
                   1778: (such as NFS) and some should be local. Some can be temporary filesystems,
                   1779: others must survive a sudden reboot.
                   1780: 
1.205     wiz      1781:   * 70 GB for the distfiles (read-write, remote, temporary)
1.71      wiz      1782: 
1.205     wiz      1783:   * 60 GB for the binary packages (read-write, remote, permanent)
1.71      wiz      1784: 
                   1785:   * 1 GB for the pkgsrc tree (read-only, remote, permanent)
                   1786: 
                   1787:   * 5 GB for LOCALBASE (read-write, local, temporary)
                   1788: 
                   1789:   * 10 GB for the log files (read-write, remote, permanent)
                   1790: 
                   1791:   * 5 GB for temporary files (read-write, local, temporary)
                   1792: 
1.178     rillig   1793: 8.4. Bulk build variants
                   1794: 
                   1795: To ensure that pkgsrc packages work in different configurations, it makes sense
                   1796: to run non-default bulk builds from time to time. This section lists some ideas
                   1797: for bulk builds that intentionally let packages fail if they don't follow the
                   1798: pkgsrc style.
                   1799: 
1.179     rillig   1800: 8.4.1. Detect unknown configure options
1.178     rillig   1801: 
                   1802: Add the following line to mk.conf.
                   1803: 
                   1804: GNU_CONFIGURE_STRICT=   yes
                   1805: 
                   1806: When a package fails this additional check, the most common cause is that the
                   1807: configure option was valid for an older version of the package but does not
                   1808: apply anymore. In that case, just remove it.
                   1809: 
1.179     rillig   1810: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.178     rillig   1811: 
                   1812: The job of a compiler is not restricted to producing executable code, most
1.179     rillig   1813: compilers also detect typical programming mistakes. The pkgsrc compiler
                   1814: wrappers make it easy to force compiler options when the package is built. This
                   1815: can be used to find typical bugs across all packages that are in pkgsrc. By
                   1816: reporting these bugs upstream, the packages will be more reliable with the next
                   1817: updates.
1.178     rillig   1818: 
1.179     rillig   1819: Add some of the following lines to mk.conf:
1.178     rillig   1820: 
                   1821: CFLAGS+=        -Werror=char-subscripts
1.179     rillig   1822: CFLAGS+=        -Werror=implicit-function-declaration
1.178     rillig   1823: 
1.179     rillig   1824: When a package fails to build using these stricter compiler options, document
                   1825: the circumstances in which the compiler produced the error message. This
                   1826: includes:
1.178     rillig   1827: 
                   1828:   * The platform (MACHINE_PLATFORM)
                   1829: 
                   1830:   * The source file
                   1831: 
                   1832:   * An excerpt of the code. GCC and Clang already do this as part of the
                   1833:     diagnostic.
                   1834: 
1.179     rillig   1835:   * The exact error message from the compiler.
1.178     rillig   1836: 
1.179     rillig   1837: If a package produces these error messages, but the package is fine, record
                   1838: this in your local mk.conf, like this, to skip this check in the next builds:
1.178     rillig   1839: 
1.179     rillig   1840: .if ${PKGPATH} == category/package
1.178     rillig   1841: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
                   1842: # error message
                   1843: # code
1.179     rillig   1844: # Reason why the code does not need to be fixed.
1.178     rillig   1845: BUILDLINK_TRANSFORM+=   rm:-Werror=char-subscripts
1.179     rillig   1846: .endif
1.178     rillig   1847: 
                   1848: If the error messages from the compiler are valid and the code needs to be
1.179     rillig   1849: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
                   1850: upstream authors of the package, providing them with the information you
                   1851: collected above.
1.178     rillig   1852: 
1.179     rillig   1853: Patches that are not essential for the package to work should only be reported
                   1854: upstream but not committed to pkgsrc, to make future updates easier.
                   1855: 
1.181     rillig   1856: 8.4.3. Force compiler options only in the build phase
                   1857: 
                   1858: When adding custom compiler flags via CFLAGS, these apply to all phases of the
                   1859: package build process. Especially in the configure phase, adding -Werror leads
                   1860: to wrong decisions. The GNU configure scripts feed many small test programs to
                   1861: the C compiler to see whether certain headers are available, functions are
                   1862: defined in a library and programs can be run. In many cases these programs
                   1863: would not survive a strict compiler run with -Wall -Wextra -Werror.
                   1864: 
                   1865: The pkgsrc infrastructure is flexible enough to support compiler options being
                   1866: added between the configure and build phases. It's a little more complicated
                   1867: than the other examples in this section but still easy enough.
                   1868: 
                   1869: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
                   1870: compiler options. The compiler wrapper's original task is to hide unwanted
                   1871: directories of include files and to normalize compiler options. It does this by
                   1872: wrapping the compiler command and rewriting the command line. To see this in
                   1873: action, run bmake patch in a package directory and examine the work/.cwrappers/
                   1874: config directory. It contains individual configurations for the C compiler and
                   1875: the related tools. The plan is to find a hook between the configure and build
                   1876: phases, and to modify these configuration files at that point.
                   1877: 
                   1878: To find this hook, have a look at mk/build/build.mk, which contains among
                   1879: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
                   1880: pre-build-hook sounds good enough.
                   1881: 
                   1882: The code to be included in mk.conf is:
                   1883: 
                   1884: # Just a few example options.
                   1885: BUILD_ONLY_CFLAGS=      -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
                   1886: 
                   1887: .if ${BUILD_ONLY_CFLAGS:U:M*}
                   1888: pre-build-checks-hook: add-build-only-cflags
                   1889: 
                   1890: add-build-only-cflags: .PHONY
                   1891:         ${RUN} cd ${CWRAPPERS_CONFIG_DIR};      \
                   1892:         ${TEST} ! -f ${.TARGET} || exit 0;      \
                   1893:         for flag in ${BUILD_ONLY_CFLAGS}; do    \
                   1894:                 ${ECHO} "append=$$flag" >> cc;  \
                   1895:         done;                                   \
                   1896:         > ${.TARGET}
                   1897: .endif
                   1898: 
                   1899: (When editing the mk.conf, make sure that the commands of the
                   1900: add-build-only-cflags target are indented with a tab, not with spaces.)
                   1901: 
                   1902: The condition in the .if statement contains the :U modifier to prevent parse
                   1903: errors if the variable should be undefined, possibly because it is only defined
                   1904: for a subset of the packages. The :M* modifier ensures that there is at least
                   1905: one compiler option, to prevent a syntax error in the shell parser.
                   1906: 
                   1907: The code around the ${.TARGET} variable ensures that the additional compiler
                   1908: options are only appended once, even if bmake build is run multiple times. To
                   1909: do this, it creates a marker file.
                   1910: 
                   1911: To verify that this setup works, run bmake configure in a package directory. Up
                   1912: to now, everything works as usual. Examine the directory work/.cwrappers/config
                   1913: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
                   1914: the file cc. Examine the tail of the work/.work.log file to see that the normal
                   1915: compiler options are used.
                   1916: 
                   1917: Now run bmake build. This will append the options to the file cc and will
                   1918: create the marker file in the same directory. After that, the build starts as
                   1919: usual, but with the added compiler options. Examine the tail of the file work
                   1920: /.work.log to see that the lines starting with [*] don't contain the compiler
                   1921: options, but the corresponding lines starting with <.> do end with these
                   1922: options.
                   1923: 
                   1924: Building packages using this setup variant and fixing the resulting bugs is the
                   1925: same as in Section 8.4.2, "Detect classes of bugs by forcing compiler warnings"
                   1926: .
                   1927: 
                   1928: 8.4.4. Use custom directories
1.178     rillig   1929: 
                   1930: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
                   1931: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
                   1932: afterwards in mk.conf.
                   1933: 
                   1934: PREFIX=         /a-random-uuid
                   1935: PKG_SYSCONFDIR= /a-random-uuid
                   1936: VARBASE=        /a-random-uuid
                   1937: PKGMANDIR=      a-random-uuid
                   1938: PKG_INFODIR=    a-random-uuid
                   1939: 
1.181     rillig   1940: 8.4.5. Turn warnings into errors
1.178     rillig   1941: 
                   1942: When building a package, warnings are typically ignored since they just flow by
                   1943: and do not cause the build to fail immediately. To find these warnings,
                   1944: redefine them to errors in mk.conf.
                   1945: 
                   1946: DELAYED_WARNING_MSG=    ${DELAYED_ERROR_MSG} "(was warning)"
                   1947: WARNING_MSG=            ${FAIL_MSG} "(was warning)"
                   1948: 
                   1949: (There are many more classes of warnings in pkgsrc, and most of them can be
                   1950: redefined with a simple definition like above.
                   1951: 
1.179     rillig   1952: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178     rillig   1953: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
                   1954: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
                   1955: 
1.181     rillig   1956: 8.4.6. Reject packages for which pkglint reports errors
1.178     rillig   1957: 
                   1958: Using pkglint as part of the regular build process is mostly a waste of time.
                   1959: If you want to fix some of the warnings, just run pkglint recursively on the
                   1960: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
                   1961: faster than a complete bulk build.
                   1962: 
1.181     rillig   1963: 8.4.7. Reject packages that contain forbidden strings
1.178     rillig   1964: 
                   1965: To ensure that the binary packages don't contain references to the build
                   1966: directory, there is already CHECK_WRKREF. If that variable includes the item
                   1967: extra, it is possible to define additional patterns that must not appear in any
                   1968: installed file. This is specified in mk.conf.
                   1969: 
                   1970: CHECK_WRKREF=                   extra
                   1971: CHECK_WRKREF_EXTRA_DIRS+=       /usr/local
                   1972: CHECK_WRKREF_EXTRA_DIRS+=       /usr/pkg
                   1973: CHECK_WRKREF_EXTRA_DIRS+=       @[A-Z][A-Z]*@
                   1974: 
                   1975: The above patterns will probably generate many false positives, therefore the
                   1976: results need to be taken with a grain of salt.
                   1977: 
1.181     rillig   1978: 8.4.8. Reject packages whose self-test fails
1.178     rillig   1979: 
                   1980: To run the test suites that come with each package, add this line to mk.conf.
                   1981: 
                   1982: PKGSRC_RUN_TEST=        yes
                   1983: 
                   1984: Be prepared that even the most basic packages fail this test. When doing a bulk
                   1985: build with this, it will often abort in the early phase where the packages are
                   1986: scanned for their dependencies since there are cyclic dependencies. There is
                   1987: still a lot to do in this area.
                   1988: 
1.181     rillig   1989: 8.4.9. Reject packages that use undefined shell variables
1.178     rillig   1990: 
                   1991: To catch typos in the shell snippets from the Makefile fragments, add the -u
                   1992: flag to most of the commands by adding this line to mk.conf.
                   1993: 
                   1994: RUN=    @set -eu;
                   1995: 
1.181     rillig   1996: After that, ensure that none of the bulk build log files (even those for
                   1997: successfully built packages) contains the string parameter not set or whatever
                   1998: error message the command sh -ceu '$undefined' outputs.
                   1999: 
1.178     rillig   2000: See mk/misc/common.mk for the existing definition.
                   2001: 
1.181     rillig   2002: 8.4.10. Turn off verbose logging
1.178     rillig   2003: 
                   2004: The build logs of a package are often quite long. This allows error messages or
                   2005: other interesting details to hide between the noise. To make the actual error
                   2006: message stand out more, add these lines to mk.conf.
                   2007: 
                   2008: GNU_CONFIGURE_QUIET=    yes
                   2009: MAKE_FLAGS+=            -s
                   2010: 
                   2011: The -s option works for both GNU Make and BSD Make. On exotic platforms with
                   2012: their own make, it may be a little different.
                   2013: 
                   2014: 8.5. Creating a multiple CD-ROM packages collection
1.1       dsieger  2015: 
                   2016: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
                   2017: of the resulting binary packages to assist in installing packages on other
                   2018: machines. The pkgtools/cdpack package provides a simple tool for creating the
                   2019: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
                   2020: keeps all the dependencies for a given package on the same CD as that package.
                   2021: 
1.178     rillig   2022: 8.5.1. Example of cdpack
1.1       dsieger  2023: 
                   2024: Complete documentation for cdpack is found in the cdpack(1) man page. The
                   2025: following short example assumes that the binary packages are left in /usr/
                   2026: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
                   2027: ISO 9660 images.
                   2028: 
                   2029: # mkdir /u2/images
                   2030: # pkg_add /usr/pkgsrc/packages/All/cdpack
                   2031: # cdpack /usr/pkgsrc/packages/All /u2/images
                   2032: 
                   2033: 
                   2034: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
                   2035: CD in the collection, then you need to create a directory which contains these
1.175     gutterid 2036: files, e.g.:
1.1       dsieger  2037: 
                   2038: # mkdir /tmp/common
                   2039: # echo "This is a README" > /tmp/common/README
                   2040: # echo "Another file" > /tmp/common/COPYING
                   2041: # mkdir /tmp/common/bin
                   2042: # echo "#!/bin/sh" > /tmp/common/bin/myscript
                   2043: # echo "echo Hello world" >> /tmp/common/bin/myscript
                   2044: # chmod 755 /tmp/common/bin/myscript
                   2045: 
                   2046: 
                   2047: Now create the images:
                   2048: 
                   2049: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
                   2050: 
                   2051: Each image will contain README, COPYING, and bin/myscript in their root
                   2052: directories.
                   2053: 
1.154     rillig   2054: Chapter 9. Directory layout of the installed files
1.1       dsieger  2055: 
                   2056: Table of Contents
                   2057: 
1.154     rillig   2058: 9.1. File system layout in ${LOCALBASE}
                   2059: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2060: 
                   2061: The files that are installed by pkgsrc are organized in a way that is similar
                   2062: to what you find in the /usr directory of the base system. But some details are
                   2063: different. This is because pkgsrc initially came from FreeBSD and had adopted
                   2064: its file system hierarchy. Later it was largely influenced by NetBSD. But no
                   2065: matter which operating system you are using pkgsrc with, you can expect the
                   2066: same layout for pkgsrc.
                   2067: 
                   2068: There are mainly four root directories for pkgsrc, which are all configurable
                   2069: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
                   2070: default locations are:
                   2071: 
                   2072: LOCALBASE=              /usr/pkg
                   2073: PKG_SYSCONFBASE=        /usr/pkg/etc
                   2074: VARBASE=                /var
1.119     sevan    2075: PKG_DBDIR=              /usr/pkg/pkgdb
1.1       dsieger  2076: 
                   2077: In unprivileged mode (when pkgsrc has been installed as any other user), the
                   2078: default locations are:
                   2079: 
                   2080: LOCALBASE=              ${HOME}/pkg
                   2081: PKG_SYSCONFBASE=        ${HOME}/pkg/etc
                   2082: VARBASE=                ${HOME}/pkg/var
1.119     sevan    2083: PKG_DBDIR=              ${HOME}/pkg/pkgdb
1.1       dsieger  2084: 
                   2085: What these four directories are for, and what they look like is explained
                   2086: below.
                   2087: 
1.25      wiz      2088:   * LOCALBASE corresponds to the /usr directory in the base system. It is the "
                   2089:     main" directory where the files are installed and contains the well-known
1.1       dsieger  2090:     subdirectories like bin, include, lib, share and sbin.
                   2091: 
                   2092:   * VARBASE corresponds to /var in the base system. Some programs (especially
                   2093:     games, network daemons) need write access to it during normal operation.
                   2094: 
                   2095:   * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
                   2096:     configuration files of the packages, as well as pkgsrc's mk.conf itself.
                   2097: 
1.154     rillig   2098: 9.1. File system layout in ${LOCALBASE}
1.1       dsieger  2099: 
                   2100: The following directories exist in a typical pkgsrc installation in $
                   2101: {LOCALBASE}.
                   2102: 
                   2103: bin
                   2104: 
                   2105:     Contains executable programs that are intended to be directly used by the
                   2106:     end user.
                   2107: 
                   2108: emul
                   2109: 
                   2110:     Contains files for the emulation layers of various other operating systems,
                   2111:     especially for NetBSD.
                   2112: 
                   2113: etc (the usual location of ${PKG_SYSCONFDIR})
                   2114: 
                   2115:     Contains the configuration files.
                   2116: 
                   2117: include
                   2118: 
                   2119:     Contains headers for the C and C++ programming languages.
                   2120: 
                   2121: info
                   2122: 
                   2123:     Contains GNU info files of various packages.
                   2124: 
                   2125: lib
                   2126: 
                   2127:     Contains shared and static libraries.
                   2128: 
                   2129: libdata
                   2130: 
                   2131:     Contains data files that don't change after installation. Other data files
                   2132:     belong into ${VARBASE}.
                   2133: 
                   2134: libexec
                   2135: 
                   2136:     Contains programs that are not intended to be used by end users, such as
                   2137:     helper programs or network daemons.
                   2138: 
                   2139: libexec/cgi-bin
                   2140: 
                   2141:     Contains programs that are intended to be executed as CGI scripts by a web
                   2142:     server.
                   2143: 
                   2144: man (the usual value of ${PKGMANDIR})
                   2145: 
                   2146:     Contains brief documentation in form of manual pages.
                   2147: 
                   2148: sbin
                   2149: 
                   2150:     Contains programs that are intended to be used only by the super-user.
                   2151: 
                   2152: share
                   2153: 
                   2154:     Contains platform-independent data files that don't change after
                   2155:     installation.
                   2156: 
                   2157: share/doc
                   2158: 
                   2159:     Contains documentation files provided by the packages.
                   2160: 
                   2161: share/examples
                   2162: 
                   2163:     Contains example files provided by the packages. Among others, the original
                   2164:     configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
                   2165:     installation.
                   2166: 
                   2167: share/examples/rc.d
                   2168: 
                   2169:     Contains the original files for rc.d scripts.
                   2170: 
                   2171: var (the usual location of ${VARBASE})
                   2172: 
                   2173:     Contains files that may be modified after installation.
                   2174: 
1.154     rillig   2175: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2176: 
                   2177: db/pkg (the usual location of ${PKG_DBDIR})
                   2178: 
                   2179:     Contains information about the currently installed packages.
                   2180: 
                   2181: games
                   2182: 
                   2183:     Contains highscore files.
                   2184: 
                   2185: log
                   2186: 
                   2187:     Contains log files.
                   2188: 
                   2189: run
                   2190: 
                   2191:     Contains informational files about daemons that are currently running.
                   2192: 
1.154     rillig   2193: Chapter 10. Frequently Asked Questions
1.1       dsieger  2194: 
                   2195: Table of Contents
                   2196: 
1.154     rillig   2197: 10.1. Are there any mailing lists for pkg-related discussion?
                   2198: 10.2. Utilities for package management (pkgtools)
                   2199: 10.3. How to use pkgsrc as non-root
                   2200: 10.4. How to resume transfers when fetching distfiles?
                   2201: 10.5. How can I install/use modular X.org from pkgsrc?
                   2202: 10.6. How to fetch files from behind a firewall
                   2203: 10.7. How to fetch files from HTTPS sites
                   2204: 10.8. How do I tell make fetch to do passive FTP?
                   2205: 10.9. How to fetch all distfiles at once
                   2206: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                   2207: 10.11. What does "Could not find bsd.own.mk" mean?
1.221     nia      2208: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154     rillig   2209: 10.13. How do I change the location of configuration files?
                   2210: 10.14. Automated security checks
                   2211: 10.15. Why do some packages ignore my CFLAGS?
                   2212: 10.16. A package does not build. What shall I do?
                   2213: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.259     leot     2214:     conflicts" mean?
1.1       dsieger  2215: 
                   2216: This section contains hints, tips & tricks on special things in pkgsrc that we
                   2217: didn't find a better place for in the previous chapters, and it contains items
                   2218: for both pkgsrc users and developers.
                   2219: 
1.154     rillig   2220: 10.1. Are there any mailing lists for pkg-related discussion?
1.1       dsieger  2221: 
                   2222: The following mailing lists may be of interest to pkgsrc users:
                   2223: 
                   2224:   * pkgsrc-users: This is a general purpose list for most issues regarding
                   2225:     pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
                   2226:     configuration, unexpected build failures, using particular packages,
                   2227:     upgrading pkgsrc installations, questions regarding the pkgsrc release
                   2228:     branches, etc. General announcements or proposals for changes that impact
                   2229:     the pkgsrc user community, e.g. major infrastructure changes, new features,
                   2230:     package removals, etc., may also be posted.
                   2231: 
                   2232:   * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
                   2233:     discussed.
                   2234: 
                   2235:   * pkgsrc-changes: This list is for those who are interested in getting a
                   2236:     commit message for every change committed to pkgsrc. It is also available
                   2237:     in digest form, meaning one daily message containing all commit messages
                   2238:     for changes to the package source tree in that 24 hour period.
                   2239: 
                   2240: To subscribe, do:
                   2241: 
                   2242: % echo subscribe listname | mail majordomo@NetBSD.org
                   2243: 
1.174     leot     2244: Archives for all these mailing lists are available from https://
1.1       dsieger  2245: mail-index.NetBSD.org/.
                   2246: 
1.154     rillig   2247: 10.2. Utilities for package management (pkgtools)
1.1       dsieger  2248: 
                   2249: The directory pkgsrc/pkgtools contains a number of useful utilities for both
                   2250: users and developers of pkgsrc. This section attempts only to make the reader
1.121     sevan    2251: aware of some of the utilities and when they might be useful, and not to
                   2252: duplicate the documentation that comes with each package.
1.1       dsieger  2253: 
                   2254: Utilities used by pkgsrc (automatically installed when needed):
                   2255: 
                   2256:   * pkgtools/x11-links: Symlinks for use by buildlink.
                   2257: 
                   2258: OS tool augmentation (automatically installed when needed):
                   2259: 
1.121     sevan    2260:   * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1       dsieger  2261: 
                   2262:   * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
                   2263: 
                   2264:   * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
                   2265: 
                   2266:   * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
                   2267:     for use on operating systems where pkg_install is not present.
                   2268: 
                   2269: Utilities used by pkgsrc (not automatically installed):
                   2270: 
                   2271:   * pkgtools/pkg_tarup: Create a binary package from an already-installed
                   2272:     package. Used by make replace to save the old package.
                   2273: 
                   2274:   * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
                   2275:     distfiles from multiple locations. It currently supports the following
                   2276:     methods: multiple CD-ROMs and network FTP/HTTP connections.
                   2277: 
                   2278:   * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24      wiz      2279:     current CPU and compiler.
1.1       dsieger  2280: 
                   2281: Utilities for keeping track of installed packages, being up to date, etc:
                   2282: 
1.65      wiz      2283:   * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
                   2284:     and upgrade binary packages easily.
                   2285: 
1.1       dsieger  2286:   * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
                   2287:     the latest pkgsrc entries.
                   2288: 
                   2289:   * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
                   2290:     strategy for updating.
                   2291: 
                   2292:   * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
                   2293:     graphviz).
                   2294: 
1.12      weinem   2295:   * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
                   2296: 
                   2297:   * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
                   2298:     complete pkgsrc system.
1.1       dsieger  2299: 
                   2300:   * pkgtools/pkgsurvey: Report what packages you have installed.
                   2301: 
                   2302: Utilities for people maintaining or creating individual packages:
                   2303: 
                   2304:   * pkgtools/pkgdiff: Automate making and maintaining patches for a package
                   2305:     (includes pkgdiff, pkgvi, mkpatches, etc.).
                   2306: 
1.65      wiz      2307:   * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1       dsieger  2308: 
                   2309: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
                   2310: 
                   2311:   * pkgtools/pkg_comp: Build packages in a chrooted area.
                   2312: 
                   2313:   * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
                   2314: 
1.154     rillig   2315: 10.3. How to use pkgsrc as non-root
1.1       dsieger  2316: 
1.108     rillig   2317: To install packages from source as a non-root user, download pkgsrc as
1.154     rillig   2318: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108     rillig   2319: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
                   2320: 
                   2321: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
                   2322: configuration mk.conf into ~/pkg/etc.
                   2323: 
                   2324: For more details, see mk/unprivileged.mk.
1.1       dsieger  2325: 
1.154     rillig   2326: 10.4. How to resume transfers when fetching distfiles?
1.1       dsieger  2327: 
                   2328: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4       rillig   2329: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
                   2330: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1       dsieger  2331: 
1.61      wiz      2332: You can also use a different program than the platform default program by
                   2333: changing the FETCH_USING variable. You can specify the program by using of ftp,
                   2334: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
                   2335: manual. A value of custom disables the system defaults and dependency tracking
                   2336: for the fetch program. In that case you have to provide FETCH_CMD,
                   2337: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1       dsieger  2338: 
1.16      jnemeth  2339: For example, if you want to use wget to download, you'll have to use something
                   2340: like:
1.1       dsieger  2341: 
1.16      jnemeth  2342: FETCH_USING=    wget
1.1       dsieger  2343: 
1.154     rillig   2344: 10.5. How can I install/use modular X.org from pkgsrc?
1.1       dsieger  2345: 
1.4       rillig   2346: If you want to use modular X.org from pkgsrc instead of your system's own X11
                   2347: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1       dsieger  2348: mk.conf:
                   2349: 
1.4       rillig   2350: X11_TYPE=modular
1.1       dsieger  2351: 
1.154     rillig   2352: 10.6. How to fetch files from behind a firewall
1.1       dsieger  2353: 
                   2354: If you are sitting behind a firewall which does not allow direct connections to
                   2355: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
                   2356: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
                   2357: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
                   2358: the proxy port number. So the proxy environment variables are:
                   2359: 
                   2360: ftp_proxy=ftp://orpheus.amdahl.com:80/
                   2361: http_proxy=http://orpheus.amdahl.com:80/
                   2362: 
1.154     rillig   2363: 10.7. How to fetch files from HTTPS sites
1.65      wiz      2364: 
                   2365: Some fetch tools are not prepared to support HTTPS by default (for example, the
                   2366: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
                   2367: openssl dependency that low in the dependency graph).
                   2368: 
                   2369: Usually you won't notice, because distribution files are mirrored weekly to "
                   2370: ftp.NetBSD.org", but that might not be often enough if you are following
                   2371: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
                   2372: "wget", which are both compiled with HTTPS support by default. Of course, these
                   2373: tools need to be installed before you can use them this way.
                   2374: 
1.154     rillig   2375: 10.8. How do I tell make fetch to do passive FTP?
1.1       dsieger  2376: 
                   2377: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
                   2378: FETCH_CMD is assigned the first available command from the following list:
                   2379: 
                   2380:   * ${LOCALBASE}/bin/ftp
                   2381: 
                   2382:   * /usr/bin/ftp
                   2383: 
                   2384: On a default NetBSD installation, this will be /usr/bin/ftp, which
                   2385: automatically tries passive connections first, and falls back to active
                   2386: connections if the server refuses to do passive. For the other tools, add the
1.4       rillig   2387: following to your mk.conf file: PASSIVE_FETCH=1.
1.1       dsieger  2388: 
                   2389: Having that option present will prevent /usr/bin/ftp from falling back to
                   2390: active transfers.
                   2391: 
1.154     rillig   2392: 10.9. How to fetch all distfiles at once
1.1       dsieger  2393: 
                   2394: You would like to download all the distfiles in a single batch from work or
                   2395: university, where you can't run a make fetch. There is an archive of distfiles
                   2396: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
                   2397: 
                   2398: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
                   2399: subdirectories, carry the resulting list to your machine at work/school and use
                   2400: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
                   2401: don't forget to set FETCH_CMD to something that fetches a URL:
                   2402: 
                   2403: At home:
                   2404: 
                   2405: % cd /usr/pkgsrc
                   2406: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
                   2407: % scp /tmp/fetch.sh work:/tmp
                   2408: 
                   2409: At work:
                   2410: 
                   2411: % sh /tmp/fetch.sh
                   2412: 
                   2413: then tar up /tmp/distfiles and take it home.
                   2414: 
                   2415: If you have a machine running NetBSD, and you want to get all distfiles (even
                   2416: ones that aren't for your machine architecture), you can do so by using the
                   2417: above-mentioned make fetch-list approach, or fetch the distfiles directly by
                   2418: running:
                   2419: 
                   2420: % make mirror-distfiles
                   2421: 
                   2422: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
                   2423: everything by running:
                   2424: 
                   2425: % make fetch NO_SKIP=yes
                   2426: 
1.154     rillig   2427: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1       dsieger  2428: 
                   2429: When compiling the pkgtools/pkg_install package, you get the error from make
                   2430: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
                   2431: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
                   2432: distribution on your machine. It is recommended to do that to format man pages.
                   2433: 
                   2434: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4       rillig   2435: NOMAN=YES either in the environment or in mk.conf.
1.1       dsieger  2436: 
1.154     rillig   2437: 10.11. What does "Could not find bsd.own.mk" mean?
1.1       dsieger  2438: 
                   2439: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
                   2440: machine. Please get and install it, by extracting it in /:
                   2441: 
                   2442: # cd /
                   2443: # tar --unlink -zxvpf .../comp.tgz
                   2444: 
                   2445: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
                   2446: release (determine via uname -r).
                   2447: 
1.221     nia      2448: 10.12. Using 'sudo' or `priv` with pkgsrc
1.1       dsieger  2449: 
                   2450: When installing packages as non-root user and using the just-in-time su(1)
                   2451: feature of pkgsrc, it can become annoying to type in the root password for each
                   2452: required package installed. To avoid this, the sudo package can be used, which
1.221     nia      2453: does password caching over a limited time. To use it, install sudo or priv
                   2454: (either as binary package, from security/priv, or security/sudo) and then put
                   2455: the following into your mk.conf, somewhere after the definition of the
                   2456: LOCALBASE variable:
1.1       dsieger  2457: 
                   2458: .if exists(${LOCALBASE}/bin/sudo)
1.260     wiz      2459: SU_CMD=        ${LOCALBASE}/bin/sudo -E /bin/sh -c
1.1       dsieger  2460: .endif
                   2461: 
1.260     wiz      2462: Note the -E flag; that tells sudo to preserve the environment. Without this,
                   2463: the bin-install target will fail when building a package with a non-default
                   2464: python version.
                   2465: 
1.154     rillig   2466: 10.13. How do I change the location of configuration files?
1.1       dsieger  2467: 
                   2468: As the system administrator, you can choose where configuration files are
                   2469: installed. The default settings make all these files go into ${PREFIX}/etc or
                   2470: some of its subdirectories; this may be suboptimal depending on your
                   2471: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
                   2472: configuration of the provided packages).
                   2473: 
                   2474: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4       rillig   2475: (in mk.conf) to point to your preferred configuration directory; some common
                   2476: examples include /etc or /etc/pkg.
1.1       dsieger  2477: 
                   2478: Furthermore, you can change this value on a per-package basis by setting the
                   2479: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
                   2480: matches the name of the package you would like to modify, that is, the contents
                   2481: of PKGBASE.
                   2482: 
                   2483: Note that after changing these settings, you must rebuild and reinstall any
                   2484: affected packages.
                   2485: 
1.154     rillig   2486: 10.14. Automated security checks
1.1       dsieger  2487: 
                   2488: Please be aware that there can often be bugs in third-party software, and some
                   2489: of these bugs can leave a machine vulnerable to exploitation by attackers. In
                   2490: an effort to lessen the exposure, the NetBSD packages team maintains a database
                   2491: of known-exploits to packages which have at one time been included in pkgsrc.
                   2492: The database can be downloaded automatically, and a security audit of all
1.14      jmcneill 2493: packages installed on a system can take place. To do this, refer to the
                   2494: following two tools (installed as part of the pkgtools/pkg_install package):
1.1       dsieger  2495: 
1.21      snj      2496:  1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
                   2497:     security vulnerabilities information. This list is kept up to date by the
1.26      spz      2498:     pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1       dsieger  2499: 
1.177     leot     2500:     https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1       dsieger  2501: 
1.21      snj      2502:  2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24      wiz      2503:     known vulnerability. If a vulnerable package is installed, it will be shown
                   2504:     by output to stdout, including a description of the type of vulnerability,
                   2505:     and a URL containing more information.
1.1       dsieger  2506: 
1.202     nia      2507: Use of these tools is strongly recommended! See Section 5.1.6, "Checking for
1.121     sevan    2508: security vulnerabilities in installed packages" for instructions on how to
                   2509: automate checking and reporting.
                   2510: 
                   2511: If this database is installed, pkgsrc builds will use it to perform a security
                   2512: check before building any package.
1.1       dsieger  2513: 
1.154     rillig   2514: 10.15. Why do some packages ignore my CFLAGS?
1.1       dsieger  2515: 
                   2516: When you add your own preferences to the CFLAGS variable in your mk.conf, these
                   2517: flags are passed in environment variables to the ./configure scripts and to
                   2518: make(1). Some package authors ignore the CFLAGS from the environment variable
                   2519: by overriding them in the Makefiles of their package.
                   2520: 
                   2521: Currently there is no solution to this problem. If you really need the package
                   2522: to use your CFLAGS you should run make patch in the package directory and then
                   2523: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
                   2524: Usually you can remove these lines. But be aware that some "smart" programmers
                   2525: write so bad code that it only works for the specific combination of CFLAGS
                   2526: they have chosen.
                   2527: 
1.172     rillig   2528: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
                   2529: 
                   2530: CPPFLAGS+=              -Dpkgsrc___CPPFLAGS
                   2531: CFLAGS+=                -Dpkgsrc___CFLAGS
                   2532: CXXFLAGS+=              -Dpkgsrc___CXXFLAGS
                   2533: 
                   2534: Then run bmake show-all-configure show-all-build to see whether the above flags
                   2535: are passed to the actual build commands in general.
                   2536: 
                   2537: To find out whether the flags are passed to individual compiler commands, have
                   2538: a look at the file work/.work.log. In most cases, the flags from the original
                   2539: command lines (the lines starting with [*]) are passed unmodified to the actual
                   2540: compiler (the lines starting with <.>). If the flag is missing from the actual
                   2541: compiler command, it must have been removed by the pkgsrc compiler wrappers.
                   2542: 
1.154     rillig   2543: 10.16. A package does not build. What shall I do?
1.1       dsieger  2544: 
                   2545:  1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
                   2546:     is that people only update pkgsrc in parts, because of performance reasons.
                   2547:     Since pkgsrc is one large system, not a collection of many small systems,
                   2548:     there are sometimes changes that only work when the whole pkgsrc tree is
                   2549:     updated.
                   2550: 
1.25      wiz      2551:  2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
                   2552:     >>>>>>" in all your pkgsrc files.
1.1       dsieger  2553: 
1.25      wiz      2554:  3. Make sure that you don't have old copies of the packages extracted. Run 
1.1       dsieger  2555:     make clean clean-depends to verify this.
                   2556: 
1.108     rillig   2557:  4. If you are a package developer who wants to invest some work, have a look
1.154     rillig   2558:     at Chapter 21, Making your package work.
1.108     rillig   2559: 
                   2560:  5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1       dsieger  2561: 
1.154     rillig   2562: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1       dsieger  2563: conflicts" mean?
                   2564: 
                   2565: You have modified a file from pkgsrc, and someone else has modified that same
                   2566: file afterwards in the CVS repository. Both changes are in the same region of
                   2567: the file, so when you updated pkgsrc, the cvs command marked the conflicting
                   2568: changes in the file. Because of these markers, the file is no longer a valid
                   2569: Makefile.
                   2570: 
                   2571: Have a look at that file, and if you don't need your local changes anymore, you
                   2572: can remove that file and run cvs -q update -dP in that directory to download
                   2573: the current version.
                   2574: 
                   2575: Part II. The pkgsrc developer's guide
                   2576: 
                   2577: This part of the book deals with creating and modifying packages. It starts
                   2578: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
                   2579: more like a reference manual for pkgsrc.
                   2580: 
                   2581: Table of Contents
                   2582: 
1.154     rillig   2583: 11. Getting help
1.184     rillig   2584: 12. Package components - files, directories and contents
                   2585:     12.1. Makefile
                   2586:     12.2. distinfo
                   2587:     12.3. patches/*
                   2588:         12.3.1. Structure of a single patch file
                   2589:         12.3.2. Creating patch files
                   2590:         12.3.3. Sources where the patch files come from
                   2591:         12.3.4. Patching guidelines
                   2592:         12.3.5. Feedback to the author
                   2593:     12.4. Other mandatory files
                   2594:     12.5. Optional files
                   2595:         12.5.1. Files affecting the binary package
                   2596:         12.5.2. Files affecting the build process
                   2597:         12.5.3. Files affecting nothing at all
                   2598:     12.6. work*
                   2599:     12.7. files/*
                   2600: 13. The build process
                   2601:     13.1. Introduction
                   2602:     13.2. Program location
                   2603:     13.3. Directories used during the build process
                   2604:     13.4. Running a phase
                   2605:     13.5. The fetch phase
                   2606:         13.5.1. What to fetch and where to get it from
                   2607:         13.5.2. How are the files fetched?
                   2608:     13.6. The checksum phase
                   2609:     13.7. The extract phase
                   2610:     13.8. The patch phase
                   2611:     13.9. The tools phase
                   2612:     13.10. The wrapper phase
                   2613:     13.11. The configure phase
                   2614:     13.12. The build phase
                   2615:     13.13. The test phase
                   2616:     13.14. The install phase
                   2617:     13.15. The package phase
                   2618:     13.16. Cleaning up
                   2619:     13.17. Other helpful targets
                   2620: 14. Creating a new pkgsrc package from scratch
                   2621:     14.1. Common types of packages
1.219     nia      2622:         14.1.1. Python modules and programs
                   2623:         14.1.2. R packages
                   2624:         14.1.3. TeXlive packages
1.184     rillig   2625:     14.2. Examples
                   2626:         14.2.1. How the www/nvu package came into pkgsrc
                   2627: 15. Programming in Makefiles
                   2628:     15.1. Caveats
                   2629:     15.2. Makefile variables
                   2630:         15.2.1. Naming conventions
                   2631:     15.3. Code snippets
                   2632:         15.3.1. Adding things to a list
                   2633:         15.3.2. Echoing a string exactly as-is
                   2634:         15.3.3. Passing CFLAGS to GNU configure scripts
                   2635:         15.3.4. Handling possibly empty variables
1.229     gutterid 2636:         15.3.5. Testing yes/no variables in conditions
1.184     rillig   2637: 16. Options handling
                   2638:     16.1. Global default options
                   2639:     16.2. Converting packages to use bsd.options.mk
                   2640:     16.3. Option Names
                   2641:     16.4. Determining the options of dependencies
                   2642: 17. Tools needed for building or running
                   2643:     17.1. Tools for pkgsrc builds
                   2644:     17.2. Tools needed by packages
                   2645:     17.3. Tools provided by platforms
                   2646: 18. Buildlink methodology
                   2647:     18.1. Converting packages to use buildlink3
                   2648:     18.2. Writing buildlink3.mk files
                   2649:         18.2.1. Anatomy of a buildlink3.mk file
                   2650:         18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
1.259     leot     2651:             pkg in buildlink3.mk files
1.184     rillig   2652:     18.3. Writing builtin.mk files
                   2653:         18.3.1. Anatomy of a builtin.mk file
                   2654: 19. PLIST issues
                   2655:     19.1. RCS ID
                   2656:     19.2. Semi-automatic PLIST generation
                   2657:     19.3. Tweaking output of make print-PLIST
                   2658:     19.4. Variable substitution in PLIST
                   2659:     19.5. Man page compression
                   2660:     19.6. Changing PLIST source with PLIST_SRC
                   2661:     19.7. Platform-specific and differing PLISTs
                   2662:     19.8. Build-specific PLISTs
                   2663:     19.9. Sharing directories between packages
                   2664: 20. The pkginstall framework
                   2665:     20.1. Files and directories outside the installation prefix
                   2666:         20.1.1. Directory manipulation
                   2667:         20.1.2. File manipulation
                   2668:     20.2. Configuration files
                   2669:         20.2.1. How PKG_SYSCONFDIR is set
                   2670:         20.2.2. Telling the software where configuration files are
1.239     dholland 2671:         20.2.3. Patching installation
                   2672:         20.2.4. Declaring configuration files
                   2673:         20.2.5. Disabling handling of configuration files
1.184     rillig   2674:     20.3. System startup scripts
                   2675:         20.3.1. Disabling handling of system startup scripts
                   2676:     20.4. System users and groups
                   2677:     20.5. System shells
                   2678:         20.5.1. Disabling shell registration
                   2679:     20.6. Fonts
                   2680:         20.6.1. Disabling automatic update of the fonts databases
1.154     rillig   2681: 21. Making your package work
                   2682:     21.1. General operation
                   2683:         21.1.1. How to pull in user-settable variables from mk.conf
                   2684:         21.1.2. User interaction
                   2685:         21.1.3. Handling licenses
                   2686:         21.1.4. Restricted packages
                   2687:         21.1.5. Handling dependencies
                   2688:         21.1.6. Handling conflicts with other packages
                   2689:         21.1.7. Packages that cannot or should not be built
                   2690:         21.1.8. Packages which should not be deleted, once installed
                   2691:         21.1.9. Handling packages with security problems
                   2692:         21.1.10. How to handle incrementing versions when fixing an existing
1.259     leot     2693:             package
1.154     rillig   2694:         21.1.11. Substituting variable text in the package files (the SUBST
1.259     leot     2695:             framework)
1.154     rillig   2696:     21.2. The fetch phase
                   2697:         21.2.1. Packages whose distfiles aren't available for plain downloading
                   2698:         21.2.2. How to handle modified distfiles with the 'old' name
                   2699:         21.2.3. Packages hosted on github.com
                   2700:     21.3. The configure phase
                   2701:         21.3.1. Shared libraries - libtool
                   2702:         21.3.2. Using libtool on GNU packages that already support libtool
                   2703:         21.3.3. GNU Autoconf/Automake
1.223     nia      2704:         21.3.4. Meson / ninja
1.260     wiz      2705:         21.3.5. Determining the endianness
1.154     rillig   2706:     21.4. Programming languages
                   2707:         21.4.1. C, C++, and Fortran
                   2708:         21.4.2. Java
1.205     wiz      2709:         21.4.3. Go
1.223     nia      2710:         21.4.4. Rust
                   2711:         21.4.5. Packages containing Perl scripts
                   2712:         21.4.6. Packages containing shell scripts
                   2713:         21.4.7. Other programming languages
1.154     rillig   2714:     21.5. The build phase
                   2715:         21.5.1. Compiling C and C++ code conditionally
                   2716:         21.5.2. How to handle compiler bugs
1.172     rillig   2717:         21.5.3. No such file or directory
                   2718:         21.5.4. Undefined reference to "..."
                   2719:         21.5.5. Running out of memory
1.154     rillig   2720:     21.6. The install phase
                   2721:         21.6.1. Creating needed directories
                   2722:         21.6.2. Where to install documentation
                   2723:         21.6.3. Installing highscore files
                   2724:         21.6.4. Adding DESTDIR support to packages
                   2725:         21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia      2726:         21.6.6. Packages installing Perl modules
1.254     wiz      2727:         21.6.7. Packages installing pkg-config files
                   2728:         21.6.8. Packages installing info files
                   2729:         21.6.9. Packages installing man pages
                   2730:         21.6.10. Packages installing X11 fonts
                   2731:         21.6.11. Packages installing SGML or XML data
                   2732:         21.6.12. Packages installing extensions to the MIME database
                   2733:         21.6.13. Packages using intltool
                   2734:         21.6.14. Packages installing startup scripts
                   2735:         21.6.15. Packages installing TeX modules
                   2736:         21.6.16. Packages supporting running binaries in emulation
                   2737:         21.6.17. Packages installing hicolor icons
                   2738:         21.6.18. Packages installing desktop files
1.154     rillig   2739:     21.7. Marking packages as having problems
1.184     rillig   2740: 22. GNOME packaging and porting
                   2741:     22.1. Meta packages
                   2742:     22.2. Packaging a GNOME application
                   2743:     22.3. Updating GNOME to a newer version
                   2744:     22.4. Patching guidelines
1.154     rillig   2745: 23. Submitting and Committing
                   2746:     23.1. Submitting binary packages
                   2747:     23.2. Submitting source packages (for non-NetBSD-developers)
                   2748:     23.3. General notes when adding, updating, or removing packages
                   2749:     23.4. Commit Messages
                   2750:     23.5. Committing: Adding a package to CVS
                   2751:     23.6. Updating a package to a newer version
                   2752:     23.7. Renaming a package in pkgsrc
                   2753:     23.8. Moving a package in pkgsrc
                   2754: 24. Frequently Asked Questions
                   2755: 
                   2756: Chapter 11. Getting help
                   2757: 
                   2758: To get help when developing pkgsrc, the definitive source is this document, the
                   2759: pkgsrc guide. If you don't find anything here, there are alternatives:
                   2760: 
                   2761:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                   2762:     Run bmake help topic=? to get help for any topic, such as a variable name
                   2763:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                   2764:     like strcasecmp or any other topic.
                   2765: 
1.207     leot     2766:     The available help topics are listed in Appendix E, Help topics.
1.154     rillig   2767: 
1.163     rillig   2768:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                   2769: 
                   2770:   * To see the values of the most common variables, run bmake show-all. These
                   2771:     variables are grouped by topic. To see the variables for a single topic,
                   2772:     run bmake show-all-topic, for example bmake show-all-fetch.
                   2773: 
1.154     rillig   2774:   * The tech-pkg mailing list, to which you can subscribe and then ask your
                   2775:     questions.
                   2776: 
                   2777:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                   2778:     a specialized chat program such as XChat. Pick any user name and join the
                   2779:     channel #pkgsrc.
1.1       dsieger  2780: 
1.184     rillig   2781: Chapter 12. Package components - files, directories and contents
1.1       dsieger  2782: 
                   2783: Table of Contents
                   2784: 
1.184     rillig   2785: 12.1. Makefile
                   2786: 12.2. distinfo
                   2787: 12.3. patches/*
                   2788:     12.3.1. Structure of a single patch file
                   2789:     12.3.2. Creating patch files
                   2790:     12.3.3. Sources where the patch files come from
                   2791:     12.3.4. Patching guidelines
                   2792:     12.3.5. Feedback to the author
                   2793: 12.4. Other mandatory files
                   2794: 12.5. Optional files
                   2795:     12.5.1. Files affecting the binary package
                   2796:     12.5.2. Files affecting the build process
                   2797:     12.5.3. Files affecting nothing at all
                   2798: 12.6. work*
                   2799: 12.7. files/*
1.1       dsieger  2800: 
1.184     rillig   2801: Whenever you're preparing a package, there are a number of files involved which
                   2802: are described in the following sections.
1.1       dsieger  2803: 
1.184     rillig   2804: 12.1. Makefile
1.1       dsieger  2805: 
1.184     rillig   2806: Building, installation and creation of a binary package are all controlled by
                   2807: the package's Makefile. The Makefile describes various things about a package,
                   2808: for example from where to get it, how to configure, build, and install it.
1.1       dsieger  2809: 
1.184     rillig   2810: A package Makefile contains several sections that describe the package.
1.1       dsieger  2811: 
1.184     rillig   2812: In the first section there are the following variables, which should appear
                   2813: exactly in the order given here. The order and grouping of the variables is
                   2814: mostly historical and has no further meaning.
1.1       dsieger  2815: 
1.184     rillig   2816:   * DISTNAME is the basename of the distribution file to be downloaded from the
                   2817:     package's website.
1.1       dsieger  2818: 
1.184     rillig   2819:   * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
                   2820:     it if DISTNAME (which is the default) is not a good name for the package in
                   2821:     pkgsrc or DISTNAME is not provided (no distribution file is required).
                   2822:     Usually it is the pkgsrc directory name together with the version number.
                   2823:     It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
                   2824:     is, it starts with a letter or digit, and contains only letters, digits,
1.204     nia      2825:     dashes, underscores, dots and plus signs. New packages should have entirely
                   2826:     lower-case names, with the exception of some that must follow pre-existing
                   2827:     conventions (e.g. R packages begin with R-). You can use the :tl variable
                   2828:     modifier to lower-case the package name.
1.26      spz      2829: 
1.184     rillig   2830:   * CATEGORIES is a list of categories which the package fits in. You can
                   2831:     choose any of the top-level directories of pkgsrc for it.
1.1       dsieger  2832: 
1.184     rillig   2833:     Currently the following values are available for CATEGORIES. If more than
                   2834:     one is used, they need to be separated by spaces:
1.1       dsieger  2835: 
1.184     rillig   2836:     archivers     cross         geography     meta-pkgs     security
                   2837:     audio         databases     graphics      misc          shells
                   2838:     benchmarks    devel         ham           multimedia    sysutils
                   2839:     biology       editors       inputmethod   net           textproc
                   2840:     cad           emulators     lang          news          time
                   2841:     chat          finance       mail          parallel      wm
                   2842:     comms         fonts         math          pkgtools      www
                   2843:     converters    games         mbone         print         x11
1.1       dsieger  2844: 
1.184     rillig   2845:   * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
                   2846:     are discussed in detail in Section 13.5, "The fetch phase".
1.1       dsieger  2847: 
1.184     rillig   2848: The second section contains information about separately downloaded patches, if
                   2849: any.
1.1       dsieger  2850: 
1.184     rillig   2851:   * PATCHFILES: Name(s) of additional files that contain distribution patches.
                   2852:     There is no default. pkgsrc will look for them at PATCH_SITES. They will
                   2853:     automatically be uncompressed before patching if the names end with .gz or
                   2854:     .Z.
1.1       dsieger  2855: 
1.184     rillig   2856:   * PATCH_SITES: Primary location(s) for distribution patch files (see
                   2857:     PATCHFILES above) if not found locally.
1.1       dsieger  2858: 
1.184     rillig   2859:   * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
                   2860:     count to help find the correct files to patch. It defaults to -p0.
1.1       dsieger  2861: 
1.184     rillig   2862: The third section contains the following variables.
1.1       dsieger  2863: 
1.253     gutterid 2864:   * MAINTAINER is the email address of the person who is currently responsible
                   2865:     for this package. In theory, the maintainer will be aware of upstream
                   2866:     release, keep it updated, and generally resolve problems. Others
                   2867:     contemplating significant changes should ask the maintainer for advice or
                   2868:     review of a proposed change. This is not necessary for micro updates, bug
                   2869:     fixes, pkgsrc-wide changes affecting many packages, and other things
                   2870:     expected to be uncontroversial. It goes with this "should ask" that the
                   2871:     maintainer should respond to inquiries reasonably promptly (most of the
                   2872:     time), and either approve changes or provide reasons why not. Typically,
                   2873:     when packaging a new program, set MAINTAINER to yourself. If you don't
                   2874:     intend to maintain the package (especially if you feel you have no special
                   2875:     insight), set it to <pkgsrc-users@NetBSD.org>. This special value is a code
                   2876:     point indicating that there is no maintainer, but the variable is
                   2877:     mandatory, absent OWNER.
                   2878: 
                   2879:   * OWNER can be used instead of MAINTAINER in relatively rare circumstances
                   2880:     when the package is such that modifying it is riskier than normal. This is
                   2881:     a stronger form of being the maintainer, with an expectation that others
                   2882:     will ask for almost all changes, except revbumps and accommodating
                   2883:     structural changes. Someone who becomes OWNER has a strong obligation to
                   2884:     keep the package very well maintained, to answer queries promptly and to be
                   2885:     a steward of the package on behalf of users. In this case, MAINTAINER
                   2886:     should be omitted.
                   2887: 
                   2888:     Because of the friction that OWNER adds, PMC may downgrade it to MAINTAINER
                   2889:     at any time.
1.1       dsieger  2890: 
1.184     rillig   2891:   * HOMEPAGE is a URL where users can find more information about the package.
1.1       dsieger  2892: 
1.184     rillig   2893:   * COMMENT is a one-line description of the package (should not include the
                   2894:     package name).
1.1       dsieger  2895: 
1.184     rillig   2896:   * LICENSE indicates the license(s) applicable for the package. See
                   2897:     Section 21.1.3, "Handling licenses" for further details.
1.1       dsieger  2898: 
1.184     rillig   2899: Other variables that affect the build:
1.1       dsieger  2900: 
1.184     rillig   2901:   * WRKSRC: The directory where the interesting distribution files of the
                   2902:     package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
                   2903:     most packages.
1.1       dsieger  2904: 
1.184     rillig   2905:     If a package doesn't create a subdirectory for itself (most GNU software
                   2906:     does, for instance), but extracts itself in the current directory, you
                   2907:     should set WRKSRC=${WRKDIR}.
1.1       dsieger  2908: 
1.184     rillig   2909:     If a package doesn't create a subdirectory with the name of DISTNAME but
                   2910:     some different name, set WRKSRC to point to the proper name in ${WRKDIR},
                   2911:     for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
                   2912:     other examples.
1.17      imil     2913: 
1.184     rillig   2914:     The name of the working directory created by pkgsrc is taken from the
                   2915:     WRKDIR_BASENAME variable. By default, its value is work. If you want to use
                   2916:     the same pkgsrc tree for building different kinds of binary packages, you
                   2917:     can change the variable according to your needs. Two other variables handle
                   2918:     common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
                   2919:     defined in mk.conf, the first component of the host's name is attached to
                   2920:     the directory name. If OBJMACHINE is defined, the platform name is
                   2921:     attached, which might look like work.i386 or work.sparc.
1.17      imil     2922: 
1.184     rillig   2923: Please pay attention to the following gotchas:
1.17      imil     2924: 
1.184     rillig   2925:   * Add MANCOMPRESSED if man pages are installed in compressed form by the
                   2926:     package. For packages using BSD-style makefiles which honor MANZ, there is
                   2927:     MANCOMPRESSED_IF_MANZ.
1.17      imil     2928: 
1.184     rillig   2929:   * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
1.103     wiz      2930: 
1.254     wiz      2931:   * If the package installs any info files, see Section 21.6.8, "Packages
1.184     rillig   2932:     installing info files".
1.103     wiz      2933: 
1.184     rillig   2934: 12.2. distinfo
1.17      imil     2935: 
1.184     rillig   2936: The distinfo file contains the message digest, or checksum, of each distfile
                   2937: needed for the package. This ensures that the distfiles retrieved from the
                   2938: Internet have not been corrupted during transfer or altered by a malign force
                   2939: to introduce a security hole. To provide maximum security, all distfiles are
1.243     gutterid 2940: protected using two different message digest algorithms (BLAKE2s and SHA512),
                   2941: as well as the file size.
1.17      imil     2942: 
1.184     rillig   2943: The distinfo file also contains the checksums for all the patches found in the
                   2944: patches directory (see Section 12.3, "patches/*"). These checksums ensure that
                   2945: patches are only applied intentionally and that they don't accidentally change,
                   2946: e.g. when merging different changes together. They also make sure that new
                   2947: patches are actually added to CVS and old ones are removed. Too see whether the
                   2948: patches and the distinfo file match, run pkglint after changing the patches.
1.17      imil     2949: 
1.184     rillig   2950: To regenerate the distinfo file, use the make distinfo command.
1.17      imil     2951: 
1.184     rillig   2952: Some packages have different sets of distfiles depending on the platform, for
                   2953: example lang/openjdk8. These are kept in the same distinfo file and care should
                   2954: be taken when upgrading such a package to ensure distfile information is not
                   2955: lost.
1.17      imil     2956: 
1.184     rillig   2957: 12.3. patches/*
1.63      wiz      2958: 
1.184     rillig   2959: Some packages don't work out-of-the box on the various platforms that are
                   2960: supported by pkgsrc. These packages need to be patched to make them work. The
                   2961: patch files can be found in the patches/ directory.
1.17      imil     2962: 
1.184     rillig   2963: In the patch phase, these patches are applied to the files in WRKSRC directory
                   2964: after extracting them, in alphabetic order.
1.160     brook    2965: 
1.184     rillig   2966: 12.3.1. Structure of a single patch file
1.160     brook    2967: 
1.184     rillig   2968: The patch-* files should be in diff -bu format, and apply without a fuzz to
                   2969: avoid problems. (To force patches to apply with fuzz you can set
                   2970: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
                   2971: a single file, and no file should be patched by more than one patch file. This
                   2972: helps to keep future modifications simple.
1.160     brook    2973: 
1.184     rillig   2974: Each patch file is structured as follows: In the first line, there is the RCS
                   2975: Id of the patch itself. The second line should be empty for aesthetic reasons.
                   2976: After that, there should be a comment for each change that the patch does.
                   2977: There are a number of standard cases:
1.160     brook    2978: 
1.184     rillig   2979:   * Patches for commonly known vulnerabilities should mention the vulnerability
                   2980:     ID (CAN, CVE).
1.160     brook    2981: 
1.184     rillig   2982:   * Patches that change source code should mention the platform and other
                   2983:     environment (for example, the compiler) that the patch is needed for.
1.160     brook    2984: 
1.184     rillig   2985: The patch should be commented so that any developer who knows the code of the
                   2986: application can make some use of the patch. Special care should be taken for
                   2987: the upstream developers, since we generally want that they accept our patches,
                   2988: so we have less work in the future.
1.160     brook    2989: 
1.184     rillig   2990: 12.3.2. Creating patch files
1.160     brook    2991: 
1.184     rillig   2992: One important thing to mention is to pay attention that no RCS IDs get stored
                   2993: in the patch files, as these will cause problems when later checked into the
                   2994: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
                   2995: avoid these problems.
1.160     brook    2996: 
1.184     rillig   2997: For even more automation, we recommend using mkpatches from the same package to
1.222     gutterid 2998: make a whole set of patches. You just have to back up files before you edit
                   2999: them to filename.orig, e.g., with cp -p filename filename.orig or, easier, by
                   3000: using pkgvi again from the same package. If you upgrade a package this way, you
                   3001: can easily compare the new set of patches with the previously existing one with
1.184     rillig   3002: patchdiff. The files in patches are replaced by new files, so carefully check
                   3003: if you want to take all the changes.
1.160     brook    3004: 
1.184     rillig   3005: When you have finished a package, remember to generate the checksums for the
                   3006: patch files by using the make makepatchsum command, see Section 12.2,
                   3007: "distinfo".
1.1       dsieger  3008: 
1.184     rillig   3009: When adding a patch that corrects a problem in the distfile (rather than e.g.
                   3010: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
                   3011: report to the maintainer. This benefits non-pkgsrc users of the package, and
                   3012: usually makes it possible to remove the patch in future version.
1.1       dsieger  3013: 
1.184     rillig   3014: The file names of the patch files are usually of the form patch-
                   3015: path_to_file__with__underscores.c. Many packages still use the previous
                   3016: convention patch-[a-z][a-z], but new patches should be of the form containing
                   3017: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
                   3018: automatically.
1.1       dsieger  3019: 
1.222     gutterid 3020: When updating pre-existing patch files, if a file uses the old patch-[a-z][a-z]
                   3021: convention, it's best not to change it to the new form, as that will just cause
                   3022: churn that makes it harder to track changes to patching over time. Similarly,
                   3023: if a patch now applies at different line offsets, but still applies cleanly
                   3024: as-is, there's no need to update it, as that also unnecessarily complicates the
                   3025: patch history.
                   3026: 
1.184     rillig   3027: 12.3.3. Sources where the patch files come from
1.1       dsieger  3028: 
1.184     rillig   3029: If you want to share patches between multiple packages in pkgsrc, e.g. because
                   3030: they use the same distfiles, set PATCHDIR to the path where the patch files can
                   3031: be found, e.g.:
1.1       dsieger  3032: 
1.184     rillig   3033: PATCHDIR=       ../../editors/xemacs/patches
1.1       dsieger  3034: 
1.184     rillig   3035: Patch files that are distributed by the author or other maintainers can be
                   3036: listed in PATCHFILES.
1.1       dsieger  3037: 
1.184     rillig   3038: If it is desired to store any patches that should not be committed into pkgsrc,
                   3039: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
                   3040: directory tree there is expected to have the same "category/package" structure
                   3041: as pkgsrc, and patches are expected to be stored inside these dirs (also known
                   3042: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
                   3043: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
                   3044: files in the named directory are expected to be patch files, and they are
                   3045: applied after pkgsrc patches are applied.
1.1       dsieger  3046: 
1.184     rillig   3047: 12.3.4. Patching guidelines
1.1       dsieger  3048: 
1.184     rillig   3049: When fixing a portability issue in the code do not use preprocessor magic to
                   3050: check for the current operating system nor platform. Doing so hurts portability
                   3051: to other platforms because the OS-specific details are not abstracted
                   3052: appropriately.
1.1       dsieger  3053: 
1.184     rillig   3054: The general rule to follow is: instead of checking for the operating system the
                   3055: application is being built on, check for the specific features you need. For
                   3056: example, instead of assuming that kqueue is available under NetBSD and using
                   3057: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
1.198     leot     3058: kqueue itself -- yes, this generally involves patching the configure script.
1.184     rillig   3059: There is absolutely nothing that prevents some OSes from adopting interfaces
                   3060: from other OSes (e.g. Linux implementing kqueue), something that the above
                   3061: checks cannot take into account.
1.1       dsieger  3062: 
1.184     rillig   3063: Of course, checking for features generally involves more work on the
                   3064: developer's side, but the resulting changes are cleaner and there are chances
                   3065: they will work on many other platforms. Not to mention that there are higher
                   3066: chances of being later integrated into the mainstream sources. Remember: It
                   3067: doesn't work unless it is right!
1.1       dsieger  3068: 
1.184     rillig   3069: Some typical examples:
1.121     sevan    3070: 
1.184     rillig   3071: Table 12.1. Patching examples
1.1       dsieger  3072: 
1.184     rillig   3073: +-------------------------------------------------------------------------------------------+
                   3074: |  Where  |        Incorrect         |                       Correct                        |
                   3075: |---------+--------------------------+------------------------------------------------------|
                   3076: |         |case ${target_os} in      |                                                      |
                   3077: |configure|netbsd*) have_kvm=yes ;;  |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
                   3078: |script   |*)       have_kvm=no  ;;  |                                                      |
                   3079: |         |esac                      |                                                      |
                   3080: |---------+--------------------------+------------------------------------------------------|
                   3081: |C source |#if defined(__NetBSD__)   |#if defined(HAVE_SYS_EVENT_H)                         |
                   3082: |file     |#  include <sys/event.h>  |#  include <sys/event.h>                              |
                   3083: |         |#endif                    |#endif                                                |
                   3084: |---------+--------------------------+------------------------------------------------------|
                   3085: |         |int                       |int                                                   |
                   3086: |         |monitor_file(...)         |monitor_file(...)                                     |
                   3087: |         |{                         |{                                                     |
                   3088: |         |#if defined(__NetBSD__)   |#if defined(HAVE_KQUEUE)                              |
                   3089: |C source |        int fd = kqueue();|        int fd = kqueue();                            |
                   3090: |file     |        ...               |        ...                                           |
                   3091: |         |#else                     |#else                                                 |
                   3092: |         |        ...               |        ...                                           |
                   3093: |         |#endif                    |#endif                                                |
                   3094: |         |}                         |}                                                     |
                   3095: +-------------------------------------------------------------------------------------------+
1.1       dsieger  3096: 
                   3097: 
1.184     rillig   3098: 12.3.5. Feedback to the author
1.1       dsieger  3099: 
1.184     rillig   3100: Always, always, always feed back any portability fixes or improvements you do
                   3101: to a package to the mainstream developers. This is the only way to get their
                   3102: attention on portability issues and to ensure that future versions can be built
                   3103: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
                   3104: get the fixes straight from the packaged code.
1.1       dsieger  3105: 
1.184     rillig   3106: This generally involves cleaning up the patches (because sometimes the patches
                   3107: that are added to pkgsrc are quick hacks), filing bug reports in the
                   3108: appropriate trackers for the projects and working with the mainstream authors
                   3109: to accept your changes. It is extremely important that you do it so that the
                   3110: packages in pkgsrc are kept simple and thus further changes can be done without
                   3111: much hassle.
1.1       dsieger  3112: 
1.184     rillig   3113: When you have done this, please add a URL to the upstream bug report to the
                   3114: patch comment.
1.1       dsieger  3115: 
1.184     rillig   3116: Support the idea of free software!
1.1       dsieger  3117: 
1.184     rillig   3118: 12.4. Other mandatory files
1.1       dsieger  3119: 
1.184     rillig   3120: DESCR
1.1       dsieger  3121: 
1.184     rillig   3122:     A multi-line description of the piece of software. This should include any
                   3123:     credits where they are due. Please bear in mind that others do not share
                   3124:     your sense of humour (or spelling idiosyncrasies), and that others will
                   3125:     read everything that you write here.
1.1       dsieger  3126: 
1.184     rillig   3127: PLIST
1.1       dsieger  3128: 
1.184     rillig   3129:     This file governs the files that are installed on your system: all the
                   3130:     binaries, manual pages, etc. There are other directives which may be
                   3131:     entered in this file, to control the creation and deletion of directories,
                   3132:     and the location of inserted files. See Chapter 19, PLIST issues for more
                   3133:     information.
1.1       dsieger  3134: 
1.184     rillig   3135: 12.5. Optional files
1.1       dsieger  3136: 
1.184     rillig   3137: 12.5.1. Files affecting the binary package
1.1       dsieger  3138: 
1.184     rillig   3139: INSTALL
1.1       dsieger  3140: 
1.184     rillig   3141:     This shell script is invoked twice by pkg_add(1). First time after package
                   3142:     extraction and before files are moved in place, the second time after the
                   3143:     files to install are moved in place. This can be used to do any custom
                   3144:     procedures not possible with @exec commands in PLIST. See pkg_add(1) and
                   3145:     pkg_create(1) for more information. See also Section 20.1, "Files and
                   3146:     directories outside the installation prefix". Please note that you can
                   3147:     modify variables in it easily by using FILES_SUBST in the package's
                   3148:     Makefile:
1.1       dsieger  3149: 
1.184     rillig   3150:     FILES_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3151: 
1.184     rillig   3152:     replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
                   3153:     substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
                   3154:     few others, type make help topic=FILES_SUBST for a complete list.
1.1       dsieger  3155: 
1.184     rillig   3156: DEINSTALL
1.1       dsieger  3157: 
1.184     rillig   3158:     This script is executed before and after any files are removed. It is this
                   3159:     script's responsibility to clean up any additional messy details around the
                   3160:     package's installation, since all pkg_delete knows is how to delete the
                   3161:     files created in the original distribution. See pkg_delete(1) and
                   3162:     pkg_create(1) for more information. The same methods to replace variables
                   3163:     can be used as for the INSTALL file.
1.1       dsieger  3164: 
1.184     rillig   3165: MESSAGE
1.1       dsieger  3166: 
1.198     leot     3167:     This file is displayed after installation of the package. While this was
                   3168:     used often in the past, it has two problems: the display will be missed if
1.257     jkoshy   3169:     many packages are installed at once, and the person installing the package
1.198     leot     3170:     and the one using or configuring it may be different. It should therefore
                   3171:     be used only in exceptional circumstances where lasting negative
                   3172:     consequences would result from someone not reading it.
                   3173: 
                   3174:     MESSAGE should not be used for:
                   3175: 
1.259     leot     3176:       + exhortations to read the documentation
1.198     leot     3177: 
1.259     leot     3178:       + reminders to install rc.d files and set variables
1.198     leot     3179: 
1.259     leot     3180:       + anything that should be explained in the installation/configuration
1.198     leot     3181:         documentation that should come with the package
                   3182: 
                   3183:     If the documentation provided by upstream needs enhancing, create e.g.
                   3184:     files/README.pkgsrc and install it in the package's documentation
                   3185:     directory.
                   3186: 
                   3187:     Note that MESSAGE is shown for all operating systems and all init systems.
                   3188:     If a MESSAGE is necessary, it should be narrowed to only those operating
                   3189:     systems and init systems to which it applies.
                   3190: 
                   3191:     Note that you can modify variables in it easily by using MESSAGE_SUBST in
                   3192:     the package's Makefile:
1.1       dsieger  3193: 
1.184     rillig   3194:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3195: 
1.184     rillig   3196:     replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
                   3197:     is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
                   3198:     PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1       dsieger  3199: 
1.184     rillig   3200:     You can display a different or additional files by setting the MESSAGE_SRC
                   3201:     variable. Its default is MESSAGE, if the file exists.
1.1       dsieger  3202: 
1.184     rillig   3203: ALTERNATIVES
1.1       dsieger  3204: 
1.184     rillig   3205:     This file is used by the alternatives framework. It creates, configures,
                   3206:     and destroys generic wrappers used to run programs with similar interfaces.
                   3207:     See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
                   3208:     information.
1.1       dsieger  3209: 
1.184     rillig   3210:     Each line of the file contains two filenames, first the wrapper and then
                   3211:     the alternative provided by the package. Both paths are relative to PREFIX.
1.1       dsieger  3212: 
1.184     rillig   3213: 12.5.2. Files affecting the build process
1.1       dsieger  3214: 
1.184     rillig   3215: Makefile.common
1.1       dsieger  3216: 
1.184     rillig   3217:     This file contains arbitrary things that could also go into a Makefile, but
                   3218:     its purpose is to be used by more than one package. This file should only
                   3219:     be used when the packages that will use the file are known in advance. For
                   3220:     other purposes it is often better to write a *.mk file and give it a good
                   3221:     name that describes what it does.
1.1       dsieger  3222: 
1.184     rillig   3223: buildlink3.mk
1.1       dsieger  3224: 
1.184     rillig   3225:     This file contains the dependency information for the buildlink3 framework
                   3226:     (see Chapter 18, Buildlink methodology).
1.1       dsieger  3227: 
1.184     rillig   3228: hacks.mk
1.1       dsieger  3229: 
1.184     rillig   3230:     This file contains workarounds for compiler bugs and similar things. It is
                   3231:     included automatically by the pkgsrc infrastructure, so you don't need an
                   3232:     extra .include line for it.
1.1       dsieger  3233: 
1.184     rillig   3234: options.mk
1.1       dsieger  3235: 
1.184     rillig   3236:     This file contains the code for the package-specific options (see
                   3237:     Chapter 16, Options handling) that can be selected by the user. If a
                   3238:     package has only one or two options, it is equally acceptable to put the
                   3239:     code directly into the Makefile.
1.1       dsieger  3240: 
1.184     rillig   3241: 12.5.3. Files affecting nothing at all
1.1       dsieger  3242: 
1.184     rillig   3243: README*
1.1       dsieger  3244: 
1.184     rillig   3245:     These files do not take place in the creation of a package and thus are
                   3246:     purely informative to the package developer.
1.1       dsieger  3247: 
1.184     rillig   3248: TODO
1.1       dsieger  3249: 
1.184     rillig   3250:     This file contains things that need to be done to make the package even
                   3251:     better.
1.1       dsieger  3252: 
1.184     rillig   3253: 12.6. work*
1.1       dsieger  3254: 
1.184     rillig   3255: When you type make, the distribution files are unpacked into the directory
                   3256: denoted by WRKDIR. It can be removed by running make clean. Besides the
                   3257: sources, this directory is also used to keep various timestamp files. The
                   3258: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
                   3259: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
1.1       dsieger  3260: 
1.184     rillig   3261: 12.7. files/*
1.80      wiz      3262: 
1.184     rillig   3263: If you have any files that you wish to be placed in the package prior to
                   3264: configuration or building, you can place these files here and use a ${CP}
                   3265: command in the "post-extract" target to achieve this.
1.1       dsieger  3266: 
1.184     rillig   3267: If you want to share files in this way with other packages, set the FILESDIR
                   3268: variable to point to the other package's files directory, e.g.:
1.1       dsieger  3269: 
1.184     rillig   3270: FILESDIR=       ../../editors/xemacs/files
1.14      jmcneill 3271: 
1.184     rillig   3272: Chapter 13. The build process
1.1       dsieger  3273: 
1.184     rillig   3274: Table of Contents
1.1       dsieger  3275: 
1.184     rillig   3276: 13.1. Introduction
                   3277: 13.2. Program location
                   3278: 13.3. Directories used during the build process
                   3279: 13.4. Running a phase
                   3280: 13.5. The fetch phase
                   3281:     13.5.1. What to fetch and where to get it from
                   3282:     13.5.2. How are the files fetched?
                   3283: 13.6. The checksum phase
                   3284: 13.7. The extract phase
                   3285: 13.8. The patch phase
                   3286: 13.9. The tools phase
                   3287: 13.10. The wrapper phase
                   3288: 13.11. The configure phase
                   3289: 13.12. The build phase
                   3290: 13.13. The test phase
                   3291: 13.14. The install phase
                   3292: 13.15. The package phase
                   3293: 13.16. Cleaning up
                   3294: 13.17. Other helpful targets
1.1       dsieger  3295: 
1.184     rillig   3296: 13.1. Introduction
1.122     leot     3297: 
1.184     rillig   3298: This chapter gives a detailed description on how a package is built. Building a
                   3299: package is separated into different phases (for example fetch, build, install),
                   3300: all of which are described in the following sections. Each phase is split into
                   3301: so-called stages, which take the name of the containing phase, prefixed by one
                   3302: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
                   3303: actual work is done in the do-* stages.
1.1       dsieger  3304: 
1.184     rillig   3305: Never override the regular targets (like fetch), if you have to, override the
                   3306: do-* ones instead.
1.1       dsieger  3307: 
1.184     rillig   3308: The basic steps for building a program are always the same. First the program's
                   3309: source (distfile) must be brought to the local system and then extracted. After
                   3310: any pkgsrc-specific patches to compile properly are applied, the software can
                   3311: be configured, then built (usually by compiling), and finally the generated
                   3312: binaries, etc. can be put into place on the system.
1.1       dsieger  3313: 
1.184     rillig   3314: To get more details about what is happening at each step, you can set the
                   3315: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
                   3316: more details about the patch step.
1.1       dsieger  3317: 
1.184     rillig   3318: 13.2. Program location
1.1       dsieger  3319: 
1.184     rillig   3320: Before outlining the process performed by the NetBSD package system in the next
                   3321: section, here's a brief discussion on where programs are installed, and which
                   3322: variables influence this.
1.1       dsieger  3323: 
1.184     rillig   3324: The automatic variable PREFIX indicates where all files of the final program
                   3325: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
                   3326: pkgs in the cross category. The value of PREFIX needs to be put into the
                   3327: various places in the program's source where paths to these files are encoded.
                   3328: See Section 12.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
                   3329: for more details.
1.1       dsieger  3330: 
1.184     rillig   3331: When choosing which of these variables to use, follow the following rules:
1.1       dsieger  3332: 
1.184     rillig   3333:   * PREFIX always points to the location where the current pkg will be
                   3334:     installed. When referring to a pkg's own installation path, use "${PREFIX}"
                   3335:     .
1.1       dsieger  3336: 
1.223     nia      3337:   * LOCALBASE is where all pkgs are installed. If you need to construct a -I or
                   3338:     -L argument to the compiler to find includes and libraries installed by
                   3339:     another pkg, use "${LOCALBASE}". The name LOCALBASE stems from FreeBSD,
                   3340:     which installed all packages in /usr/local. As pkgsrc leaves /usr/local for
                   3341:     the system administrator, this variable is a misnomer.
1.1       dsieger  3342: 
1.184     rillig   3343:   * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
                   3344:     installed. When looking for standard X11 includes (not those installed by a
                   3345:     package), use "${X11BASE}".
1.1       dsieger  3346: 
1.184     rillig   3347:   * X11-based packages using imake must set USE_IMAKE to be installed correctly
                   3348:     under LOCALBASE.
1.1       dsieger  3349: 
1.184     rillig   3350:   * Within ${PREFIX}, packages should install files according to hier(7), with
                   3351:     the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
                   3352:     man.
1.1       dsieger  3353: 
1.184     rillig   3354: 13.3. Directories used during the build process
1.2       rillig   3355: 
1.184     rillig   3356: When building a package, various directories are used to store source files,
                   3357: temporary files, pkgsrc-internal files, and so on. These directories are
                   3358: explained here.
1.1       dsieger  3359: 
1.184     rillig   3360: Some of the directory variables contain relative pathnames. There are two
                   3361: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
                   3362: used for directories that are pkgsrc-specific. WRKSRC is used for directories
                   3363: inside the package itself.
1.1       dsieger  3364: 
1.184     rillig   3365: PKGSRCDIR
1.1       dsieger  3366: 
1.184     rillig   3367:     This is an absolute pathname that points to the pkgsrc root directory.
                   3368:     Generally, you don't need it.
1.1       dsieger  3369: 
1.184     rillig   3370: PKGDIR
1.1       dsieger  3371: 
1.184     rillig   3372:     This is an absolute pathname that points to the current package.
1.1       dsieger  3373: 
1.184     rillig   3374: PKGPATH
1.1       dsieger  3375: 
1.184     rillig   3376:     This is a pathname relative to PKGSRCDIR that points to the current
1.228     gutterid 3377:     package. It is defined after including bsd.prefs.mk and can be used in
                   3378:     makefile fragments that are used by several packages to distinguish between
                   3379:     these packages. Other variables that would serve the same purpose are
                   3380:     PKGBASE and PKGNAME, but these are only defined after including bsd.pkg.mk,
                   3381:     which is too late.
                   3382: 
                   3383:     In mk.conf, the pkgsrc user can use PKGPATH to tweak variables like
                   3384:     MAKE_JOBS and CFLAGS.
1.1       dsieger  3385: 
1.184     rillig   3386: WRKDIR
1.1       dsieger  3387: 
1.184     rillig   3388:     This is an absolute pathname pointing to the directory where all work takes
                   3389:     place. The distfiles are extracted to this directory. It also contains
                   3390:     temporary directories and log files used by the various pkgsrc frameworks,
                   3391:     like buildlink or the wrappers.
1.1       dsieger  3392: 
1.184     rillig   3393: WRKSRC
1.1       dsieger  3394: 
1.184     rillig   3395:     This is an absolute pathname pointing to the directory where the distfiles
                   3396:     are extracted. It is usually a direct subdirectory of WRKDIR, and often
                   3397:     it's the only directory entry that isn't hidden. This variable may be
                   3398:     changed by a package Makefile.
1.1       dsieger  3399: 
1.184     rillig   3400: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
                   3401: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
                   3402: created in the pkgsrc entry's directory. If users would like to have their
                   3403: pkgsrc trees behave in a read-only manner, then the value of
                   3404: CREATE_WRKDIR_SYMLINK should be set to no.
1.1       dsieger  3405: 
1.184     rillig   3406: 13.4. Running a phase
1.1       dsieger  3407: 
1.184     rillig   3408: You can run a particular phase by typing make phase, where phase is the name of
                   3409: the phase. This will automatically run all phases that are required for this
                   3410: phase. The default phase is build, that is, when you run make without
                   3411: parameters in a package directory, the package will be built, but not
                   3412: installed.
1.1       dsieger  3413: 
1.184     rillig   3414: 13.5. The fetch phase
1.1       dsieger  3415: 
1.184     rillig   3416: The first step in building a package is to fetch the distribution files
                   3417: (distfiles) from the sites that are providing them. This is the task of the 
                   3418: fetch phase.
1.25      wiz      3419: 
1.184     rillig   3420: 13.5.1. What to fetch and where to get it from
1.1       dsieger  3421: 
1.184     rillig   3422: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
                   3423: name is derived from the DISTNAME variable, is fetched. The more complicated
                   3424: cases are described below.
1.1       dsieger  3425: 
1.184     rillig   3426: The variable DISTFILES specifies the list of distfiles that have to be fetched.
                   3427: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
                   3428: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
                   3429: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
                   3430: your package requires additional distfiles to the default one, you cannot just
                   3431: append the additional filenames using the += operator, but you have write for
                   3432: example:
1.1       dsieger  3433: 
1.184     rillig   3434: DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1       dsieger  3435: 
1.184     rillig   3436: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
                   3437: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
                   3438: can set SITES.distfile to the list of URLs where the file distfile (including
                   3439: the suffix) can be found.
1.1       dsieger  3440: 
1.184     rillig   3441: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   3442: DISTFILES+=     foo-file.tar.gz
                   3443: SITES.foo-file.tar.gz= \
                   3444: https://www.somewhere.com/somehow/ \
                   3445: https://www.somewhereelse.com/mirror/somehow/
1.1       dsieger  3446: 
1.184     rillig   3447: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
                   3448: gets the name of each distfile appended to it, without an intermediate slash.
                   3449: Therefore, all site values have to end with a slash or other separator
                   3450: character. This allows for example to set MASTER_SITES to a URL of a CGI script
                   3451: that gets the name of the distfile as a parameter. In this case, the definition
                   3452: would look like:
1.1       dsieger  3453: 
1.184     rillig   3454: MASTER_SITES=   https://www.example.com/download.cgi?file=
1.1       dsieger  3455: 
1.184     rillig   3456: The exception to this rule are URLs starting with a dash. In that case the URL
                   3457: is taken as is, fetched and the result stored under the name of the distfile.
                   3458: You can use this style for the case when the download URL style does not match
                   3459: the above common case. For example, if permanent download URL is a redirector
                   3460: to the real download URL, or the download file name is offered by an HTTP
                   3461: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
                   3462: created instead of the default v1.0.0.tar.gz.
1.1       dsieger  3463: 
1.184     rillig   3464: DISTNAME=       foo-1.0.0
                   3465: MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
1.29      wiz      3466: 
1.184     rillig   3467: There are some predefined values for MASTER_SITES, which can be used in
                   3468: packages. The names of the variables should speak for themselves.
1.29      wiz      3469: 
1.260     wiz      3470: MASTER_SITE_APACHE          MASTER_SITE_BACKUP
                   3471: MASTER_SITE_CRATESIO        MASTER_SITE_CYGWIN
                   3472: MASTER_SITE_DEBIAN          MASTER_SITE_FREEBSD
                   3473: MASTER_SITE_FREEBSD_LOCAL   MASTER_SITE_GENTOO
                   3474: MASTER_SITE_GITHUB          MASTER_SITE_GITLAB
                   3475: MASTER_SITE_GNOME           MASTER_SITE_GNU
                   3476: MASTER_SITE_GNUPG           MASTER_SITE_GNUSTEP
                   3477: MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
                   3478: MASTER_SITE_KDE             MASTER_SITE_MOZILLA
                   3479: MASTER_SITE_MOZILLA_ALL     MASTER_SITE_MYSQL
                   3480: MASTER_SITE_NETLIB          MASTER_SITE_OPENBSD
                   3481: MASTER_SITE_OPENOFFICE      MASTER_SITE_OSDN
                   3482: MASTER_SITE_PERL_CPAN       MASTER_SITE_PGSQL
                   3483: MASTER_SITE_PYPI            MASTER_SITE_RUBYGEMS
                   3484: MASTER_SITE_R_CRAN          MASTER_SITE_SOURCEFORGE
                   3485: MASTER_SITE_SUNSITE         MASTER_SITE_SUSE
                   3486: MASTER_SITE_TEX_CTAN        MASTER_SITE_XCONTRIB
                   3487: MASTER_SITE_XEMACS          MASTER_SITE_XORG
1.1       dsieger  3488: 
1.184     rillig   3489: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
                   3490: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
                   3491: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
                   3492: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
                   3493: distfiles/LOCAL_PORTS/.
1.1       dsieger  3494: 
1.184     rillig   3495: If you choose one of these predefined sites, you may want to specify a
                   3496: subdirectory of that site. Since these macros may expand to more than one
                   3497: actual site, you must use the following construct to specify a subdirectory:
1.1       dsieger  3498: 
1.184     rillig   3499: MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   3500: MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1       dsieger  3501: 
1.184     rillig   3502: Note the trailing slash after the subdirectory name.
1.1       dsieger  3503: 
1.184     rillig   3504: 13.5.2. How are the files fetched?
1.1       dsieger  3505: 
1.184     rillig   3506: The fetch phase makes sure that all the distfiles exist in a local directory
                   3507: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
                   3508: are fetched using commands of the form
1.1       dsieger  3509: 
1.184     rillig   3510: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
1.1       dsieger  3511: 
1.184     rillig   3512: where ${site} varies through several possibilities in turn: first,
                   3513: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
                   3514: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
                   3515: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
                   3516: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
                   3517: MASTER_SORT_AWK or MASTER_SORT_REGEX.
1.1       dsieger  3518: 
1.184     rillig   3519: The specific command and arguments used depend on the FETCH_USING parameter.
                   3520: The example above is for FETCH_USING=custom.
1.66      asau     3521: 
1.184     rillig   3522: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
                   3523: target to mirror the distfiles, if they are freely distributable. Packages
                   3524: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
                   3525: distfiles mirrored.
1.1       dsieger  3526: 
1.184     rillig   3527: 13.6. The checksum phase
1.1       dsieger  3528: 
1.184     rillig   3529: After the distfile(s) are fetched, their checksum is generated and compared
                   3530: with the checksums stored in the distinfo file. If the checksums don't match,
                   3531: the build is aborted. This is to ensure the same distfile is used for building,
                   3532: and that the distfile wasn't changed, e.g. by some malign force, deliberately
                   3533: changed distfiles on the master distribution site or network lossage.
1.1       dsieger  3534: 
1.184     rillig   3535: 13.7. The extract phase
1.1       dsieger  3536: 
1.184     rillig   3537: When the distfiles are present on the local system, they need to be extracted,
                   3538: as they usually come in the form of some compressed archive format.
1.1       dsieger  3539: 
1.184     rillig   3540: By default, all DISTFILES are extracted. If you only need some of them, you can
                   3541: set the EXTRACT_ONLY variable to the list of those files.
1.1       dsieger  3542: 
1.184     rillig   3543: Extracting the files is usually done by a little program, mk/extract/extract,
                   3544: which already knows how to extract various archive formats, so most likely you
                   3545: will not need to change anything here. But if you need, the following variables
                   3546: may help you:
1.1       dsieger  3547: 
1.184     rillig   3548: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
1.1       dsieger  3549: 
1.184     rillig   3550:     Use these variables to override the default options for an extract command,
                   3551:     which are defined in mk/extract/extract.
1.1       dsieger  3552: 
1.184     rillig   3553: EXTRACT_USING
1.1       dsieger  3554: 
1.184     rillig   3555:     This variable can be set to bsdtar, gtar, nbtar (which is the default
                   3556:     value), pax, or an absolute pathname pointing to the command with which tar
                   3557:     archives should be extracted. It is preferred to choose bsdtar over gtar if
                   3558:     NetBSD's pax-as-tar is not good enough.
1.1       dsieger  3559: 
1.184     rillig   3560: If the extract program doesn't serve your needs, you can also override the
                   3561: EXTRACT_CMD variable, which holds the command used for extracting the files.
                   3562: This command is executed in the ${WRKSRC} directory. During execution of this
                   3563: command, the shell variable extract_file holds the absolute pathname of the
                   3564: file that is going to be extracted.
1.1       dsieger  3565: 
1.184     rillig   3566: And if that still does not suffice, you can override the do-extract target in
                   3567: the package Makefile.
1.1       dsieger  3568: 
1.184     rillig   3569: 13.8. The patch phase
1.1       dsieger  3570: 
1.184     rillig   3571: After extraction, all the patches named by the PATCHFILES, those present in the
                   3572: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
                   3573: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
                   3574: are uncompressed before they are applied, files ending in .orig or .rej are
                   3575: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
                   3576: Section 12.3, "patches/*" for more details.
1.1       dsieger  3577: 
1.184     rillig   3578: By default patch(1) is given special arguments to make it fail if the expected
                   3579: text from the patch context is not found in the patched file. If that happens,
                   3580: fix the patch file by comparing it with the actual text in the file to be
                   3581: patched.
1.1       dsieger  3582: 
1.184     rillig   3583: 13.9. The tools phase
1.1       dsieger  3584: 
1.184     rillig   3585: This is covered in Chapter 17, Tools needed for building or running.
1.1       dsieger  3586: 
1.184     rillig   3587: 13.10. The wrapper phase
1.1       dsieger  3588: 
1.184     rillig   3589: This phase creates wrapper programs for the compilers and linkers. The
                   3590: following variables can be used to tweak the wrappers.
1.1       dsieger  3591: 
1.184     rillig   3592: ECHO_WRAPPER_MSG
1.1       dsieger  3593: 
1.184     rillig   3594:     The command used to print progress messages. Does nothing by default. Set
                   3595:     to ${ECHO} to see the progress messages.
1.1       dsieger  3596: 
1.184     rillig   3597: WRAPPER_DEBUG
1.1       dsieger  3598: 
1.184     rillig   3599:     This variable can be set to yes (default) or no, depending on whether you
                   3600:     want additional information in the wrapper log file.
1.1       dsieger  3601: 
1.184     rillig   3602: WRAPPER_UPDATE_CACHE
1.1       dsieger  3603: 
1.184     rillig   3604:     This variable can be set to yes or no, depending on whether the wrapper
                   3605:     should use its cache, which will improve the speed. The default value is
                   3606:     yes, but is forced to no if the platform does not support it.
1.1       dsieger  3607: 
1.184     rillig   3608: WRAPPER_REORDER_CMDS
1.1       dsieger  3609: 
1.184     rillig   3610:     A list of reordering commands. A reordering command has the form reorder:l:
                   3611:     lib1:lib2. It ensures that that -llib1 occurs before -llib2.
1.1       dsieger  3612: 
1.184     rillig   3613: 13.11. The configure phase
1.1       dsieger  3614: 
1.184     rillig   3615: Most pieces of software need information on the header files, system calls, and
                   3616: library routines which are available on the platform they run on. The process
                   3617: of determining this information is known as configuration, and is usually
                   3618: automated. In most cases, a script is supplied with the distfiles, and its
                   3619: invocation results in generation of header files, Makefiles, etc.
1.1       dsieger  3620: 
1.184     rillig   3621: If the package contains a configure script, this can be invoked by setting
                   3622: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
1.187     rillig   3623: should set GNU_CONFIGURE to "yes" instead.
1.1       dsieger  3624: 
1.187     rillig   3625: In the do-configure stage, a rough equivalent of the following command is run.
                   3626: See mk/configure/configure.mk, target do-configure-script for the exact
                   3627: definition.
                   3628: 
                   3629: .for dir in ${CONFIGURE_DIRS}
                   3630:         cd ${WRKSRC} && cd ${dir} \
                   3631:         && env ${CONFIGURE_ENV} \
                   3632:             ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
1.184     rillig   3633: .endfor
1.1       dsieger  3634: 
1.184     rillig   3635: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
                   3636: each of these directories, the configure script is run with the environment
                   3637: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
                   3638: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
                   3639: by the package.
1.1       dsieger  3640: 
1.184     rillig   3641: If the program uses the Perl way of configuration (mainly Perl modules, but not
                   3642: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
                   3643: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
                   3644: (e.g., MAKE_PARAMS+=foo=bar
1.1       dsieger  3645: 
1.184     rillig   3646: If the program uses an Imakefile for configuration, the appropriate steps can
                   3647: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
                   3648: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
                   3649: SCRIPTS_ENV variable.
1.1       dsieger  3650: 
1.184     rillig   3651: If the program uses cmake for configuration, the appropriate steps can be
1.233     wiz      3652: invoked by including ../../devel/cmake/build.mk. You can add variables to
                   3653: cmake's environment by adding them to the CONFIGURE_ENV variable and arguments
1.256     wiz      3654: to cmake by adding them to the CMAKE_CONFIGURE_ARGS variable. If you want to
                   3655: add arguments only for particular stages, you can use the CMAKE_CONFIGURE_ARGS,
1.233     wiz      3656: CMAKE_BUILD_ARGS, and CMAKE_INSTALL_ARGS variables. You can set the
                   3657: CONFIGURE_DIRS variable to the directories in which CMake should be run,
                   3658: relative to WRKSRC. This defaults to to ".".
1.1       dsieger  3659: 
1.256     wiz      3660: Any package using the now-deprecated USE_CMAKE=yes should be converted.
                   3661: Essentially, replace with an include of ../../devel/cmake/build.mk, prune
                   3662: creation of a build directory and settings to use it, and check/fix settings
                   3663: that intend to perform the build in a subdirectory.
                   3664: 
1.184     rillig   3665: If there is no configure step at all, set NO_CONFIGURE to "yes".
1.1       dsieger  3666: 
1.184     rillig   3667: 13.12. The build phase
1.1       dsieger  3668: 
1.187     rillig   3669: For building a package, a rough equivalent of the following code is executed;
                   3670: see mk/build/build.mk, target do-build for the exact definition.
1.154     rillig   3671: 
1.187     rillig   3672: .for dir in ${BUILD_DIRS}
                   3673:         cd ${WRKSRC} && cd ${dir} \
1.184     rillig   3674:         && env ${MAKE_ENV} \
1.187     rillig   3675:             ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
1.184     rillig   3676:                 -f ${MAKE_FILE} \
                   3677:                 ${BUILD_TARGET}
                   3678: .endfor
1.1       dsieger  3679: 
1.184     rillig   3680: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
                   3681: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
                   3682: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
                   3683: and BUILD_TARGET may all be changed by the package.
1.1       dsieger  3684: 
1.184     rillig   3685: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
                   3686: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
                   3687: defaults to "all".
1.1       dsieger  3688: 
1.184     rillig   3689: If there is no build step at all, set NO_BUILD to "yes".
1.1       dsieger  3690: 
1.184     rillig   3691: 13.13. The test phase
1.1       dsieger  3692: 
1.184     rillig   3693: [TODO]
1.1       dsieger  3694: 
1.184     rillig   3695: 13.14. The install phase
1.1       dsieger  3696: 
1.184     rillig   3697: Once the build stage has completed, the final step is to install the software
                   3698: in public directories, so users can access the programs and files.
1.1       dsieger  3699: 
1.187     rillig   3700: In the install phase, a rough equivalent of the following code is executed; see
                   3701: mk/install/install.mk, target do-install for the exact definition.
                   3702: Additionally, before and after this code, several consistency checks are run
                   3703: against the files-to-be-installed, see mk/check/*.mk for details.
                   3704: 
                   3705: .for dir in ${INSTALL_DIRS}
                   3706:         cd ${WRKSRC} && cd ${dir} \
                   3707:         && env ${INSTALL_ENV} ${MAKE_ENV} \
                   3708:             ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \
                   3709:                 -f ${MAKE_FILE} ${INSTALL_TARGET}
1.184     rillig   3710: .endfor
1.1       dsieger  3711: 
1.184     rillig   3712: The variable's meanings are analogous to the ones in the build phase.
                   3713: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
                   3714: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
                   3715: defined.
1.1       dsieger  3716: 
1.184     rillig   3717: In the install phase, the following variables are useful. They are all
                   3718: variations of the install(1) command that have the owner, group and permissions
                   3719: preset. INSTALL is the plain install command. The specialized variants,
                   3720: together with their intended use, are:
1.1       dsieger  3721: 
1.184     rillig   3722: INSTALL_PROGRAM_DIR
1.1       dsieger  3723: 
1.184     rillig   3724:     directories that contain binaries
1.1       dsieger  3725: 
1.184     rillig   3726: INSTALL_SCRIPT_DIR
1.1       dsieger  3727: 
1.184     rillig   3728:     directories that contain scripts
1.1       dsieger  3729: 
1.184     rillig   3730: INSTALL_LIB_DIR
1.1       dsieger  3731: 
1.184     rillig   3732:     directories that contain shared and static libraries
1.1       dsieger  3733: 
1.184     rillig   3734: INSTALL_DATA_DIR
1.108     rillig   3735: 
1.184     rillig   3736:     directories that contain data files
1.108     rillig   3737: 
1.184     rillig   3738: INSTALL_MAN_DIR
1.108     rillig   3739: 
1.184     rillig   3740:     directories that contain man pages
1.108     rillig   3741: 
1.184     rillig   3742: INSTALL_GAME_DIR
1.108     rillig   3743: 
1.184     rillig   3744:     directories that contain data files for games
1.108     rillig   3745: 
1.184     rillig   3746: INSTALL_PROGRAM
1.108     rillig   3747: 
1.184     rillig   3748:     binaries that can be stripped from debugging symbols
1.108     rillig   3749: 
1.184     rillig   3750: INSTALL_SCRIPT
1.108     rillig   3751: 
1.184     rillig   3752:     binaries that cannot be stripped
1.108     rillig   3753: 
1.184     rillig   3754: INSTALL_GAME
1.108     rillig   3755: 
1.184     rillig   3756:     game binaries
1.108     rillig   3757: 
1.184     rillig   3758: INSTALL_LIB
1.108     rillig   3759: 
1.184     rillig   3760:     shared and static libraries
1.108     rillig   3761: 
1.184     rillig   3762: INSTALL_DATA
1.108     rillig   3763: 
1.184     rillig   3764:     data files
1.1       dsieger  3765: 
1.184     rillig   3766: INSTALL_GAME_DATA
1.1       dsieger  3767: 
1.184     rillig   3768:     data files for games
1.108     rillig   3769: 
1.184     rillig   3770: INSTALL_MAN
1.108     rillig   3771: 
1.184     rillig   3772:     man pages
1.1       dsieger  3773: 
1.184     rillig   3774: Some other variables are:
1.1       dsieger  3775: 
1.184     rillig   3776: INSTALL_UNSTRIPPED
1.1       dsieger  3777: 
1.184     rillig   3778:     If set to yes, do not run strip(1) when installing binaries. Any debugging
                   3779:     sections and symbols present in binaries will be preserved.
1.1       dsieger  3780: 
1.184     rillig   3781: INSTALLATION_DIRS
1.1       dsieger  3782: 
1.184     rillig   3783:     A list of directories relative to PREFIX that are created by pkgsrc at the
                   3784:     beginning of the install phase. The package is supposed to create all
                   3785:     needed directories itself before installing files to it and list all other
                   3786:     directories here.
1.1       dsieger  3787: 
1.184     rillig   3788: In the rare cases that a package shouldn't install anything, set NO_INSTALL to 
                   3789: "yes". This is mostly relevant for packages in the regress category.
1.1       dsieger  3790: 
1.184     rillig   3791: 13.15. The package phase
1.121     sevan    3792: 
1.184     rillig   3793: Once the install stage has completed, a binary package of the installed files
                   3794: can be built. These binary packages can be used for quick installation without
                   3795: previous compilation, e.g. by the make bin-install or by using pkg_add.
1.1       dsieger  3796: 
1.184     rillig   3797: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
                   3798: created in ${PACKAGES}/category, one for each category in the CATEGORIES
                   3799: variable. PACKAGES defaults to pkgsrc/packages.
1.1       dsieger  3800: 
1.184     rillig   3801: 13.16. Cleaning up
1.1       dsieger  3802: 
1.184     rillig   3803: Once you're finished with a package, you can clean the work directory by
                   3804: running make clean. If you want to clean the work directories of all
                   3805: dependencies too, use make clean-depends.
1.1       dsieger  3806: 
1.184     rillig   3807: 13.17. Other helpful targets
1.1       dsieger  3808: 
1.184     rillig   3809: pre/post-*
1.1       dsieger  3810: 
1.184     rillig   3811:     For any of the main targets described in the previous section (configure,
                   3812:     build, install, etc.), two auxiliary targets exist with "pre-" and "post-"
                   3813:     used as a prefix for the main target's name. These targets are invoked
                   3814:     before and after the main target is called, allowing extra configuration or
                   3815:     installation steps be performed from a package's Makefile, for example,
                   3816:     which a program's configure script or install target omitted.
                   3817: 
                   3818:     About 5% of the pkgsrc packages define their custom post-extract target,
                   3819:     another 5% define pre-configure, and 10% define post-install. The other pre
                   3820:     /post-* targets are defined even less often.
1.1       dsieger  3821: 
1.184     rillig   3822: do-*
1.182     leot     3823: 
1.184     rillig   3824:     Should one of the main targets do the wrong thing, and should there be no
                   3825:     variable to fix this, you can redefine it with the do-* target. (Note that
                   3826:     redefining the target itself instead of the do-* target is a bad idea, as
                   3827:     the pre-* and post-* targets won't be called anymore, etc.)
1.1       dsieger  3828: 
1.184     rillig   3829:     About 15% of the pkgsrc packages override the default do-install, the other
                   3830:     do-* targets are overridden even less often.
1.1       dsieger  3831: 
1.184     rillig   3832: reinstall
1.1       dsieger  3833: 
1.184     rillig   3834:     If you did a make install and you noticed some file was not installed
                   3835:     properly, you can repeat the installation with this target, which will
                   3836:     ignore the "already installed" flag.
1.1       dsieger  3837: 
1.184     rillig   3838:     This is the default value of DEPENDS_TARGET except in the case of make
                   3839:     update and make package, where the defaults are "package" and "update",
                   3840:     respectively.
1.1       dsieger  3841: 
1.184     rillig   3842: deinstall
1.1       dsieger  3843: 
1.184     rillig   3844:     This target does a pkg_delete(1) in the current directory, effectively
                   3845:     de-installing the package. The following variables can be used to tune the
                   3846:     behaviour:
1.1       dsieger  3847: 
1.184     rillig   3848:     PKG_VERBOSE
1.1       dsieger  3849: 
1.184     rillig   3850:         Add a "-v" to the pkg_delete(1) command.
1.1       dsieger  3851: 
1.184     rillig   3852:     DEINSTALLDEPENDS
1.1       dsieger  3853: 
1.184     rillig   3854:         Remove all packages that require (depend on) the given package. This
                   3855:         can be used to remove any packages that may have been pulled in by a
                   3856:         given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
                   3857:         pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
                   3858:         " to the pkg_delete(1) command line.
1.1       dsieger  3859: 
1.184     rillig   3860: bin-install
1.1       dsieger  3861: 
1.184     rillig   3862:     Install a binary package from local disk and via FTP from a list of sites
                   3863:     (see the BINPKG_SITES variable), and do a make package if no binary package
                   3864:     is available anywhere. The arguments given to pkg_add can be set via
                   3865:     BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
1.1       dsieger  3866: 
1.184     rillig   3867: install-clean
1.1       dsieger  3868: 
1.184     rillig   3869:     This target removes the state files for the "install" and later phases so
                   3870:     that the "install" target may be re-invoked. This can be used after editing
                   3871:     the PLIST to install the package without rebuilding it.
1.1       dsieger  3872: 
1.184     rillig   3873: build-clean
1.18      mishka   3874: 
1.184     rillig   3875:     This target removes the state files for the "build" and later phases so
                   3876:     that the "build" target may be re-invoked.
1.18      mishka   3877: 
1.184     rillig   3878: update
1.18      mishka   3879: 
1.184     rillig   3880:     This target causes the current package to be updated to the latest version.
                   3881:     The package and all depending packages first get de-installed, then current
                   3882:     versions of the corresponding packages get compiled and installed. This is
                   3883:     similar to manually noting which packages are currently installed, then
                   3884:     performing a series of make deinstall and make install (or whatever
                   3885:     UPDATE_TARGET is set to) for these packages.
1.18      mishka   3886: 
1.184     rillig   3887:     You can use the "update" target to resume package updating in case a
                   3888:     previous make update was interrupted for some reason. However, in this
                   3889:     case, make sure you don't call make clean or otherwise remove the list of
                   3890:     dependent packages in WRKDIR. Otherwise, you lose the ability to
                   3891:     automatically update the current package along with the dependent packages
                   3892:     you have installed.
1.121     sevan    3893: 
1.184     rillig   3894:     Resuming an interrupted make update will only work as long as the package
                   3895:     tree remains unchanged. If the source code for one of the packages to be
                   3896:     updated has been changed, resuming make update will most certainly fail!
1.1       dsieger  3897: 
1.184     rillig   3898:     The following variables can be used either on the command line or in
                   3899:     mk.conf to alter the behaviour of make update:
1.1       dsieger  3900: 
1.184     rillig   3901:     UPDATE_TARGET
1.1       dsieger  3902: 
1.184     rillig   3903:         Install target to recursively use for the updated package and the
                   3904:         dependent packages. Defaults to DEPENDS_TARGET if set, "install"
                   3905:         otherwise for make update. Other good targets are "package" or "
                   3906:         bin-install". Do not set this to "update" or you will get stuck in an
                   3907:         endless loop!
1.1       dsieger  3908: 
1.184     rillig   3909:     NOCLEAN
1.1       dsieger  3910: 
1.184     rillig   3911:         Don't clean up after updating. Useful if you want to leave the work
                   3912:         sources of the updated packages around for inspection or other
                   3913:         purposes. Be sure you eventually clean up the source tree (see the "
                   3914:         clean-update" target below) or you may run into troubles with old
                   3915:         source code still lying around on your next make or make update.
1.1       dsieger  3916: 
1.184     rillig   3917:     REINSTALL
1.1       dsieger  3918: 
1.184     rillig   3919:         Deinstall each package before installing (making DEPENDS_TARGET). This
                   3920:         may be necessary if the "clean-update" target (see below) was called
                   3921:         after interrupting a running make update.
1.1       dsieger  3922: 
1.184     rillig   3923:     DEPENDS_TARGET
1.1       dsieger  3924: 
1.184     rillig   3925:         Allows you to disable recursion and hardcode the target for packages.
                   3926:         The default is "update" for the update target, facilitating a recursive
                   3927:         update of prerequisite packages. Only set DEPENDS_TARGET if you want to
                   3928:         disable recursive updates. Use UPDATE_TARGET instead to just set a
                   3929:         specific target for each package to be installed during make update
                   3930:         (see above).
1.1       dsieger  3931: 
1.184     rillig   3932: clean-update
1.1       dsieger  3933: 
1.184     rillig   3934:     Clean the source tree for all packages that would get updated if make
                   3935:     update was called from the current directory. This target should not be
                   3936:     used if the current package (or any of its depending packages) have already
                   3937:     been de-installed (e.g., after calling make update) or you may lose some
                   3938:     packages you intended to update. As a rule of thumb: only use this target 
                   3939:     before the first time you run make update and only if you have a dirty
                   3940:     package tree (e.g., if you used NOCLEAN).
1.86      wiz      3941: 
1.184     rillig   3942:     If you are unsure about whether your tree is clean, you can either perform
                   3943:     a make clean at the top of the tree, or use the following sequence of
                   3944:     commands from the directory of the package you want to update (before
                   3945:     running make update for the first time, otherwise you lose all the packages
                   3946:     you wanted to update!):
1.86      wiz      3947: 
1.184     rillig   3948:     # make clean-update
                   3949:     # make clean CLEANDEPENDS=YES
                   3950:     # make update
1.86      wiz      3951: 
                   3952: 
1.184     rillig   3953:     The following variables can be used either on the command line or in
                   3954:     mk.conf to alter the behaviour of make clean-update:
1.86      wiz      3955: 
1.184     rillig   3956:     CLEAR_DIRLIST
1.86      wiz      3957: 
1.184     rillig   3958:         After make clean, do not reconstruct the list of directories to update
                   3959:         for this package. Only use this if make update successfully installed
                   3960:         all packages you wanted to update. Normally, this is done automatically
                   3961:         on make update, but may have been suppressed by the NOCLEAN variable
                   3962:         (see above).
1.1       dsieger  3963: 
1.184     rillig   3964: replace
1.1       dsieger  3965: 
1.184     rillig   3966:     Update the installation of the current package. This differs from update in
                   3967:     that it does not replace dependent packages. You will need to install
                   3968:     pkgtools/pkg_tarup for this target to work.
1.1       dsieger  3969: 
1.184     rillig   3970:     Be careful when using this target! There are no guarantees that dependent
                   3971:     packages will still work, in particular they will most certainly break if
                   3972:     you make replace a library package whose shared library major version
                   3973:     changed between your installed version and the new one. For this reason,
                   3974:     this target is not officially supported and only recommended for advanced
                   3975:     users.
1.1       dsieger  3976: 
1.184     rillig   3977: info
1.1       dsieger  3978: 
1.184     rillig   3979:     This target invokes pkg_info(1) for the current package. You can use this
                   3980:     to check which version of a package is installed.
1.86      wiz      3981: 
1.184     rillig   3982: index
1.1       dsieger  3983: 
1.184     rillig   3984:     This is a top-level command, i.e. it should be used in the pkgsrc
                   3985:     directory. It creates a database of all packages in the local pkgsrc tree,
                   3986:     including dependencies, comment, maintainer, and some other useful
                   3987:     information. Individual entries are created by running make describe in the
                   3988:     packages' directories. This index file is saved as pkgsrc/INDEX. It can be
                   3989:     displayed in verbose format by running make print-index. You can search in
                   3990:     it with make search key=something. You can extract a list of all packages
                   3991:     that depend on a particular one by running make show-deps PKG=somepackage.
1.1       dsieger  3992: 
1.184     rillig   3993:     Running this command takes a very long time, some hours even on fast
                   3994:     machines!
1.1       dsieger  3995: 
1.184     rillig   3996: readme
1.1       dsieger  3997: 
1.199     nia      3998:     This target generates a index.html file, which can be viewed using a
1.184     rillig   3999:     browser such as www/firefox or www/links. The generated files contain
                   4000:     references to any packages which are in the PACKAGES directory on the local
                   4001:     host. The generated files can be made to refer to URLs based on
                   4002:     FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
1.199     nia      4003:     index.html files which pointed to binary packages on the local machine, in
1.184     rillig   4004:     the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
                   4005:     FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
                   4006:     subdirectories will be searched for all the binary packages.
1.1       dsieger  4007: 
1.184     rillig   4008:     The target can be run at the toplevel or in category directories, in which
                   4009:     case it descends recursively.
1.1       dsieger  4010: 
1.184     rillig   4011: readme-all
1.1       dsieger  4012: 
1.184     rillig   4013:     This is a top-level command, run it in pkgsrc. Use this target to create a
                   4014:     file README-all.html which contains a list of all packages currently
                   4015:     available in the NetBSD Packages Collection, together with the category
                   4016:     they belong to and a short description. This file is compiled from the
1.199     nia      4017:     pkgsrc/*/index.html files, so be sure to run this after a make readme.
1.1       dsieger  4018: 
1.184     rillig   4019: cdrom-readme
1.1       dsieger  4020: 
1.184     rillig   4021:     This is very much the same as the "readme" target (see above), but is to be
                   4022:     used when generating a pkgsrc tree to be written to a CD-ROM. This target
1.199     nia      4023:     also produces index.html files, and can be made to refer to URLs based on
1.184     rillig   4024:     CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
1.1       dsieger  4025: 
1.184     rillig   4026: show-distfiles
1.1       dsieger  4027: 
1.184     rillig   4028:     This target shows which distfiles and patchfiles are needed to build the
                   4029:     package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
                   4030:     patches/*).
1.1       dsieger  4031: 
1.184     rillig   4032: show-downlevel
1.1       dsieger  4033: 
1.184     rillig   4034:     This target shows nothing if the package is not installed. If a version of
                   4035:     this package is installed, but is not the version provided in this version
                   4036:     of pkgsrc, then a warning message is displayed. This target can be used to
                   4037:     show which of your installed packages are downlevel, and so the old
                   4038:     versions can be deleted, and the current ones added.
1.1       dsieger  4039: 
1.184     rillig   4040: show-pkgsrc-dir
1.1       dsieger  4041: 
1.184     rillig   4042:     This target shows the directory in the pkgsrc hierarchy from which the
                   4043:     package can be built and installed. This may not be the same directory as
                   4044:     the one from which the package was installed. This target is intended to be
                   4045:     used by people who may wish to upgrade many packages on a single host, and
                   4046:     can be invoked from the top-level pkgsrc Makefile by using the "
                   4047:     show-host-specific-pkgs" target.
1.1       dsieger  4048: 
1.184     rillig   4049: show-installed-depends
1.1       dsieger  4050: 
1.184     rillig   4051:     This target shows which installed packages match the current package's
                   4052:     DEPENDS. Useful if out of date dependencies are causing build problems.
1.1       dsieger  4053: 
1.184     rillig   4054: print-build-depends-list
1.1       dsieger  4055: 
1.184     rillig   4056:     This target shows the list of packages that the current package depends on
                   4057:     for building.
1.1       dsieger  4058: 
1.184     rillig   4059: print-run-depends-list
1.1       dsieger  4060: 
1.184     rillig   4061:     This target shows the list of packages that the current package depends on
                   4062:     for running.
1.1       dsieger  4063: 
1.184     rillig   4064: check-shlibs
1.1       dsieger  4065: 
1.184     rillig   4066:     After a package is installed, check all its binaries and (on ELF platforms)
                   4067:     shared libraries to see if they find the shared libs they need. Run by
                   4068:     default if PKG_DEVELOPER is set in mk.conf.
1.1       dsieger  4069: 
1.184     rillig   4070: print-PLIST
1.1       dsieger  4071: 
1.184     rillig   4072:     After a "make install" from a new or upgraded pkg, this prints out an
                   4073:     attempt to generate a new PLIST from a find -newer work/.extract_done. An
                   4074:     attempt is made to care for shared libs etc., but it is strongly
                   4075:     recommended to review the result before putting it into PLIST. On upgrades,
                   4076:     it's useful to diff the output of this command against an already existing
                   4077:     PLIST file.
1.1       dsieger  4078: 
1.184     rillig   4079:     If the package installs files via tar(1) or other methods that don't update
                   4080:     file access times, be sure to add these files manually to your PLIST, as
                   4081:     the "find -newer" command used by this target won't catch them!
1.56      ryoon    4082: 
1.184     rillig   4083:     See Section 19.3, "Tweaking output of make print-PLIST" for more
                   4084:     information on this target.
1.1       dsieger  4085: 
1.255     wiz      4086: rebuild
                   4087: 
                   4088:     If you did a make build and you noticed some further modifications of
                   4089:     sources are needed, you can repeat the build with this target, which will
                   4090:     ignore the "already built" flag. This target is helpful while working with
                   4091:     patches.
                   4092: 
                   4093: repackage
                   4094: 
                   4095:     If you did a make package and you noticed some further modifications of
                   4096:     sources are needed, you can repeat the package with this target, which will
                   4097:     ignore the "already packaged" flag. This target is helpful while working
                   4098:     with patches, PLIST* files etc.
                   4099: 
                   4100: retest
                   4101: 
                   4102:     If you did a make test and you noticed some further modifications of
                   4103:     sources are needed, you can repeat the test with this target, which will
                   4104:     ignore the "already tested" flag. This target is helpful while working with
                   4105:     patches.
                   4106: 
1.184     rillig   4107: Chapter 14. Creating a new pkgsrc package from scratch
1.1       dsieger  4108: 
1.184     rillig   4109: Table of Contents
1.1       dsieger  4110: 
1.184     rillig   4111: 14.1. Common types of packages
1.219     nia      4112:     14.1.1. Python modules and programs
                   4113:     14.1.2. R packages
                   4114:     14.1.3. TeXlive packages
1.184     rillig   4115: 14.2. Examples
                   4116:     14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  4117: 
1.184     rillig   4118: When you find a package that is not yet in pkgsrc, you most likely have a URL
                   4119: from where you can download the source code. Starting with this URL, creating a
                   4120: package involves only a few steps.
1.1       dsieger  4121: 
1.184     rillig   4122:  1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
1.1       dsieger  4123: 
1.184     rillig   4124:  2. Install the package meta-pkgs/pkg_developer, which among others will
                   4125:     install the utilities url2pkg, pkglint, pkgvi and mkpatches:
1.1       dsieger  4126: 
1.184     rillig   4127:     $ cd /usr/pkgsrc
                   4128:     $ (cd meta-pkgs/pkg_developer && bmake update)
1.1       dsieger  4129: 
1.184     rillig   4130:  3. Choose one of the top-level directories as the category in which you want
                   4131:     to place your package. You can also create a directory of your own (maybe
1.219     nia      4132:     called local). Change into that category directory:
1.1       dsieger  4133: 
1.219     nia      4134:     $ cd category
1.1       dsieger  4135: 
1.219     nia      4136:  4. Run the program url2pkg, passing as argument the URL of the distribution
                   4137:     file (in most cases a .tar.gz file). This will download the distribution
                   4138:     file and create the necessary files of the package, based on what's in the
                   4139:     distribution file:
1.1       dsieger  4140: 
1.184     rillig   4141:     $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
1.1       dsieger  4142: 
1.184     rillig   4143:  5. Examine the extracted files to determine the dependencies of your package.
                   4144:     Ideally, this is mentioned in some README file, but things may differ. For
                   4145:     each of these dependencies, look where it exists in pkgsrc, and if there is
                   4146:     a file called buildlink3.mk in that directory, add a line to your package
                   4147:     Makefile which includes that file just before the last line. If the
                   4148:     buildlink3.mk file does not exist, it must be created first. The
                   4149:     buildlink3.mk file makes sure that the package's include files and
                   4150:     libraries are provided.
1.1       dsieger  4151: 
1.219     nia      4152:     If you just need binaries from a dependent package, add a DEPENDS line to
                   4153:     the Makefile, which specifies the version of the dependency and where it
                   4154:     can be found in pkgsrc. This line should be placed in the third paragraph.
                   4155:     If the dependency is only needed for building the package, but not when
                   4156:     using it, use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The
                   4157:     difference between TOOL_DEPENDS and BUILD_DEPENDS occurs when
                   4158:     cross-compiling: TOOL_DEPENDS are native packages, i.e. packages for the
                   4159:     platform where the package is built; BUILD_DEPENDS are target packages,
                   4160:     i.e. packages for the platform for which the package is built. There is
                   4161:     also TEST_DEPENDS, which specifies a dependency used only for testing the
                   4162:     resulting package built, using the upstream project's included test suite,
                   4163:     on the native platform. Your package may then look like this:
1.1       dsieger  4164: 
1.184     rillig   4165:     [...]
1.1       dsieger  4166: 
1.184     rillig   4167:     TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
                   4168:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   4169:     DEPENDS+=       screen>=4.0:../../misc/screen
1.1       dsieger  4170: 
1.184     rillig   4171:     [...]
1.1       dsieger  4172: 
1.184     rillig   4173:     .include "../../category/package/buildlink3.mk"
                   4174:     .include "../../devel/glib2/buildlink3.mk"
                   4175:     .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4176: 
1.184     rillig   4177:  6. Run pkglint to see what things still need to be done to make your package a
                   4178:     "good" one. If you don't know what pkglint's warnings want to tell you, try
                   4179:     pkglint --explain or pkglint -e, which outputs additional explanations.
1.1       dsieger  4180: 
1.184     rillig   4181:  7. In many cases the package is not yet ready to build. You can find
                   4182:     instructions for the most common cases in the next section, Section 14.1,
                   4183:     "Common types of packages". After you have followed the instructions over
                   4184:     there, you can hopefully continue here.
1.1       dsieger  4185: 
1.184     rillig   4186:  8. Run bmake clean to clean the working directory from the extracted files.
1.219     nia      4187:     Besides these files, a lot of cache files and other system information have
                   4188:     been saved in the working directory, which may have become outdated after
                   4189:     you edited the Makefile.
1.1       dsieger  4190: 
1.184     rillig   4191:  9. Now, run bmake to build the package. For the various things that can go
                   4192:     wrong in this phase, consult Chapter 21, Making your package work.
1.1       dsieger  4193: 
1.184     rillig   4194:     If the extracted files from the package need to be fixed, run multiple
                   4195:     rounds of these commands:
1.1       dsieger  4196: 
1.219     nia      4197:     $ bmake
1.184     rillig   4198:     $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
                   4199:     $ mkpatches
1.219     nia      4200:     $ bmake mps
                   4201:     $ bmake clean
1.1       dsieger  4202: 
1.184     rillig   4203: 10. When the package builds fine, the next step is to install the package. Run 
                   4204:     bmake install and hope that everything works.
1.1       dsieger  4205: 
1.184     rillig   4206: 11. Up to now, the file PLIST, which contains a list of the files that are
                   4207:     installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
                   4208:     generate a probably correct list. Check the file using your preferred text
                   4209:     editor to see if the list of files looks plausible.
1.1       dsieger  4210: 
1.184     rillig   4211: 12. Run pkglint again to see if the generated PLIST contains garbage or not.
1.1       dsieger  4212: 
1.184     rillig   4213: 13. When you ran bmake install, the package had been registered in the database
                   4214:     of installed files, but with an empty list of files. To fix this, run bmake
                   4215:     deinstall and bmake install again. Now the package is registered with the
                   4216:     list of files from PLIST.
1.48      wiz      4217: 
1.219     nia      4218: 14. Run bmake clean update to run everything from above again in a single step,
1.184     rillig   4219:     making sure that the PLIST is correct and the whole package is created as
                   4220:     intended.
1.48      wiz      4221: 
1.219     nia      4222: 15. Run pkglint to see if there's anything left to do.
1.48      wiz      4223: 
1.219     nia      4224: 16. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
1.184     rillig   4225:     and Committing.
1.50      wiz      4226: 
1.184     rillig   4227: 14.1. Common types of packages
1.1       dsieger  4228: 
1.219     nia      4229: 14.1.1. Python modules and programs
1.1       dsieger  4230: 
1.184     rillig   4231: Python modules and programs packages are easily created using a set of
                   4232: predefined variables.
1.1       dsieger  4233: 
1.184     rillig   4234: If some Python versions are not supported by the software, set the
                   4235: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
                   4236: supported, e.g.
1.1       dsieger  4237: 
1.184     rillig   4238: PYTHON_VERSIONS_INCOMPATIBLE=       27
1.1       dsieger  4239: 
1.249     gutterid 4240: If the packaged software is a Python module, include ../../lang/python/
1.258     wiz      4241: wheel.mk. Note per PEP-518, the minimum and default requirement to create .whl
                   4242: files is devel/py-setuptools; however, there are various other possible tools
                   4243: that projects can use. Thus inclusion of wheel.mk does not imply these defaults
                   4244: are defined as TOOL_DEPENDS. Whatever the project specifically requires as
                   4245: packaging tools must be defined in the package Makefile.
1.1       dsieger  4246: 
1.248     wiz      4247: The package directory should be called "py-software" and PKGNAME should be set
                   4248: to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.1       dsieger  4249: 
1.184     rillig   4250: DISTNAME=   foopymodule-1.2.10
                   4251: PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
1.1       dsieger  4252: 
1.226     gutterid 4253: For software in PyPi, the name should match what PyPi specifies for "pip
                   4254: install software".
                   4255: 
1.184     rillig   4256: If it is an application, include "../../lang/python/application.mk". In order
                   4257: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
                   4258: variable and set it to the list of files (paths relative to WRKSRC) that must
                   4259: be corrected. For example:
1.1       dsieger  4260: 
1.184     rillig   4261: REPLACE_PYTHON=   *.py
1.1       dsieger  4262: 
1.219     nia      4263: 14.1.2. R packages
1.1       dsieger  4264: 
1.184     rillig   4265: Simple R packages from CRAN are handled automatically by R2pkg, which is
                   4266: available in pkgtools/R2pkg. Individual packages (and optionally their
                   4267: dependencies) may be created and updated. R packages generally follow the same
                   4268: form, and most of the relevant information needed is contained in a DESCRIPTION
                   4269: file as part of each R package on CRAN. Consequently, R2pkg downloads that
                   4270: information and creates or updates a package in the canonical form. The
                   4271: resulting package should be reviewed for correctness.
1.1       dsieger  4272: 
1.219     nia      4273: 14.1.3. TeXlive packages
1.1       dsieger  4274: 
1.184     rillig   4275: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
                   4276: available in pkgtools/texlive2pkg.
1.1       dsieger  4277: 
1.184     rillig   4278: If the TeXlive package name is not known, it may be useful to search CTAN. A "
                   4279: Contained in" field on the package page typically identifies the basename of
                   4280: the package file in the TeXlive archive.
1.1       dsieger  4281: 
1.184     rillig   4282: If the TeXlive package name is known, download the files from the TeXlive
                   4283: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
                   4284: packages also have associated documentation packages, so download
                   4285: foo.doc.tar.xz at the same time. These files should be placed in the
                   4286: appropriate category directory, which is often but not always print. Then run
                   4287: the following command in the category directory.
1.1       dsieger  4288: 
1.184     rillig   4289: texlive2pkg foo.tar.xz foo.doc.tar.xz
1.1       dsieger  4290: 
1.184     rillig   4291: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
                   4292: both packages are correct.
1.1       dsieger  4293: 
1.184     rillig   4294: Finally, CTAN currently does not include version information in package
                   4295: filenames and changes their contents periodically when updates occur.
                   4296: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
                   4297: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
                   4298: e.g., the main one and the corresponding documentation, upload the distfiles
                   4299: with the following command in each package directory.
1.1       dsieger  4300: 
1.184     rillig   4301: make upload-distfiles
1.117     sevan    4302: 
1.184     rillig   4303: 14.2. Examples
1.117     sevan    4304: 
1.184     rillig   4305: 14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  4306: 
1.184     rillig   4307: 14.2.1.1. The initial package
1.1       dsieger  4308: 
1.184     rillig   4309: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
                   4310: been imported into pkgsrc. As the description says it has to do with the web,
                   4311: the obvious choice for the category is "www".
1.1       dsieger  4312: 
1.184     rillig   4313: $ mkdir www/nvu
                   4314: $ cd www/nvu
1.1       dsieger  4315: 
1.184     rillig   4316: The web site says that the sources are available as a tar file, so I fed that
                   4317: URL to the url2pkg program:
1.1       dsieger  4318: 
1.184     rillig   4319: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
1.1       dsieger  4320: 
1.184     rillig   4321: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
                   4322: package name should not have the word "sources" in it. I also filled in the
                   4323: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
                   4324: that:
1.1       dsieger  4325: 
1.184     rillig   4326: # $NetBSD $
                   4327: #
1.1       dsieger  4328: 
1.184     rillig   4329: DISTNAME=       nvu-1.0-sources
                   4330: PKGNAME=        nvu-1.0
                   4331: CATEGORIES=     www
                   4332: MASTER_SITES=   http://cvs.nvu.com/download/
                   4333: EXTRACT_SUFX=   .tar.bz2
1.1       dsieger  4334: 
1.184     rillig   4335: MAINTAINER=     rillig@NetBSD.org
                   4336: HOMEPAGE=       http://cvs.nvu.com/
                   4337: COMMENT=        Web Authoring System
1.1       dsieger  4338: 
1.184     rillig   4339: # url2pkg-marker (please do not remove this line.)
                   4340: .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4341: 
1.184     rillig   4342: On the first line of output above, an artificial space has been added between
                   4343: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
                   4344: the guide.
1.1       dsieger  4345: 
1.184     rillig   4346: Then, I quit the editor and watched pkgsrc downloading a large source archive:
1.1       dsieger  4347: 
1.184     rillig   4348: url2pkg> Running "make makesum" ...
                   4349: => Required installed package digest>=20010302: digest-20060826 found
                   4350: => Fetching nvu-1.0-sources.tar.bz2
                   4351: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   4352: 100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
                   4353: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
                   4354: url2pkg> Running "make extract" ...
                   4355: => Required installed package digest>=20010302: digest-20060826 found
                   4356: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4357: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4358: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
                   4359: ===> Installing dependencies for nvu-1.0
                   4360: ===> Overriding tools for nvu-1.0
                   4361: ===> Extracting for nvu-1.0
                   4362: url2pkg> Adjusting the Makefile.
1.1       dsieger  4363: 
1.184     rillig   4364: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
1.1       dsieger  4365: 
1.184     rillig   4366: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
1.1       dsieger  4367: 
1.184     rillig   4368: 14.2.1.2. Fixing all kinds of problems to make the package work
1.1       dsieger  4369: 
1.184     rillig   4370: Now that the package has been extracted, let's see what's inside it. The
                   4371: package has a README.txt, but that only says something about mozilla, so it's
                   4372: probably useless for seeing what dependencies this package has. But since there
                   4373: is a GNU configure script in the package, let's hope that it will complain
                   4374: about everything it needs.
1.1       dsieger  4375: 
1.184     rillig   4376: $ bmake
                   4377: => Required installed package digest>=20010302: digest-20060826 found
                   4378: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4379: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4380: ===> Patching for nvu-1.0
                   4381: ===> Creating toolchain wrappers for nvu-1.0
                   4382: ===> Configuring for nvu-1.0
                   4383: [...]
                   4384: configure: error: Perl 5.004 or higher is required.
                   4385: [...]
                   4386: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
                   4387: [...]
1.1       dsieger  4388: 
1.184     rillig   4389: That worked quite well. So I opened the package Makefile in my editor, and
                   4390: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
                   4391: dependencies of the package have changed now, and since a perl wrapper is
                   4392: automatically installed in the "tools" phase, I need to build the package from
                   4393: scratch.
1.1       dsieger  4394: 
1.184     rillig   4395: $ bmake clean
                   4396: ===> Cleaning for nvu-1.0
                   4397: $ bmake
                   4398: [...]
                   4399: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
                   4400: GNU Make.  You will not be able to build Mozilla without GNU Make.
                   4401: [...]
1.1       dsieger  4402: 
1.184     rillig   4403: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
1.1       dsieger  4404: 
1.184     rillig   4405: [...]
                   4406: checking for GTK - version >= 1.2.0... no
                   4407: *** Could not run GTK test program, checking why...
                   4408: [...]
1.1       dsieger  4409: 
1.184     rillig   4410: Now to the other dependencies. The first question is: Where is the GTK package
                   4411: hidden in pkgsrc?
1.1       dsieger  4412: 
1.184     rillig   4413: $ echo ../../*/gtk*
                   4414: [many packages ...]
                   4415: $ echo ../../*/gtk
                   4416: ../../x11/gtk
                   4417: $ echo ../../*/gtk2
                   4418: ../../x11/gtk2
                   4419: $ echo ../../*/gtk2/bui*
                   4420: ../../x11/gtk2/buildlink3.mk
1.1       dsieger  4421: 
1.184     rillig   4422: The first try was definitely too broad. The second one had exactly one result,
                   4423: which is very good. But there is one pitfall with GNOME packages. Before GNOME
                   4424: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
                   4425: able to continue to use these packages, the GNOME 2 packages were imported as
                   4426: separate packages, and their names usually have a "2" appended. So I checked
                   4427: whether this was the case here, and indeed it was.
1.1       dsieger  4428: 
1.184     rillig   4429: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
                   4430: easy. I just inserted an .include line before the last line of the package
                   4431: Makefile, so that it now looks like this:
1.1       dsieger  4432: 
1.184     rillig   4433: [...]
                   4434: .include "../../x11/gtk2/buildlink3.mk"
                   4435: .include "../../mk/bsd.pkg.mk
1.1       dsieger  4436: 
1.184     rillig   4437: After another bmake clean && bmake, the answer was:
1.108     rillig   4438: 
1.184     rillig   4439: [...]
                   4440: checking for gtk-config... /home/roland/pkg/bin/gtk-config
                   4441: checking for GTK - version >= 1.2.0... no
                   4442: *** Could not run GTK test program, checking why...
                   4443: *** The test program failed to compile or link. See the file config.log for the
                   4444: *** exact error that occured. This usually means GTK was incorrectly installed
                   4445: *** or that you have moved GTK since it was installed. In the latter case, you
                   4446: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
                   4447: configure: error: Test for GTK failed.
                   4448: [...]
1.1       dsieger  4449: 
1.184     rillig   4450: In this particular case, the assumption that "every package prefers GNOME 2"
                   4451: had been wrong. The first of the lines above told me that this package really
                   4452: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
                   4453: it would have looked for pkg-config instead of gtk-config. So I changed the x11
                   4454: /gtk2 to x11/gtk in the package Makefile, and tried again.
1.1       dsieger  4455: 
1.184     rillig   4456: [...]
                   4457: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
                   4458: In file included from xpidl.c:42:
                   4459: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
                   4460: In file included from xpidl.c:42:
                   4461: xpidl.h:132: error: parse error before "IDL_ns"
                   4462: [...]
1.1       dsieger  4463: 
1.184     rillig   4464: The package still does not find all of its dependencies. Now the question is:
                   4465: Which package provides the libIDL/IDL.h header file?
1.1       dsieger  4466: 
1.184     rillig   4467: $ echo ../../*/*idl*
                   4468: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
                   4469: $ echo ../../*/*IDL*
                   4470: ../../net/libIDL
1.1       dsieger  4471: 
1.184     rillig   4472: Let's take the one from the second try. So I included the ../../net/libIDL/
                   4473: buildlink3.mk file and tried again. But the error didn't change. After digging
                   4474: through some of the code, I concluded that the build process of the package was
                   4475: broken and couldn't have ever worked, but since the Mozilla source tree is
                   4476: quite large, I didn't want to fix it. So I added the following to the package
                   4477: Makefile and tried again:
1.1       dsieger  4478: 
1.184     rillig   4479: CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
                   4480: BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
1.1       dsieger  4481: 
1.184     rillig   4482: The latter line is needed because the package expects the library libIDL.so,
                   4483: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
                   4484: that on the fly.
1.1       dsieger  4485: 
1.184     rillig   4486: The next problem was related to a recent change of the FreeType interface. I
                   4487: looked up in www/seamonkey which patch files were relevant for this issue and
                   4488: copied them to the patches directory. Then I retried, fixed the patches so that
                   4489: they applied cleanly and retried again. This time, everything worked.
1.1       dsieger  4490: 
1.184     rillig   4491: 14.2.1.3. Installing the package
1.1       dsieger  4492: 
1.184     rillig   4493: $ bmake CHECK_FILES=no install
                   4494: [...]
                   4495: $ bmake print-PLIST >PLIST
                   4496: $ bmake deinstall
                   4497: $ bmake install
1.1       dsieger  4498: 
1.184     rillig   4499: Chapter 15. Programming in Makefiles
1.1       dsieger  4500: 
1.184     rillig   4501: Table of Contents
1.1       dsieger  4502: 
1.184     rillig   4503: 15.1. Caveats
                   4504: 15.2. Makefile variables
                   4505:     15.2.1. Naming conventions
                   4506: 15.3. Code snippets
                   4507:     15.3.1. Adding things to a list
                   4508:     15.3.2. Echoing a string exactly as-is
                   4509:     15.3.3. Passing CFLAGS to GNU configure scripts
                   4510:     15.3.4. Handling possibly empty variables
1.229     gutterid 4511:     15.3.5. Testing yes/no variables in conditions
1.1       dsieger  4512: 
1.184     rillig   4513: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
                   4514: part of the pkgsrc system. Using the make(1) system as a programming language
                   4515: for a big system like pkgsrc requires some discipline to keep the code correct
                   4516: and understandable.
1.1       dsieger  4517: 
1.184     rillig   4518: The basic ingredients for Makefile programming are variables and shell
                   4519: commands. Among these shell commands may even be more complex ones like awk(1)
                   4520: programs. To make sure that every shell command runs as intended it is
                   4521: necessary to quote all variables correctly when they are used.
1.1       dsieger  4522: 
1.184     rillig   4523: This chapter describes some patterns that appear quite often in Makefiles,
                   4524: including the pitfalls that come along with them.
1.1       dsieger  4525: 
1.184     rillig   4526: 15.1. Caveats
1.1       dsieger  4527: 
1.184     rillig   4528:   * When you are creating a file as a target of a rule, always write the data
                   4529:     to a temporary file first and finally rename that file. Otherwise there
                   4530:     might occur an error in the middle of generating the file, and when the
                   4531:     user runs make(1) for the second time, the file exists and will not be
                   4532:     regenerated properly. Example:
1.1       dsieger  4533: 
1.184     rillig   4534:     wrong:
                   4535:             @echo "line 1" > ${.TARGET}
                   4536:             @echo "line 2" >> ${.TARGET}
                   4537:             @false
1.1       dsieger  4538: 
1.184     rillig   4539:     correct:
                   4540:             @echo "line 1" > ${.TARGET}.tmp
                   4541:             @echo "line 2" >> ${.TARGET}.tmp
                   4542:             @false
                   4543:             @mv ${.TARGET}.tmp ${.TARGET}
1.1       dsieger  4544: 
1.184     rillig   4545:     When you run make wrong twice, the file wrong will exist, although there
                   4546:     was an error message in the first run. On the other hand, running make
                   4547:     correct gives an error message twice, as expected.
1.1       dsieger  4548: 
1.184     rillig   4549:     You might remember that make(1) sometimes removes ${.TARGET} in case of
                   4550:     error, but this only happens when it is interrupted, for example by
                   4551:     pressing Ctrl+C. This does not happen when one of the commands fails (like
                   4552:     false(1) above).
1.1       dsieger  4553: 
1.184     rillig   4554: 15.2. Makefile variables
1.1       dsieger  4555: 
1.184     rillig   4556: Makefile variables contain strings that can be processed using the five
                   4557: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1       dsieger  4558: 
1.184     rillig   4559: When a variable's value is parsed from a Makefile, the hash character # and the
                   4560: backslash character \ are handled specially. If a backslash is the last
                   4561: character in a line, that backslash is removed from the line and the line
                   4562: continues with the next line of the file.
1.1       dsieger  4563: 
1.184     rillig   4564: The # character starts a comment that reaches until the end of the line. To get
                   4565: an actual # character, such as in a URL, write \# instead.
1.1       dsieger  4566: 
1.184     rillig   4567: The evaluation of variables either happens immediately or lazy. It happens
                   4568: immediately when the variable occurs on the right-hand side of the := or the !=
                   4569: operator, in a .if condition or a .for loop. In the other cases, it is
                   4570: evaluated lazily.
1.1       dsieger  4571: 
1.184     rillig   4572: Some of the modifiers split the string into words and then operate on the
                   4573: words, others operate on the string as a whole. When a string is split into
                   4574: words, double quotes and single quotes are interpreted as delimiters, just like
                   4575: in sh(1).
1.1       dsieger  4576: 
1.184     rillig   4577: 15.2.1. Naming conventions
1.1       dsieger  4578: 
1.184     rillig   4579:   * All variable names starting with an underscore are reserved for use by the
                   4580:     pkgsrc infrastructure. They shall not be used by packages.
1.1       dsieger  4581: 
1.184     rillig   4582:   * In .for loops you should use lowercase variable names for the iteration
                   4583:     variables.
1.1       dsieger  4584: 
1.184     rillig   4585:   * All list variables should have a plural name, such as PKG_OPTIONS or
                   4586:     DISTFILES.
1.1       dsieger  4587: 
1.184     rillig   4588: 15.3. Code snippets
1.1       dsieger  4589: 
1.184     rillig   4590: 15.3.1. Adding things to a list
1.1       dsieger  4591: 
1.184     rillig   4592: When adding a string that possibly contains whitespace or quotes to a list
                   4593: (example 1), it must be quoted using the :Q modifier.
1.1       dsieger  4594: 
1.184     rillig   4595: When adding another list to a list (example 2), it must not be quoted, since
                   4596: its elements are already quoted.
1.1       dsieger  4597: 
1.184     rillig   4598: STRING=         foo * bar `date`
                   4599: LIST=           # empty
                   4600: ANOTHER_LIST=   a=b c=d
1.1       dsieger  4601: 
1.184     rillig   4602: LIST+=          ${STRING:Q}       # 1
                   4603: LIST+=          ${ANOTHER_LIST}   # 2
1.1       dsieger  4604: 
1.184     rillig   4605: 15.3.2. Echoing a string exactly as-is
1.1       dsieger  4606: 
1.184     rillig   4607: Echoing a string containing special characters needs special work.
1.1       dsieger  4608: 
1.184     rillig   4609: STRING=         foo bar <    > * `date` $$HOME ' "
                   4610: EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
1.1       dsieger  4611: 
1.184     rillig   4612: all:
                   4613:         echo ${STRING}                  # 1
                   4614:         echo ${STRING:Q}                # 2
                   4615:         printf '%s\n' ${STRING:Q}''     # 3
                   4616:         env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
1.1       dsieger  4617: 
1.184     rillig   4618: Example 1 leads to a syntax error in the shell, as the characters are just
                   4619: copied.
1.1       dsieger  4620: 
1.184     rillig   4621: Example 2 quotes the string so that the shell interprets it correctly. But the
                   4622: echo command may additionally interpret strings with a leading dash or those
                   4623: containing backslashes.
1.1       dsieger  4624: 
1.184     rillig   4625: Example 3 can handle arbitrary strings, since printf(1) only interprets the
                   4626: format string, but not the next argument. The trailing single quotes handle the
                   4627: case when the string is empty. In that case, the :Q modifier would result in an
                   4628: empty string too, which would then be skipped by the shell. For printf(1) this
                   4629: doesn't make a difference, but other programs may care.
1.1       dsieger  4630: 
1.184     rillig   4631: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
                   4632: has already been done when adding elements to the list.
1.1       dsieger  4633: 
1.184     rillig   4634: 15.3.3. Passing CFLAGS to GNU configure scripts
1.1       dsieger  4635: 
1.184     rillig   4636: When passing CFLAGS or similar variables to a GNU-style configure script
                   4637: (especially those that call other configure scripts), it must not have leading
                   4638: or trailing whitespace, since otherwise the configure script gets confused. To
                   4639: trim leading and trailing whitespace, use the :M modifier, as in the following
                   4640: example:
1.1       dsieger  4641: 
1.184     rillig   4642: CPPFLAGS=               # empty
                   4643: CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
                   4644: CPPFLAGS+=              ${MY_CPPFLAGS}
1.1       dsieger  4645: 
1.184     rillig   4646: CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
1.1       dsieger  4647: 
1.184     rillig   4648: all:
                   4649:         echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   4650:         echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
1.1       dsieger  4651: 
1.184     rillig   4652: In this example, CPPFLAGS has both leading and trailing whitespace because the
                   4653: += operator always adds a space.
1.1       dsieger  4654: 
1.184     rillig   4655: 15.3.4. Handling possibly empty variables
1.1       dsieger  4656: 
1.184     rillig   4657: When a possibly empty variable is used in a shell program, it may lead to a
                   4658: syntax error.
1.1       dsieger  4659: 
1.184     rillig   4660: EGFILES=        # empty
1.1       dsieger  4661: 
1.184     rillig   4662: install-examples:   # produces a syntax error in the shell
                   4663:         for egfile in ${EGFILES}; do            \
                   4664:                 echo "Installing $$egfile";     \
                   4665:         done
1.1       dsieger  4666: 
1.184     rillig   4667: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
                   4668: with an empty string by make(1). To fix this syntax error, use one of the
                   4669: snippets below.
1.1       dsieger  4670: 
1.229     gutterid 4671: EGFILES=        # empty
1.1       dsieger  4672: 
1.184     rillig   4673: install-examples:
                   4674:         for egfile in ${EGFILES} ""; do         \
                   4675:                 [ -n "$$egfile" ] || continue;  \
                   4676:                 echo "Installing $$egfile";     \
                   4677:         done
1.1       dsieger  4678: 
1.184     rillig   4679: In this case, an empty string is appended to the iteration list (to prevent the
                   4680: syntax error) and filtered out later.
1.1       dsieger  4681: 
1.184     rillig   4682: EGFILES=        # empty
1.1       dsieger  4683: 
1.184     rillig   4684: install-examples:
                   4685: .for egfile in ${EGFILES}
                   4686:         echo "Installing ${egfile}"
                   4687: .endfor
1.1       dsieger  4688: 
1.184     rillig   4689: If one of the filenames contains special characters, it should be enclosed in
                   4690: single or double quotes.
1.1       dsieger  4691: 
1.184     rillig   4692: To have a shell command test whether a make variable is empty, use the
                   4693: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1       dsieger  4694: 
1.229     gutterid 4695: 15.3.5. Testing yes/no variables in conditions
                   4696: 
                   4697: When a variable can have the values yes or no, use the following pattern to
                   4698: test the variable:
                   4699: 
                   4700: .if ${VAR:U:tl} == "yes"
                   4701: # do something
                   4702: .endif
                   4703: 
                   4704: The :U modifier is only necessary if the variable can be undefined. If the
                   4705: variable is guaranteed to be defined, the :U can be omitted.
                   4706: 
                   4707: The :tl modifier converts the variable value to lowercase, allowing for the
                   4708: values yes, Yes, YES.
                   4709: 
1.184     rillig   4710: Chapter 16. Options handling
1.1       dsieger  4711: 
                   4712: Table of Contents
                   4713: 
1.184     rillig   4714: 16.1. Global default options
                   4715: 16.2. Converting packages to use bsd.options.mk
                   4716: 16.3. Option Names
                   4717: 16.4. Determining the options of dependencies
1.1       dsieger  4718: 
                   4719: Many packages have the ability to be built to support different sets of
                   4720: features. bsd.options.mk is a framework in pkgsrc that provides generic
                   4721: handling of those options that determine different ways in which the packages
                   4722: can be built. It's possible for the user to specify exactly which sets of
                   4723: options will be built into a package or to allow a set of global default
                   4724: options apply.
                   4725: 
1.7       rillig   4726: There are two broad classes of behaviors that one might want to control via
                   4727: options. One is whether some particular feature is enabled in a program that
                   4728: will be built anyway, often by including or not including a dependency on some
                   4729: other package. The other is whether or not an additional program will be built
                   4730: as part of the package. Generally, it is better to make a split package for
                   4731: such additional programs instead of using options, because it enables binary
                   4732: packages to be built which can then be added separately. For example, the foo
                   4733: package might have minimal dependencies (those packages without which foo
                   4734: doesn't make sense), and then the foo-gfoo package might include the GTK
                   4735: frontend program gfoo. This is better than including a gtk option to foo that
                   4736: adds gfoo, because either that option is default, in which case binary users
                   4737: can't get foo without gfoo, or not default, in which case they can't get gfoo.
                   4738: With split packages, they can install foo without having GTK, and later decide
                   4739: to install gfoo (pulling in GTK at that time). This is an advantage to source
                   4740: users too, avoiding the need for rebuilds.
                   4741: 
                   4742: Plugins with widely varying dependencies should usually be split instead of
                   4743: options.
                   4744: 
                   4745: It is often more work to maintain split packages, especially if the upstream
                   4746: package does not support this. The decision of split vs. option should be made
                   4747: based on the likelihood that users will want or object to the various pieces,
                   4748: the size of the dependencies that are included, and the amount of work.
                   4749: 
                   4750: A further consideration is licensing. Non-free parts, or parts that depend on
                   4751: non-free dependencies (especially plugins) should almost always be split if
                   4752: feasible.
                   4753: 
1.184     rillig   4754: 16.1. Global default options
1.1       dsieger  4755: 
                   4756: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
                   4757: the options that should be built into every package if that option is
1.4       rillig   4758: supported. This variable should be set in mk.conf.
1.1       dsieger  4759: 
1.184     rillig   4760: 16.2. Converting packages to use bsd.options.mk
1.1       dsieger  4761: 
                   4762: The following example shows how bsd.options.mk should be used by the
                   4763: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
                   4764: e.g. options.mk, that is included by the main package Makefile.
                   4765: 
                   4766: PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   4767: PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   4768: PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   4769: PKG_OPTIONS_GROUP.database=     mysql pgsql
                   4770: PKG_SUGGESTED_OPTIONS=          wibble-foo
                   4771: PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   4772: PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
                   4773: 
                   4774: .include "../../mk/bsd.prefs.mk"
                   4775: 
                   4776: # this package was previously named wibble2
                   4777: .if defined(PKG_OPTIONS.wibble2)
                   4778: PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   4779: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
                   4780:         "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
                   4781: .endif
                   4782: 
                   4783: .include "../../mk/bsd.options.mk"
                   4784: 
                   4785: # Package-specific option-handling
                   4786: 
                   4787: ###
                   4788: ### FOO support
                   4789: ###
                   4790: .if !empty(PKG_OPTIONS:Mwibble-foo)
                   4791: CONFIGURE_ARGS+=    --enable-foo
                   4792: .endif
                   4793: 
                   4794: ###
                   4795: ### LDAP support
                   4796: ###
                   4797: .if !empty(PKG_OPTIONS:Mldap)
                   4798: .  include "../../databases/openldap-client/buildlink3.mk"
                   4799: CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
                   4800: .endif
                   4801: 
                   4802: ###
                   4803: ### database support
                   4804: ###
                   4805: .if !empty(PKG_OPTIONS:Mmysql)
                   4806: .  include "../../mk/mysql.buildlink3.mk"
                   4807: .endif
                   4808: .if !empty(PKG_OPTIONS:Mpgsql)
                   4809: .  include "../../mk/pgsql.buildlink3.mk"
                   4810: .endif
                   4811: 
                   4812: The first section contains the information about which build options are
                   4813: supported by the package, and any default options settings if needed.
                   4814: 
                   4815:  1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
                   4816:     to override the default options. It should be set to PKG_OPTIONS.pkgbase.
                   4817:     Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
                   4818:     the point where the options are processed.
                   4819: 
                   4820:  2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
                   4821: 
                   4822:  3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
                   4823:     exclusive options. The options in each group are listed in
                   4824:     PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
                   4825:     the group takes precedence over all other options in the group. Options
                   4826:     from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
                   4827: 
                   4828:  4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
                   4829:     building the packages will fail if no option from the group is selected.
                   4830: 
                   4831:  5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
                   4832:     one option from each set must be selected. The options in each set are
                   4833:     listed in PKG_OPTIONS_SET.setname. Options from the sets will be
                   4834:     automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
                   4835:     fail if no option from the set is selected.
                   4836: 
                   4837:  6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
                   4838:     default.
                   4839: 
                   4840:  7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4       rillig   4841:     legacy mk.conf variables to their option counterparts. Pairs should be
1.1       dsieger  4842:     added with "+=" to keep the listing of global legacy variables. A warning
                   4843:     will be issued if the user uses a legacy variable.
                   4844: 
                   4845:  8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
                   4846:     options that have been renamed to their new counterparts. Pairs should be
                   4847:     added with "+=" to keep the listing of global legacy options. A warning
                   4848:     will be issued if the user uses a legacy option.
                   4849: 
                   4850:  9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
                   4851:     used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
                   4852:     PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
                   4853: 
                   4854: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
                   4855:     variables or options used, and what to use instead.
                   4856: 
                   4857: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
                   4858: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
                   4859: options, use PKG_SUGGESTED_OPTIONS.
                   4860: 
                   4861: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
                   4862: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
                   4863: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
                   4864: options if none of them is supported on the current platform), PKG_OPTIONS is
                   4865: set to the empty list and the package is otherwise treated as not using the
                   4866: options framework.
                   4867: 
                   4868: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
                   4869: list of selected build options, properly filtered to remove unsupported and
                   4870: duplicate options.
                   4871: 
                   4872: The remaining sections contain the logic that is specific to each option. The
                   4873: correct way to check for an option is to check whether it is listed in
                   4874: PKG_OPTIONS:
                   4875: 
                   4876: .if !empty(PKG_OPTIONS:Moption)
                   4877: 
1.184     rillig   4878: 16.3. Option Names
1.1       dsieger  4879: 
                   4880: Options that enable similar features in different packages (like optional
                   4881: support for a library) should use a common name in all packages that support it
                   4882: (like the name of the library). If another package already has an option with
                   4883: the same meaning, use the same name.
                   4884: 
                   4885: Options that enable features specific to one package, where it's unlikely that
                   4886: another (unrelated) package has the same (or a similar) optional feature,
                   4887: should use a name prefixed with pkgname-.
                   4888: 
                   4889: If a group of related packages share an optional feature specific to that
                   4890: group, prefix it with the name of the "main" package (e. g.
                   4891: djbware-errno-hack).
                   4892: 
                   4893: For new options, add a line to mk/defaults/options.description. Lines have two
                   4894: fields, separated by tab. The first field is the option name, the second its
                   4895: description. The description should be a whole sentence (starting with an
                   4896: uppercase letter and ending with a period) that describes what enabling the
                   4897: option does. E. g. "Enable ispell support." The file is sorted by option names.
                   4898: 
1.184     rillig   4899: 16.4. Determining the options of dependencies
1.7       rillig   4900: 
                   4901: When writing buildlink3.mk files, it is often necessary to list different
                   4902: dependencies based on the options with which the package was built. For
                   4903: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
                   4904: A typical example looks like this:
                   4905: 
                   4906: pkgbase := libpurple
                   4907: .include "../../mk/pkg-build-options.mk"
                   4908: 
                   4909: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
                   4910: ...
                   4911: .endif
                   4912: 
                   4913: Including pkg-build-options.mk here will set the variable
                   4914: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
                   4915: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
                   4916: pkg-build-options.mk for more details.
                   4917: 
1.184     rillig   4918: Chapter 17. Tools needed for building or running
                   4919: 
                   4920: Table of Contents
                   4921: 
                   4922: 17.1. Tools for pkgsrc builds
                   4923: 17.2. Tools needed by packages
                   4924: 17.3. Tools provided by platforms
                   4925: 
                   4926: The USE_TOOLS definition is used both internally by pkgsrc and also for
                   4927: individual packages to define what commands are needed for building a package
                   4928: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
                   4929: DEPENDS). If the native system provides an adequate tool, then in many cases, a
                   4930: pkgsrc package will not be used.
                   4931: 
                   4932: When building a package, the replacement tools are made available in a
                   4933: directory (as symlinks or wrapper scripts) that is early in the executable
                   4934: search path. Just like the buildlink system, this helps with consistent builds.
                   4935: 
                   4936: A tool may be needed to help build a specific package. For example, perl, GNU
                   4937: make (gmake) or yacc may be needed.
                   4938: 
                   4939: Also a tool may be needed, for example, because the native system's supplied
                   4940: tool may be inefficient for building a package with pkgsrc. For example, a
                   4941: package may need GNU awk, bison (instead of yacc) or a better sed.
                   4942: 
                   4943: The tools used by a package can be listed by running make show-tools.
                   4944: 
                   4945: 17.1. Tools for pkgsrc builds
                   4946: 
                   4947: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
                   4948: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
                   4949: seen by running: make show-var VARNAME=USE_TOOLS.
                   4950: 
                   4951: If a package needs a specific program to build then the USE_TOOLS variable can
                   4952: be used to define the tools needed.
                   4953: 
                   4954: 17.2. Tools needed by packages
                   4955: 
                   4956: In the following examples, the :run means that it is needed at run-time (and
                   4957: becomes a DEPENDS). The default is a build dependency which can be set with
                   4958: :build. (So in this example, it is the same as gmake:build and
                   4959: pkg-config:build.)
                   4960: 
                   4961: USE_TOOLS+=     gmake perl:run pkg-config
                   4962: 
                   4963: When using the tools framework, a TOOLS_PATH.foo variable is defined which
                   4964: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
                   4965: could be "/bin/bash" on Linux systems.
                   4966: 
                   4967: If you always need a pkgsrc version of the tool at run-time, then just use
                   4968: DEPENDS instead.
                   4969: 
                   4970: 17.3. Tools provided by platforms
                   4971: 
                   4972: When improving or porting pkgsrc to a new platform, have a look at (or create)
                   4973: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
                   4974: tools.${OPSYS}.mk which defines the name of the common tools. For example:
                   4975: 
                   4976: .if exists(/usr/bin/bzcat)
                   4977: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   4978: .elif exists(/usr/bin/bzip2)
                   4979: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   4980: .endif
                   4981: 
                   4982: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   4983: 
                   4984: Chapter 18. Buildlink methodology
1.1       dsieger  4985: 
                   4986: Table of Contents
                   4987: 
1.184     rillig   4988: 18.1. Converting packages to use buildlink3
                   4989: 18.2. Writing buildlink3.mk files
                   4990:     18.2.1. Anatomy of a buildlink3.mk file
                   4991:     18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.259     leot     4992:         buildlink3.mk files
1.184     rillig   4993: 18.3. Writing builtin.mk files
                   4994:     18.3.1. Anatomy of a builtin.mk file
                   4995: 
                   4996: Buildlink is a framework in pkgsrc that controls what headers and libraries are
                   4997: seen by a package's configure and build processes. This is implemented in a two
                   4998: step process:
                   4999: 
                   5000:  1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
                   5001:     default is a subdirectory of WRKDIR.
                   5002: 
                   5003:  2. Create wrapper scripts that are used in place of the normal compiler tools
                   5004:     that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
                   5005:     references to BUILDLINK_DIR. The wrapper scripts also make native compiler
                   5006:     on some operating systems look like GCC, so that packages that expect GCC
                   5007:     won't require modifications to build with those native compilers.
                   5008: 
                   5009: This normalizes the environment in which a package is built so that the package
                   5010: may be built consistently despite what other software may be installed. Please
                   5011: note that the normal system header and library paths, e.g. /usr/include, /usr/
                   5012: lib, etc., are always searched -- buildlink3 is designed to insulate the
                   5013: package build from non-system-supplied software.
                   5014: 
                   5015: 18.1. Converting packages to use buildlink3
1.1       dsieger  5016: 
1.184     rillig   5017: The process of converting packages to use the buildlink3 framework ("bl3ifying"
                   5018: ) is fairly straightforward. The things to keep in mind are:
1.1       dsieger  5019: 
1.184     rillig   5020:  1. Ensure that the build always calls the wrapper scripts instead of the
                   5021:     actual toolchain. Some packages are tricky, and the only way to know for
                   5022:     sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
                   5023:     invoked.
1.1       dsieger  5024: 
1.184     rillig   5025:  2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
                   5026:     standalone shells, etc., because the code to symlink files into $
                   5027:     {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
1.1       dsieger  5028: 
1.184     rillig   5029:  3. Remember that only the buildlink3.mk files that you list in a package's
                   5030:     Makefile are added as dependencies for that package.
1.1       dsieger  5031: 
1.184     rillig   5032: If a dependency on a particular package is required for its libraries and
                   5033: headers, then we replace:
1.1       dsieger  5034: 
1.184     rillig   5035: DEPENDS+=       foo>=1.1.0:../../category/foo
1.1       dsieger  5036: 
1.184     rillig   5037: with
1.1       dsieger  5038: 
1.184     rillig   5039: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5040: 
1.184     rillig   5041: The buildlink3.mk files usually define the required dependencies. If you need a
                   5042: newer version of the dependency when using buildlink3.mk files, then you can
                   5043: define it in your Makefile; for example:
1.1       dsieger  5044: 
1.184     rillig   5045: BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
                   5046: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5047: 
1.184     rillig   5048: There are several buildlink3.mk files in pkgsrc/mk that handle special package
                   5049: issues:
1.1       dsieger  5050: 
1.184     rillig   5051:   * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
                   5052:     implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
1.1       dsieger  5053: 
1.184     rillig   5054:   * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
                   5055:     this will take care to install the devel/ncurses package.
1.1       dsieger  5056: 
1.184     rillig   5057:   * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
                   5058:     a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
                   5059:     implementation.
1.1       dsieger  5060: 
1.184     rillig   5061:   * motif.buildlink3.mk checks for a system-provided Motif installation or adds
                   5062:     a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
                   5063:     dt", "lesstif" or "motif" to choose which Motif version will be used.
1.1       dsieger  5064: 
1.184     rillig   5065:   * readline.buildlink3.mk checks for a system-provided GNU readline or
                   5066:     editline (libedit) installation, or adds a dependency on devel/readline,
                   5067:     devel/editline. The user can set READLINE_DEFAULT to choose readline
                   5068:     implementation. If your package really needs GNU readline library, its
                   5069:     Makefile should include devel/readline/buildlink3.mk instead of
                   5070:     readline.buildlink3.mk.
1.1       dsieger  5071: 
1.184     rillig   5072:   * oss.buildlink3.mk defines several variables that may be used by packages
                   5073:     that use the Open Sound System (OSS) API.
1.1       dsieger  5074: 
1.184     rillig   5075:   * pgsql.buildlink3.mk will accept any of the Postgres versions in the
                   5076:     variable PGSQL_VERSIONS_ACCEPTED and default to the version
                   5077:     PGSQL_VERSION_DEFAULT. See the file for more information.
1.1       dsieger  5078: 
1.184     rillig   5079:   * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
                   5080:     pthreads or adds a dependency on devel/pth as needed.
1.1       dsieger  5081: 
1.184     rillig   5082:   * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
                   5083:     widgets library.
1.1       dsieger  5084: 
1.184     rillig   5085: The comments in those buildlink3.mk files provide a more complete description
                   5086: of how to use them properly.
1.1       dsieger  5087: 
1.184     rillig   5088: 18.2. Writing buildlink3.mk files
1.1       dsieger  5089: 
1.184     rillig   5090: A package's buildlink3.mk file is included by Makefiles to indicate the need to
                   5091: compile and link against header files and libraries provided by the package. A
                   5092: buildlink3.mk file should always provide enough information to add the correct
                   5093: type of dependency relationship and include any other buildlink3.mk files that
                   5094: it needs to find headers and libraries that it needs in turn.
1.1       dsieger  5095: 
1.184     rillig   5096: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
                   5097: pkgtools/createbuildlink package is highly recommended. For most packages, the
                   5098: following command will generate a good starting point for buildlink3.mk files:
1.1       dsieger  5099: 
1.184     rillig   5100: % cd pkgsrc/category/pkgdir
                   5101: % createbuildlink >buildlink3.mk
1.1       dsieger  5102: 
                   5103: 
1.184     rillig   5104: 18.2.1. Anatomy of a buildlink3.mk file
1.1       dsieger  5105: 
1.184     rillig   5106: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
                   5107: tiff:
1.14      jmcneill 5108: 
1.184     rillig   5109: BUILDLINK_TREE+=        tiff
1.1       dsieger  5110: 
1.184     rillig   5111: .if !defined(TIFF_BUILDLINK3_MK)
                   5112: TIFF_BUILDLINK3_MK:=
1.1       dsieger  5113: 
1.184     rillig   5114: BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
                   5115: BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
                   5116: BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
1.1       dsieger  5117: 
1.184     rillig   5118: .include "../../devel/zlib/buildlink3.mk"
                   5119: .include "../../graphics/jpeg/buildlink3.mk"
                   5120: .endif # TIFF_BUILDLINK3_MK
1.1       dsieger  5121: 
1.184     rillig   5122: BUILDLINK_TREE+=        -tiff
1.1       dsieger  5123: 
1.184     rillig   5124: The header and footer manipulate BUILDLINK_TREE, which is common across all
                   5125: buildlink3.mk files and is used to track the dependency tree.
1.1       dsieger  5126: 
1.184     rillig   5127: The main section is protected from multiple inclusion and controls how the
                   5128: dependency on pkg is added. Several important variables are set in the section:
1.1       dsieger  5129: 
1.185     wiz      5130:   * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
1.184     rillig   5131:     installed package; this should always be set using += to ensure that we're
                   5132:     appending to any pre-existing list of values. This variable should be set
1.185     wiz      5133:     to the last version of the package that had an backwards-incompatible API
1.184     rillig   5134:     change.
1.1       dsieger  5135: 
1.184     rillig   5136:   * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
1.1       dsieger  5137: 
1.184     rillig   5138:   * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
1.236     gutterid 5139:     BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
                   5140:     is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
                   5141:     full dependency is used.
1.1       dsieger  5142: 
1.184     rillig   5143:   * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
                   5144:     of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
                   5145:     library search paths. These default to "include" and "lib" respectively.
1.1       dsieger  5146: 
1.184     rillig   5147:   * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
                   5148:     to add to CPPFLAGS, which are passed on to the configure and build phases.
                   5149:     The "-I" option should be avoided and instead be handled using
                   5150:     BUILDLINK_INCDIRS.pkg as above.
1.66      asau     5151: 
1.184     rillig   5152: The following variables are all optionally defined within this second section
                   5153: (protected against multiple inclusion) and control which package files are
                   5154: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
                   5155: symlinking:
1.23      jakllsch 5156: 
1.184     rillig   5157:   * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
                   5158:     {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
                   5159:     *.h.
1.1       dsieger  5160: 
1.184     rillig   5161:   * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
                   5162:     to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
                   5163:     resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
                   5164:     takes the +CONTENTS of a pkg and filters it through $
                   5165:     {BUILDLINK_CONTENTS_FILTER.pkg}.
1.1       dsieger  5166: 
1.184     rillig   5167:   * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
                   5168:     filters +CONTENTS input into a list of files relative to $
                   5169:     {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
                   5170:     outputs the contents of the include and lib directories in the package
                   5171:     +CONTENTS.
1.1       dsieger  5172: 
1.184     rillig   5173:   * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
                   5174:     used to transform the name of the source filename into a destination
                   5175:     filename, e.g. -e "s|/curses.h|/ncurses.h|g".
1.1       dsieger  5176: 
1.184     rillig   5177: This section can additionally include any buildlink3.mk needed for pkg's
                   5178: library dependencies. Including these buildlink3.mk files means that the
                   5179: headers and libraries for these dependencies are also symlinked into $
                   5180: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
                   5181: are only added for directly include buildlink3.mk files.
1.1       dsieger  5182: 
1.184     rillig   5183: When providing a buildlink3.mk and including other buildlink3.mk files in it,
                   5184: please only add necessary ones, i.e., those whose libraries or header files are
                   5185: automatically exposed when the package is use.
1.1       dsieger  5186: 
1.184     rillig   5187: In particular, if only an executable (bin/foo) is linked against a library,
                   5188: that library does not need to be propagated in the buildlink3.mk file.
1.1       dsieger  5189: 
1.184     rillig   5190: The following steps should help you decide if a buildlink3.mk file needs to be
                   5191: included:
1.1       dsieger  5192: 
1.184     rillig   5193:   * Look at the installed header files: What headers do they include? The
                   5194:     packages providing these files must be buildlinked.
1.1       dsieger  5195: 
1.184     rillig   5196:   * Run ldd on all installed libraries and look against what other libraries
                   5197:     they link. Some of the packages providing these probably need to be
                   5198:     buildlinked; however, it's not automatic, since e.g. GTK on some systems
                   5199:     pulls in the X libraries, so they will show up in the ldd output, while on
                   5200:     others (like OS X) it won't. ldd output can thus only be used as a hint.
1.1       dsieger  5201: 
1.184     rillig   5202: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
                   5203: buildlink3.mk files
1.16      jnemeth  5204: 
1.185     wiz      5205: Both variables set lower bounds for a version of this package. The two
                   5206: variables differ in that one describes source compatibility (API) and the other
                   5207: binary compatibility (ABI). The difference is that a change in the API breaks
                   5208: compilation of programs while changes in the ABI stop compiled programs from
                   5209: running.
                   5210: 
                   5211: The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
                   5212: very rarely. (One possible scenario: If all packages using this package need a
                   5213: higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
                   5214: could be updated to that higher version.)
                   5215: 
                   5216: On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
                   5217: variable will need to be updated every time the major version of one of its
                   5218: shared libraries is changed, or any other change where a binary built against
                   5219: the previous version of the package will not run against the new version any
                   5220: longer.
                   5221: 
                   5222: In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
                   5223: require the new package version. Then the PKGREVISION of all packages foo that
                   5224: depend on this package need to be increased, and if they have buildlink3.mk
                   5225: files, BUILDLINK_ABI_DEPENDS.foo in their buildlink3.mk files must be increased
                   5226: to the new version as well. This is required so that a package will pull in the
                   5227: versions of the packages that use the new ABI and that the packages'
                   5228: PKGREVISIONs uniquely identify the packages built against the new ABI. The
                   5229: pkgtools/revbump package can help with these updates.
1.1       dsieger  5230: 
1.184     rillig   5231: See Section 21.1.5, "Handling dependencies" for more information about
1.185     wiz      5232: dependencies on other packages, including the BUILDLINK_API_DEPENDS
                   5233: definitions.
1.1       dsieger  5234: 
1.184     rillig   5235: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
1.185     wiz      5236: BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
                   5237: unneeded package deletions and rebuilds. In many cases, new versions of
                   5238: packages work just fine with older dependencies.
1.1       dsieger  5239: 
1.211     gutterid 5240: Also, it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
1.184     rillig   5241: BUILDLINK_API_DEPENDS.pkg.
1.1       dsieger  5242: 
1.211     gutterid 5243: Note there is also the distinction that users are able to disable enforcement
                   5244: of ABI dependencies using the USE_ABI_DEPENDS variable, but there is no
                   5245: equivalent option for API dependencies.
                   5246: 
1.184     rillig   5247: 18.3. Writing builtin.mk files
1.1       dsieger  5248: 
1.184     rillig   5249: Some packages in pkgsrc install headers and libraries that coincide with
                   5250: headers and libraries present in the base system. Aside from a buildlink3.mk
                   5251: file, these packages should also include a builtin.mk file that includes the
                   5252: necessary checks to decide whether using the built-in software or the pkgsrc
                   5253: software is appropriate.
1.1       dsieger  5254: 
1.184     rillig   5255: The only requirements of a builtin.mk file for pkg are:
1.1       dsieger  5256: 
1.184     rillig   5257:  1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
1.1       dsieger  5258: 
1.184     rillig   5259:  2. It should not override any USE_BUILTIN.pkg which is already set before the
                   5260:     builtin.mk file is included.
1.1       dsieger  5261: 
1.184     rillig   5262:  3. It should be written to allow multiple inclusion. This is very important
                   5263:     and takes careful attention to Makefile coding.
1.1       dsieger  5264: 
1.184     rillig   5265: 18.3.1. Anatomy of a builtin.mk file
1.1       dsieger  5266: 
1.184     rillig   5267: The following is the recommended template for builtin.mk files:
1.1       dsieger  5268: 
1.184     rillig   5269: .if !defined(IS_BUILTIN.foo)
                   5270: #
                   5271: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   5272: # genuinely exists in the system or not.
                   5273: #
                   5274: IS_BUILTIN.foo?=        no
1.1       dsieger  5275: 
1.184     rillig   5276: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   5277: # version can be determined.
                   5278: #
                   5279: .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   5280: BUILTIN_PKG.foo?=       foo-1.0
                   5281: .  endif
                   5282: .endif  # IS_BUILTIN.foo
1.1       dsieger  5283: 
1.184     rillig   5284: .if !defined(USE_BUILTIN.foo)
                   5285: USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   5286: .  if defined(BUILTIN_PKG.foo)
                   5287: .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   5288: .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   5289: USE_BUILTIN.foo!=                                                       \
                   5290:         ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
                   5291:         && ${ECHO} "yes" || ${ECHO} "no"
                   5292: .      endif
                   5293: .    endfor
                   5294: .  endif
                   5295: .endif  # USE_BUILTIN.foo
1.1       dsieger  5296: 
1.184     rillig   5297: CHECK_BUILTIN.foo?=     no
                   5298: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   5299: #
                   5300: # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   5301: # "yes" or "no".
                   5302: #
                   5303: .endif  # CHECK_BUILTIN.foo
1.1       dsieger  5304: 
1.184     rillig   5305: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
                   5306: base system. This should not be a base system software with similar
                   5307: functionality to pkg; it should only be "yes" if the actual package is included
                   5308: as part of the base system. This variable is only used internally within the
                   5309: builtin.mk file.
1.1       dsieger  5310: 
1.184     rillig   5311: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
                   5312: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
                   5313: internally within the builtin.mk file.
1.1       dsieger  5314: 
1.184     rillig   5315: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
                   5316: The code in this section must make the determination whether the built-in
                   5317: software is adequate to satisfy the dependencies listed in
                   5318: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
                   5319: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg 
                   5320: must be set to the correct value by the end of the builtin.mk file. Note that
                   5321: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
                   5322: the determination that the built-in version of the software is similar enough
                   5323: to be used as a replacement.
1.1       dsieger  5324: 
1.184     rillig   5325: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
                   5326: the value of USE_BUILTIN.pkg set in the previous section. This typically
                   5327: includes, e.g., adding additional dependency restrictions and listing
                   5328: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
1.1       dsieger  5329: 
1.184     rillig   5330: Chapter 19. PLIST issues
1.1       dsieger  5331: 
1.184     rillig   5332: Table of Contents
1.1       dsieger  5333: 
1.184     rillig   5334: 19.1. RCS ID
                   5335: 19.2. Semi-automatic PLIST generation
                   5336: 19.3. Tweaking output of make print-PLIST
                   5337: 19.4. Variable substitution in PLIST
                   5338: 19.5. Man page compression
                   5339: 19.6. Changing PLIST source with PLIST_SRC
                   5340: 19.7. Platform-specific and differing PLISTs
                   5341: 19.8. Build-specific PLISTs
                   5342: 19.9. Sharing directories between packages
1.1       dsieger  5343: 
1.184     rillig   5344: The PLIST file contains a package's "packing list", i.e. a list of files that
                   5345: belong to the package (relative to the ${PREFIX} directory it's been installed
                   5346: in) plus some additional statements - see the pkg_create(1) man page for a full
                   5347: list. This chapter addresses some issues that need attention when dealing with
                   5348: the PLIST file (or files, see below!).
1.1       dsieger  5349: 
1.184     rillig   5350: 19.1. RCS ID
1.1       dsieger  5351: 
1.184     rillig   5352: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
1.1       dsieger  5353: 
1.184     rillig   5354: @comment $NetBSD $
1.1       dsieger  5355: 
1.184     rillig   5356: An artificial space has been added between NetBSD and $, this is a workaround
                   5357: here to prevent CVS expanding to the filename of the guide. When adding the RCS
                   5358: ID the space should be omitted.
1.38      wiz      5359: 
1.184     rillig   5360: 19.2. Semi-automatic PLIST generation
1.1       dsieger  5361: 
1.184     rillig   5362: You can use the make print-PLIST command to output a PLIST that matches any new
                   5363: files since the package was extracted. See Section 13.17, "Other helpful
                   5364: targets" for more information on this target.
1.11      rillig   5365: 
1.184     rillig   5366: 19.3. Tweaking output of make print-PLIST
1.1       dsieger  5367: 
1.184     rillig   5368: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
                   5369: used to filter the output of print-PLIST. You can append any chunk of AWK
                   5370: scripting you like to it, but be careful with quoting.
1.1       dsieger  5371: 
1.184     rillig   5372: For example, to get all files inside the libdata/foo directory removed from the
                   5373: resulting PLIST:
1.1       dsieger  5374: 
1.184     rillig   5375: PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
1.1       dsieger  5376: 
1.185     wiz      5377: The PRINT_PLIST_AWK transformations are evaluated after the file list and
                   5378: directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
                   5379: it operates before the file list and directory list are sorted.
                   5380: 
1.184     rillig   5381: 19.4. Variable substitution in PLIST
1.1       dsieger  5382: 
1.184     rillig   5383: A number of variables are substituted automatically in PLISTs when a package is
                   5384: installed on a system. This includes the following variables:
1.1       dsieger  5385: 
1.184     rillig   5386: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
1.1       dsieger  5387: 
1.184     rillig   5388:     Some packages like emacs and perl embed information about which
                   5389:     architecture they were built on into the pathnames where they install their
                   5390:     files. To handle this case, PLIST will be preprocessed before actually
                   5391:     used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
                   5392:     gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
                   5393:     PLIST somewhere - use this on packages that have GNU autoconf-created
                   5394:     configure scripts.
1.1       dsieger  5395: 
1.184     rillig   5396:     Legacy note
1.1       dsieger  5397: 
1.184     rillig   5398:     There used to be a symbol "$ARCH" that was replaced by the output of uname
                   5399:     -m, but that's no longer supported and has been removed.
1.1       dsieger  5400: 
1.184     rillig   5401: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
1.1       dsieger  5402: 
1.184     rillig   5403:     Some packages want to embed the OS name and version into some paths. To do
                   5404:     this, use these variables in the PLIST:
1.1       dsieger  5405: 
1.259     leot     5406:       + ${OPSYS} - output of "uname -s"
1.1       dsieger  5407: 
1.259     leot     5408:       + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1       dsieger  5409: 
1.259     leot     5410:       + ${OS_VERSION} - "uname -r"
1.1       dsieger  5411: 
1.184     rillig   5412: For a list of values which are replaced by default, the output of make help
                   5413: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
                   5414: PLIST_SUBST should help.
1.1       dsieger  5415: 
1.184     rillig   5416: If you want to change other variables not listed above, you can add variables
                   5417: and their expansions to this variable in the following way, similar to
                   5418: MESSAGE_SUBST (see Section 12.5, "Optional files"):
1.1       dsieger  5419: 
1.184     rillig   5420: PLIST_SUBST+=   SOMEVAR="somevalue"
1.1       dsieger  5421: 
1.184     rillig   5422: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
1.1       dsieger  5423: 
1.184     rillig   5424: The PLIST_VARS variable can be used to simplify the common case of
                   5425: conditionally including some PLIST entries. It can be done by adding
                   5426: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
                   5427: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
                   5428: either """" or ""@comment "". For example, in Makefile:
1.1       dsieger  5429: 
1.184     rillig   5430: PLIST_VARS+=    foo
                   5431: .if condition
                   5432: PLIST.foo=      yes
                   5433: .else
1.1       dsieger  5434: 
1.184     rillig   5435: And then in PLIST:
1.1       dsieger  5436: 
1.184     rillig   5437: @comment $NetBSD $
                   5438: bin/bar
                   5439: man/man1/bar.1
                   5440: ${PLIST.foo}bin/foo
                   5441: ${PLIST.foo}man/man1/foo.1
                   5442: ${PLIST.foo}share/bar/foo.data
1.1       dsieger  5443: 
1.184     rillig   5444: An artificial space has been added between NetBSD and $, this is a workaround
                   5445: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.195     gutterid 5446: ID the space should be omitted.
1.1       dsieger  5447: 
1.184     rillig   5448: 19.5. Man page compression
1.1       dsieger  5449: 
1.184     rillig   5450: Man pages should be installed in compressed form if MANZ is set (in
                   5451: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
                   5452: suffix ".gz" is appended/removed automatically for man pages according to MANZ
                   5453: and MANCOMPRESSED being set or not, see above for details. This modification of
                   5454: the PLIST file is done on a copy of it, not PLIST itself.
1.100     leot     5455: 
1.184     rillig   5456: 19.6. Changing PLIST source with PLIST_SRC
1.100     leot     5457: 
1.184     rillig   5458: To use one or more files as source for the PLIST used in generating the binary
                   5459: package, set the variable PLIST_SRC to the names of that file(s). The files are
                   5460: later concatenated using cat(1), and the order of things is important. The
                   5461: default for PLIST_SRC is ${PKGDIR}/PLIST.
1.1       dsieger  5462: 
1.184     rillig   5463: 19.7. Platform-specific and differing PLISTs
1.1       dsieger  5464: 
1.184     rillig   5465: Some packages decide to install a different set of files based on the operating
                   5466: system being used. These differences can be automatically handled by using the
                   5467: following files:
1.1       dsieger  5468: 
1.184     rillig   5469:   * PLIST.common
1.1       dsieger  5470: 
1.184     rillig   5471:   * PLIST.${OPSYS}
1.1       dsieger  5472: 
1.184     rillig   5473:   * PLIST.${MACHINE_ARCH}
1.1       dsieger  5474: 
1.184     rillig   5475:   * PLIST.${OPSYS}-${MACHINE_ARCH}
1.1       dsieger  5476: 
1.184     rillig   5477:   * PLIST.common_end
1.1       dsieger  5478: 
1.184     rillig   5479: 19.8. Build-specific PLISTs
1.1       dsieger  5480: 
1.184     rillig   5481: Some packages decide to generate hard-to-guess file names during installation
                   5482: that are hard to wire down.
1.1       dsieger  5483: 
1.184     rillig   5484: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
                   5485: (with a semicolon) that will output PLIST entries which will be appended to the
                   5486: PLIST
1.1       dsieger  5487: 
1.184     rillig   5488: You can find one example in editors/xemacs:
1.1       dsieger  5489: 
1.184     rillig   5490: GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.1       dsieger  5491: 
1.184     rillig   5492: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
1.1       dsieger  5493: 
1.184     rillig   5494: 19.9. Sharing directories between packages
1.1       dsieger  5495: 
1.184     rillig   5496: A "shared directory" is a directory where multiple (and unrelated) packages
                   5497: install files. These directories were problematic because you had to add
                   5498: special tricks in the PLIST to conditionally remove them, or have some
                   5499: centralized package handle them.
1.106     tnn      5500: 
1.184     rillig   5501: In pkgsrc, it is now easy: Each package should create directories and install
                   5502: files as needed; pkg_delete will remove any directories left empty after
                   5503: uninstalling a package.
1.106     tnn      5504: 
1.184     rillig   5505: If a package needs an empty directory to work, create the directory during
                   5506: installation as usual, and also add an entry to the PLIST:
1.1       dsieger  5507: 
1.184     rillig   5508: @pkgdir path/to/empty/directory
1.1       dsieger  5509: 
1.184     rillig   5510: or take a look at MAKE_DIRS and OWN_DIRS.
1.1       dsieger  5511: 
1.184     rillig   5512: Chapter 20. The pkginstall framework
1.1       dsieger  5513: 
1.184     rillig   5514: Table of Contents
1.1       dsieger  5515: 
1.184     rillig   5516: 20.1. Files and directories outside the installation prefix
                   5517:     20.1.1. Directory manipulation
                   5518:     20.1.2. File manipulation
                   5519: 20.2. Configuration files
                   5520:     20.2.1. How PKG_SYSCONFDIR is set
                   5521:     20.2.2. Telling the software where configuration files are
1.239     dholland 5522:     20.2.3. Patching installation
                   5523:     20.2.4. Declaring configuration files
                   5524:     20.2.5. Disabling handling of configuration files
1.184     rillig   5525: 20.3. System startup scripts
                   5526:     20.3.1. Disabling handling of system startup scripts
                   5527: 20.4. System users and groups
                   5528: 20.5. System shells
                   5529:     20.5.1. Disabling shell registration
                   5530: 20.6. Fonts
                   5531:     20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  5532: 
1.184     rillig   5533: This chapter describes the framework known as pkginstall, whose key features
                   5534: are:
1.1       dsieger  5535: 
1.184     rillig   5536:   * Generic installation and manipulation of directories and files outside the
                   5537:     pkgsrc-handled tree, LOCALBASE.
1.1       dsieger  5538: 
1.184     rillig   5539:   * Automatic handling of configuration files during installation, provided
                   5540:     that packages are correctly designed.
1.1       dsieger  5541: 
1.184     rillig   5542:   * Generation and installation of system startup scripts.
1.1       dsieger  5543: 
1.184     rillig   5544:   * Registration of system users and groups.
1.1       dsieger  5545: 
1.184     rillig   5546:   * Registration of system shells.
1.1       dsieger  5547: 
1.184     rillig   5548:   * Automatic updating of fonts databases.
1.1       dsieger  5549: 
1.184     rillig   5550: The following sections inspect each of the above points in detail.
1.1       dsieger  5551: 
1.184     rillig   5552: You may be thinking that many of the things described here could be easily done
                   5553: with simple code in the package's post-installation target (post-install). This
                   5554: is incorrect, as the code in them is only executed when building from source.
                   5555: Machines using binary packages could not benefit from it at all (as the code
                   5556: itself could be unavailable). Therefore, the only way to achieve any of the
                   5557: items described above is by means of the installation scripts, which are
                   5558: automatically generated by pkginstall.
1.1       dsieger  5559: 
1.184     rillig   5560: 20.1. Files and directories outside the installation prefix
1.95      wiz      5561: 
1.184     rillig   5562: As you already know, the PLIST file holds a list of files and directories that
                   5563: belong to a package. The names used in it are relative to the installation
                   5564: prefix (${PREFIX}), which means that it cannot register files outside this
                   5565: directory (absolute path names are not allowed). Despite this restriction, some
                   5566: packages need to install files outside this location; e.g., under ${VARBASE} or
                   5567: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
                   5568: installation time by using installation scripts.
1.95      wiz      5569: 
1.184     rillig   5570: The generic installation scripts are shell scripts that can contain arbitrary
                   5571: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
                   5572: which defaults to INSTALL. A similar variable exists for package removal
                   5573: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
                   5574: commands, so they have the potential to create and manage files anywhere in the
                   5575: file system.
1.95      wiz      5576: 
1.184     rillig   5577: Using these general installation files is not recommended, but may be needed in
                   5578: some special cases. One reason for avoiding them is that the user has to trust
                   5579: the packager that there is no unwanted or simply erroneous code included in the
                   5580: installation script. Also, previously there were many similar scripts for the
                   5581: same functionality, and fixing a common error involved finding and changing all
                   5582: of them.
1.95      wiz      5583: 
1.184     rillig   5584: The pkginstall framework offers another, standardized way. It provides generic
                   5585: scripts to abstract the manipulation of such files and directories based on
                   5586: variables set in the package's Makefile. The rest of this section describes
                   5587: these variables.
1.1       dsieger  5588: 
1.184     rillig   5589: 20.1.1. Directory manipulation
1.1       dsieger  5590: 
1.184     rillig   5591: The following variables can be set to request the creation of directories
                   5592: anywhere in the file system:
1.1       dsieger  5593: 
1.184     rillig   5594:   * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
                   5595:     and should attempt to be destroyed by the installation scripts. The
                   5596:     difference between the two is that the latter prompts the administrator to
                   5597:     remove any directories that may be left after deinstallation (because they
                   5598:     were not empty), while the former does not. Example:
1.1       dsieger  5599: 
1.184     rillig   5600:     MAKE_DIRS+=             ${VARBASE}/foo/private
1.1       dsieger  5601: 
1.184     rillig   5602:   * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
                   5603:     which directories should be created and should attempt to be destroyed by
                   5604:     the installation scripts. Each tuple holds the following values, separated
                   5605:     by spaces: the directory name, its owner, its group and its numerical mode.
                   5606:     For example:
1.1       dsieger  5607: 
1.184     rillig   5608:     MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
                   5609:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5610: 
1.184     rillig   5611:     The difference between the two is exactly the same as their non-PERMS
                   5612:     counterparts.
1.1       dsieger  5613: 
1.184     rillig   5614: 20.1.2. File manipulation
1.1       dsieger  5615: 
1.184     rillig   5616: Creating non-empty files outside the installation prefix is tricky because the
                   5617: PLIST forces all files to be inside it. To overcome this problem, the only
1.239     dholland 5618: solution is to extract the file in a known place (i.e., inside the installation
                   5619: prefix) and copy it to the appropriate location during installation (done by
                   5620: the installation scripts generated by pkginstall). We will call the former the 
                   5621: reference file in the following paragraphs, which describe the variables that
                   5622: can be used to automatically and consistently handle files outside the
                   5623: installation prefix:
                   5624: 
                   5625:   * REQD_FILES is a list of pairs of reference and target files. At
                   5626:     installation time, the reference file is copied to the target if and only
                   5627:     if the latter does not exist. Upon deinstallation, the reference file is
1.184     rillig   5628:     removed provided that it was not modified by the installation.
1.1       dsieger  5629: 
1.239     dholland 5630:   * REQD_FILES_PERMS contains tuples describing reference files and targets,
                   5631:     including owner, group, and numeric permissions that should be set. For
                   5632:     example:
1.1       dsieger  5633: 
1.184     rillig   5634:     REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
                   5635:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5636: 
1.239     dholland 5637:   * CONF_FILES and CONF_FILES_PERMS have the same syntax as REQD_FILES and
                   5638:     REQD_FILES_PERMS respectively. The difference is that these variables are
                   5639:     specifically intended for handling configuration files, for which
                   5640:     additional conventions and constraints apply. See Section 20.2,
                   5641:     "Configuration files" for further discussion. Note in particular that while
                   5642:     handling of configuration files can be disabled by the user (see
                   5643:     Section 20.2.5, "Disabling handling of configuration files"), this setting
                   5644:     does not affect REQD_FILES and REQD_FILES_PERMS.
                   5645: 
                   5646: To install an empty file, one can use these macros and /dev/null as the
                   5647: reference file.
1.1       dsieger  5648: 
1.184     rillig   5649: 20.2. Configuration files
1.1       dsieger  5650: 
1.239     dholland 5651: There are two principles that govern the handling of configuration files in
                   5652: pkgsrc: first, the user's configuration must not be lost or overwritten by
                   5653: upgrades or reinstallations; and second, the default configuration should
                   5654: always be available for reference. To that end, pkgsrc has a framework
                   5655: specifically for handling configuration files. In general, configuration files
                   5656: are installed into ${PREFIX}/share/examples, and copied from there to the
                   5657: pertinent etc directory as a separate step and only as needed.
                   5658: 
                   5659: To make this work, there are three things that need to happen, any of which may
                   5660: require patching. First, the package must be told to read its configuration
                   5661: from the correct place at runtime; this place is ${PKG_SYSCONFDIR} (or possibly
                   5662: a subdirectory of it) which is often but not always ${PREFIX}/etc. Second, the
                   5663: package must be taught to install its default configuration files in ${PREFIX}/
                   5664: share/examples/${PKGBASE}; this is the point at which patching often becomes
                   5665: required because it is not the same place as the runtime location. Third, the
                   5666: configuration files need to be declared in the package makefile; this is the
                   5667: easy part.
                   5668: 
                   5669: With those elements in place, the right things will happen: the package install
                   5670: phase and resulting binary package will not touch ${PKG_SYSCONFDIR}, and the
                   5671: default configuration will be copied into place by the pkgsrc framework only if
                   5672: not already present. Similarly, upon deinstall the configuration will not be
                   5673: removed if it has been modified. (This means that in the case of reinstallation
                   5674: and upgrades, unmodified configuration files are updated but modifications are
                   5675: never discarded.)
                   5676: 
                   5677: The following sections describe how to make these things happen and document
                   5678: other relevant knobs available in the pkgsrc infrastructure.
1.1       dsieger  5679: 
1.184     rillig   5680: 20.2.1. How PKG_SYSCONFDIR is set
1.1       dsieger  5681: 
1.184     rillig   5682: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
                   5683: shall be installed. Its contents are set based upon the following variables:
1.1       dsieger  5684: 
1.184     rillig   5685:   * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
1.239     dholland 5686:     etc although it may be overridden by the user to point to their preferred
1.184     rillig   5687:     location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
1.1       dsieger  5688: 
1.184     rillig   5689:   * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
                   5690:     configuration files for the package being built shall be installed. The
                   5691:     definition of this variable only makes sense in the package's Makefile
                   5692:     (i.e., it is not user-customizable).
1.1       dsieger  5693: 
1.184     rillig   5694:     As an example, consider the Apache package, www/apache24, which places its
                   5695:     configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
                   5696:     should be set in the package Makefile.
1.1       dsieger  5697: 
1.184     rillig   5698:   * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
                   5699:     package's configuration directory (if different from PKG_SYSCONFBASE). It
                   5700:     defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
1.1       dsieger  5701: 
1.184     rillig   5702:   * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
                   5703:     configuration files for the package identified by PKG_SYSCONFVAR's shall be
                   5704:     placed.
1.1       dsieger  5705: 
1.184     rillig   5706: Based on the above variables, pkginstall determines the value of
1.239     dholland 5707: PKG_SYSCONFDIR, which is the only variable that may be used within a package to
1.184     rillig   5708: refer to its configuration directory. The algorithm used to set its value is
                   5709: basically the following:
1.1       dsieger  5710: 
1.184     rillig   5711:  1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
1.1       dsieger  5712: 
1.184     rillig   5713:  2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
                   5714:     package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
                   5715:     {PKG_SYSCONFSUBDIR}.
1.1       dsieger  5716: 
1.184     rillig   5717:  3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
1.1       dsieger  5718: 
1.184     rillig   5719: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.239     dholland 5720: OWN_DIRS. This causes it to be automatically created if needed. See
                   5721: Section 20.1.1, "Directory manipulation" for further details. This does not
                   5722: apply to subdirectories of ${PKG_SYSCONFDIR}; they must be manually created
                   5723: with OWN_DIRS or MAKE_DIRS.
1.1       dsieger  5724: 
1.184     rillig   5725: 20.2.2. Telling the software where configuration files are
1.1       dsieger  5726: 
1.184     rillig   5727: Given that pkgsrc (and users!) expect configuration files to be in a known
1.239     dholland 5728: place, you need to teach each package where to install its files. In some cases
                   5729: you will have to patch the package Makefiles to achieve it. If you are lucky,
                   5730: though, it may be as easy as passing an extra flag to the configuration script.
                   5731: This is the case for packages using GNU autoconf:
1.1       dsieger  5732: 
1.184     rillig   5733: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1       dsieger  5734: 
1.184     rillig   5735: Note that this specifies where the package has to look for its configuration
1.239     dholland 5736: files, not where they will be installed. Fortunately, there is a different way
1.240     gutterid 5737: to specify the latter, as seen in the next section, although the combination is
                   5738: rather confusing at first glance.
1.1       dsieger  5739: 
1.239     dholland 5740: 20.2.3. Patching installation
1.1       dsieger  5741: 
1.239     dholland 5742: As discussed above, packages themselves must not touch the contents of $
1.184     rillig   5743: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
                   5744: will, out of the box, mess with the contents of that directory. So what is the
                   5745: correct procedure to fix this issue?
1.1       dsieger  5746: 
1.184     rillig   5747: You must teach the package (usually by manually patching it) to install any
                   5748: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
                   5749: This way, the PLIST registers them and the administrator always has the
                   5750: original copies available.
1.1       dsieger  5751: 
1.239     dholland 5752: It turns out that for packages using GNU autoconf it is possible to create the
                   5753: desired effect by setting sysconfdir on the make command line at install time.
                   5754: Consider this example taken from mail/mutt:
                   5755: 
                   5756: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5757: INSTALL_MAKE_FLAGS=     ${MAKE_FLAGS} sysconfdir=${EGDIR}
                   5758: 
                   5759: Note that the EGDIR variable, though commonly used for this purpose, is local
                   5760: to that package and has no meaning outside it.
1.1       dsieger  5761: 
1.239     dholland 5762: 20.2.4. Declaring configuration files
1.1       dsieger  5763: 
1.239     dholland 5764: Once the required configuration files are in place (i.e., under the examples
                   5765: hierarchy), the pkginstall framework can use them as reference copies during
                   5766: the package installation to update what is in ${PKG_SYSCONFDIR}. To achieve
                   5767: this, the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
                   5768: Section 20.1.2, "File manipulation" for further information about their syntax
                   5769: and their purpose. Here is an example, taken from the mail/mutt package:
                   5770: 
                   5771: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5772: CONF_FILES=             ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
                   5773: 
                   5774: Note that (as in the previous section's example) the EGDIR variable is specific
                   5775: to the package and has no meaning outside it.
                   5776: 
                   5777: For reference, the complete example from Mutt is as follows:
                   5778: 
                   5779: CONFIGURE_ARGS+=        --sysconfdir=${PKG_SYSCONFDIR}
                   5780: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5781: CONF_FILES=             ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
                   5782: INSTALLATION_DIRS+=     ${EGDIR}
                   5783: INSTALL_MAKE_FLAGS=     ${MAKE_FLAGS} sysconfdir=${EGDIR}
1.1       dsieger  5784: 
1.239     dholland 5785: 20.2.5. Disabling handling of configuration files
1.1       dsieger  5786: 
1.184     rillig   5787: The automatic copying of config files can be toggled by setting the environment
                   5788: variable PKG_CONFIG prior to package installation.
1.1       dsieger  5789: 
1.184     rillig   5790: 20.3. System startup scripts
1.1       dsieger  5791: 
1.184     rillig   5792: System startup scripts are special files because they must be installed in a
                   5793: place known by the underlying OS, usually outside the installation prefix.
                   5794: Therefore, the same rules described in Section 20.1, "Files and directories
                   5795: outside the installation prefix" apply, and the same solutions can be used.
                   5796: However, pkginstall provides a special mechanism to handle these files.
1.1       dsieger  5797: 
1.184     rillig   5798: In order to provide system startup scripts, the package has to:
1.1       dsieger  5799: 
1.184     rillig   5800:  1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
1.223     nia      5801:     Considering the print/cups-base package as an example, it has a cupsd.sh in
                   5802:     its files directory.
1.95      wiz      5803: 
1.184     rillig   5804:  2. Tell pkginstall to handle it, appending the name of the script, without its
                   5805:     extension, to the RCD_SCRIPTS variable. Continuing the previous example:
1.95      wiz      5806: 
1.184     rillig   5807:     RCD_SCRIPTS+=   cupsd
1.95      wiz      5808: 
1.184     rillig   5809: Once this is done, pkginstall will do the following steps for each script in an
                   5810: automated fashion:
1.95      wiz      5811: 
1.184     rillig   5812:  1. Process the file found in the files directory applying all the
                   5813:     substitutions described in the FILES_SUBST variable.
1.1       dsieger  5814: 
1.184     rillig   5815:  2. Copy the script from the files directory to the examples hierarchy, $
1.239     dholland 5816:     {PREFIX}/share/examples/rc.d/. Note that this reference file must be
1.184     rillig   5817:     explicitly registered in the PLIST.
1.1       dsieger  5818: 
1.184     rillig   5819:  3. Add code to the installation scripts to copy the startup script from the
                   5820:     examples hierarchy into the system-wide startup scripts directory.
1.1       dsieger  5821: 
1.184     rillig   5822: 20.3.1. Disabling handling of system startup scripts
1.1       dsieger  5823: 
1.184     rillig   5824: The automatic copying of config files can be toggled by setting the environment
                   5825: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
                   5826: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
                   5827: rc.d/, no matter what the value of this variable is.
1.1       dsieger  5828: 
1.184     rillig   5829: 20.4. System users and groups
1.1       dsieger  5830: 
1.184     rillig   5831: If a package needs to create special users and/or groups during installation,
                   5832: it can do so by using the pkginstall framework.
1.1       dsieger  5833: 
1.184     rillig   5834: Users can be created by adding entries to the PKG_USERS variable. Each entry
                   5835: has the following syntax:
1.1       dsieger  5836: 
1.184     rillig   5837: user:group
1.1       dsieger  5838: 
1.184     rillig   5839: Further specification of user details may be done by setting per-user
                   5840: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
                   5841: user's description or comment. PKG_HOME.user is the user's home directory, and
                   5842: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
                   5843: and defaults to /sbin/nologin if not specified.
1.1       dsieger  5844: 
1.184     rillig   5845: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
                   5846: whose syntax is:
1.1       dsieger  5847: 
1.184     rillig   5848: group
1.1       dsieger  5849: 
1.184     rillig   5850: The numeric GID of the group may be set by defining PKG_GID.group.
1.1       dsieger  5851: 
1.184     rillig   5852: If a package needs to create the users and groups at an earlier stage, then it
                   5853: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
                   5854: the phase before which the users and groups are created. In this case, the
                   5855: numeric UIDs and GIDs of the created users and groups are automatically
                   5856: hardcoded into the final installation scripts.
1.1       dsieger  5857: 
1.184     rillig   5858: 20.5. System shells
1.1       dsieger  5859: 
1.184     rillig   5860: Packages that install system shells should register them in the shell database,
                   5861: /etc/shells, to make things easier to the administrator. This must be done from
                   5862: the installation scripts to keep binary packages working on any system.
                   5863: pkginstall provides an easy way to accomplish this task.
1.1       dsieger  5864: 
1.184     rillig   5865: When a package provides a shell interpreter, it has to set the PKG_SHELL
                   5866: variable to its absolute file name. This will add some hooks to the
                   5867: installation scripts to handle it. Consider the following example, taken from
                   5868: shells/zsh:
1.1       dsieger  5869: 
1.184     rillig   5870: PKG_SHELL=      ${PREFIX}/bin/zsh
1.1       dsieger  5871: 
1.184     rillig   5872: 20.5.1. Disabling shell registration
1.1       dsieger  5873: 
1.184     rillig   5874: The automatic registration of shell interpreters can be disabled by the
                   5875: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
1.1       dsieger  5876: 
1.184     rillig   5877: 20.6. Fonts
1.1       dsieger  5878: 
1.184     rillig   5879: Packages that install X11 fonts should update the database files that index the
                   5880: fonts within each fonts directory. This can easily be accomplished within the
                   5881: pkginstall framework.
1.1       dsieger  5882: 
1.184     rillig   5883: When a package installs X11 fonts, it must list the directories in which fonts
                   5884: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
                   5885: "type1" or "x11". This will add hooks to the installation scripts to run the
                   5886: appropriate commands to update the fonts database files within each of those
                   5887: directories. For convenience, if the directory path is relative, it is taken to
                   5888: be relative to the package's installation prefix. Consider the following
                   5889: example, taken from fonts/dbz-ttf:
1.1       dsieger  5890: 
1.184     rillig   5891: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1       dsieger  5892: 
1.184     rillig   5893: 20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  5894: 
1.184     rillig   5895: The automatic update of fonts databases can be disabled by the administrator by
                   5896: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
1.1       dsieger  5897: 
1.154     rillig   5898: Chapter 21. Making your package work
1.1       dsieger  5899: 
                   5900: Table of Contents
                   5901: 
1.154     rillig   5902: 21.1. General operation
                   5903:     21.1.1. How to pull in user-settable variables from mk.conf
                   5904:     21.1.2. User interaction
                   5905:     21.1.3. Handling licenses
                   5906:     21.1.4. Restricted packages
                   5907:     21.1.5. Handling dependencies
                   5908:     21.1.6. Handling conflicts with other packages
                   5909:     21.1.7. Packages that cannot or should not be built
                   5910:     21.1.8. Packages which should not be deleted, once installed
                   5911:     21.1.9. Handling packages with security problems
                   5912:     21.1.10. How to handle incrementing versions when fixing an existing
1.259     leot     5913:         package
1.154     rillig   5914:     21.1.11. Substituting variable text in the package files (the SUBST
1.259     leot     5915:         framework)
1.154     rillig   5916: 21.2. The fetch phase
                   5917:     21.2.1. Packages whose distfiles aren't available for plain downloading
                   5918:     21.2.2. How to handle modified distfiles with the 'old' name
                   5919:     21.2.3. Packages hosted on github.com
                   5920: 21.3. The configure phase
                   5921:     21.3.1. Shared libraries - libtool
                   5922:     21.3.2. Using libtool on GNU packages that already support libtool
                   5923:     21.3.3. GNU Autoconf/Automake
1.223     nia      5924:     21.3.4. Meson / ninja
1.260     wiz      5925:     21.3.5. Determining the endianness
1.154     rillig   5926: 21.4. Programming languages
                   5927:     21.4.1. C, C++, and Fortran
                   5928:     21.4.2. Java
1.205     wiz      5929:     21.4.3. Go
1.223     nia      5930:     21.4.4. Rust
                   5931:     21.4.5. Packages containing Perl scripts
                   5932:     21.4.6. Packages containing shell scripts
                   5933:     21.4.7. Other programming languages
1.154     rillig   5934: 21.5. The build phase
                   5935:     21.5.1. Compiling C and C++ code conditionally
                   5936:     21.5.2. How to handle compiler bugs
1.172     rillig   5937:     21.5.3. No such file or directory
                   5938:     21.5.4. Undefined reference to "..."
                   5939:     21.5.5. Running out of memory
1.154     rillig   5940: 21.6. The install phase
                   5941:     21.6.1. Creating needed directories
                   5942:     21.6.2. Where to install documentation
                   5943:     21.6.3. Installing highscore files
                   5944:     21.6.4. Adding DESTDIR support to packages
                   5945:     21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia      5946:     21.6.6. Packages installing Perl modules
1.254     wiz      5947:     21.6.7. Packages installing pkg-config files
                   5948:     21.6.8. Packages installing info files
                   5949:     21.6.9. Packages installing man pages
                   5950:     21.6.10. Packages installing X11 fonts
                   5951:     21.6.11. Packages installing SGML or XML data
                   5952:     21.6.12. Packages installing extensions to the MIME database
                   5953:     21.6.13. Packages using intltool
                   5954:     21.6.14. Packages installing startup scripts
                   5955:     21.6.15. Packages installing TeX modules
                   5956:     21.6.16. Packages supporting running binaries in emulation
                   5957:     21.6.17. Packages installing hicolor icons
                   5958:     21.6.18. Packages installing desktop files
1.154     rillig   5959: 21.7. Marking packages as having problems
1.1       dsieger  5960: 
1.154     rillig   5961: 21.1. General operation
1.1       dsieger  5962: 
                   5963: One appealing feature of pkgsrc is that it runs on many different platforms. As
                   5964: a result, it is important to ensure, where possible, that packages in pkgsrc
                   5965: are portable. This chapter mentions some particular details you should pay
                   5966: attention to while working on pkgsrc.
                   5967: 
1.154     rillig   5968: 21.1.1. How to pull in user-settable variables from mk.conf
1.1       dsieger  5969: 
                   5970: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4       rillig   5971: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
                   5972: those variables in the preprocessor directives of make(1) (for example .if or
                   5973: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
                   5974: loads the user preferences.
1.1       dsieger  5975: 
                   5976: But note that some variables may not be completely defined after ../../mk/
                   5977: bsd.prefs.mk has been included, as they may contain references to variables
1.108     rillig   5978: that are not yet defined. In shell commands (the lines in Makefile that are
                   5979: indented with a tab) this is no problem, since variables are only expanded when
                   5980: they are used. But in the preprocessor directives mentioned above and in
                   5981: dependency lines (of the form target: dependencies) the variables are expanded
                   5982: at load time.
1.1       dsieger  5983: 
                   5984: Note
                   5985: 
1.108     rillig   5986: To check whether a variable can be used at load time, run pkglint -Wall on your
                   5987: package.
1.1       dsieger  5988: 
1.154     rillig   5989: 21.1.2. User interaction
1.1       dsieger  5990: 
                   5991: Occasionally, packages require interaction from the user, and this can be in a
                   5992: number of ways:
                   5993: 
                   5994:   * When fetching the distfiles, some packages require user interaction such as
                   5995:     entering username/password or accepting a license on a web page.
                   5996: 
                   5997:   * When extracting the distfiles, some packages may ask for passwords.
                   5998: 
                   5999:   * help to configure the package before it is built
                   6000: 
                   6001:   * help during the build process
                   6002: 
                   6003:   * help during the installation of a package
                   6004: 
1.108     rillig   6005: A package can set the INTERACTIVE_STAGE variable to define which stages need
                   6006: interaction. This should be done in the package's Makefile, e.g.:
1.1       dsieger  6007: 
                   6008: INTERACTIVE_STAGE=      configure install
                   6009: 
                   6010: The user can then decide to skip this package by setting the BATCH variable.
1.108     rillig   6011: Packages that require interaction are also excluded from bulk builds.
1.1       dsieger  6012: 
1.154     rillig   6013: 21.1.3. Handling licenses
1.1       dsieger  6014: 
                   6015: Authors of software can choose the licence under which software can be copied.
1.111     sevan    6016: The Free Software Foundation has declared some licenses "Free", and the Open
                   6017: Source Initiative has a definition of "Open Source".
                   6018: 
                   6019: By default, pkgsrc allows packages with Free or Open Source licenses to be
                   6020: built. To allow packages with other licenses to be built as well, the pkgsrc
                   6021: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
                   6022: . Note that this variable only affects which packages may be built, while the
                   6023: license terms often also restrict the actual use of the package and its
                   6024: redistribution.
1.1       dsieger  6025: 
                   6026: One might want to only install packages with a BSD license, or the GPL, and not
1.20      jnemeth  6027: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111     sevan    6028: variable. The pkgsrc user can override the default by setting the
                   6029: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
                   6030: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
                   6031: pkgsrc/mk/license.mk.
1.1       dsieger  6032: 
                   6033: The license tag mechanism is intended to address copyright-related issues
                   6034: surrounding building, installing and using a package, and not to address
1.20      jnemeth  6035: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
                   6036: redistribution restrictions should set these tags.
1.1       dsieger  6037: 
                   6038: Denoting that a package may be copied according to a particular license is done
                   6039: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
                   6040: string identifying the license, e.g. in graphics/xv:
                   6041: 
                   6042: LICENSE=        xv-license
                   6043: 
                   6044: When trying to build, the user will get a notice that the package is covered by
                   6045: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
                   6046: 
                   6047: % make
                   6048: ===> xv-3.10anb9 has an unacceptable license: xv-license.
                   6049: ===>     To view the license, enter "/usr/bin/make show-license".
                   6050: ===>     To indicate acceptance, add this line to your /etc/mk.conf:
                   6051: ===>     ACCEPTABLE_LICENSES+=xv-license
                   6052: *** Error code 1
                   6053: 
1.260     wiz      6054: In case a package requires multiple licenses, you can add all of them to the
                   6055: LICENSE variable, connected with the upper-case keyword AND. If the user has a
                   6056: choice between multiple licenses, you can add them connected with the
                   6057: upper-case keyword OR, for example:
                   6058: 
                   6059: LICENSE=        isc AND apache-2.0
                   6060: LICENSE=        2-clause-bsd OR ruby-license
                   6061: 
1.1       dsieger  6062: The license can be viewed with make show-license, and if the user so chooses,
1.4       rillig   6063: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1       dsieger  6064: should not in the future fail because of that license:
                   6065: 
                   6066: ACCEPTABLE_LICENSES+=xv-license
                   6067: 
1.111     sevan    6068: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
                   6069: is deprecated because it does not crisply refer to a particular license text.
                   6070: Another problem with such usage is that it does not enable a user to tell
                   6071: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
                   6072: for all packages with that tag.
                   6073: 
1.154     rillig   6074: 21.1.3.1. Adding a package with a new license
1.1       dsieger  6075: 
1.49      rodent   6076: When adding a package with a new license, the following steps are required:
                   6077: 
1.111     sevan    6078:  1. Check whether the license qualifies as Free or Open Source by referencing
                   6079:     Various Licenses and Comments about Them and Licenses by Name | Open Source
                   6080:     Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
                   6081:     need the -license suffix, and the license name should be added to:
1.49      rodent   6082: 
                   6083:       + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
                   6084: 
                   6085:       + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
                   6086:         license.c
                   6087: 
                   6088:  2. The license text should be added to pkgsrc/licenses for displaying. A list
                   6089:     of known licenses can be seen in this directory.
1.1       dsieger  6090: 
1.154     rillig   6091: 21.1.3.2. Change to the license
1.1       dsieger  6092: 
1.111     sevan    6093: When the license changes (in a way other than formatting), make sure that the
                   6094: new license has a different name (e.g., append the version number if it exists,
                   6095: or the date). Just because a user told pkgsrc to build programs under a
                   6096: previous version of a license does not mean that pkgsrc should build programs
                   6097: under the new licenses. The higher-level point is that pkgsrc does not evaluate
                   6098: licenses for reasonableness; the only test is a mechanistic test of whether a
                   6099: particular text has been approved by either of two bodies (FSF or OSI).
1.1       dsieger  6100: 
1.154     rillig   6101: 21.1.4. Restricted packages
1.1       dsieger  6102: 
1.111     sevan    6103: Some licenses restrict how software may be re-distributed. By declaring the
                   6104: restrictions, package tools can automatically refrain from e.g. placing binary
                   6105: packages on FTP sites.
                   6106: 
                   6107: There are four possible restrictions, which are the cross product of sources
                   6108: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
                   6109: this is rarely the exact language in any license, and because non-Free licenses
                   6110: tend to be different from each other, pkgsrc adopts a definition of FTP and
                   6111: CD-ROM. "FTP" means making the source or binary file available over the
                   6112: Internet at no charge. "CD-ROM" means making the source or binary available on
                   6113: some kind of media, together with other source and binary packages, which is
                   6114: sold for a distribution charge.
1.1       dsieger  6115: 
                   6116: In order to encode these restrictions, the package system defines five make
                   6117: variables that can be set to note these restrictions:
                   6118: 
                   6119:   * RESTRICTED
                   6120: 
                   6121:     This variable should be set whenever a restriction exists (regardless of
                   6122:     its kind). Set this variable to a string containing the reason for the
                   6123:     restriction. It should be understood that those wanting to understand the
                   6124:     restriction will have to read the license, and perhaps seek advice of
                   6125:     counsel.
                   6126: 
                   6127:   * NO_BIN_ON_CDROM
                   6128: 
                   6129:     Binaries may not be placed on CD-ROM containing other binary packages, for
                   6130:     which a distribution charge may be made. In this case, set this variable to
                   6131:     ${RESTRICTED}.
                   6132: 
                   6133:   * NO_BIN_ON_FTP
                   6134: 
                   6135:     Binaries may not made available on the Internet without charge. In this
                   6136:     case, set this variable to ${RESTRICTED}. If this variable is set, binary
                   6137:     packages will not be included on ftp.NetBSD.org.
                   6138: 
                   6139:   * NO_SRC_ON_CDROM
                   6140: 
                   6141:     Distfiles may not be placed on CD-ROM, together with other distfiles, for
                   6142:     which a fee may be charged. In this case, set this variable to $
                   6143:     {RESTRICTED}.
                   6144: 
                   6145:   * NO_SRC_ON_FTP
                   6146: 
                   6147:     Distfiles may not made available via FTP at no charge. In this case, set
                   6148:     this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
                   6149:     will not be mirrored on ftp.NetBSD.org.
                   6150: 
1.111     sevan    6151: Please note that packages will be removed from pkgsrc when the distfiles are
1.33      wiz      6152: not distributable and cannot be obtained for a period of one full quarter
1.111     sevan    6153: branch. Packages with manual/interactive fetch must have a maintainer and it is
                   6154: his/her responsibility to ensure this.
1.33      wiz      6155: 
1.154     rillig   6156: 21.1.5. Handling dependencies
1.1       dsieger  6157: 
1.175     gutterid 6158: Your package may depend on some other package being present, and there are
                   6159: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
                   6160: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
                   6161: definition, as well as dependencies via buildlink3.mk, which is the preferred
                   6162: way to handle dependencies, and which uses the variables named above. See
1.184     rillig   6163: Chapter 18, Buildlink methodology for more information.
1.175     gutterid 6164: 
                   6165: The basic difference is that the DEPENDS definition registers that
                   6166: pre-requisite in the binary package so it will be pulled in when the binary
                   6167: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
                   6168: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
1.184     rillig   6169: building or testing the resulting package. See also Chapter 14, Creating a new
1.175     gutterid 6170: pkgsrc package from scratch for more information.
                   6171: 
                   6172: This means that if you only need a package present whilst you are building or
                   6173: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
                   6174: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
                   6175: architecture where the package is built; BUILD_DEPENDS are target packages,
                   6176: i.e., packages for the architecture for which the package is built.
1.1       dsieger  6177: 
1.175     gutterid 6178: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
                   6179: definition is:
1.1       dsieger  6180: 
                   6181: <pre-req-package-name>:../../<category>/<pre-req-package>
                   6182: 
                   6183: Please note that the "pre-req-package-name" may include any of the wildcard
                   6184: version numbers recognized by pkg_info(1).
                   6185: 
1.55      wiz      6186:  1. If your package needs another package's binaries or libraries to build and
1.1       dsieger  6187:     run, and if that package has a buildlink3.mk file available, use it:
                   6188: 
                   6189:     .include "../../graphics/jpeg/buildlink3.mk"
                   6190: 
1.55      wiz      6191:  2. If your package needs another package's binaries or libraries only for
                   6192:     building, and if that package has a buildlink3.mk file available, use it:
                   6193: 
                   6194:     .include "../../graphics/jpeg/buildlink3.mk"
                   6195: 
                   6196:     but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
                   6197:     This case is rather rare.
                   6198: 
                   6199:  3. If your package needs binaries from another package to build, use the
1.156     leot     6200:     TOOL_DEPENDS definition:
                   6201: 
                   6202:     TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1       dsieger  6203: 
1.156     leot     6204:  4. If your package needs static libraries to link against, header files to
                   6205:     include, etc. from another package to build, use the BUILD_DEPENDS
                   6206:     definition.
1.1       dsieger  6207: 
1.156     leot     6208:  5. If your package needs a library with which to link and there is no
1.26      spz      6209:     buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
                   6210:     because the include files and libraries will be hidden from the compiler.
1.1       dsieger  6211: 
1.156     leot     6212:  6. If your package needs some executable to be able to run correctly and if
1.26      spz      6213:     there's no buildlink3.mk file, this is specified using the DEPENDS
                   6214:     variable. The print/lyx package needs to be able to execute the latex
1.129     wiz      6215:     binary from the tex-latex-bin package when it runs, and that is specified:
1.1       dsieger  6216: 
1.129     wiz      6217:     DEPENDS+=        tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1       dsieger  6218: 
1.175     gutterid 6219:  7. If your package includes a test suite that has extra dependencies only
                   6220:     required for this purpose (frequently this can be run as a "make test"
                   6221:     target), use the TEST_DEPENDS variable.
                   6222: 
                   6223:  8. You can use wildcards in package dependencies. Note that such wildcard
1.26      spz      6224:     dependencies are retained when creating binary packages. The dependency is
                   6225:     checked when installing the binary package and any package which matches
                   6226:     the pattern will be used. Wildcard dependencies should be used with care.
1.1       dsieger  6227: 
                   6228:     The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
                   6229:     matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
                   6230: 
                   6231:     Wildcards can also be used to specify that a package will only build
                   6232:     against a certain minimum version of a pre-requisite:
                   6233: 
1.26      spz      6234:     DEPENDS+=       ImageMagick>=6.0:../../graphics/ImageMagick
1.1       dsieger  6235: 
1.26      spz      6236:     This means that the package will build using version 6.0 of ImageMagick or
                   6237:     newer. Such a dependency may be warranted if, for example, the command line
                   6238:     options of an executable have changed.
                   6239: 
1.183     wiz      6240:     If you need to depend on minimum versions of libraries, set
                   6241:     BUILDLINK_API_DEPENDS.pkg to the appropriate pattern before including its
                   6242:     buildlink3.mk file, e.g.
                   6243: 
                   6244:     BUILDLINK_API_DEPENDS.jpeg+=    jpeg>=9.0
                   6245:     .include "../../graphics/jpeg/buildlink3.mk"
1.1       dsieger  6246: 
                   6247:     For security fixes, please update the package vulnerabilities file. See
1.154     rillig   6248:     Section 21.1.9, "Handling packages with security problems" for more
1.1       dsieger  6249:     information.
                   6250: 
                   6251: If your package needs files from another package to build, add the relevant
                   6252: distribution files to DISTFILES, so they will be extracted automatically. See
                   6253: the print/ghostscript package for an example. (It relies on the jpeg sources
                   6254: being present in source form during the build.)
                   6255: 
1.154     rillig   6256: 21.1.6. Handling conflicts with other packages
1.1       dsieger  6257: 
1.226     gutterid 6258: Your package may conflict with other packages users might already have
                   6259: installed on their system, e.g., if your package installs the same set of files
1.227     wiz      6260: as another package in the pkgsrc tree.
1.1       dsieger  6261: 
1.142     leot     6262: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
                   6263: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1       dsieger  6264: 
1.142     leot     6265: CONFLICTS=      Xaw-Xpm-[0-9]*
1.1       dsieger  6266: 
1.142     leot     6267: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1       dsieger  6268: 
1.142     leot     6269: CONFLICTS=      libXaw3d-[0-9]*
1.1       dsieger  6270: 
1.142     leot     6271: pkg_add(1) is able to detect attempts to install packages that conflict with
                   6272: existing packages and abort. However, in many situations this is too late in
                   6273: the process. Binary package managers will not know about the conflict until
                   6274: they attempt to install the package after already downloading it and all its
                   6275: dependencies. Users may also waste time building a package and its dependencies
                   6276: only to find out at the end that it conflicts with another package they have
                   6277: installed.
                   6278: 
                   6279: To avoid these issues CONFLICTS entries should be added in all cases where it
                   6280: is known that packages conflict with each other. These CONFLICTS entries are
                   6281: exported in pkg_summary(5) files and consumed by binary package managers to
                   6282: inform users that packages cannot be installed onto the target system.
1.1       dsieger  6283: 
1.154     rillig   6284: 21.1.7. Packages that cannot or should not be built
1.1       dsieger  6285: 
                   6286: There are several reasons why a package might be instructed to not build under
                   6287: certain circumstances. If the package builds and runs on most platforms, the
1.83      dholland 6288: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
                   6289: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
                   6290: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
                   6291: (OS-version-platform) that can use glob-style wildcards.
                   6292: 
1.114     maya     6293: If a package is not appropriate for some platforms (as opposed to merely
1.83      dholland 6294: broken), a different set of variables should be used as this affects failure
                   6295: reporting and statistics. If the package is appropriate for most platforms, the
                   6296: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
                   6297: for only a small handful of platforms (often exactly one), set
                   6298: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
                   6299: triples (OS-version-platform) that can use glob-style wildcards.
1.1       dsieger  6300: 
                   6301: Some packages are tightly bound to a specific version of an operating system,
                   6302: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
                   6303: with other versions of the OS, and should be uploaded to a version specific
                   6304: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
                   6305: to "yes". This variable is not currently used by any of the package system
                   6306: internals, but may be used in the future.
                   6307: 
                   6308: If the package should be skipped (for example, because it provides
                   6309: functionality already provided by the system), set PKG_SKIP_REASON to a
                   6310: descriptive message. If the package should fail because some preconditions are
                   6311: not met, set PKG_FAIL_REASON to a descriptive message.
                   6312: 
1.154     rillig   6313: 21.1.8. Packages which should not be deleted, once installed
1.1       dsieger  6314: 
                   6315: To ensure that a package may not be deleted, once it has been installed, the
                   6316: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25      wiz      6317: carried into any binary package that is made from this pkgsrc entry. A "
                   6318: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1       dsieger  6319: option is used.
                   6320: 
1.154     rillig   6321: 21.1.9. Handling packages with security problems
1.1       dsieger  6322: 
1.247     wiz      6323: When a vulnerability is found, this should be noted in pkgsrc/doc/
                   6324: pkg-vulnerabilities. Entries in that file consist of three parts:
1.205     wiz      6325: 
                   6326:   * package version pattern
                   6327: 
                   6328:   * type of vulnerability (please cut'n'paste an existing one where possible)
                   6329: 
                   6330:   * URL providing additional information about the issue
                   6331: 
                   6332: For the package version pattern please always use `<' to mark an upper bound
                   6333: (not `<='!). This will avoid possible problems due unrelated PKGREVISION bumps
                   6334: not related to security fixes. Lower bounds can be added too, using '>' or '>=
1.206     wiz      6335: '. For example, "foo>=1<1.2" would mark versions 1.0 (included) to 1.2
1.205     wiz      6336: (excluded) of "foo" as affected by the security issue.
                   6337: 
                   6338: Entries should always be added at the bottom of the file.
                   6339: 
                   6340: When fixing packages, please modify the upper bound of the corresponding entry.
                   6341: To continue the previous example, if a fix was backported to version 1.1nb2,
1.206     wiz      6342: change the previous pattern to "foo>=1<1.1nb2".
1.205     wiz      6343: 
                   6344: To locally test a package version pattern against a PKGNAME you can use the 
                   6345: pkg_admin pmatch command.
                   6346: 
                   6347: The URL should be as permanent as possible and provide as much information
                   6348: about the issue as possible. CVE entries are preferred.
                   6349: 
                   6350: After committing that file, ask pkgsrc-security@NetBSD.org to update the file
                   6351: on ftp.NetBSD.org.
1.1       dsieger  6352: 
                   6353: After fixing the vulnerability by a patch, its PKGREVISION should be increased
                   6354: (this is of course not necessary if the problem is fixed by using a newer
1.32      wiz      6355: release of the software), and the pattern in the pkg-vulnerabilities file must
                   6356: be updated.
1.1       dsieger  6357: 
                   6358: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
                   6359: submit a pullup request!
                   6360: 
                   6361: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
                   6362: a weekly cron job.
                   6363: 
1.205     wiz      6364: In case a security issue is disputed, please contact
                   6365: pkgsrc-security@NetBSD.org.
                   6366: 
1.154     rillig   6367: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1       dsieger  6368: 
                   6369: When making fixes to an existing package it can be useful to change the version
                   6370: number in PKGNAME. To avoid conflicting with future versions by the original
                   6371: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
                   6372: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
                   6373: e.g.
                   6374: 
                   6375: DISTNAME=       foo-17.42
                   6376: PKGREVISION=    9
                   6377: 
                   6378: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
                   6379: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
                   6380: PKGNAME_NOREV.
                   6381: 
                   6382: When a new release of the package is released, the PKGREVISION should be
                   6383: removed, e.g. on a new minor release of the above package, things should be
                   6384: like:
                   6385: 
                   6386: DISTNAME=       foo-17.43
                   6387: 
                   6388: PKGREVISION should be incremented for any non-trivial change in the resulting
                   6389: binary package. Without a PKGREVISION bump, someone with the previous version
                   6390: installed has no way of knowing that their package is out of date. Thus,
                   6391: changes without increasing PKGREVISION are essentially labeled "this is so
                   6392: trivial that no reasonable person would want to upgrade", and this is the rough
                   6393: test for when increasing PKGREVISION is appropriate. Examples of changes that
                   6394: do not merit increasing PKGREVISION are:
                   6395: 
1.14      jmcneill 6396:   * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1       dsieger  6397: 
                   6398:   * Changing build variables if the resulting binary package is the same.
                   6399: 
                   6400:   * Changing DESCR.
                   6401: 
                   6402:   * Adding PKG_OPTIONS if the default options don't change.
                   6403: 
                   6404: Examples of changes that do merit an increase to PKGREVISION include:
                   6405: 
                   6406:   * Security fixes
                   6407: 
                   6408:   * Changes or additions to a patch file
                   6409: 
                   6410:   * Changes to the PLIST
                   6411: 
1.12      weinem   6412:   * A dependency is changed or renamed.
                   6413: 
1.1       dsieger  6414: PKGREVISION must also be incremented when dependencies have ABI changes.
                   6415: 
1.154     rillig   6416: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1       dsieger  6417: 
1.180     rillig   6418: When you want to replace the same text in multiple files, or multiple times in
                   6419: the same file, it is cumbersome to maintain a patch file for this. This is
                   6420: where the SUBST framework steps in. It provides an easy-to-use interface for
                   6421: replacing text in files. It just needs the following information:
1.172     rillig   6422: 
1.180     rillig   6423:   * In which phase of the package build cycle should the replacement happen?
1.172     rillig   6424: 
1.180     rillig   6425:   * In which files should the replacement happen?
1.172     rillig   6426: 
                   6427:   * Which text should be replaced with what?
                   6428: 
1.180     rillig   6429: This information is encoded in a block of SUBST variables. A minimal example
                   6430: is:
                   6431: 
                   6432: SUBST_CLASSES+=         paths
                   6433: SUBST_STAGE.paths=      pre-configure
                   6434: SUBST_FILES.paths=      src/*.c
                   6435: SUBST_SED.paths=        -e 's,/usr/local,${PREFIX},g'
                   6436: 
                   6437: Translated into English, it means: In the pre-configure stage (that is, after
                   6438: applying the patches from the patches/ directory and before running the
                   6439: configure script and the portability check), replace the text /usr/local with
                   6440: the content of the variable PREFIX.
                   6441: 
                   6442: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
                   6443: =). This identifier can be chosen freely by the package. If there should ever
                   6444: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
                   6445: early, so don't worry about name collisions.
                   6446: 
                   6447: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
                   6448: using this identifier. In the remainder of this section, these parameterized
                   6449: variables are written as SUBST_STAGE.*.
                   6450: 
                   6451: SUBST_CLASSES+=         paths
                   6452: SUBST_STAGE.paths=      pre-configure
                   6453: SUBST_MESSAGE.paths=    Fixing absolute paths.
                   6454: SUBST_FILES.paths=      src/*.c
                   6455: SUBST_FILES.paths+=     scripts/*.sh
                   6456: SUBST_SED.paths=        -e 's,"/usr/local,"${PREFIX},g'
                   6457: SUBST_SED.paths+=       -e 's,"/var/log,"${VARBASE}/log,g'
                   6458: SUBST_VARS.paths=       LOCALBASE PREFIX PKGVERSION
                   6459: 
                   6460: To get a complete picture about the SUBST substitutions, run bmake
                   6461: show-all-subst. If something doesn't work as expected, run pkglint on the
                   6462: package, which detects several typical mistakes surrounding the SUBST blocks.
                   6463: For any questions that might remain after this, have a look at mk/subst.mk.
                   6464: 
                   6465: 21.1.11.1. Choosing the time where the substitutions happen
                   6466: 
                   6467: The SUBST_STAGE.* is one of {pre,do,post}-
                   6468: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
                   6469: most often, by far. The most popular stages are, in chronological order:
                   6470: 
                   6471: post-extract
                   6472: 
                   6473:     The substitutions are applied immediately after the distfiles are
                   6474:     extracted. Running bmake extract on the package will leave no traces of the
                   6475:     original files.
                   6476: 
                   6477:     When the substitution applies to files for which there is also a patch in
                   6478:     the patches/ directory, this means that the patches will be computed based
                   6479:     on the result of the substitution. When these patches are sent to the
                   6480:     upstream maintainer later, to be fixed in the upstream package, these
                   6481:     patches may no longer match what the upstream author is used to. Because of
                   6482:     this, pre-configure is often a better choice.
                   6483: 
                   6484: pre-configure
                   6485: 
                   6486:     The substitutions are applied after the patches from the patches/
                   6487:     directory. This makes it possible to run bmake patch on the package, after
                   6488:     which the patches can be edited using the tools pkgvi and mkpatches from
                   6489:     the pkgtools/pkgdiff package.
                   6490: 
                   6491:     When updating the patches, it is helpful to explicitly separate the bmake
                   6492:     patch from the bmake configure, and to only edit the patches between these
                   6493:     commands. Otherwise the substitutions from the SUBST block will end up in
                   6494:     the patch file. When this happens in really obvious ways, pkglint will
                   6495:     complain about patches that contain a hard-coded /usr/pkg instead of the
                   6496:     correct and intended @PREFIX@, but it can only detect these really obvious
                   6497:     cases.
                   6498: 
                   6499: do-configure
                   6500: 
                   6501:     This stage should only be used if the package defines a pre-configure
                   6502:     action itself, and the substitution must happen after that. Typical
                   6503:     examples are packages that use the pre-configure stage to regenerate the
                   6504:     GNU configure script from configure.ac.
                   6505: 
                   6506: post-configure
                   6507: 
                   6508:     This stage is used to fix up any mistakes by the configure stage.
                   6509: 
                   6510: pre-build
                   6511: 
                   6512:     This stage should only be used for substitutions that are clearly related
                   6513:     to building the package, not for fixing the configuration. Substitutions
                   6514:     for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
                   6515:     (such as replacing @MY_USER@ with the actual username) belong in
                   6516:     pre-configure or post-configure instead.
                   6517: 
                   6518: post-build
                   6519: 
                   6520:     Just as with pre-build, this stage should only be used for substitutions
                   6521:     that are clearly related to building the package, not for fixing the
                   6522:     configuration. Substitutions for pathnames (such as replacing /usr/local
                   6523:     with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
                   6524:     username) belong in pre-configure or post-configure instead.
                   6525: 
                   6526:     A typical use is to update pkg-config files to include the rpath compiler
                   6527:     options.
                   6528: 
                   6529: pre-install
                   6530: 
                   6531:     In general, the install phase should be as simple as possible. As with the
                   6532:     pre-build and post-build stages, it should not be used to fix pathnames or
                   6533:     user names, these belong in pre-configure instead. There are only few
                   6534:     legitimate use cases for applying substitutions in this stage.
                   6535: 
1.181     rillig   6536: 21.1.11.2. Choosing the files where the substitutions happen
1.180     rillig   6537: 
                   6538: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
                   6539: are relative to WRKSRC since that is where most substitutions happen. A typical
                   6540: example is:
                   6541: 
                   6542: SUBST_FILES.path=       Makefile */Makefile */*/Makefile *.[ch]
                   6543: 
                   6544: The above patterns, especially the last, are quite broad. The SUBST
                   6545: implementation checks that each filename pattern that is mentioned here has an
                   6546: effect. For example, if none of the */*/Makefile files contains the patterns to
                   6547: be found and substituted, that filename pattern is redundant and should be left
1.181     rillig   6548: out. By default, the SUBST framework will complain with an error message. If
                   6549: the text to be substituted occurs in some of the files from a single pattern,
                   6550: but not in all of them, that is totally ok, and the SUBST framework will only
                   6551: print an INFO message for those files.
1.180     rillig   6552: 
                   6553: If there is a good reason for having redundant filename patterns, set
1.181     rillig   6554: SUBST_NOOP_OK.* to yes.
1.180     rillig   6555: 
                   6556: Another popular way of choosing the files for the substitutions is via a shell
                   6557: command, like this:
                   6558: 
1.181     rillig   6559: C_FILES_CMD=            cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180     rillig   6560: SUBST_FILES.path=       ${C_FILES_CMD:sh}
                   6561: 
                   6562: The variable name C_FILES_CMD in this example is freely chosen and independent
                   6563: of the SUBST framework.
                   6564: 
                   6565: In this variant, the SUBST_FILES.* variable lists each file individually.
                   6566: Thereby chances are higher that there are filename patterns in which no
                   6567: substitution happens. Since the SUBST framework cannot know whether the
                   6568: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
                   6569: (where any redundant filename pattern would be suspicious) or been generated by
                   6570: a shell command (in which redundant filename patterns are more likely and to be
                   6571: expected), it will complain about these redundant filename patterns. Therefore,
                   6572: SUBST blocks that use a shell command to generate the list of filename patterns
                   6573: often need to set SUBST_NOOP_OK.* to yes.
                   6574: 
                   6575: 21.1.11.3. Choosing what to substitute
                   6576: 
                   6577: In most cases, the substitutions are given using one or more sed(1) commands,
                   6578: like this:
                   6579: 
                   6580: SUBST_SED.path=         -e 's|/usr/local|${PREFIX}|g'
                   6581: 
                   6582: Each of the sed commands needs to be preceded by the -e option and should be
                   6583: specified on a line of its own, to avoid hiding short sed commands at the end
                   6584: of a line.
                   6585: 
                   6586: Since the sed commands often contain shell metacharacters as the separator (the
                   6587: | in the above example), it is common to enclose them in single quotes.
                   6588: 
                   6589: A common substitution is to replace placeholders of the form @VARNAME@ with
                   6590: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
                   6591: 
                   6592: SUBST_VARS.path=        PREFIX
                   6593: 
1.181     rillig   6594: This type of substitutions is typically done by the GNU configure scripts
                   6595: during the do-configure stage, but in some cases these need to be overridden.
                   6596: The same pattern is also used when a package defines patches that replace
                   6597: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
                   6598: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
                   6599: In many of these cases, it works equally well to just use the SUBST framework
                   6600: to directly replace /usr/local with ${PREFIX}, thereby omitting the
                   6601: intermediate patch file.
1.180     rillig   6602: 
                   6603: If the above is not flexible enough, it is possible to not use sed at all for
                   6604: the substitution but to specify an entirely different command, like this:
                   6605: 
                   6606: SUBST_FILTER_CMD.path=  LC_ALL=C ${TR} -d '\r'
1.1       dsieger  6607: 
1.180     rillig   6608: This is used for the few remaining packages in which the distributed files use
                   6609: Windows-style line endings that need to be converted to UNIX-style line
                   6610: endings.
1.1       dsieger  6611: 
1.180     rillig   6612: 21.1.11.4. Other SUBST variables
1.172     rillig   6613: 
1.180     rillig   6614: When a SUBST block is applied during a package build, a message is logged. The
                   6615: default message is fine for most purposes but can be overridden by setting
                   6616: SUBST_MESSAGE.* to an individual message.
1.1       dsieger  6617: 
1.154     rillig   6618: 21.2. The fetch phase
1.1       dsieger  6619: 
1.154     rillig   6620: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1       dsieger  6621: 
                   6622: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
                   6623: a make fetch will call files/getsite.sh with the name of each file to download
                   6624: as an argument, expecting it to output the URL of the directory from which to
                   6625: download it. graphics/ns-cult3d is an example of this usage.
                   6626: 
                   6627: If the download can't be automated, because the user must submit personal
                   6628: information to apply for a password, or must pay for the source, or whatever,
                   6629: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
                   6630: before aborting the build. Example:
                   6631: 
                   6632: FETCH_MESSAGE=  "Please download the files"
                   6633: FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   6634: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   6635: 
1.154     rillig   6636: 21.2.2. How to handle modified distfiles with the 'old' name
1.1       dsieger  6637: 
                   6638: Sometimes authors of a software package make some modifications after the
                   6639: software was released, and they put up a new distfile without changing the
                   6640: package's version number. If a package is already in pkgsrc at that time, the
                   6641: checksum will no longer match. The contents of the new distfile should be
                   6642: compared against the old one before changing anything, to make sure the
                   6643: distfile was really updated on purpose, and that no trojan horse or so crept
                   6644: in. Please mention that the distfiles were compared and what was found in your
1.54      rodent   6645: commit message.
                   6646: 
                   6647: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109     wiz      6648: directory name, usually based on PKGNAME_NOREV (but take care with python or
                   6649: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
                   6650: PATCHFILES for this package will be put in that subdirectory of the local
1.154     rillig   6651: distfiles directory. (See Section 21.1.10, "How to handle incrementing versions
1.109     wiz      6652: when fixing an existing package" for more details.) In case this happens more
                   6653: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
                   6654: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54      rodent   6655: 
                   6656: DIST_SUBDIR is also used when a distfile's name does not contain a version and
                   6657: the distfile is apt to change. In cases where the likelihood of this is very
                   6658: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
                   6659: removed unless the distfile name changes, even if a package is being moved or
                   6660: renamed.
                   6661: 
                   6662: Do not forget regenerating the distinfo file after that, since it contains the
                   6663: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
                   6664: installed package is different. Furthermore, a mail to the package's authors
                   6665: seems appropriate telling them that changing distfiles after releases without
                   6666: changing the file names is not good practice.
1.1       dsieger  6667: 
1.154     rillig   6668: 21.2.3. Packages hosted on github.com
1.88      tnn      6669: 
1.90      tnn      6670: Helper methods exist for packages hosted on github.com which will often have
                   6671: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
                   6672: of the three recipes from below:
1.88      tnn      6673: 
1.154     rillig   6674: 21.2.3.1. Fetch based on a tagged release
1.88      tnn      6675: 
1.189     bacon    6676: If your distfile URL looks similar to https://github.com/username/example/
                   6677: archive/v1.0.zip, then you are packaging a tagged release.
1.88      tnn      6678: 
1.189     bacon    6679: DISTNAME=       example-1.0
1.90      tnn      6680: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
1.189     bacon    6681: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
1.90      tnn      6682: GITHUB_TAG=     v${PKGVERSION_NOREV}
1.88      tnn      6683: EXTRACT_SUFX=   .zip
                   6684: 
1.230     gutterid 6685: Here, DISTNAME combined with use of GITHUB_TAG leads the file fetching
                   6686: infrastructure to save the resulting file locally as example-1.0.zip.
                   6687: 
1.189     bacon    6688: 21.2.3.2. Fetch based on a specific commit before the first release
                   6689: 
                   6690: If your distfile looks similar to https://github.com/username/example/archive/
                   6691: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit before the first
                   6692: release, then set the package version to 0.0.0.N, where N is the number of
                   6693: commits to the repository, and set GITHUB_TAG to the commit hash. This will
                   6694: (almost) ensure that the first tagged release will have a version greater than
                   6695: this one so that package upgrades will function properly.
                   6696: 
                   6697: DISTNAME=       example-0.0.0.347
                   6698: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6699: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
                   6700: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
                   6701: 
                   6702: 21.2.3.3. Fetch based on a specific commit after a release
1.88      tnn      6703: 
1.189     bacon    6704: If your distfile looks similar to https://github.com/username/example/archive/
                   6705: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit after a release,
                   6706: then include the last release version and the commit count since that release
                   6707: in the package version and set GITHUB_TAG to the commit hash. The latest
                   6708: release and commit count are shown in the output of "git describe --tags":
                   6709: 
                   6710: # git clone https://github.com/username/example
                   6711: # cd example
                   6712: # git describe --tags
                   6713: 1.2.3-5-g988881a
1.88      tnn      6714: 
1.189     bacon    6715: DISTNAME=       example-1.2.3.5
                   6716: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6717: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
1.90      tnn      6718: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88      tnn      6719: 
1.189     bacon    6720: 21.2.3.4. Fetch based on release
1.88      tnn      6721: 
1.189     bacon    6722: If your distfile URL looks similar to https://github.com/username/example/
                   6723: releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
1.88      tnn      6724: 
1.90      tnn      6725: DISTNAME=       offensive-1.6
1.88      tnn      6726: PKGNAME=        ${DISTNAME:S/offensive/proper/}
1.90      tnn      6727: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
1.189     bacon    6728: GITHUB_PROJECT= example
1.90      tnn      6729: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
                   6730: EXTRACT_SUFX=   .zip
1.88      tnn      6731: 
1.154     rillig   6732: 21.3. The configure phase
1.1       dsieger  6733: 
1.154     rillig   6734: 21.3.1. Shared libraries - libtool
1.1       dsieger  6735: 
                   6736: pkgsrc supports many different machines, with different object formats like
                   6737: a.out and ELF, and varying abilities to do shared library and dynamic loading
                   6738: at all. To accompany this, varying commands and options have to be passed to
                   6739: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
                   6740: especially if you don't have all the machines at your hand to test things. The
                   6741: devel/libtool pkg can help here, as it just "knows" how to build both static
                   6742: and dynamic libraries from a set of source files, thus being
                   6743: platform-independent.
                   6744: 
                   6745: Here's how to use libtool in a package in seven simple steps:
                   6746: 
                   6747:  1. Add USE_LIBTOOL=yes to the package Makefile.
                   6748: 
                   6749:  2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
                   6750:     {CC}". You could even add it to the definition of CC, if only libraries are
                   6751:     being built in a given Makefile. This one command will build both PIC and
                   6752:     non-PIC library objects, so you need not have separate shared and
                   6753:     non-shared library rules.
                   6754: 
                   6755:  3. For the linking of the library, remove any "ar", "ranlib", and "ld
                   6756:     -Bshareable" commands, and instead use:
                   6757: 
                   6758:     ${LIBTOOL} --mode=link \
                   6759:         ${CC} -o ${.TARGET:.a=.la} \
                   6760:             ${OBJS:.o=.lo} \
                   6761:             -rpath ${PREFIX}/lib \
                   6762:             -version-info major:minor
                   6763: 
                   6764:     Note that the library is changed to have a .la extension, and the objects
                   6765:     are changed to have a .lo extension. Change OBJS as necessary. This
                   6766:     automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
                   6767:     necessary) in the build directory. Be sure to include "-version-info",
                   6768:     especially when major and minor are zero, as libtool will otherwise strip
                   6769:     off the shared library version.
                   6770: 
                   6771:     From the libtool manual:
                   6772: 
                   6773:     So, libtool library versions are described by three integers:
                   6774: 
                   6775:     CURRENT
                   6776:     The most recent interface number that this library implements.
                   6777: 
                   6778:     REVISION
                   6779:     The implementation number of the CURRENT interface.
                   6780: 
                   6781:     AGE
                   6782:     The difference between the newest and oldest interfaces that
                   6783:     this library implements.  In other words, the library implements
                   6784:     all the interface numbers in the range from number `CURRENT -
                   6785:     AGE' to `CURRENT'.
                   6786: 
                   6787:     If two libraries have identical CURRENT and AGE numbers, then the
                   6788:     dynamic linker chooses the library with the greater REVISION number.
                   6789: 
                   6790:     The "-release" option will produce different results for a.out and ELF
1.25      wiz      6791:     (excluding symlinks) in only one case. An ELF library of the form "
                   6792:     libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1       dsieger  6793:     platform. This is handled automatically.
                   6794: 
                   6795:     The "-rpath argument" is the install directory of the library being built.
                   6796: 
                   6797:     In the PLIST, include only the .la file, the other files will be added
                   6798:     automatically.
                   6799: 
                   6800:  4. When linking shared object (.so) files, i.e. files that are loaded via
                   6801:     dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
                   6802:     them getting version tacked on.
                   6803: 
                   6804:     The PLIST file gets the foo.so entry.
                   6805: 
                   6806:  5. When linking programs that depend on these libraries before they are
                   6807:     installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
                   6808:     and it will find the correct libraries (static or shared), but please be
                   6809:     aware that libtool will not allow you to specify a relative path in -L
                   6810:     (such as "-L../somelib"), because it expects you to change that argument to
                   6811:     be the .la file. e.g.
                   6812: 
                   6813:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   6814: 
                   6815:     should be changed to:
                   6816: 
                   6817:     ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
                   6818: 
                   6819:     and it will do the right thing with the libraries.
                   6820: 
                   6821:  6. When installing libraries, preface the install(1) or cp(1) command with "$
                   6822:     {LIBTOOL} --mode=install", and change the library name to .la. e.g.
                   6823: 
1.23      jakllsch 6824:     ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1       dsieger  6825: 
                   6826:     This will install the static .a, shared library, any needed symlinks, and
                   6827:     run ldconfig(8).
                   6828: 
                   6829:  7. In your PLIST, include only the .la file (this is a change from previous
                   6830:     behaviour).
                   6831: 
1.154     rillig   6832: 21.3.2. Using libtool on GNU packages that already support libtool
1.1       dsieger  6833: 
                   6834: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
                   6835: own libtool in most cases. For older libtool using packages, libtool is made by
                   6836: ltconfig script during the do-configure step; you can check the libtool script
                   6837: location by doing make configure; find work*/ -name libtool.
                   6838: 
                   6839: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
                   6840: override. By default, it is set to "libtool */libtool */*/libtool". If this
                   6841: does not match the location of the package's libtool script(s), set it as
                   6842: appropriate.
                   6843: 
                   6844: If you do not need *.a static libraries built and installed, then use
                   6845: SHLIBTOOL_OVERRIDE instead.
                   6846: 
                   6847: If your package makes use of the platform-independent library for loading
                   6848: dynamic shared objects, that comes with libtool (libltdl), you should include
                   6849: devel/libltdl/buildlink3.mk.
                   6850: 
                   6851: Some packages use libtool incorrectly so that the package may not work or build
                   6852: in some circumstances. Some of the more common errors are:
                   6853: 
                   6854:   * The inclusion of a shared object (-module) as a dependent library in an
                   6855:     executable or library. This in itself isn't a problem if one of two things
                   6856:     has been done:
                   6857: 
                   6858:      1. The shared object is named correctly, i.e. libfoo.la, not foo.la
                   6859: 
                   6860:      2. The -dlopen option is used when linking an executable.
                   6861: 
                   6862:   * The use of libltdl without the correct calls to initialisation routines.
                   6863:     The function lt_dlinit() should be called and the macro
                   6864:     LTDL_SET_PRELOADED_SYMBOLS included in executables.
                   6865: 
1.154     rillig   6866: 21.3.3. GNU Autoconf/Automake
1.1       dsieger  6867: 
                   6868: If a package needs GNU autoconf or automake to be executed to regenerate the
1.223     nia      6869: configure script and Makefile.in makefile templates from configure.ac and
                   6870: Makefile.am, then they should be executed in a pre-configure target:
1.1       dsieger  6871: 
1.223     nia      6872: USE_TOOLS+=     autoconf automake autoreconf
                   6873: GNU_CONFIGURE=  yes
1.1       dsieger  6874: ...
                   6875: 
                   6876: pre-configure:
1.223     nia      6877:         set -e; cd ${WRKSRC} && autoreconf -fi
1.1       dsieger  6878: ...
                   6879: 
1.223     nia      6880: Packages which use GNU Automake will sometimes require GNU Make (gmake in
                   6881: USE_TOOLS), but not always. Note that autoreconf only needs to be executed if
                   6882: configure.ac or Makefiles are modified, or configure is not present.
1.1       dsieger  6883: 
                   6884: There are times when the configure process makes additional changes to the
                   6885: generated files, which then causes the build process to try to re-execute the
                   6886: automake sequence. This is prevented by touching various files in the configure
                   6887: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
                   6888: NO in the package Makefile.
                   6889: 
1.223     nia      6890: 21.3.4. Meson / ninja
                   6891: 
                   6892: Packages using Meson to configure need to include:
                   6893: 
                   6894: .include "../../devel/meson/build.mk"
                   6895: 
                   6896: In nearly all cases (any program with dependencies), pkg-config needs to be
                   6897: added to USE_TOOLS. If the package installs translation files for non-English
                   6898: languages, also add msgfmt and xgettext:
                   6899: 
                   6900: USE_TOOLS+=     pkg-config msgfmt xgettext
                   6901: 
                   6902: If any options need to be passed to Meson, use MESON_ARGS instead of
                   6903: CONFIGURE_ARGS:
                   6904: 
                   6905: MESON_ARGS+=    -Dx11=false
                   6906: 
1.260     wiz      6907: 21.3.5. Determining the endianness
                   6908: 
                   6909: To determine the endianness of the target platform, have a look at mk/
                   6910: endian.mk.
                   6911: 
1.154     rillig   6912: 21.4. Programming languages
1.1       dsieger  6913: 
1.154     rillig   6914: 21.4.1. C, C++, and Fortran
1.1       dsieger  6915: 
1.244     gutterid 6916: Compilers for the C and C++ languages come with the NetBSD base system. By
1.223     nia      6917: default, pkgsrc assumes that a package is written in C and will hide all other
                   6918: compilers (via the wrapper framework, see Chapter 18, Buildlink methodology).
1.1       dsieger  6919: 
1.243     gutterid 6920: To declare which languages should be made available through pkgsrc's compiler
                   6921: wrappers, use the USE_LANGUAGES variable. Allowed values currently are:
1.212     wiz      6922: 
1.244     gutterid 6923: c, c++, fortran, fortran77, java, objc, obj-c++, and ada.
1.212     wiz      6924: 
                   6925: (and any combination). The default is "c". Packages using GNU configure
                   6926: scripts, even if written in C++, usually need a C compiler for the configure
1.244     gutterid 6927: phase.
1.243     gutterid 6928: 
1.250     jnemeth  6929: To declare which features a package requires from the compiler, set either
1.243     gutterid 6930: USE_CC_FEATURES or USE_CXX_FEATURES. Allowed values for USE_CC_FEATURES are
                   6931: currently:
                   6932: 
                   6933: c11, c99, has_include
                   6934: 
                   6935: Allowed values for USE_CXX_FEATURES are currently:
                   6936: 
                   6937: c++11, c++14, c++17, c++20, has_include, regex, filesystem,
                   6938: charconv, parallelism_ts, unique_ptr, put_time,
                   6939: is_trivially_copy_constructible
1.1       dsieger  6940: 
1.251     gutterid 6941: Note at present these variables only affect use of GCC, not other compilers.
                   6942: 
1.244     gutterid 6943: Language variants like gnu99 and c++11 can be specified in FORCE_C_STD and
                   6944: FORCE_CXX_STD if the package does not explicitly set -std=... when compiling
                   6945: (i.e. the package assumes the compiler defaults to C++11 or some other
                   6946: standard). This is a common bug in upstream build systems.
                   6947: 
                   6948: Allowed values for FORCE_C_STD are currently:
                   6949: 
                   6950: c90, c99, c11, gnu90, gnu99, gnu11
                   6951: 
                   6952: Allowed values for FORCE_CXX_STD are currently:
                   6953: 
                   6954: c++03, c++11, c++14, c++17, c++20,
                   6955: gnu++03, gnu++11, gnu++14, gnu++17, gnu++20
                   6956: 
1.251     gutterid 6957: Note at present these variables only affect use of GCC and Clang.
                   6958: 
1.154     rillig   6959: 21.4.2. Java
1.1       dsieger  6960: 
                   6961: If a program is written in Java, use the Java framework in pkgsrc. The package
                   6962: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
                   6963: variables:
                   6964: 
                   6965:   * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
                   6966:     set to "run", then there is only a runtime dependency on the JDK. The
                   6967:     default is "yes", which also adds a build dependency on the JDK.
                   6968: 
                   6969:   * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
                   6970:     supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
                   6971:     implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
                   6972:     accepts versions 1.5 or above. This variable is not set by default.
                   6973: 
1.25      wiz      6974:   * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
                   6975:     implementation dependency. It may be used to set JAVA_HOME to a good value
                   6976:     if the program needs this variable to be defined.
                   6977: 
1.205     wiz      6978: 21.4.3. Go
                   6979: 
                   6980: If a program is written in Go and has any dependencies on other Go modules,
                   6981: have the package include ../../lang/go/go-module.mk.
                   6982: 
                   6983:  1. Generate a list of those dependencies with make clean && make patch && make
                   6984:     show-go-modules > go-modules.mk.
                   6985: 
1.223     nia      6986:  2. Prepend .include "go-modules.mk" to any other .includes.
                   6987: 
                   6988:  3. Incorporate these modules in distinfo with make makesum.
1.205     wiz      6989: 
1.223     nia      6990: 21.4.4. Rust
1.205     wiz      6991: 
1.223     nia      6992: If a program is written in Rust and uses Cargo to build, have the package
                   6993: include ../../lang/rust/cargo.mk.
1.205     wiz      6994: 
1.223     nia      6995:  1. Generate a list of those dependencies with make CARGO_ARGS="build
                   6996:     --release" build && make print-cargo-depends > cargo-depends.mk.
1.205     wiz      6997: 
1.223     nia      6998:  2. Prepend .include "cargo-depends.mk" to any other .includes.
1.205     wiz      6999: 
                   7000:  3. Incorporate these modules in distinfo with make makesum.
                   7001: 
1.223     nia      7002: 21.4.5. Packages containing Perl scripts
1.1       dsieger  7003: 
1.203     nia      7004: If your package contains interpreted Perl scripts, add "perl" to the USE_TOOLS
1.1       dsieger  7005: variable and set REPLACE_PERL to ensure that the proper interpreter path is
                   7006: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74      wiz      7007: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
1.210     gutterid 7008: replaced with the full path to the Perl executable.
1.1       dsieger  7009: 
1.210     gutterid 7010: If a particular version of Perl is needed, set the PERL5_REQD variable to the
1.1       dsieger  7011: version number. The default is "5.0".
                   7012: 
1.203     nia      7013: See Section 21.6.6, "Packages installing Perl modules" for information about
1.210     gutterid 7014: handling Perl modules.
                   7015: 
                   7016: There is also the REPLACE_PERL6 variable for the language now known as Raku.
1.1       dsieger  7017: 
1.223     nia      7018: 21.4.6. Packages containing shell scripts
1.41      wiz      7019: 
                   7020: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
1.225     gutterid 7021: shell she-bangs in files. Please use the appropriate one, preferring REPLACE_SH
                   7022: when this shell is sufficient. Each should contain a list of scripts, relative
                   7023: to WRKSRC, that you want adjusted. Every occurrence of the matching shell in a
                   7024: she-bang line will be replaced with the full path to the shell executable. When
                   7025: using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41      wiz      7026: 
1.223     nia      7027: 21.4.7. Other programming languages
1.1       dsieger  7028: 
1.210     gutterid 7029: There are further similar REPLACE variables available, e.g., REPLACE_AWK for
                   7030: packages containing awk scripts, and REPLACE_R for R. These two, like the
1.211     gutterid 7031: others noted above, have their actions defined centrally in mk/configure/
                   7032: replace-interpreter.mk. Other languages define the actions of these variables
                   7033: within their own dedicated part of the tree, e.g., REPLACE_PHP is actioned in
1.245     gutterid 7034: lang/php/replace.mk, and REPLACE_PYTHON is actioned in lang/python/
1.211     gutterid 7035: application.mk. For other languages, consult the mk files found within their
1.216     gutterid 7036: specific directories (the naming convention varies), or check the list found in
                   7037: Appendix E, Help topics.
1.210     gutterid 7038: 
                   7039: Currently, special handling for other languages varies in pkgsrc. If a compiler
                   7040: package provides a buildlink3.mk file, include that, otherwise just add a
                   7041: (build) dependency on the appropriate compiler package.
1.1       dsieger  7042: 
1.154     rillig   7043: 21.5. The build phase
1.1       dsieger  7044: 
                   7045: The most common failures when building a package are that some platforms do not
                   7046: provide certain header files, functions or libraries, or they provide the
                   7047: functions in a library that the original package author didn't know. To work
                   7048: around this, you can rewrite the source code in most cases so that it does not
                   7049: use the missing functions or provides a replacement function.
                   7050: 
1.154     rillig   7051: 21.5.1. Compiling C and C++ code conditionally
1.1       dsieger  7052: 
                   7053: If a package already comes with a GNU configure script, the preferred way to
                   7054: fix the build failure is to change the configure script, not the code. In the
                   7055: other cases, you can utilize the C preprocessor, which defines certain macros
                   7056: depending on the operating system and hardware architecture it compiles for.
                   7057: These macros can be queried using for example #if defined(__i386). Almost every
                   7058: operating system, hardware architecture and compiler has its own macro. For
                   7059: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
                   7060: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
                   7061: GCC.
                   7062: 
                   7063: The list of the following macros for hardware and operating system depends on
                   7064: the compiler that is used. For example, if you want to conditionally compile
                   7065: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
                   7066: Use __sun instead.
                   7067: 
1.154     rillig   7068: 21.5.1.1. C preprocessor macros to identify the operating system
1.1       dsieger  7069: 
1.223     nia      7070: To distinguish between specific NetBSD versions, you should use the following
                   7071: code.
                   7072: 
                   7073: #ifdef __NetBSD__
                   7074: #include <sys/param.h>
                   7075: #if __NetBSD_Prereq__(9,99,17)
                   7076: /* use a newer feature */
                   7077: #else
                   7078: /* older code */
                   7079: #endif
                   7080: #endif
                   7081: 
                   7082: #ifndef _WIN32
                   7083: /* Unix-like specific code */
                   7084: #endif
                   7085: 
1.1       dsieger  7086: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
                   7087: should use the following code.
                   7088: 
                   7089: #include <sys/param.h>
                   7090: #if (defined(BSD) && BSD >= 199306)
                   7091: /* BSD-specific code goes here */
                   7092: #else
                   7093: /* non-BSD-specific code goes here */
                   7094: #endif
                   7095: 
1.223     nia      7096: You can also test for the following macros:
1.1       dsieger  7097: 
1.46      obache   7098: Cygwin      __CYGWIN__
                   7099: DragonFly   __DragonFly__
1.1       dsieger  7100: FreeBSD     __FreeBSD__
1.46      obache   7101: Haiku       __HAIKU__
1.1       dsieger  7102: Interix     __INTERIX
                   7103: IRIX        __sgi (TODO: get a definite source for this)
1.223     nia      7104: Linux       __linux
1.83      dholland 7105: Mac OS X    __APPLE__
1.46      obache   7106: Minix3      __minix
1.1       dsieger  7107: NetBSD      __NetBSD__
                   7108: OpenBSD     __OpenBSD__
                   7109: Solaris     sun, __sun
                   7110: 
1.154     rillig   7111: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1       dsieger  7112: 
                   7113: i386        i386, __i386, __i386__
1.223     nia      7114: x86-64      __amd64__, __x86_64__
                   7115: ARM         __arm__
1.1       dsieger  7116: MIPS        __mips
                   7117: SPARC       sparc, __sparc
1.223     nia      7118: PowerPC     __powerpc
1.1       dsieger  7119: 
1.154     rillig   7120: 21.5.1.3. C preprocessor macros to identify the compiler
1.1       dsieger  7121: 
                   7122: GCC         __GNUC__ (major version), __GNUC_MINOR__
                   7123: MIPSpro     _COMPILER_VERSION (0x741 for MIPSpro 7.41)
                   7124: SunPro      __SUNPRO_C (0x570 for Sun C 5.7)
                   7125: SunPro C++  __SUNPRO_CC (0x580 for Sun C++ 5.8)
                   7126: 
1.154     rillig   7127: 21.5.2. How to handle compiler bugs
1.1       dsieger  7128: 
                   7129: Some source files trigger bugs in the compiler, based on combinations of
                   7130: compiler version and architecture and almost always relation to optimisation
                   7131: being enabled. Common symptoms are gcc internal errors or never finishing
                   7132: compiling a file.
                   7133: 
                   7134: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87      tnn      7135: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
                   7136: 
                   7137: This used to be a big problem in the past, but is rarely needed now as compiler
                   7138: technology has matured. If you still need to add a compiler specific
                   7139: workaround, please do so in the file hacks.mk and describe the symptom and
                   7140: compiler version as detailed as possible.
1.1       dsieger  7141: 
1.172     rillig   7142: 21.5.3. No such file or directory
                   7143: 
                   7144: Compilation sometimes fails with an error message like this:
                   7145: 
                   7146: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
                   7147:     fatal error: pango/pango.h: No such file or directory
                   7148: 
                   7149: The proper way to fix this problem depends on the type of the header, which is
                   7150: described in the following sections.
                   7151: 
                   7152: 21.5.3.1. Headers from other packages
                   7153: 
                   7154: If the header name looks like it comes from a different package, that other
                   7155: package should be included via the buildlink3 framework.
                   7156: 
                   7157: First, look whether the header is somewhere in the buildlink3 directory below
                   7158: WRKDIR. In the above case of the missing Pango header:
                   7159: 
                   7160: $ find work/.buildlink/ -print | grep -F pango/pango.h
                   7161: 
                   7162: In the case of Pango, the output is:
                   7163: 
                   7164: work/.buildlink/include/pango-1.0/pango/pango.h
                   7165: 
                   7166: If the pango/pango.h file were placed directly in the .buildlink directory, it
                   7167: would have been found automatically. There is an extra pango-1.0 path component
                   7168: though, which means that the compiler command line must contain an option of
                   7169: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
                   7170: option is generated by the configure script, which can be examined using:
                   7171: 
                   7172: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
                   7173: -I/usr/pkg/include/pango-1.0
                   7174: -I/usr/pkg/include/pango-1.0
                   7175: -I/usr/pkg/include/pango-1.0
                   7176: -I/usr/pkg/include/pango-1.0
                   7177: -I/usr/pkg/include/pango-1.0
                   7178: 
                   7179: This looks good. These options are transformed by the buildlink wrapper to
                   7180: refer to the correct path inside work/.buildlink.
                   7181: 
                   7182: Since the compilation fails though, examine the compiler command lines in work
                   7183: /.work.log to see whether the -I option is included in the particular command
                   7184: line.
                   7185: 
                   7186: To further analyze the situation, run bmake build-env, which sets up an
                   7187: interactive, realistic environment including all the pkgsrc wrapper commands
                   7188: and environment variables. From there, try to compile some simple example
                   7189: programs that use the header.
                   7190: 
                   7191: 21.5.3.2. Headers generated during the build
                   7192: 
                   7193: If the name of the header seems to come from the package itself, and if the
                   7194: build is run with parallel jobs, the package may have some undeclared
                   7195: dependencies between the .c and the .h files, and a C file is compiled before
                   7196: its required header is generated.
                   7197: 
                   7198: To see whether the build runs with parallel jobs, run bmake show-all-build |
                   7199: grep JOBS. Its output looks like this:
                   7200: 
                   7201:   usr   MAKE_JOBS=              7
                   7202:   pkg   MAKE_JOBS_SAFE          # undefined
                   7203:   def   _MAKE_JOBS_N=           7
                   7204: 
                   7205: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
                   7206: parallel (MAKE_JOBS). The package could have disabled parallel builds by
                   7207: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
                   7208: 
                   7209: To see whether the build failure is caused by parallel builds, first save the
                   7210: exact error message and a bit of context, maybe you need it later for reporting
                   7211: a bug. Next, run:
                   7212: 
                   7213: MAKE_JOBS_SAFE=no bmake clean build
                   7214: 
                   7215: If that succeeds, file a bug report against the pkgsrc package, including the
                   7216: exact error message and the contents of your mk.conf file.
                   7217: 
1.173     rillig   7218: 21.5.3.3. Symlinks
                   7219: 
                   7220: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
                   7221: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
                   7222: in symlink-based directories. Existing pkgsrc installations are not checked for
                   7223: symlinks though.
                   7224: 
                   7225: The "No such file or directory" error messages are a typical symptom of
                   7226: symlinks, and it's quite difficult to find out that this is the actual cause.
                   7227: 
                   7228: 21.5.3.4. Stale working directories
                   7229: 
                   7230: When building a hierarchy of packages, it may happen that one package is built
                   7231: and then pkgsrc is updated. This situation can provoke various hard to diagnose
                   7232: build errors. To clean up the situation:
                   7233: 
1.223     nia      7234: $ (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work)
1.173     rillig   7235: 
1.223     nia      7236: (The only purpose of the bsd.pkg.mk is to prevent running this command in the
                   7237: wrong directory.)
1.173     rillig   7238: 
                   7239: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
                   7240: 
                   7241: 21.5.3.5. Other possible reasons
                   7242: 
                   7243: On platforms other than BSD, third-party packages are installed in /usr/
                   7244: include, together with the base system. This means that pkgsrc cannot
                   7245: distinguish between headers provided by the base system (which it needs) and
                   7246: headers from third-party packages (which are often included in pkgsrc as well).
                   7247: This can lead to subtle version mismatches.
                   7248: 
                   7249: In pkgsrc installations that have been active for several years, it may happen
                   7250: that some files are manually deleted. To exclude this unlikely reason, run 
                   7251: pkg_admin check.
                   7252: 
                   7253: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
                   7254: 
                   7255: If all of the above doesn't help, see Chapter 2, Getting help for contact
                   7256: information. Be prepared to describe what you have tried so far and what any
                   7257: error messages were.
                   7258: 
1.172     rillig   7259: 21.5.4. Undefined reference to "..."
1.1       dsieger  7260: 
                   7261: This error message often means that a package did not link to a shared library
                   7262: it needs. The following functions are known to cause this error message over
                   7263: and over.
                   7264: 
                   7265: +-----------------------------------------------------+
                   7266: |        Function         |Library |Affected platforms|
                   7267: |-------------------------+--------+------------------|
                   7268: |accept, bind, connect    |-lsocket|Solaris           |
                   7269: |-------------------------+--------+------------------|
                   7270: |crypt                    |-lcrypt |DragonFly, NetBSD |
                   7271: |-------------------------+--------+------------------|
                   7272: |dlopen, dlsym            |-ldl    |Linux             |
                   7273: |-------------------------+--------+------------------|
                   7274: |gethost*                 |-lnsl   |Solaris           |
                   7275: |-------------------------+--------+------------------|
                   7276: |inet_aton                |-lresolv|Solaris           |
                   7277: |-------------------------+--------+------------------|
                   7278: |nanosleep, sem_*, timer_*|-lrt    |Solaris           |
                   7279: |-------------------------+--------+------------------|
                   7280: |openpty                  |-lutil  |Linux             |
                   7281: +-----------------------------------------------------+
                   7282: 
1.223     nia      7283: To fix these linker errors, it is often sufficient to add LIBS.OperatingSystem+
                   7284: = -lfoo to the package Makefile and then run bmake clean; bmake.
1.1       dsieger  7285: 
1.223     nia      7286: 21.5.4.1. The SunPro compiler and inline functions
1.1       dsieger  7287: 
                   7288: When you are using the SunPro compiler, there is another possibility. That
                   7289: compiler cannot handle the following code:
                   7290: 
                   7291: extern int extern_func(int);
                   7292: 
                   7293: static inline int
                   7294: inline_func(int x)
                   7295: {
                   7296:         return extern_func(x);
                   7297: }
                   7298: 
                   7299: int main(void)
                   7300: {
                   7301:         return 0;
                   7302: }
                   7303: 
                   7304: It generates the code for inline_func even if that function is never used. This
                   7305: code then refers to extern_func, which can usually not be resolved. To solve
                   7306: this problem you can try to tell the package to disable inlining of functions.
                   7307: 
1.228     gutterid 7308: 21.5.4.2. Missing atomic functions
                   7309: 
                   7310: When building for older machine architectures (e.g., i386, PowerPC), builds may
                   7311: fail because the package expects modern 64-bit atomic functions which the
                   7312: underlying hardware either doesn't support, or will only support with specific
                   7313: compiler flags. This is generally handled via inclusion of mk/atomic64.mk.
                   7314: 
1.172     rillig   7315: 21.5.5. Running out of memory
1.1       dsieger  7316: 
                   7317: Sometimes packages fail to build because the compiler runs into an operating
                   7318: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.223     nia      7319: told to unlimit the resources. The allowed values are any combination of "
                   7320: cputime", "datasize", "memorysize", "stacksize" and "virtualsize". Setting this
                   7321: variable is similar to running the shell builtin ulimit command to raise the
                   7322: maximum data segment size or maximum stack size of a process, respectively, to
                   7323: their hard limits.
1.1       dsieger  7324: 
1.154     rillig   7325: 21.6. The install phase
1.1       dsieger  7326: 
1.154     rillig   7327: 21.6.1. Creating needed directories
1.1       dsieger  7328: 
                   7329: The BSD-compatible install supplied with some operating systems cannot create
                   7330: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
                   7331: like this:
                   7332: 
                   7333: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   7334: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
                   7335: 
1.223     nia      7336: Instead of running the install commands directly, you can also append "dir1
                   7337: dir2" to the INSTALLATION_DIRS variable, which will automatically do the right
                   7338: thing.
1.1       dsieger  7339: 
1.154     rillig   7340: 21.6.2. Where to install documentation
1.1       dsieger  7341: 
                   7342: In general, documentation should be installed into ${PREFIX}/share/doc/$
1.223     nia      7343: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME_NOREV} (the latter includes the
                   7344: version number of the package).
1.1       dsieger  7345: 
                   7346: Many modern packages using GNU autoconf allow to set the directory where HTML
                   7347: documentation is installed with the "--with-html-dir" option. Sometimes using
                   7348: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
1.223     nia      7349: share/doc/html or other places. In pkgsrc, the HTML documentation should go
                   7350: into the package-specific directory, just like any other documentation.
1.1       dsieger  7351: 
                   7352: An exception to the above is that library API documentation generated with the
                   7353: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
                   7354: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
                   7355: can be recognized from files ending in .devhelp or .devhelp2. (It is also
                   7356: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
                   7357: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
                   7358: then, no additional subdirectory level is allowed in this case. This is usually
                   7359: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
                   7360: gtk-doc is preferred though.)
                   7361: 
1.154     rillig   7362: 21.6.3. Installing highscore files
1.1       dsieger  7363: 
                   7364: Certain packages, most of them in the games category, install a score file that
                   7365: allows all users on the system to record their highscores. In order for this to
                   7366: work, the binaries need to be installed setgid and the score files owned by the
1.36      wiz      7367: appropriate group and/or owner (traditionally the "games" user/group). Set
                   7368: USE_GAMESGROUP to yes to support this. The following variables, documented in
                   7369: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100     leot     7370: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
                   7371: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
                   7372: 
                   7373: An example that illustrates some of the variables described above is games/
                   7374: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
                   7375: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
                   7376: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
                   7377: to install setgid the game binary:
                   7378: 
                   7379: USE_GAMESGROUP=         yes
                   7380: 
                   7381: BUILD_DEFS+=            VARBASE
                   7382: 
                   7383: OWN_DIRS_PERMS+=        ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
                   7384: REQD_FILES_PERMS+=      /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
                   7385: SPECIAL_PERMS+=         ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
                   7386: 
                   7387: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
                   7388: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
                   7389: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1       dsieger  7390: 
1.14      jmcneill 7391: A package should therefore never hard code file ownership or access permissions
1.100     leot     7392: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
                   7393: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1       dsieger  7394: 
1.154     rillig   7395: 21.6.4. Adding DESTDIR support to packages
1.4       rillig   7396: 
1.14      jmcneill 7397: DESTDIR support means that a package installs into a staging directory, not the
                   7398: final location of the files. Then a binary package is created which can be used
                   7399: for installation as usual. There are two ways: Either the package must install
1.25      wiz      7400: as root ("destdir") or the package can install as non-root user ("user-destdir"
                   7401: ).
1.14      jmcneill 7402: 
1.113     leot     7403:   * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
                   7404:     default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
                   7405:     potential packaging problems. If bsd.prefs.mk is included in the Makefile,
                   7406:     PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14      jmcneill 7407: 
1.4       rillig   7408:   * All installation operations have to be prefixed with ${DESTDIR}.
                   7409: 
                   7410:   * automake gets this DESTDIR mostly right automatically. Many manual rules
                   7411:     and pre/post-install often are incorrect; fix them.
                   7412: 
1.17      imil     7413:   * If files are installed with special owner/group use SPECIAL_PERMS.
1.4       rillig   7414: 
                   7415:   * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
                   7416: 
1.154     rillig   7417: 21.6.5. Packages with hardcoded paths to other interpreters
1.1       dsieger  7418: 
                   7419: Your package may also contain scripts with hardcoded paths to other
1.203     nia      7420: interpreters besides (or as well as) Perl. To correct the full pathname to the
1.1       dsieger  7421: script interpreter, you need to set the following definitions in your Makefile
                   7422: (we shall use tclsh in this example):
                   7423: 
                   7424: REPLACE_INTERPRETER+=   tcl
                   7425: REPLACE.tcl.old=        .*/bin/tclsh
                   7426: REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   7427: REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   7428: # relative to ${WRKSRC}, just as in REPLACE_PERL
                   7429: 
1.203     nia      7430: 21.6.6. Packages installing Perl modules
1.1       dsieger  7431: 
                   7432: Makefiles of packages providing perl5 modules should include the Makefile
                   7433: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
                   7434: standard perl configuration for such modules as well as various hooks to tune
                   7435: this configuration. See comments in this file for details.
                   7436: 
                   7437: Perl5 modules will install into different places depending on the version of
                   7438: perl used during the build process. To address this, pkgsrc will append lines
                   7439: to the PLIST corresponding to the files listed in the installed .packlist file
                   7440: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48      wiz      7441: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
                   7442: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1       dsieger  7443: 
1.48      wiz      7444: PERL5_PACKLIST= auto/Pg/.packlist
1.1       dsieger  7445: 
1.48      wiz      7446: The perl5 config variables installarchlib, installscript, installvendorbin,
                   7447: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
                   7448: and installvendorman3dir represent those locations in which components of perl5
                   7449: modules may be installed, provided as variable with uppercase and prefixed with
                   7450: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
                   7451: have a packlist. These variables are also substituted for in the PLIST as
                   7452: uppercase prefixed with PERL5_SUB_.
1.1       dsieger  7453: 
1.254     wiz      7454: 21.6.7. Packages installing pkg-config files
                   7455: 
                   7456: Some packages, usually those providing libraries, install pkg-config files so
                   7457: that their headers and libraries can easily be found. The file names end with
                   7458: .pc.
                   7459: 
                   7460: Most of the time, these files only provide the linker flags for the library,
                   7461: but do not include the flags for setting the rpath so the libraries can also be
                   7462: found at runtime. Since this is so common, pkgsrc provides PKGCONFIG_OVERRIDE
                   7463: for this. Many packages generate the .pc from .pc.in, in that case add those
                   7464: files to the PKGCONFIG_OVERRIDE variable:
                   7465: 
                   7466: PKGCONFIG_OVERRIDE+=   foo.pc.in
                   7467: 
                   7468: 
                   7469: For packages using meson, the files are generated during build and you also
                   7470: need to change the phase in which the replacement is done. For example:
                   7471: 
                   7472: PKGCONFIG_OVERRIDE+=            output/meson-private/foo.pc
                   7473: PKGCONFIG_OVERRIDE_STAGE=       post-build
                   7474: 
                   7475: 
                   7476: 21.6.8. Packages installing info files
1.1       dsieger  7477: 
                   7478: Some packages install info files or use the "makeinfo" or "install-info"
                   7479: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
                   7480: and DEINSTALL scripts will be generated to handle registration of the info
                   7481: files in the Info directory file. The "install-info" command used for the info
                   7482: files registration is either provided by the system, or by a special purpose
                   7483: package automatically added as dependency if needed.
                   7484: 
                   7485: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
                   7486: located. PKGINFODIR defaults to "info" and can be overridden by the user.
                   7487: 
                   7488: The info files for the package should be listed in the package PLIST; however
                   7489: any split info files need not be listed.
                   7490: 
                   7491: A package which needs the "makeinfo" command at build time must add "makeinfo"
                   7492: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
                   7493: needed it should be noted with the TEXINFO_REQD variable in the package
                   7494: Makefile. By default, a minimum version of 3.12 is required. If the system does
                   7495: not provide a makeinfo command or if it does not match the required minimum, a
                   7496: build dependency on the devel/gtexinfo package will be added automatically.
                   7497: 
                   7498: The build and installation process of the software provided by the package
                   7499: should not use the install-info command as the registration of info files is
1.25      wiz      7500: the task of the package INSTALL script, and it must use the appropriate 
1.1       dsieger  7501: makeinfo command.
                   7502: 
                   7503: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
                   7504: the install-info and makeinfo commands in a directory listed early in PATH.
                   7505: 
                   7506: The script overriding install-info has no effect except the logging of a
                   7507: message. The script overriding makeinfo logs a message and according to the
                   7508: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
                   7509: error.
                   7510: 
1.254     wiz      7511: 21.6.9. Packages installing man pages
1.1       dsieger  7512: 
                   7513: All packages that install manual pages should install them into the same
                   7514: directory, so that there is one common place to look for them. In pkgsrc, this
                   7515: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25      wiz      7516: packages. The default for PKGMANDIR is "man". Another often-used value is "
                   7517: share/man".
1.1       dsieger  7518: 
                   7519: Note
                   7520: 
                   7521: The support for a custom PKGMANDIR is far from complete.
                   7522: 
                   7523: The PLIST files can just use man/ as the top level directory for the man page
                   7524: file entries, and the pkgsrc framework will convert as needed. In all other
                   7525: places, the correct PKGMANDIR must be used.
                   7526: 
                   7527: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
                   7528: use the ./configure --mandir switch to set where the man pages should be
                   7529: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
                   7530: {PKGMANDIR}.
                   7531: 
                   7532: Packages that use GNU_CONFIGURE but do not use --mandir, can set
                   7533: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
                   7534: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
                   7535: 
1.184     rillig   7536: See Section 19.5, "Man page compression" for information on installation of
1.1       dsieger  7537: compressed manual pages.
                   7538: 
1.254     wiz      7539: 21.6.10. Packages installing X11 fonts
1.1       dsieger  7540: 
                   7541: If a package installs font files, you will need to rebuild the fonts database
                   7542: in the directory where they get installed at installation and deinstallation
                   7543: time. This can be automatically done by using the pkginstall framework.
                   7544: 
                   7545: You can list the directories where fonts are installed in the FONTS_DIRS.type
                   7546: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
                   7547: that the database file fonts.dir is not listed in the PLIST.
                   7548: 
                   7549: Note that you should not create new directories for fonts; instead use the
                   7550: standard ones to avoid that the user needs to manually configure his X server
                   7551: to find them.
                   7552: 
1.254     wiz      7553: 21.6.11. Packages installing SGML or XML data
1.1       dsieger  7554: 
                   7555: If a package installs SGML or XML data files that need to be registered in
                   7556: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
                   7557: extra steps:
                   7558: 
                   7559:  1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
                   7560:     care of registering those files in system-wide catalogs at installation and
                   7561:     deinstallation time.
                   7562: 
                   7563:  2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
                   7564:     package.
                   7565: 
                   7566:  3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
                   7567:     package.
                   7568: 
                   7569:  4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
                   7570:     These come in groups of three strings; see xmlcatmgr(1) for more
                   7571:     information (specifically, arguments recognized by the 'add' action). Note
                   7572:     that you will normally not use this variable.
                   7573: 
                   7574:  5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
                   7575:     come in groups of three strings; see xmlcatmgr(1) for more information
                   7576:     (specifically, arguments recognized by the 'add' action). Note that you
                   7577:     will normally not use this variable.
                   7578: 
1.254     wiz      7579: 21.6.12. Packages installing extensions to the MIME database
1.1       dsieger  7580: 
                   7581: If a package provides extensions to the MIME database by installing .xml files
                   7582: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
                   7583: ensure that the database is kept consistent with respect to these new files:
                   7584: 
                   7585:  1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
                   7586:     buildlink3.mk file from this same directory, which is reserved for
                   7587:     inclusion from other buildlink3.mk files). It takes care of rebuilding the
                   7588:     MIME database at installation and deinstallation time, and disallows any
                   7589:     access to it directly from the package.
                   7590: 
1.25      wiz      7591:  2. Check the PLIST and remove any entries under the share/mime directory, 
1.1       dsieger  7592:     except for files saved under share/mime/packages. The former are handled
                   7593:     automatically by the update-mime-database program, but the latter are
                   7594:     package-dependent and must be removed by the package that installed them in
                   7595:     the first place.
                   7596: 
                   7597:  3. Remove any share/mime/* directories from the PLIST. They will be handled by
                   7598:     the shared-mime-info package.
                   7599: 
1.254     wiz      7600: 21.6.13. Packages using intltool
1.1       dsieger  7601: 
                   7602: If a package uses intltool during its build, add intltool to the USE_TOOLS,
                   7603: which forces it to use the intltool package provided by pkgsrc, instead of the
                   7604: one bundled with the distribution file.
                   7605: 
                   7606: This tracks intltool's build-time dependencies and uses the latest available
                   7607: version; this way, the package benefits of any bug fixes that may have appeared
                   7608: since it was released.
                   7609: 
1.254     wiz      7610: 21.6.14. Packages installing startup scripts
1.1       dsieger  7611: 
1.256     wiz      7612: If a package contains an rc.d script, it won't be copied into the startup
                   7613: directory (/etc/rc.d) by default, but you can enable copying by setting the
                   7614: option PKG_RCD_SCRIPTS=YES in mk.conf. With PKG_RCD_SCRIPTS=YES, rc.d scripts
                   7615: will be copied into /etc/rc.d when a package is installed, but only if the
                   7616: target does not already exist. Copies in /etc/rc.d will be automatically
                   7617: removed only if they have not been modified.
                   7618: 
                   7619: Note that this alone does not enable the service: It must still be added to /
                   7620: etc/rc.conf.
1.1       dsieger  7621: 
1.254     wiz      7622: 21.6.15. Packages installing TeX modules
1.1       dsieger  7623: 
                   7624: If a package installs TeX packages into the texmf tree, the ls-R database of
                   7625: the tree needs to be updated.
                   7626: 
                   7627: Note
                   7628: 
1.23      jakllsch 7629: Except the main TeX packages such as kpathsea, packages should install files
                   7630: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1       dsieger  7631: 
1.23      jakllsch 7632:  1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
                   7633:     ls-R database at installation and deinstallation time.
1.1       dsieger  7634: 
1.23      jakllsch 7635:  2. If your package installs files into a texmf tree other than the one at $
                   7636:     {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
                   7637:     trees that need database update.
1.1       dsieger  7638: 
                   7639:     If your package also installs font map files that need to be registered
1.30      dholland 7640:     using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
                   7641:     and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then 
                   7642:     updmap will be run automatically at installation/deinstallation to enable/
                   7643:     disable font map files for TeX output drivers.
1.1       dsieger  7644: 
                   7645:  3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30      dholland 7646:     be removed only by the kpathsea package.
1.1       dsieger  7647: 
1.254     wiz      7648: 21.6.16. Packages supporting running binaries in emulation
1.1       dsieger  7649: 
                   7650: There are some packages that provide libraries and executables for running
                   7651: binaries from a one operating system on a different one (if the latter supports
                   7652: it). One example is running Linux binaries on NetBSD.
                   7653: 
                   7654: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
                   7655: 
                   7656: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
                   7657: if all libraries for each installed executable can be found by the dynamic
                   7658: linker. Since the standard dynamic linker is run, this fails for emulation
                   7659: packages, because the libraries used by the emulation are not in the standard
                   7660: directories.
                   7661: 
1.254     wiz      7662: 21.6.17. Packages installing hicolor icons
1.1       dsieger  7663: 
                   7664: If a package installs images under the share/icons/hicolor and/or updates the
                   7665: share/icons/hicolor/icon-theme.cache database, you need to take some extra
                   7666: steps to make sure that the shared theme directory is handled appropriately and
                   7667: that the cache database is rebuilt:
                   7668: 
                   7669:  1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
                   7670: 
                   7671:  2. Check the PLIST and remove the entry that refers to the theme cache.
                   7672: 
                   7673:  3. Ensure that the PLIST does not remove the shared icon directories from the
                   7674:     share/icons/hicolor hierarchy because they will be handled automatically.
                   7675: 
                   7676: The best way to verify that the PLIST is correct with respect to the last two
                   7677: points is to regenerate it using make print-PLIST.
                   7678: 
1.254     wiz      7679: 21.6.18. Packages installing desktop files
1.1       dsieger  7680: 
                   7681: If a package installs .desktop files under share/applications and these include
1.54      rodent   7682: MIME information (MimeType key), you need to take extra steps to ensure that
                   7683: they are registered into the MIME database:
1.1       dsieger  7684: 
                   7685:  1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
                   7686: 
                   7687:  2. Check the PLIST and remove the entry that refers to the share/applications/
                   7688:     mimeinfo.cache file. It will be handled automatically.
                   7689: 
                   7690: The best way to verify that the PLIST is correct with respect to the last point
                   7691: is to regenerate it using make print-PLIST.
                   7692: 
1.154     rillig   7693: 21.7. Marking packages as having problems
1.1       dsieger  7694: 
1.23      jakllsch 7695: In some cases one does not have the time to solve a problem immediately. In
                   7696: this case, one can plainly mark a package as broken. For this, one just sets
                   7697: the variable BROKEN to the reason why the package is broken (similar to the
1.162     rillig   7698: PKG_FAIL_REASON variable). A user trying to build the package will immediately
                   7699: be shown this message, and the build will not be even tried.
1.1       dsieger  7700: 
1.23      jakllsch 7701: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1       dsieger  7702: 
1.184     rillig   7703: Chapter 22. GNOME packaging and porting
                   7704: 
                   7705: Table of Contents
                   7706: 
                   7707: 22.1. Meta packages
                   7708: 22.2. Packaging a GNOME application
                   7709: 22.3. Updating GNOME to a newer version
                   7710: 22.4. Patching guidelines
                   7711: 
                   7712: Quoting GNOME's web site:
                   7713: 
                   7714:     The GNOME project provides two things: The GNOME desktop environment, an
                   7715:     intuitive and attractive desktop for users, and the GNOME development
                   7716:     platform, an extensive framework for building applications that integrate
                   7717:     into the rest of the desktop.
                   7718: 
                   7719: pkgsrc provides a seamless way to automatically build and install a complete
                   7720: GNOME environment under many different platforms. We can say with confidence
                   7721: that pkgsrc is one of the most advanced build and packaging systems for GNOME
                   7722: due to its included technologies buildlink3, the wrappers and tools framework
                   7723: and automatic configuration file management. Lots of efforts are put into
                   7724: achieving a completely clean deinstallation of installed software components.
                   7725: 
                   7726: Given that pkgsrc is NetBSD's official packaging system, the above also means
                   7727: that great efforts are put into making GNOME work under this operating system.
                   7728: 
                   7729: This chapter is aimed at pkgsrc developers and other people interested in
                   7730: helping our GNOME porting and packaging efforts. It provides instructions on
                   7731: how to manage the existing packages and some important information regarding
                   7732: their internals.
                   7733: 
                   7734: 22.1. Meta packages
                   7735: 
                   7736: pkgsrc includes three GNOME-related meta packages:
                   7737: 
                   7738:   * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
                   7739:     includes the necessary bits to get it to boot correctly, although it may
                   7740:     lack important functionality for daily operation. The idea behind this
                   7741:     package is to let end users build their own configurations on top of this
                   7742:     one, first installing this meta package to achieve a functional setup and
                   7743:     then adding individual applications.
                   7744: 
                   7745:   * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
                   7746:     desktop as defined by the GNOME project; this is based on the components
                   7747:     distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
                   7748:     directories of the official FTP server. Developer-only tools found in those
                   7749:     directories are not installed unless required by some other component to
                   7750:     work properly. Similarly, packages from the bindings set (bindings/x.y/
                   7751:     x.y.z/sources) are not pulled in unless required as a dependency for an
                   7752:     end-user component. This package "extends" meta-pkgs/gnome-base.
                   7753: 
                   7754:   * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
                   7755:     component when fetched from the CVS repository. These are required to let
                   7756:     the autogen.sh scripts work appropriately.
                   7757: 
                   7758: In all these packages, the DEPENDS lines are sorted in a way that eases
                   7759: updates: a package may depend on other packages listed before it but not on any
                   7760: listed after it. It is very important to keep this order to ease updates so... 
                   7761: do not change it to alphabetical sorting!
                   7762: 
                   7763: 22.2. Packaging a GNOME application
                   7764: 
                   7765: Almost all GNOME applications are written in C and use a common set of tools as
                   7766: their build system. Things get different with the new bindings to other
                   7767: languages (such as Python), but the following will give you a general idea on
                   7768: the minimum required tools:
                   7769: 
                   7770:   * Almost all GNOME applications use the GNU Autotools as their build system.
                   7771:     As a general rule you will need to tell this to your package:
                   7772: 
1.223     nia      7773:     GNU_CONFIGURE=  yes
                   7774:     USE_LIBTOOL=    yes
                   7775:     USE_TOOLS+=     gmake
1.184     rillig   7776: 
                   7777:   * If the package uses pkg-config to detect dependencies, add this tool to the
                   7778:     list of required utilities:
                   7779: 
1.223     nia      7780:     USE_TOOLS+=     pkg-config
1.184     rillig   7781: 
                   7782:     Also use pkgtools/verifypc at the end of the build process to ensure that
                   7783:     you did not miss to specify any dependency in your package and that the
                   7784:     version requirements are all correct.
                   7785: 
                   7786:   * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
                   7787:     handle dependencies and to force the package to use the latest available
                   7788:     version.
                   7789: 
                   7790:   * If the package uses gtk-doc (a documentation generation utility), do not
                   7791:     add a dependency on it. The tool is rather big and the distfile should come
                   7792:     with pregenerated documentation anyway; if it does not, it is a bug that
                   7793:     you ought to report. For such packages you should disable gtk-doc (unless
                   7794:     it is the default):
                   7795: 
1.223     nia      7796:     CONFIGURE_ARGS+=        --disable-gtk-doc
1.184     rillig   7797: 
                   7798:     The default location of installed HTML files (share/gtk-doc/<package-name>)
                   7799:     is correct and should not be changed unless the package insists on
                   7800:     installing them somewhere else. Otherwise programs as devhelp will not be
                   7801:     able to open them. You can do that with an entry similar to:
1.1       dsieger  7802: 
1.223     nia      7803:     CONFIGURE_ARGS+=        --with-html-dir=${PREFIX}/share/gtk-doc/...
1.1       dsieger  7804: 
1.184     rillig   7805: GNOME uses multiple shared directories and files under the installation prefix
                   7806: to maintain databases. In this context, shared means that those exact same
                   7807: directories and files are used among several different packages, leading to
                   7808: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
                   7809: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
                   7810: your file lists and omitting shared files from them. If you find yourself doing
                   7811: those, your package is most likely incorrect.
1.1       dsieger  7812: 
1.184     rillig   7813: The following table lists the common situations that result in using shared
                   7814: directories or files. For each of them, the appropriate solution is given.
                   7815: After applying the solution be sure to regenerate the package's file list with 
                   7816: make print-PLIST and ensure it is correct.
1.1       dsieger  7817: 
1.184     rillig   7818: Table 22.1. PLIST handling for GNOME packages
1.1       dsieger  7819: 
1.184     rillig   7820: +-----------------------------------------------------------------------------+
                   7821: |             If the package...             |             Then...             |
                   7822: |-------------------------------------------+---------------------------------|
1.254     wiz      7823: |Installs icons under the share/icons/      |See Section 21.6.17, "Packages   |
1.203     nia      7824: |hicolor hierarchy or updates share/icons/  |installing hicolor icons".       |
1.184     rillig   7825: |hicolor/icon-theme.cache.                  |                                 |
                   7826: |-------------------------------------------+---------------------------------|
1.254     wiz      7827: |                                           |See Section 21.6.12, "Packages   |
1.184     rillig   7828: |Installs files under share/mime/packages.  |installing extensions to the MIME|
                   7829: |                                           |database".                       |
                   7830: |-------------------------------------------+---------------------------------|
1.254     wiz      7831: |Installs .desktop files under share/       |See Section 21.6.18, "Packages   |
1.184     rillig   7832: |applications and these include MIME        |installing desktop files".       |
                   7833: |information.                               |                                 |
                   7834: +-----------------------------------------------------------------------------+
1.1       dsieger  7835: 
                   7836: 
1.184     rillig   7837: 22.3. Updating GNOME to a newer version
1.1       dsieger  7838: 
1.184     rillig   7839: When seeing GNOME as a whole, there are two kinds of updates:
1.1       dsieger  7840: 
1.184     rillig   7841: Major update
1.1       dsieger  7842: 
1.184     rillig   7843:     Given that there is still a very long way for GNOME 3 (if it ever appears),
                   7844:     we consider a major update one that goes from a 2.X version to a 2.Y one,
                   7845:     where Y is even and greater than X. These are hard to achieve because they
                   7846:     introduce lots of changes in the components' code and almost all GNOME
                   7847:     distfiles are updated to newer versions. Some of them can even break API
                   7848:     and ABI compatibility with the previous major version series. As a result,
                   7849:     the update needs to be done all at once to minimize breakage.
1.1       dsieger  7850: 
1.184     rillig   7851:     A major update typically consists of around 80 package updates and the
                   7852:     addition of some new ones.
1.1       dsieger  7853: 
1.184     rillig   7854: Minor update
1.1       dsieger  7855: 
1.184     rillig   7856:     We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
                   7857:     one where Y is greater than X. These are easy to achieve because they do
                   7858:     not update all GNOME components, can be done in an incremental way and do
                   7859:     not break API nor ABI compatibility.
1.1       dsieger  7860: 
1.184     rillig   7861:     A minor update typically consists of around 50 package updates, although
                   7862:     the numbers here may vary a lot.
1.1       dsieger  7863: 
1.184     rillig   7864: In order to update the GNOME components in pkgsrc to a new stable release
                   7865: (either major or minor), the following steps should be followed:
1.1       dsieger  7866: 
1.184     rillig   7867:  1. Get a list of all the tarballs that form the new release by using the
                   7868:     following commands. These will leave the full list of the components'
                   7869:     distfiles into the list.txt file:
1.1       dsieger  7870: 
1.184     rillig   7871:     % echo ls "*.tar.bz2" | \
                   7872:         ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   7873:         awk '{ print $9 }' >list.txt
                   7874:     % echo ls "*.tar.bz2" | \
                   7875:         ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   7876:         awk '{ print $9 }' >>list.txt
1.1       dsieger  7877: 
1.184     rillig   7878:  2. Open each meta package's Makefile and bump their version to the release you
                   7879:     are updating them to. The three meta packages should be always consistent
                   7880:     with versioning. Obviously remove any PKGREVISIONs that might be in them.
1.1       dsieger  7881: 
1.184     rillig   7882:  3. For each meta package, update all its DEPENDS lines to match the latest
                   7883:     versions as shown by the above commands. Do not list any newer version
                   7884:     (even if found in the FTP) because the meta packages are supposed to list
                   7885:     the exact versions that form a specific GNOME release. Exceptions are
                   7886:     permitted here if a newer version solves a serious issue in the overall
                   7887:     desktop experience; these typically come in the form of a revision bump in
                   7888:     pkgsrc, not in newer versions from the developers.
1.1       dsieger  7889: 
1.184     rillig   7890:     Packages not listed in the list.txt file should be updated to the latest
                   7891:     version available (if found in pkgsrc). This is the case, for example, of
                   7892:     the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
                   7893:     package.
1.1       dsieger  7894: 
1.184     rillig   7895:  4. Generate a patch from the modified meta packages and extract the list of
                   7896:     "new" lines. This will provide you an outline on what packages need to be
                   7897:     updated in pkgsrc and in what order:
1.1       dsieger  7898: 
1.184     rillig   7899:     % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
1.1       dsieger  7900: 
1.184     rillig   7901:  5. For major desktop updates it is recommended to zap all your installed
                   7902:     packages and start over from scratch at this point.
1.1       dsieger  7903: 
1.184     rillig   7904:  6. Now comes the longest step by far: iterate over the contents of todo.txt
                   7905:     and update the packages listed in it in order. For major desktop updates
                   7906:     none of these should be committed until the entire set is completed because
                   7907:     there are chances of breaking not-yet-updated packages.
1.1       dsieger  7908: 
1.184     rillig   7909:  7. Once the packages are up to date and working, commit them to the tree one
                   7910:     by one with appropriate log messages. At the end, commit the three meta
                   7911:     package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
                   7912:     and pkgsrc/doc/TODO files.
1.1       dsieger  7913: 
1.184     rillig   7914: 22.4. Patching guidelines
1.1       dsieger  7915: 
1.184     rillig   7916: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
                   7917: it is very important that you always, always, always feed back any portability
                   7918: fixes you do to a GNOME package to the mainstream developers (see
                   7919: Section 12.3.5, "Feedback to the author"). This is the only way to get their
                   7920: attention on portability issues and to ensure that future versions can be built
                   7921: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
                   7922: updates are. Those developers in charge of issuing major GNOME updates will be
                   7923: grateful if you do that.
1.1       dsieger  7924: 
1.200     cirnatda 7925: The most common places to report bugs are the GNOME's GitLab and the
                   7926: freedesktop.org's GitLab. Not all components use these to track bugs, but most
                   7927: of them do. Do not be short on your reports: always provide detailed
1.184     rillig   7928: explanations of the current failure, how it can be improved to achieve maximum
1.200     cirnatda 7929: portability and, if at all possible, provide a patch against the main Git
                   7930: branch. The more verbose you are, the higher chances of your patch being
                   7931: accepted.
1.1       dsieger  7932: 
1.184     rillig   7933: Also, please avoid using preprocessor magic to fix portability issues. While
                   7934: the FreeBSD GNOME people are doing a great job in porting GNOME to their
                   7935: operating system, the official GNOME sources are now plagued by conditionals
                   7936: that check for __FreeBSD__ and similar macros. This hurts portability. Please
                   7937: see our patching guidelines (Section 12.3.4, "Patching guidelines") for more
                   7938: details.
1.1       dsieger  7939: 
1.154     rillig   7940: Chapter 23. Submitting and Committing
1.1       dsieger  7941: 
                   7942: Table of Contents
                   7943: 
1.154     rillig   7944: 23.1. Submitting binary packages
                   7945: 23.2. Submitting source packages (for non-NetBSD-developers)
                   7946: 23.3. General notes when adding, updating, or removing packages
                   7947: 23.4. Commit Messages
                   7948: 23.5. Committing: Adding a package to CVS
                   7949: 23.6. Updating a package to a newer version
                   7950: 23.7. Renaming a package in pkgsrc
                   7951: 23.8. Moving a package in pkgsrc
1.1       dsieger  7952: 
1.154     rillig   7953: 23.1. Submitting binary packages
1.1       dsieger  7954: 
                   7955: Our policy is that we accept binaries only from pkgsrc developers to guarantee
                   7956: that the packages don't contain any trojan horses etc. This is not to annoy
                   7957: anyone but rather to protect our users! You're still free to put up your
                   7958: home-made binary packages and tell the world where to get them. NetBSD
1.154     rillig   7959: developers doing bulk builds and wanting to upload them please see Chapter 8, 
1.66      asau     7960: Creating binary packages for everything in pkgsrc (bulk builds).
1.1       dsieger  7961: 
1.154     rillig   7962: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1       dsieger  7963: 
1.218     nia      7964: Firstly, you can import new packages into pkgsrc-wip ("pkgsrc work-in-progress"
                   7965: ); see the homepage at https://pkgsrc.org/wip/ for details.
                   7966: 
                   7967: Next, check that your package is complete, compiles and runs well; see
1.184     rillig   7968: Chapter 14, Creating a new pkgsrc package from scratch and the rest of this
1.218     nia      7969: document. Run the pkgtools/pkglint tool and fix any errors that appear.
                   7970: 
                   7971: Finally, send a report to the pkgsrc bug tracking system, either with the
                   7972: send-pr(1) command, or if you don't have that, go to the web page https://
                   7973: www.NetBSD.org/support/send-pr.html, which contains some instructions and a
                   7974: link to a form where you can submit packages. The sysutils/gtk-send-pr package
                   7975: is also available as a substitute for either of the above two tools.
1.1       dsieger  7976: 
                   7977: In the form of the problem report, the category should be "pkg", the synopsis
                   7978: should include the package name and version number, and the description field
                   7979: should contain a short description of your package (contents of the COMMENT
1.218     nia      7980: variable or DESCR file are OK).
1.1       dsieger  7981: 
1.154     rillig   7982: 23.3. General notes when adding, updating, or removing packages
1.1       dsieger  7983: 
                   7984: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
                   7985: CHANGES-YYYY. It's very important to keep this file up to date and conforming
                   7986: to the existing format, because it will be used by scripts to automatically
                   7987: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
                   7988: doc/TODO file and remove the entry for the package you updated or removed, in
                   7989: case it was mentioned there.
                   7990: 
                   7991: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
                   7992: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
                   7993: that result from a dependency being updated should not be mentioned. In all
                   7994: other cases it's the developer's decision.
                   7995: 
                   7996: There is a make target that helps in creating proper CHANGES-YYYY entries: make
                   7997: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
                   7998: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
                   7999: (to avoid having to resolve conflicts later-on) and then to cd to the package
                   8000: directory. For package updates, make changes-entry is enough. For new packages,
                   8001: or package moves or removals, set the CTYPE variable on the command line to
1.4       rillig   8002: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23      jakllsch 8003: your local login name is not the same as your NetBSD login name. The target
                   8004: also automatically removes possibly existing entries for the package in the
                   8005: TODO file. Don't forget to commit the changes, e.g. by using make
1.66      asau     8006: commit-changes-entry! If you are not using a checkout directly from
1.23      jakllsch 8007: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
                   8008: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1       dsieger  8009: 
1.154     rillig   8010: 23.4. Commit Messages
1.130     wiz      8011: 
                   8012: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
1.257     jkoshy   8013: Standard practice when using these tools is to make the first line of a commit
1.130     wiz      8014: message function as a summary that can be read without the rest, such as is
                   8015: commonly done with "git log --oneline". For this reason, we have the following
                   8016: guidelines for pkgsrc commit messages:
                   8017: 
1.131     wiz      8018:   * Start the commit message with a line that explains the big picture in 65
1.130     wiz      8019:     characters or less. When a commit is for one package, include the name of
                   8020:     the package. For updates, include the version to which it is updated.
                   8021: 
                   8022:   * Leave the next line empty.
                   8023: 
                   8024:   * Then come the details for the commit (changes in that package, reason for a
                   8025:     change) and any relevant PRs. Wrap this section.
                   8026: 
                   8027: Here is an example:
                   8028: 
1.238     wiz      8029: libxslt: update to 1.0.30
1.130     wiz      8030: 
1.238     wiz      8031: Changes since 1.0.29:
                   8032: ...
1.130     wiz      8033: 
                   8034: Here is another example:
                   8035: 
1.238     wiz      8036: mk/bsd.pkg.mk: enable SSP by default on NetBSD
1.130     wiz      8037: 
1.238     wiz      8038: (rationale)
1.130     wiz      8039: 
                   8040: Commit messages are final: no "cvs admin" is allowed on the pkgsrc repository
                   8041: to change commit messages.
                   8042: 
1.154     rillig   8043: 23.5. Committing: Adding a package to CVS
1.1       dsieger  8044: 
                   8045: This section is only of interest for pkgsrc developers with write access to the
1.34      wiz      8046: pkgsrc repository.
                   8047: 
                   8048: When the package is finished, "cvs add" the files. Start by adding the
                   8049: directory and then files in the directory. Don't forget to add the new package
                   8050: to the category's Makefile. Make sure you don't forget any files; you can check
                   8051: by running "cvs status". An example:
                   8052: 
                   8053: $ cd .../pkgsrc/category
                   8054: $ cvs add pkgname
                   8055: $ cd pkgname
                   8056: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
                   8057: $ cvs add patches/p*
                   8058: $ cvs status | less
1.35      wiz      8059: $ cvs commit
1.34      wiz      8060: $ cd ..
1.236     gutterid 8061: $ vi Makefile # add SUBDIR+=pkgname line
1.35      wiz      8062: $ cvs commit Makefile
1.66      asau     8063: $ cd pkgname
1.73      jnemeth  8064: $ make CTYPE=Added commit-changes-entry
1.1       dsieger  8065: 
                   8066: The commit message of the initial import should include part of the DESCR file,
                   8067: so people reading the mailing lists know what the package is/does.
                   8068: 
1.34      wiz      8069: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
                   8070: 
                   8071: Previously, "cvs import" was suggested, but it was much easier to get wrong
                   8072: than "cvs add".
1.1       dsieger  8073: 
1.154     rillig   8074: 23.6. Updating a package to a newer version
1.1       dsieger  8075: 
                   8076: Please always put a concise, appropriate and relevant summary of the changes
                   8077: between old and new versions into the commit log when updating a package. There
                   8078: are various reasons for this:
                   8079: 
                   8080:   * A URL is volatile, and can change over time. It may go away completely or
                   8081:     its information may be overwritten by newer information.
                   8082: 
                   8083:   * Having the change information between old and new versions in our CVS
                   8084:     repository is very useful for people who use either cvs or anoncvs.
                   8085: 
                   8086:   * Having the change information between old and new versions in our CVS
                   8087:     repository is very useful for people who read the pkgsrc-changes mailing
                   8088:     list, so that they can make tactical decisions about when to upgrade the
                   8089:     package.
                   8090: 
                   8091: Please also recognize that, just because a new version of a package has been
                   8092: released, it should not automatically be upgraded in the CVS repository. We
                   8093: prefer to be conservative in the packages that are included in pkgsrc -
                   8094: development or beta packages are not really the best thing for most places in
                   8095: which pkgsrc is used. Please use your judgement about what should go into
                   8096: pkgsrc, and bear in mind that stability is to be preferred above new and
                   8097: possibly untested features.
                   8098: 
1.154     rillig   8099: 23.7. Renaming a package in pkgsrc
1.21      snj      8100: 
                   8101: Renaming packages is not recommended.
                   8102: 
1.175     gutterid 8103: When renaming packages, be sure to fix any references to the old name in other
1.21      snj      8104: Makefiles, options, buildlink files, etc.
                   8105: 
1.175     gutterid 8106: Also, when renaming a package, please add the package name and version pattern
1.167     leot     8107: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
                   8108: renames. The new package would be an exact replacement. Example:
                   8109: 
                   8110: SUPERSEDES+=    p5-IO-Compress-Zlib<2.017
                   8111: SUPERSEDES+=    optcomp-[0-9]*
1.21      snj      8112: 
                   8113: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
                   8114: supersedes, as that successor may not be an exact replacement but is a
                   8115: suggestion for the replaced functionality.
                   8116: 
1.154     rillig   8117: 23.8. Moving a package in pkgsrc
1.21      snj      8118: 
                   8119: It is preferred that packages are not renamed or moved, but if needed please
                   8120: follow these steps.
1.1       dsieger  8121: 
                   8122:  1. Make a copy of the directory somewhere else.
                   8123: 
                   8124:  2. Remove all CVS dirs.
                   8125: 
                   8126:     Alternatively to the first two steps you can also do:
                   8127: 
                   8128:     % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
                   8129: 
                   8130:     and use that for further work.
                   8131: 
1.25      wiz      8132:  3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of 
1.1       dsieger  8133:     "../../category/package".
                   8134: 
1.21      snj      8135:  4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
                   8136:     previous category/package pathname. The PREV_PKGPATH can be used by tools
                   8137:     for doing an update using pkgsrc building; for example, it can search the
                   8138:     pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
                   8139:     the corresponding new PKGPATH for that moved package. Note that it may have
                   8140:     multiple matches, so the tool should also check on the PKGBASE too. The
                   8141:     PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
                   8142:     PKGBASE stays the same.
                   8143: 
1.237     gutterid 8144:  5. cvs add the modified package in the new place.
1.1       dsieger  8145: 
1.21      snj      8146:  6. Check if any package depends on it:
1.1       dsieger  8147: 
                   8148:     % cd /usr/pkgsrc
                   8149:     % grep /package */*/Makefile* */*/buildlink*
                   8150: 
1.21      snj      8151:  7. Fix paths in packages from step 5 to point to new location.
1.1       dsieger  8152: 
1.21      snj      8153:  8. cvs rm (-f) the package at the old location.
1.1       dsieger  8154: 
1.21      snj      8155:  9. Remove from oldcategory/Makefile.
1.1       dsieger  8156: 
1.21      snj      8157: 10. Add to newcategory/Makefile.
1.1       dsieger  8158: 
1.21      snj      8159: 11. Commit the changed and removed files:
1.1       dsieger  8160: 
                   8161:     % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
                   8162: 
                   8163:     (and any packages from step 5, of course).
                   8164: 
1.154     rillig   8165: Chapter 24. Frequently Asked Questions
1.1       dsieger  8166: 
                   8167: This section contains the answers to questions that may arise when you are
                   8168: writing a package. If you don't find your question answered here, first have a
                   8169: look in the other chapters, and if you still don't have the answer, ask on the
                   8170: pkgsrc-users mailing list.
                   8171: 
1.154     rillig   8172: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
                   8173: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
                   8174: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.223     nia      8175: 24.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
                   8176: 24.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.259     leot     8177:     the := inside it.
1.223     nia      8178: 24.6. Which mailing lists are there for package developers?
                   8179: 24.7. Where is the pkgsrc documentation?
                   8180: 24.8. I have a little time to kill. What shall I do?
1.1       dsieger  8181: 
1.154     rillig   8182: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1       dsieger  8183: 
                   8184:       MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
1.223     nia      8185:       (1).
                   8186: 
                   8187:       MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM when
                   8188:       building the package.
                   8189: 
                   8190:       .MAKEFLAGS is an internal variable of bmake and should not be used by
                   8191:       packages.
1.1       dsieger  8192: 
1.154     rillig   8193: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1       dsieger  8194: 
                   8195:       MAKE is the path to the make(1) program that is used in the pkgsrc
1.223     nia      8196:       infrastructure.
                   8197: 
                   8198:       GMAKE is the path to GNU Make, but you need to say USE_TOOLS+=gmake to
                   8199:       use that.
                   8200: 
                   8201:       MAKE_PROGRAM is the path to the Make program that is used for building
                   8202:       the package.
1.1       dsieger  8203: 
1.154     rillig   8204: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1       dsieger  8205: 
                   8206:       CC is the path to the real C compiler, which can be configured by the
1.223     nia      8207:       pkgsrc user.
1.1       dsieger  8208: 
1.223     nia      8209:       PKG_CC is the path to the compiler wrapper.
1.1       dsieger  8210: 
1.223     nia      8211:       PKGSRC_COMPILER is not a path to a compiler, but the type of compiler
                   8212:       that should be used. See mk/compiler.mk for more information about the
                   8213:       latter variable.
1.1       dsieger  8214: 
1.223     nia      8215: 24.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1       dsieger  8216: 
1.25      wiz      8217:       For optimization reasons, some variables are only available in the "
                   8218:       wrapper" phase and later. To "simulate" the wrapper phase, append 
1.1       dsieger  8219:       PKG_PHASE=wrapper to the above command.
                   8220: 
1.223     nia      8221: 24.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  8222:       the := inside it.
                   8223: 
1.223     nia      8224:       The := is not an assignment operator, even though it may look like one.
1.108     rillig   8225:       Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
                   8226:       is documented in the make(1) man page and which is commonly used in the
                   8227:       form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
                   8228:       string and new_string is package/. That's where the : and the = fall
                   8229:       together.
1.1       dsieger  8230: 
1.223     nia      8231: 24.6. Which mailing lists are there for package developers?
1.1       dsieger  8232: 
                   8233:       tech-pkg
                   8234: 
                   8235:           This is a list for technical discussions related to pkgsrc
                   8236:           development, e.g. soliciting feedback for changes to pkgsrc
                   8237:           infrastructure, proposed new features, questions related to porting
                   8238:           pkgsrc to a new platform, advice for maintaining a package, patches
                   8239:           that affect many packages, help requests moved from pkgsrc-users when
                   8240:           an infrastructure bug is found, etc.
                   8241: 
                   8242:       pkgsrc-bugs
                   8243: 
                   8244:           All bug reports in category "pkg" sent with send-pr(1) appear here.
                   8245:           Please do not report your bugs here directly; use one of the other
                   8246:           mailing lists.
1.259     leot     8247:          
1.223     nia      8248: 24.7. Where is the pkgsrc documentation?
1.1       dsieger  8249: 
                   8250:       There are many places where you can find documentation about pkgsrc:
                   8251: 
                   8252:         * The pkgsrc guide (this document) is a collection of chapters that
                   8253:           explain large parts of pkgsrc, but some chapters tend to be outdated.
                   8254:           Which ones they are is hard to say.
                   8255: 
1.174     leot     8256:         * On the mailing list archives (see https://mail-index.NetBSD.org/),
                   8257:           you can find discussions about certain features, announcements of new
1.1       dsieger  8258:           parts of the pkgsrc infrastructure and sometimes even announcements
                   8259:           that a certain feature has been marked as obsolete. The benefit here
                   8260:           is that each message has a date appended to it.
                   8261: 
                   8262:         * Many of the files in the mk/ directory start with a comment that
                   8263:           describes the purpose of the file and how it can be used by the
                   8264:           pkgsrc user and package authors. An easy way to find this
                   8265:           documentation is to run bmake help.
                   8266: 
                   8267:         * The CVS log messages are a rich source of information, but they tend
                   8268:           to be highly abbreviated, especially for actions that occur often.
                   8269:           Some contain a detailed description of what has changed, but they are
                   8270:           geared towards the other pkgsrc developers, not towards an average
                   8271:           pkgsrc user. They also only document changes, so if you don't know
                   8272:           what has been before, these messages may not be worth too much to
                   8273:           you.
                   8274: 
                   8275:         * Some parts of pkgsrc are only "implicitly documented", that is the
                   8276:           documentation exists only in the mind of the developer who wrote the
                   8277:           code. To get this information, use the cvs annotate command to see
                   8278:           who has written it and ask on the tech-pkg mailing list, so that
                   8279:           others can find your questions later (see above). To be sure that the
                   8280:           developer in charge reads the mail, you may CC him or her.
                   8281: 
1.223     nia      8282: 24.8. I have a little time to kill. What shall I do?
1.1       dsieger  8283: 
                   8284:       This is not really an FAQ yet, but here's the answer anyway.
                   8285: 
                   8286:         * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
                   8287:           about newer versions of installed packages that are available, but
                   8288:           not yet updated in pkgsrc.
                   8289: 
1.198     leot     8290:         * Browse pkgsrc/doc/TODO -- it contains a list of suggested new
                   8291:           packages and a list of cleanups and enhancements for pkgsrc that
                   8292:           would be nice to have.
1.1       dsieger  8293: 
1.71      wiz      8294:         * Review packages for which review was requested on the tech-pkg
                   8295:           mailing list.
1.1       dsieger  8296: 
                   8297: Part III. The pkgsrc infrastructure internals
                   8298: 
                   8299: This part of the guide deals with everything from the infrastructure that is
                   8300: behind the interfaces described in the developer's guide. A casual package
                   8301: maintainer should not need anything from this part.
                   8302: 
                   8303: Table of Contents
                   8304: 
1.184     rillig   8305: 25. Design of the pkgsrc infrastructure
                   8306:     25.1. The meaning of variable definitions
                   8307:     25.2. Avoiding problems before they arise
                   8308:     25.3. Variable evaluation
                   8309:         25.3.1. At load time
                   8310:         25.3.2. At runtime
                   8311:     25.4. How can variables be specified?
                   8312:     25.5. Designing interfaces for Makefile fragments
                   8313:         25.5.1. Procedures with parameters
                   8314:         25.5.2. Actions taken on behalf of parameters
                   8315:     25.6. The order in which files are loaded
                   8316:         25.6.1. The order in bsd.prefs.mk
                   8317:         25.6.2. The order in bsd.pkg.mk
                   8318: 26. Regression tests
                   8319:     26.1. Running the regression tests
                   8320:     26.2. Adding a new regression test
                   8321:         26.2.1. Overridable functions
                   8322:         26.2.2. Helper functions
                   8323: 27. Porting pkgsrc
                   8324:     27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8325: 
1.184     rillig   8326: Chapter 25. Design of the pkgsrc infrastructure
1.1       dsieger  8327: 
                   8328: Table of Contents
                   8329: 
1.184     rillig   8330: 25.1. The meaning of variable definitions
                   8331: 25.2. Avoiding problems before they arise
                   8332: 25.3. Variable evaluation
                   8333:     25.3.1. At load time
                   8334:     25.3.2. At runtime
                   8335: 25.4. How can variables be specified?
                   8336: 25.5. Designing interfaces for Makefile fragments
                   8337:     25.5.1. Procedures with parameters
                   8338:     25.5.2. Actions taken on behalf of parameters
                   8339: 25.6. The order in which files are loaded
                   8340:     25.6.1. The order in bsd.prefs.mk
                   8341:     25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8342: 
                   8343: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
                   8344: fragment needs a properly specified interface. This chapter explains how such
                   8345: an interface looks like.
                   8346: 
1.184     rillig   8347: 25.1. The meaning of variable definitions
1.1       dsieger  8348: 
                   8349: Whenever a variable is defined in the pkgsrc infrastructure, the location and
                   8350: the way of definition provide much information about the intended use of that
                   8351: variable. Additionally, more documentation may be found in a header comment or
                   8352: in this pkgsrc guide.
                   8353: 
                   8354: A special file is mk/defaults/mk.conf, which lists all variables that are
                   8355: intended to be user-defined. They are either defined using the ?= operator or
                   8356: they are left undefined because defining them to anything would effectively
                   8357: mean "yes". All these variables may be overridden by the pkgsrc user in the
                   8358: MAKECONF file.
                   8359: 
                   8360: Outside this file, the following conventions apply: Variables that are defined
                   8361: using the ?= operator may be overridden by a package.
                   8362: 
                   8363: Variables that are defined using the = operator may be used read-only at
                   8364: run-time.
                   8365: 
                   8366: Variables whose name starts with an underscore must not be accessed outside the
                   8367: pkgsrc infrastructure at all. They may change without further notice.
                   8368: 
                   8369: Note
                   8370: 
                   8371: These conventions are currently not applied consistently to the complete pkgsrc
                   8372: infrastructure.
                   8373: 
1.184     rillig   8374: 25.2. Avoiding problems before they arise
1.1       dsieger  8375: 
                   8376: All variables that contain lists of things should default to being empty. Two
                   8377: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
                   8378: variables cannot simply be modified using the += operator in package Makefiles
                   8379: (or other files included by them), since there is no guarantee whether the
                   8380: variable is already set or not, and what its value is. In the case of
                   8381: DISTFILES, the packages "know" the default value and just define it as in the
                   8382: following example.
                   8383: 
                   8384: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   8385: 
                   8386: Because of the selection of this default value, the same value appears in many
                   8387: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
                   8388: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
                   8389: in many files.
                   8390: 
1.184     rillig   8391: 25.3. Variable evaluation
1.1       dsieger  8392: 
1.184     rillig   8393: 25.3.1. At load time
1.1       dsieger  8394: 
                   8395: Variable evaluation takes place either at load time or at runtime, depending on
                   8396: the context in which they occur. The contexts where variables are evaluated at
                   8397: load time are:
                   8398: 
                   8399:   * The right hand side of the := and != operators,
                   8400: 
                   8401:   * Make directives like .if or .for,
                   8402: 
                   8403:   * Dependency lines.
                   8404: 
                   8405: A special exception are references to the iteration variables of .for loops,
                   8406: which are expanded inline, no matter in which context they appear.
                   8407: 
                   8408: As the values of variables may change during load time, care must be taken not
                   8409: to evaluate them by accident. Typical examples for variables that should not be
                   8410: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
                   8411: clear, here is an example:
                   8412: 
                   8413: CONFIGURE_ARGS=         # none
                   8414: CFLAGS=                 -O
                   8415: CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
                   8416: 
                   8417: CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
                   8418: 
                   8419: CFLAGS+=                -Wall
                   8420: 
                   8421: This code shows how the use of the := operator can quickly lead to unexpected
                   8422: results. The first paragraph is fairly common code. The second paragraph
                   8423: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
                   8424: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
                   8425: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
                   8426: typically occur in completely unrelated files.
                   8427: 
1.184     rillig   8428: 25.3.2. At runtime
1.1       dsieger  8429: 
                   8430: After all the files have been loaded, the values of the variables cannot be
                   8431: changed anymore. Variables that are used in the shell commands are expanded at
                   8432: this point.
                   8433: 
1.184     rillig   8434: 25.4. How can variables be specified?
1.1       dsieger  8435: 
                   8436: There are many ways in which the definition and use of a variable can be
                   8437: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108     rillig   8438: policies. A package can be checked with pkglint -Wall to see whether it meets
                   8439: these rules.
1.1       dsieger  8440: 
1.184     rillig   8441: 25.5. Designing interfaces for Makefile fragments
1.1       dsieger  8442: 
                   8443: Most of the .mk files fall into one of the following classes. Cases where a
                   8444: file falls into more than one class should be avoided as it often leads to
                   8445: subtle bugs.
                   8446: 
1.184     rillig   8447: 25.5.1. Procedures with parameters
1.1       dsieger  8448: 
                   8449: In a traditional imperative programming language some of the .mk files could be
1.198     leot     8450: described as procedures. They take some input parameters and--after
                   8451: inclusion--provide a result in output parameters. Since all variables in
1.23      jakllsch 8452: Makefiles have global scope care must be taken not to use parameter names that
                   8453: have already another meaning. For example, PKGNAME is a bad choice for a
                   8454: parameter name.
1.1       dsieger  8455: 
                   8456: Procedures are completely evaluated at preprocessing time. That is, when
                   8457: calling a procedure all input parameters must be completely resolvable. For
                   8458: example, CONFIGURE_ARGS should never be an input parameter since it is very
                   8459: likely that further text will be added after calling the procedure, which would
                   8460: effectively apply the procedure to only a part of the variable. Also,
1.108     rillig   8461: references to other variables will be modified after calling the procedure.
1.1       dsieger  8462: 
                   8463: A procedure can declare its output parameters either as suitable for use in
                   8464: preprocessing directives or as only available at runtime. The latter
                   8465: alternative is for variables that contain references to other runtime
                   8466: variables.
                   8467: 
                   8468: Procedures shall be written such that it is possible to call the procedure more
                   8469: than once. That is, the file must not contain multiple-inclusion guards.
                   8470: 
                   8471: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
                   8472: To express that the parameters are evaluated at load time, they should be
                   8473: assigned using the := operator, which should be used only for this purpose.
                   8474: 
1.184     rillig   8475: 25.5.2. Actions taken on behalf of parameters
1.1       dsieger  8476: 
                   8477: Action files take some input parameters and may define runtime variables. They
                   8478: shall not define loadtime variables. There are action files that are included
                   8479: implicitly by the pkgsrc infrastructure, while other must be included
                   8480: explicitly.
                   8481: 
                   8482: An example for action files is mk/subst.mk.
                   8483: 
1.184     rillig   8484: 25.6. The order in which files are loaded
1.1       dsieger  8485: 
                   8486: Package Makefiles usually consist of a set of variable definitions, and include
                   8487: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
                   8488: include various other *.mk files if they need to query the availability of
                   8489: certain features like the type of compiler or the X11 implementation. Due to
                   8490: the heavy use of preprocessor directives like .if and .for, the order in which
                   8491: the files are loaded matters.
                   8492: 
                   8493: This section describes at which point the various files are loaded and gives
                   8494: reasons for that order.
                   8495: 
1.184     rillig   8496: 25.6.1. The order in bsd.prefs.mk
1.1       dsieger  8497: 
                   8498: The very first action in bsd.prefs.mk is to define some essential variables
                   8499: like OPSYS, OS_VERSION and MACHINE_ARCH.
                   8500: 
1.4       rillig   8501: Then, the user settings are loaded from the file specified in MAKECONF, which
                   8502: is usually mk.conf. After that, those variables that have not been overridden
                   8503: by the user are loaded from mk/defaults/mk.conf.
1.1       dsieger  8504: 
                   8505: After the user settings, the system settings and platform settings are loaded,
                   8506: which may override the user settings.
                   8507: 
                   8508: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
                   8509: This only happens when building a package, so the proper variables must be used
                   8510: instead of the direct tool names.
                   8511: 
                   8512: As the last steps, some essential variables from the wrapper and the package
                   8513: system flavor are loaded, as well as the variables that have been cached in
                   8514: earlier phases of a package build.
                   8515: 
1.184     rillig   8516: 25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8517: 
                   8518: First, bsd.prefs.mk is loaded.
                   8519: 
                   8520: Then, the various *-vars.mk files are loaded, which fill default values for
                   8521: those variables that have not been defined by the package. These variables may
                   8522: later be used even in unrelated files.
                   8523: 
                   8524: Then, the file bsd.pkg.error.mk provides the target error-check that is added
                   8525: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
                   8526: DELAYED_WARNING_MSG.
                   8527: 
                   8528: Then, the package-specific hacks from hacks.mk are included.
                   8529: 
                   8530: Then, various other files follow. Most of them don't have any dependencies on
                   8531: what they need to have included before or after them, though some do.
                   8532: 
                   8533: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
                   8534: restricts the use of these variables to all the files that have been included
                   8535: before. Appearances in later files will be silently ignored.
                   8536: 
                   8537: Then, the files for the main targets are included, in the order of later
                   8538: execution, though the actual order should not matter.
                   8539: 
                   8540: At last, some more files are included that don't set any interesting variables
                   8541: but rather just define make targets to be executed.
                   8542: 
1.184     rillig   8543: Chapter 26. Regression tests
1.1       dsieger  8544: 
                   8545: Table of Contents
                   8546: 
1.184     rillig   8547: 26.1. Running the regression tests
                   8548: 26.2. Adding a new regression test
                   8549:     26.2.1. Overridable functions
                   8550:     26.2.2. Helper functions
1.1       dsieger  8551: 
                   8552: The pkgsrc infrastructure consists of a large codebase, and there are many
                   8553: corners where every little bit of a file is well thought out, making pkgsrc
                   8554: likely to fail as soon as anything is changed near those parts. To prevent most
                   8555: changes from breaking anything, a suite of regression tests should go along
                   8556: with every important part of the pkgsrc infrastructure. This chapter describes
                   8557: how regression tests work in pkgsrc and how you can add new tests.
                   8558: 
1.184     rillig   8559: 26.1. Running the regression tests
1.1       dsieger  8560: 
1.25      wiz      8561: You first need to install the pkgtools/pkg_regress package, which provides the 
1.1       dsieger  8562: pkg_regress command. Then you can simply run that command, which will run all
1.168     rillig   8563: tests in the regress/ directory.
1.1       dsieger  8564: 
1.184     rillig   8565: 26.2. Adding a new regression test
1.1       dsieger  8566: 
1.168     rillig   8567: Every directory in the regress/ directory that contains a file called spec is
1.1       dsieger  8568: considered a regression test. This file is a shell program that is included by
                   8569: the pkg_regress command. The following functions can be overridden to suit your
                   8570: needs.
                   8571: 
1.184     rillig   8572: 26.2.1. Overridable functions
1.1       dsieger  8573: 
1.108     rillig   8574: These functions do not take any parameters. Although they are called in "set -e
1.168     rillig   8575: " mode, they don't stop at the first failing command. See this Stack Overflow
1.108     rillig   8576: question for details.
1.1       dsieger  8577: 
1.108     rillig   8578: do_setup
1.1       dsieger  8579: 
                   8580:     This function prepares the environment for the test. By default it does
                   8581:     nothing.
                   8582: 
1.108     rillig   8583: do_test
1.1       dsieger  8584: 
                   8585:     This function runs the actual test. By default, it calls TEST_MAKE with the
                   8586:     arguments MAKEARGS_TEST and writes its output including error messages into
                   8587:     the file TEST_OUTFILE.
                   8588: 
1.108     rillig   8589:     When defining this function, make sure that all output that needs to be
                   8590:     checked is written to the correct output file. Example:
                   8591: 
                   8592:     do_test() {
                   8593:             echo "Example output"
                   8594:     } 1>$TEST_OUTFILE 2>&1
                   8595: 
                   8596: check_result
1.1       dsieger  8597: 
                   8598:     This function is run after the test and is typically used to compare the
                   8599:     actual output from the one that is expected. It can make use of the various
1.108     rillig   8600:     helper functions from the next section. Example:
                   8601: 
                   8602:     check_result() {
                   8603:             exit_status 0
                   8604:             output_require "Example"
                   8605:             output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
                   8606:             output_prohibit "no such file or directory"
1.169     rillig   8607:             regress_fail "expected $expected but got $actual for input $input"
1.108     rillig   8608:     }
1.1       dsieger  8609: 
1.108     rillig   8610: do_cleanup
1.1       dsieger  8611: 
                   8612:     This function cleans everything up after the test has been run. By default
                   8613:     it does nothing.
                   8614: 
1.184     rillig   8615: 26.2.2. Helper functions
1.1       dsieger  8616: 
1.168     rillig   8617: regress_fail message...
                   8618: 
                   8619:     This function makes the test fail with the given error message.
                   8620: 
1.108     rillig   8621: exit_status expected
1.1       dsieger  8622: 
1.108     rillig   8623:     This function compares the exitcode of the do_test function with its first
                   8624:     parameter. If they differ, the test will fail.
1.1       dsieger  8625: 
1.108     rillig   8626: output_require regex...
1.1       dsieger  8627: 
                   8628:     This function checks for each of its parameters if the output from do_test
1.108     rillig   8629:     matches the extended regular expression. If it does not, the test will
                   8630:     fail. Example:
                   8631: 
                   8632:     output_require "looks fine"
                   8633:     output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1       dsieger  8634: 
1.177     leot     8635: output_prohibit regex...
1.1       dsieger  8636: 
                   8637:     This function checks for each of its parameters if the output from do_test
                   8638:     () does not match the extended regular expression. If any of the regular
                   8639:     expressions matches, the test will fail.
                   8640: 
1.184     rillig   8641: Chapter 27. Porting pkgsrc
1.1       dsieger  8642: 
                   8643: Table of Contents
                   8644: 
1.184     rillig   8645: 27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8646: 
                   8647: The pkgsrc system has already been ported to many operating systems, hardware
                   8648: architectures and compilers. This chapter explains the necessary steps to make
                   8649: pkgsrc even more portable.
                   8650: 
1.184     rillig   8651: 27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8652: 
                   8653: To port pkgsrc to a new operating system (called MyOS in this example), you
                   8654: need to touch the following files:
                   8655: 
                   8656: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
                   8657: 
                   8658:     This file contains some basic definitions, for example the name of the C
                   8659:     compiler.
                   8660: 
                   8661: mk/bsd.prefs.mk
                   8662: 
1.212     wiz      8663:     Insert code that defines the variables OPSYS, OS_VERSION, OPSYS_VERSION,
1.1       dsieger  8664:     LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
                   8665:     that appear in this file.
                   8666: 
                   8667: mk/platform/MyOS.mk
                   8668: 
                   8669:     This file contains the platform-specific definitions that are used by
                   8670:     pkgsrc. Start by copying one of the other files and edit it to your needs.
                   8671: 
                   8672: mk/tools/tools.MyOS.mk
                   8673: 
                   8674:     This file defines the paths to all the tools that are needed by one or the
                   8675:     other package in pkgsrc, as well as by pkgsrc itself. Find out where these
                   8676:     tools are on your platform and add them.
                   8677: 
                   8678: Now, you should be able to build some basic packages, like lang/perl5, shells/
                   8679: bash.
                   8680: 
                   8681: Appendix A. A simple example package: bison
                   8682: 
                   8683: Table of Contents
                   8684: 
                   8685: A.1. files
                   8686:     A.1.1. Makefile
                   8687:     A.1.2. DESCR
                   8688:     A.1.3. PLIST
                   8689:     A.1.4. Checking a package with pkglint
                   8690: A.2. Steps for building, installing, packaging
                   8691: 
                   8692: We checked to find a piece of software that wasn't in the packages collection,
1.25      wiz      8693: and picked GNU bison. Quite why someone would want to have bison when Berkeley 
1.1       dsieger  8694: yacc is already present in the tree is beyond us, but it's useful for the
                   8695: purposes of this exercise.
                   8696: 
                   8697: A.1. files
                   8698: 
                   8699: A.1.1. Makefile
                   8700: 
1.2       rillig   8701: # $NetBSD$
1.1       dsieger  8702: #
                   8703: 
                   8704: DISTNAME=       bison-1.25
                   8705: CATEGORIES=     devel
1.171     rillig   8706: MASTER_SITES=   ${MASTER_SITE_GNU:=bison/}
1.1       dsieger  8707: 
1.30      dholland 8708: MAINTAINER=     pkgsrc-users@NetBSD.org
1.174     leot     8709: HOMEPAGE=       https://www.gnu.org/software/bison/bison.html
1.1       dsieger  8710: COMMENT=        GNU yacc clone
                   8711: 
                   8712: GNU_CONFIGURE=  yes
1.47      wiz      8713: INFO_FILES=     yes
1.1       dsieger  8714: 
                   8715: .include "../../mk/bsd.pkg.mk"
                   8716: 
                   8717: A.1.2. DESCR
                   8718: 
                   8719: GNU version of yacc.  Can make re-entrant parsers, and numerous other
                   8720: improvements.  Why you would want this when Berkeley yacc(1) is part
                   8721: of the NetBSD source tree is beyond me.
                   8722: 
                   8723: A.1.3. PLIST
                   8724: 
1.2       rillig   8725: @comment $NetBSD$
1.1       dsieger  8726: bin/bison
                   8727: man/man1/bison.1.gz
                   8728: share/bison.simple
                   8729: share/bison.hairy
                   8730: 
                   8731: A.1.4. Checking a package with pkglint
                   8732: 
                   8733: The NetBSD package system comes with pkgtools/pkglint which helps to check the
                   8734: contents of these files. After installation it is quite easy to use, just
1.171     rillig   8735: change to the directory of the package you wish to examine and run pkglint:
1.1       dsieger  8736: 
                   8737: $ pkglint
1.171     rillig   8738: ERROR: Makefile: Each package must define its LICENSE.
                   8739: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
                   8740: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
                   8741: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
                   8742: 1 error, 2 warnings and 1 note found.
                   8743: (Run "pkglint -e" to show explanations.)
                   8744: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172     rillig   8745: (Run "pkglint -F" to automatically fix some issues.)
1.1       dsieger  8746: 
                   8747: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170     rillig   8748: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1       dsieger  8749: 
                   8750: A.2. Steps for building, installing, packaging
                   8751: 
                   8752: Create the directory where the package lives, plus any auxiliary directories:
                   8753: 
                   8754: # cd /usr/pkgsrc/lang
                   8755: # mkdir bison
                   8756: # cd bison
                   8757: # mkdir patches
                   8758: 
1.184     rillig   8759: Create Makefile, DESCR and PLIST (see Chapter 12, Package components - files,
1.1       dsieger  8760: directories and contents) then continue with fetching the distfile:
                   8761: 
                   8762: # make fetch
                   8763: >> bison-1.25.tar.gz doesn't seem to exist on this system.
                   8764: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   8765: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8766: ftp: Error retrieving file: 500 Internal error
                   8767: 
                   8768: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   8769: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8770: ftp: Error retrieving file: 500 Internal error
                   8771: 
                   8772: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   8773: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8774: Successfully retrieved file.
                   8775: 
                   8776: Generate the checksum of the distfile into distinfo:
                   8777: 
                   8778: # make makedistinfo
                   8779: 
                   8780: Now compile:
                   8781: 
                   8782: # make
                   8783: >> Checksum OK for bison-1.25.tar.gz.
                   8784: ===>  Extracting for bison-1.25
                   8785: ===>  Patching for bison-1.25
                   8786: ===>   Ignoring empty patch directory
                   8787: ===>  Configuring for bison-1.25
                   8788: creating cache ./config.cache
                   8789: checking for gcc... cc
                   8790: checking whether we are using GNU C... yes
                   8791: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   8792: checking how to run the C preprocessor... cc -E
                   8793: checking for minix/config.h... no
                   8794: checking for POSIXized ISC... no
                   8795: checking whether cross-compiling... no
                   8796: checking for ANSI C header files... yes
                   8797: checking for string.h... yes
                   8798: checking for stdlib.h... yes
                   8799: checking for memory.h... yes
                   8800: checking for working const... yes
                   8801: checking for working alloca.h... no
                   8802: checking for alloca... yes
                   8803: checking for strerror... yes
                   8804: updating cache ./config.cache
                   8805: creating ./config.status
                   8806: creating Makefile
                   8807: ===>  Building for bison-1.25
                   8808: 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
                   8809: 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
                   8810: 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
                   8811: 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
                   8812: 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
                   8813: 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
                   8814: 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
                   8815: 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
                   8816: 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
                   8817: 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
                   8818: 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
                   8819: 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
                   8820: 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
                   8821: 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
                   8822: 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
                   8823: 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
                   8824: 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
                   8825: 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
                   8826: 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
                   8827: 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
                   8828: 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
                   8829: 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
                   8830: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   8831: rm -f bison.s1
                   8832: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
                   8833: 
                   8834: Everything seems OK, so install the files:
                   8835: 
                   8836: # make install
                   8837: >> Checksum OK for bison-1.25.tar.gz.
                   8838: ===>  Installing for bison-1.25
                   8839: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   8840: rm -f /usr/pkg/bin/bison
                   8841: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   8842: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   8843: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   8844: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   8845: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   8846: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   8847: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
                   8848: ===>  Registering installation for bison-1.25
                   8849: 
                   8850: You can now use bison, and also - if you decide so - remove it with pkg_delete
                   8851: bison. Should you decide that you want a binary package, do this now:
                   8852: 
                   8853: # make package
                   8854: >> Checksum OK for bison-1.25.tar.gz.
                   8855: ===>  Building package for bison-1.25
                   8856: Creating package bison-1.25.tgz
                   8857: Registering depends:.
                   8858: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
                   8859: 
                   8860: Now that you don't need the source and object files any more, clean up:
                   8861: 
                   8862: # make clean
                   8863: ===>  Cleaning for bison-1.25
                   8864: 
1.207     leot     8865: Appendix B. Security hardening
                   8866: 
                   8867: Table of Contents
                   8868: 
                   8869: B.1. Mechanisms
                   8870:     B.1.1. Enabled by default
                   8871:     B.1.2. Not enabled by default
                   8872: B.2. Caveats
                   8873:     B.2.1. Problems with PKGSRC_MKPIE
                   8874:     B.2.2. Problems with PKGSRC_USE_FORTIFY
                   8875:     B.2.3. Problems with PKGSRC_USE_RELRO
                   8876:     B.2.4. Problems with PKGSRC_USE_SSP
                   8877: B.3. Auditing the system
                   8878:     B.3.1. Checking for PIE
                   8879:     B.3.2. Checking for partial RELRO
                   8880:     B.3.3. Checking for full RELRO
                   8881:     B.3.4. Checking for SSP
                   8882: 
                   8883: A number of mechanisms are available in pkgsrc to improve the security of the
                   8884: resulting system. This page describes the mechanisms, and gives hints about
                   8885: detecting and fixing problems.
                   8886: 
                   8887: Mechanisms can be enabled individually in mk.conf, and are individually
                   8888: described below.
                   8889: 
                   8890: Typically, a feature will cause some programs to fail to build or work when
                   8891: first enabled. This can be due to latent problems in the program, and can be
                   8892: due to other reasons. After enough testing to have confidence that user
                   8893: problems will be quite rare, individual mechanisms will be enabled by default.
                   8894: 
                   8895: For each mechanism, see the Caveats section below for an explanation of what
                   8896: might go wrong at compile time and at run time, and how to notice and address
                   8897: these problems.
                   8898: 
                   8899: B.1. Mechanisms
                   8900: 
                   8901: B.1.1. Enabled by default
                   8902: 
                   8903: B.1.1.1. PKGSRC_USE_FORTIFY
                   8904: 
                   8905: This allows substitute wrappers to be used for some commonly used library
                   8906: functions that do not have built-in bounds checking - but could in some cases.
                   8907: 
                   8908: Two mitigation levels are available:
                   8909: 
                   8910:   * "weak" only enables checks at compile-time.
                   8911: 
                   8912:   * "strong" enables checks at compile-time and runtime.
                   8913: 
                   8914: "strong" has been enabled by default since pkgsrc-2017Q3.
                   8915: 
                   8916: B.1.1.2. PKGSRC_USE_SSP
                   8917: 
                   8918: This enables a stack-smashing protection mitigation. It is done by adding a
                   8919: guard variable to functions with vulnerable objects. The guards are initialized
                   8920: when a function is entered and then checked when the function exits. The guard
                   8921: check will fail and the program forcibly exited if the variable was modified in
                   8922: the meantime. This can happen in case of buffer overflows or memory corruption,
                   8923: and therefore exposing these bugs.
                   8924: 
                   8925: Different mitigation levels are available:
                   8926: 
                   8927:   * "yes", which will only protect functions considered vulnerable by the
                   8928:     compiler;
                   8929: 
                   8930:   * "all", which will protect every function;
                   8931: 
                   8932:   * "strong", the default, which will apply a better balance between the two
                   8933:     settings above.
                   8934: 
                   8935: This mitigation is supported by both GCC and clang. It may be supported in
                   8936: additional compilers, possibly under a different name. It is particularly
                   8937: useful for unsafe programming languages, such as C/C++.
                   8938: 
                   8939:   * "yes" is enabled by default where known supported since pkgsrc-2017Q3.
                   8940: 
                   8941:   * "strong" is enabled by default where known supported since pkgsrc-2021Q4.
                   8942: 
                   8943: More details can be found here:
                   8944: 
                   8945:   * Buffer overflow protection on Wikipedia
                   8946: 
                   8947: B.1.1.3. PKGSRC_MKPIE
                   8948: 
                   8949: This requests the creation of PIE (Position Independent Executables) for all
                   8950: executables. The PIE mechanism is normally used for shared libraries, so that
                   8951: they can be loaded at differing addresses at runtime. PIE itself does not have
                   8952: useful security properties; however, it is necessary to fully leverage some,
                   8953: such as ASLR. Some operating systems support Address Space Layout Randomization
                   8954: (ASLR), which causes different addresses to be used each time a program is run.
                   8955: This makes it more difficult for an attacker to guess addresses and thus makes
                   8956: exploits harder to construct. With PIE, ASLR can really be applied to the
                   8957: entire program, instead of the stack and heap only.
                   8958: 
                   8959: PIE executables will only be built for toolchains that are known to support
                   8960: PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
                   8961: 
                   8962: PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch.
                   8963: 
1.219     nia      8964: B.1.1.4. PKGSRC_USE_RELRO
1.207     leot     8965: 
                   8966: This also makes the exploitation of some security vulnerabilities more
                   8967: difficult in some cases.
                   8968: 
                   8969: Two different mitigation levels are available:
                   8970: 
1.219     nia      8971:   * partial (the default): the ELF sections are reordered so that internal data
                   8972:     sections precede the program's own data sections, and non-PLT GOT is
                   8973:     read-only;
1.207     leot     8974: 
                   8975:   * full: in addition to partial RELRO, every relocation is performed
1.218     nia      8976:     immediately when starting the program, allowing the entire GOT to be
                   8977:     read-only. This can greatly slow down startup of large programs.
1.207     leot     8978: 
                   8979: This is currently supported by GCC. Many software distributions now enable this
1.220     nia      8980: feature by default, at the "partial" level.
1.207     leot     8981: 
                   8982: More details can be found here:
                   8983: 
                   8984:   * Hardening ELF binaries using Relocation Read-Only (RELRO)
                   8985: 
1.219     nia      8986: B.1.2. Not enabled by default
                   8987: 
                   8988: B.1.2.1. PKGSRC_MKREPRO
                   8989: 
                   8990: With this option, pkgsrc will try to build packages reproducibly. This allows
                   8991: packages built from the same tree and with the same options, to produce
                   8992: identical results bit by bit. This option should be combined with ASLR and
                   8993: PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to
                   8994: exploit security vulnerabilities.
                   8995: 
                   8996: More details can be found here:
                   8997: 
                   8998:   * Reproducible Builds - a set of software development practices that create
                   8999:     an independently-verifiable path from source to binary code
                   9000: 
                   9001: More work likely needs to be done before pkgsrc is fully reproducible.
                   9002: 
                   9003: B.1.2.2. PKGSRC_USE_STACK_CHECK
1.207     leot     9004: 
                   9005: This uses -fstack-check with GCC for another stack protection mitigation.
                   9006: 
                   9007: It asks the compiler to generate code verifying that it does not corrupt the
                   9008: stack. According to GCC's manual page, this is really only useful for
                   9009: multi-threaded programs.
                   9010: 
                   9011: B.2. Caveats
                   9012: 
                   9013: B.2.1. Problems with PKGSRC_MKPIE
                   9014: 
                   9015: B.2.1.1. Packages failing to build
                   9016: 
                   9017: A number of packages may fail to build with this option enabled. The failures
                   9018: are often related to the absence of the -fPIC compilation flag when building
                   9019: libraries or executables (or ideally -fPIE in the latter case). This flag is
                   9020: added to the CFLAGS already, but requires the package to actually support it.
                   9021: 
                   9022: B.2.1.1.1. How to fix
                   9023: 
                   9024: These instructions are meant as a reference only; they likely need to be
                   9025: adapted for many packages individually.
                   9026: 
                   9027: For packages using Makefiles:
                   9028: 
                   9029: MAKE_FLAGS+=    CFLAGS=${CFLAGS:Q}
                   9030: MAKE_FLAGS+=    LDFLAGS=${LDFLAGS:Q}
                   9031: 
                   9032: For packages using Imakefiles:
                   9033: 
                   9034: MAKE_FLAGS+=    CCOPTIONS=${CFLAGS:Q}
                   9035: MAKE_FLAGS+=    LOCAL_LDFLAGS=${LDFLAGS:Q}
                   9036: 
                   9037: B.2.1.2. Run-time crashes
                   9038: 
                   9039: Some programs may fail to run, or crash at random times once built as PIE. Two
                   9040: scenarios are essentially possible. This is nearly always due to a bug in the
                   9041: program being exposed due to ASLR.
                   9042: 
                   9043: B.2.1.3. Disabling PKGSRC_MKPIE on a per-package basis
                   9044: 
                   9045: Ideally, packages should be fixed for compatibility with MKPIE. However, in
                   9046: some cases this is very difficult, due to complex build systems, packages using
                   9047: non-standard toolchains, or programming languages with odd bootstrapping
                   9048: mechanisms.
                   9049: 
                   9050: To disable PKGSRC_MKPIE on a per-package basis, set MKPIE_SUPPORTED= no in the
                   9051: package's Makefile before bsd.prefs.mk is included.
                   9052: 
                   9053: B.2.2. Problems with PKGSRC_USE_FORTIFY
                   9054: 
                   9055: B.2.2.1. Packages failing to build
                   9056: 
                   9057: This feature makes use of pre-processing directives to look for hardened,
                   9058: alternative implementations of essential library calls. Some programs may fail
                   9059: to build as a result; this usually happens for those trying too hard to be
                   9060: portable, or otherwise abusing definitions in the standard library.
                   9061: 
                   9062: B.2.2.2. Run-time crashes
                   9063: 
                   9064: This feature may cause some programs to crash, usually indicating an actual bug
                   9065: in the program. The fix will typically involve patching the original program's
                   9066: source code.
                   9067: 
                   9068: B.2.2.3. Optimization is required
                   9069: 
                   9070: At least in the case of GCC, FORTIFY will only be applied if optimization is
                   9071: applied while compiling. This means that the CFLAGS should also contain -O, -O2
                   9072: or another optimization level. This cannot easily be applied globally, as some
                   9073: packages may require specific optimization levels.
                   9074: 
                   9075: B.2.2.4. Disabling FORTIFY on a per-package basis
                   9076: 
                   9077: Note
                   9078: 
                   9079: FORTIFY should not be disabled to work around runtime crashes in the program!
                   9080: This is a very bad idea and will expose you to security vulnerabilities.
                   9081: 
                   9082: To disable FORTIFY on a per-package basis, set the following in the package's
                   9083: Makefile before bsd.prefs.mk is included:
                   9084: 
                   9085: FORTIFY_SUPPORTED=      no
                   9086: 
                   9087: B.2.3. Problems with PKGSRC_USE_RELRO
                   9088: 
                   9089: B.2.3.1. Performance impact
                   9090: 
                   9091: For better protection, full RELRO requires every symbol to be resolved when the
                   9092: program starts, rather than simply when required at run-time. This will have
                   9093: more impact on programs using a lot of symbols, or linked to libraries exposing
                   9094: a lot of symbols. Therefore, daemons or programs otherwise running in
                   9095: background are affected only when started. Programs loading plug-ins at
                   9096: run-time are affected when loading the plug-ins.
                   9097: 
                   9098: The impact is not expected to be noticeable on modern hardware, except in some
                   9099: cases for big programs.
                   9100: 
                   9101: B.2.3.2. Run-time crashes
                   9102: 
                   9103: Some programs handle plug-ins and dependencies in a way that conflicts with
                   9104: RELRO: for instance, with an initialization routine listing any other plug-in
                   9105: required. With full RELRO, the missing symbols are resolved before the
                   9106: initialization routine can run, and the dynamic loader will not be able to find
                   9107: them directly and abort as a result. Unfortunately, this is how Xorg loads its
                   9108: drivers. Partial RELRO can be applied instead in this case.
                   9109: 
                   9110: B.2.3.3. Disabling RELRO on a per-package basis
                   9111: 
                   9112: To disable RELRO on a per-package basis, set the following in the package's
                   9113: Makefile before bsd.prefs.mk is included:
                   9114: 
                   9115: RELRO_SUPPORTED=        no
                   9116: 
1.209     nia      9117: It is also possible to at most enable partial RELRO, by setting RELRO_SUPPORTED
                   9118: to partial.
                   9119: 
1.207     leot     9120: B.2.4. Problems with PKGSRC_USE_SSP
                   9121: 
                   9122: B.2.4.1. Packages failing to build
                   9123: 
                   9124: The stack-smashing protection provided by this option does not work for some
                   9125: programs. The most common situation in which this happens is when the program
                   9126: allocates variables on the stack, with the size determined at run-time.
                   9127: 
                   9128: B.2.4.2. Run-time crashes
                   9129: 
                   9130: Again, this feature may cause some programs to crash via a SIGABRT, usually
                   9131: indicating an actual bug in the program.
                   9132: 
                   9133: On NetBSD LOG_CRIT level syslog messages are sent and - by default - appended
                   9134: to /var/log/messages, e.g.:
                   9135: 
                   9136: Jan  6 15:42:51 hostname -: hostname program - - - buffer overflow detected; terminated
                   9137: 
                   9138: (where hostname is the hostname(1) and program is the basename(1) of the
                   9139: program crashed).
                   9140: 
                   9141: Patching the original program is then required.
                   9142: 
                   9143: Rebuilding the package via:
                   9144: 
                   9145: % env CFLAGS=-g INSTALL_UNSTRIPPED=yes make replace
                   9146: 
                   9147: and inspecting the backtrace of the coredump via the debugger should point out
                   9148: the problematic call by inspecting the frame calling the _chk() (SSP) function.
                   9149: 
                   9150: B.2.4.3. Performance impact
                   9151: 
                   9152: The compiler emits extra code when using this feature: a check for buffer
                   9153: overflows is performed when entering and exiting functions, requiring an extra
                   9154: variable on the stack. The level of protection can otherwise be adjusted to
                   9155: affect only those functions considered more sensitive by the compiler (with
                   9156: -fstack-protector instead of -fstack-protector-all).
                   9157: 
                   9158: The impact is not expected to be noticeable on modern hardware. However,
                   9159: programs with a hard requirement to run at the fastest possible speed should
                   9160: avoid using this feature, or using libraries built with this feature.
                   9161: 
                   9162: B.2.4.4. Disabling SSP on a per-package basis
                   9163: 
                   9164: Note
                   9165: 
                   9166: SSP should not be disabled to work around runtime crashes in the program! This
                   9167: is a very bad idea and will expose you to security vulnerabilities.
                   9168: 
                   9169: To disable SSP on a per-package basis, set the following in the package's
                   9170: Makefile before bsd.prefs.mk is included:
                   9171: 
                   9172: SSP_SUPPORTED=  no
                   9173: 
                   9174: B.3. Auditing the system
                   9175: 
                   9176: The illusion of security is worse than having no security at all. This section
                   9177: lists a number of ways to ensure the security features requested are actually
                   9178: effective.
                   9179: 
                   9180: These instructions were obtained and tested on a system derived from NetBSD 7
                   9181: (amd64). YMMV.
                   9182: 
                   9183: B.3.1. Checking for PIE
                   9184: 
                   9185: The ELF executable type in use changes for binaries built as PIE; without:
                   9186: 
                   9187: $ file /path/to/bin/ary
                   9188: /path/to/bin/ary: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 7.0, not stripped
                   9189: 
                   9190: as opposed to the following binary, built as PIE:
                   9191: 
                   9192: $ file /path/to/pie/bin/ary
                   9193: /path/to/pie/bin/ary: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 7.0, not stripped
                   9194: 
                   9195: The latter result is then what is expected.
                   9196: 
                   9197: B.3.2. Checking for partial RELRO
                   9198: 
                   9199: The following command should list a section called RELRO:
                   9200: 
                   9201: $ objdump -p /path/to/bin/ary
                   9202: 
                   9203: /path/to/bin/ary:     file format elf64-x86-64
                   9204: 
                   9205: Program Header:
                   9206: [...]
                   9207:    RELRO off    0x0000000000000d78 vaddr 0x0000000000600d78 paddr 0x0000000000600d78 align 2**0
                   9208: 
                   9209: This check is now performed automatically if PKG_DEVELOPER is set and RELRO is
                   9210: enabled.
                   9211: 
                   9212: B.3.3. Checking for full RELRO
                   9213: 
                   9214: The dynamic loader will apply RELRO immediately when detecting the presence of
                   9215: the BIND_NOW flag:
                   9216: 
                   9217: $ objdump -x /path/to/bin/ary
                   9218: 
                   9219: /path/to/bin/ary:     file format elf64-x86-64
                   9220: 
                   9221: Dynamic Section:
                   9222: [...]
                   9223:   BIND_NOW             0x0000000000000000
                   9224: 
                   9225: This has to be combined with partial RELRO (see above) to be fully efficient.
                   9226: 
                   9227: This check is now performed automatically (where supported) if PKG_DEVELOPER is
                   9228: set.
                   9229: 
                   9230: B.3.4. Checking for SSP
                   9231: 
1.208     nia      9232: Note
                   9233: 
                   9234: Checking for SSP using this method only works where the operating system uses
                   9235: libssp. libssp is not used on recent NetBSD/FreeBSD/Linux versions.
                   9236: 
1.207     leot     9237: Building objects, binaries and libraries with SSP will affect the presence of
                   9238: additional symbols in the resulting file:
                   9239: 
                   9240: $ nm /path/to/bin/ary
                   9241: [...]
                   9242:                  U __stack_chk_fail
                   9243: 0000000000600ea0 B __stack_chk_guard
                   9244: 
                   9245: This is an indicator that the program was indeed built with support for SSP.
                   9246: 
                   9247: This check is now performed automatically (where supported) if PKG_DEVELOPER is
                   9248: set and SSP is enabled.
                   9249: 
                   9250: Appendix C. Build logs
1.1       dsieger  9251: 
                   9252: Table of Contents
                   9253: 
1.207     leot     9254: C.1. Building figlet
                   9255: C.2. Packaging figlet
1.1       dsieger  9256: 
1.207     leot     9257: C.1. Building figlet
1.1       dsieger  9258: 
                   9259: # make
                   9260: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9261: => figlet221.tar.gz doesn't seem to exist on this system.
                   9262: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   9263: => [172219 bytes]
                   9264: Connected to ftp.plig.net.
                   9265: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   9266: 331 Guest login ok, send your complete e-mail address as password.
                   9267: 230-You are user #5 of 500 simultaneous users allowed.
                   9268: 230-
                   9269: 230-  ___ _             _ _
                   9270: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
                   9271: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   9272: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   9273: 230-         |_|   |_|     |___|         |___|
                   9274: 230-
                   9275: 230-** Welcome to ftp.plig.org **
                   9276: 230-
                   9277: 230-Please note that all transfers from this FTP site are logged. If you
                   9278: 230-do not like this, please disconnect now.
                   9279: 230-
1.19      snj      9280: 230-This archive is available via
1.1       dsieger  9281: 230-
                   9282: 230-HTTP:  http://ftp.plig.org/
                   9283: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   9284: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   9285: 230-
                   9286: 230-Please email comments, bug reports and requests for packages to be
                   9287: 230-mirrored to ftp-admin@plig.org.
                   9288: 230-
                   9289: 230-
                   9290: 230 Logged in anonymously.
                   9291: Remote system type is UNIX.
                   9292: Using binary mode to transfer files.
                   9293: 200 Type okay.
                   9294: 250 "/pub" is new cwd.
                   9295: 250-"/pub/figlet" is new cwd.
                   9296: 250-
                   9297: 250-Welcome to the figlet archive at ftp.figlet.org
                   9298: 250-
                   9299: 250-    ftp://ftp.figlet.org/pub/figlet/
                   9300: 250-
                   9301: 250-The official FIGlet web page is:
                   9302: 250-    http://www.figlet.org/
                   9303: 250-
                   9304: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   9305: 250-contribute a font or something else, you can email us.
                   9306: 250
                   9307: 250 "/pub/figlet/program" is new cwd.
                   9308: 250 "/pub/figlet/program/unix" is new cwd.
                   9309: local: figlet221.tar.gz remote: figlet221.tar.gz
                   9310: 502 Unimplemented command.
                   9311: 227 Entering Passive Mode (195,40,6,41,246,104)
                   9312: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   9313: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   9314: 226 Transfer completed.
                   9315: 172219 bytes received in 00:02 (75.99 KB/s)
                   9316: 221 Goodbye.
                   9317: => Checksum OK for figlet221.tar.gz.
                   9318: ===> Extracting for figlet-2.2.1nb2
                   9319: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   9320: ===> Patching for figlet-2.2.1nb2
                   9321: ===> Applying pkgsrc patches for figlet-2.2.1nb2
                   9322: ===> Overriding tools for figlet-2.2.1nb2
                   9323: ===> Creating toolchain wrappers for figlet-2.2.1nb2
                   9324: ===> Configuring for figlet-2.2.1nb2
                   9325: ===> Building for figlet-2.2.1nb2
                   9326: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   9327: chmod a+x figlet
                   9328: gcc -O2 -o chkfont chkfont.c
                   9329: => Unwrapping files-to-be-installed.
                   9330: #
                   9331: # make install
                   9332: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9333: ===> Installing for figlet-2.2.1nb2
                   9334: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   9335: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   9336: mkdir -p /usr/pkg/share/figlet
                   9337: cp figlet /usr/pkg/bin
                   9338: cp chkfont /usr/pkg/bin
                   9339: chmod 555 figlist showfigfonts
                   9340: cp figlist /usr/pkg/bin
                   9341: cp showfigfonts /usr/pkg/bin
                   9342: cp fonts/*.flf /usr/pkg/share/figlet
                   9343: cp fonts/*.flc /usr/pkg/share/figlet
                   9344: cp figlet.6 /usr/pkg/man/man6
                   9345: ===> Registering installation for figlet-2.2.1nb2
                   9346: #
                   9347: 
1.207     leot     9348: C.2. Packaging figlet
1.1       dsieger  9349: 
                   9350: # make package
                   9351: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9352: ===> Packaging figlet-2.2.1nb2
                   9353: ===> Building binary package for figlet-2.2.1nb2
                   9354: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   9355: Using SrcDir value of /usr/pkg
                   9356: Registering depends:.
                   9357: #
                   9358: 
1.207     leot     9359: Appendix D. Directory layout of the pkgsrc FTP server
1.1       dsieger  9360: 
                   9361: Table of Contents
                   9362: 
1.207     leot     9363: D.1. distfiles: The distributed source files
                   9364: D.2. misc: Miscellaneous things
                   9365: D.3. packages: Binary packages
                   9366: D.4. reports: Bulk build reports
                   9367: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9368: 
                   9369: As in other big projects, the directory layout of pkgsrc is quite complex for
                   9370: newbies. This chapter explains where you find things on the FTP server. The
                   9371: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
                   9372: different, but inside this directory, everything should look the same, no
                   9373: matter on which server you are. This directory contains some subdirectories,
                   9374: which are explained below.
                   9375: 
1.207     leot     9376: D.1. distfiles: The distributed source files
1.1       dsieger  9377: 
                   9378: The directory distfiles contains lots of archive files from all pkgsrc
                   9379: packages, which are mirrored here. The subdirectories are called after their
                   9380: package names and are used when the distributed files have names that don't
                   9381: explicitly contain a version number or are otherwise too generic (for example
                   9382: release.tar.gz).
                   9383: 
1.207     leot     9384: D.2. misc: Miscellaneous things
1.1       dsieger  9385: 
                   9386: This directory contains things that individual pkgsrc developers find worth
                   9387: publishing.
                   9388: 
1.207     leot     9389: D.3. packages: Binary packages
1.1       dsieger  9390: 
1.3       rillig   9391: This directory contains binary packages for the various platforms that are
                   9392: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
                   9393: The meaning of these variables is:
                   9394: 
                   9395:   * OPSYS is the name of the operating system for which the packages have been
1.9       rillig   9396:     built. The name is taken from the output of the uname command, so it may
                   9397:     differ from the one you are used to hear.
1.3       rillig   9398: 
1.8       rillig   9399:   * ARCH is the hardware architecture of the platform for which the packages
1.10      hubertf  9400:     have been built. It also includes the ABI (Application Binary Interface)
                   9401:     for platforms that have several of them.
1.3       rillig   9402: 
1.255     wiz      9403:   * OSVERSION is the version of the operating system. Typically it is the
                   9404:     version defining an ABI, e.g. 9.0.
                   9405: 
                   9406:   * TAG is either 20YYQN for a stable branch, or current for packages built
                   9407:     from the HEAD branch. The latter should only be used when the packages are
                   9408:     updated on a regular basis.
                   9409: 
                   9410: The rationale for this scheme is that users can first search by OPSYS and ARCH,
                   9411: since these are more or less unchangeable. After that, there is a management
                   9412: set of directories with OSVERSION and TAG.
                   9413: 
                   9414: See also README.md in packages for more details, including about symlinks.
1.3       rillig   9415: 
                   9416: In each of these directories, there is a whole binary packages collection for a
                   9417: specific platform. It has a directory called All which contains all binary
1.255     wiz      9418: packages.
1.1       dsieger  9419: 
1.207     leot     9420: D.4. reports: Bulk build reports
1.8       rillig   9421: 
                   9422: Here are the reports from bulk builds, for those who want to fix packages that
                   9423: didn't build on some of the platforms. The structure of subdirectories should
1.207     leot     9424: look like the one in Section D.3, "packages: Binary packages".
1.8       rillig   9425: 
1.207     leot     9426: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9427: 
                   9428: These directories contain the "real" pkgsrc, that is the files that define how
                   9429: to create binary packages from source archives.
                   9430: 
1.149     leot     9431: Each of the current, stable and pkgsrc-20xxQy directories share the same
                   9432: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
                   9433: 
1.1       dsieger  9434: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149     leot     9435: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
                   9436: directory, ready to be downloaded as a whole.
1.1       dsieger  9437: 
1.149     leot     9438: The current directory contains files related to the HEAD branch of the CVS
                   9439: repository. In this directory there is an additional file called
                   9440: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
                   9441: about categories and packages.
                   9442: 
                   9443: The stable directory is a symlink to the latest pkgsrc-20xxQy.
                   9444: 
                   9445: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
                   9446: branch of the CVS repository. In these directories there is an additional file
                   9447: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
                   9448: was branched.
1.148     leot     9449: 
1.207     leot     9450: Appendix E. Help topics
1.154     rillig   9451: 
                   9452: The following list contains all help topics that are available when running 
                   9453: bmake help topic=:index.
                   9454: 
1.260     wiz      9455: #!                                -lintl
                   9456: 32bit                             64bit
                   9457: ABI                               ACCEPTABLE_LICENSES
                   9458: ACROREAD_FONTPATH                 ADDITIONAL
                   9459: AFAIK                             AIX
                   9460: ALLOW_NETWORK_ACCESS              ALLOW_NEWER_COMPILER
                   9461: ALLOW_VULNERABLE_PACKAGES         ALL_ENV
1.262   ! dholland 9462: ALTERNATIVES_SRC                  AMANDA_TMP
        !          9463: AMANDA_USER                       AMANDA_VAR
        !          9464: APACHE_GROUP                      APACHE_MODULE_NAME
        !          9465: APACHE_MODULE_SRC                 APACHE_MODULE_SRCDIR
        !          9466: APACHE_PKG_PREFIX                 APACHE_SUEXEC_CONFIGURE_ARGS
        !          9467: APACHE_SUEXEC_DOCROOT             APACHE_USER
        !          9468: ARGMAX_REQ                        ARG_MAX
        !          9469: ARLA_CACHE                        AUDIT_PACKAGES_FLAGS
        !          9470: AUTOCONF_REQD                     AUTOMAKE_OVERRIDE
        !          9471: AUTOMAKE_REQD                     AUTO_MKDIRS
        !          9472: AUX                               BDB185_DEFAULT
        !          9473: BDBBASE                           BDB_ACCEPTED
        !          9474: BDB_DEFAULT                       BDB_LIBS
        !          9475: BDB_TYPE                          BINCIMAP_GROUP
        !          9476: BINCIMAP_LOG_USER                 BINCIMAP_USER
        !          9477: BIND_DIR                          BIND_GROUP
        !          9478: BIND_USER                         BINOWN
        !          9479: BINPKG_SITES                      BIN_INSTALL_FLAGS
        !          9480: BISON_PKGDATADIR                  BLAS
        !          9481: BLAS_ACCEPTED                     BLAS_C_INTERFACE
        !          9482: BLAS_INCLUDES                     BLAS_INDEX64
        !          9483: BLAS_LIBS                         BLAS_PC
        !          9484: BLAS_TYPE                         BOOTSTRAP_DEPENDS
        !          9485: BROKEN                            BROKEN_EXCEPT_ON_PLATFORM
        !          9486: BROKEN_ON_PLATFORM                BSDSRCDIR
        !          9487: BSDXSRCDIR                        BSD_MAKE_ENV
        !          9488: BUILDLINK_AUTO_DIRS               BUILDLINK_AUTO_VARS
        !          9489: BUILDLINK_CFLAGS                  BUILDLINK_CONTENTS_FILTER
        !          9490: BUILDLINK_CPPFLAGS                BUILDLINK_FILES
1.260     wiz      9491: BUILDLINK_FILES_CMD               BUILDLINK_FNAME_TRANSFORM
                   9492: BUILDLINK_LDFLAGS                 BUILDLINK_LIBS
                   9493: BUILDLINK_OPSYS_SUPPORT_PTHREAD   BUILDLINK_PKGNAME
                   9494: BUILDLINK_PREFIX                  BUILDLINK_RPATHDIRS
                   9495: BUILDLINK_TREE                    BUILD_DEFS
                   9496: BUILD_DEFS_EFFECTS                BUILD_DEPENDS
                   9497: BUILD_DIRS                        BUILD_ENV_SHELL
                   9498: BUILD_MAKE_CMD                    BUILD_MAKE_FLAGS
                   9499: BUILD_TARGET                      BUILTIN_FIND_FILES
                   9500: BUILTIN_FIND_FILES_VAR            BUILTIN_FIND_GREP
                   9501: BUILTIN_FIND_HEADERS              BUILTIN_FIND_HEADERS_VAR
                   9502: BUILTIN_FIND_PKGCONFIG            BUILTIN_FIND_PKGCONFIG_VAR
                   9503: BUILTIN_PKG                       BUILTIN_TEST_CURSES_DEFINES
                   9504: BUILTIN_TEST_CURSES_FUNCS         BUILTIN_VERSION_SCRIPT
                   9505: BUILTIN_X11_TYPE                  BUILTIN_X11_VERSION
                   9506: CACTI_GROUP                       CACTI_USER
                   9507: CANNA_GROUP                       CANNA_USER
                   9508: CAT                               CBLAS_LIBS
                   9509: CBLAS_PC                          CCACHE_BASE
                   9510: CCACHE_DIR                        CCACHE_LOGFILE
                   9511: CCACHE_RECACHE                    CC_VERSION
                   9512: CC_VERSION_STRING                 CDRECORD_CONF
                   9513: CDROM_PKG_URL_DIR                 CDROM_PKG_URL_HOST
1.262   ! dholland 9514: CHANGES                           CHECK_COMPILER
        !          9515: CHECK_FAKEHOME                    CHECK_FILES
        !          9516: CHECK_FILES_ONLY_PREFIX           CHECK_FILES_SKIP
        !          9517: CHECK_FILES_STRICT                CHECK_HEADERS
        !          9518: CHECK_HEADERS_SKIP                CHECK_INTERPRETER
        !          9519: CHECK_INTERPRETER_SKIP            CHECK_PERMS
        !          9520: CHECK_PERMS_AUTOFIX               CHECK_PERMS_SKIP
        !          9521: CHECK_PIE                         CHECK_PIE_SKIP
        !          9522: CHECK_PIE_SUPPORTED               CHECK_PORTABILITY
        !          9523: CHECK_PORTABILITY_EXPERIMENTAL    CHECK_PORTABILITY_SKIP
        !          9524: CHECK_RELRO                       CHECK_RELRO_SKIP
        !          9525: CHECK_RELRO_SUPPORTED             CHECK_SHLIBS
        !          9526: CHECK_SHLIBS_SKIP                 CHECK_SHLIBS_SUPPORTED
        !          9527: CHECK_SHLIBS_TOXIC                CHECK_SSP
        !          9528: CHECK_SSP_SKIP                    CHECK_SSP_SUPPORTED
        !          9529: CHECK_STRIPPED                    CHECK_STRIPPED_SKIP
        !          9530: CHECK_WRKREF                      CHECK_WRKREF_EXTRA_DIRS
        !          9531: CHECK_WRKREF_SKIP                 CLAMAV_DBDIR
        !          9532: CLAMAV_GROUP                      CLAMAV_USER
        !          9533: CLANGBASE                         CLEANDEPENDS
        !          9534: CLT                               CMAKE_DEPENDENCIES_REWRITE
        !          9535: CMAKE_INSTALL_NAME_DIR            CMAKE_INSTALL_PREFIX
        !          9536: CMAKE_MODULE_PATH_OVERRIDE        CMAKE_PKGSRC_BUILD_FLAGS
        !          9537: CMAKE_PREFIX_PATH                 CMAKE_USE_GNU_INSTALL_DIRS
1.260     wiz      9538: COMPILER_RPATH_FLAG               COMPILER_USE_SYMLINKS
                   9539: CONFIGURE_ARGS                    CONFIGURE_DIRS
                   9540: CONFIGURE_ENV                     CONFIGURE_ENV_SHELL
                   9541: CONFIGURE_HAS_INFODIR             CONFIGURE_HAS_MANDIR
                   9542: CONFIGURE_SCRIPT                  CONFIG_SHELL
                   9543: CONFIG_SHELL_FLAGS                CONF_FILES
                   9544: CONF_FILES_MODE                   CONF_FILES_PERMS
                   9545: CONSERVER_DEFAULTHOST             CONSERVER_DEFAULTPORT
                   9546: CP                                CPE
                   9547: CPE_EDITION                       CPE_LANG
                   9548: CPE_OTHER                         CPE_PART
                   9549: CPE_PRODUCT                       CPE_SW_EDITION
                   9550: CPE_TARGET_HW                     CPE_TARGET_SW
                   9551: CPE_UPDATE                        CPE_URI
                   9552: CPE_VENDOR                        CPE_VERSION
                   9553: CPP                               CPP_PRECOMP_FLAGS
                   9554: CREATE_WRKDIR_SYMLINK             CROSSBASE
                   9555: CTFCONVERT                        CTF_FILES_SKIP
                   9556: CTF_SUPPORTED                     CTYPE
                   9557: CUPS_GROUP                        CUPS_SYSTEM_GROUPS
                   9558: CUPS_USER                         CURSES_DEFAULT
1.262   ! dholland 9559: CURSES_TYPE                       CXX
        !          9560: CYRUS_GROUP                       CYRUS_IDLE
        !          9561: CYRUS_USER                        DAEMONTOOLS_GROUP
        !          9562: DAEMONTOOLS_LOG_USER              DARWIN_NO_SYSTEM_LIBS
        !          9563: DARWIN_REQUIRES_FILTER            DBUS_GROUP
        !          9564: DBUS_USER                         DEFANG_GROUP
        !          9565: DEFANG_USER                       DEFAULT_ACCEPTABLE_LICENSES
        !          9566: DEFAULT_DISTFILES                 DEFAULT_IRC_SERVER
        !          9567: DEFAULT_SERIAL_DEVICE             DEF_UMASK
        !          9568: DEINSTALLDEPENDS                  DEINSTALL_SRC
        !          9569: DEINSTALL_TEMPLATES               DELAYED_ERROR_MSG
        !          9570: DELAYED_WARNING_MSG               DEPENDS
        !          9571: DEPENDS_TARGET                    DEPENDS_TYPE
        !          9572: DESTDIR                           DESTDIR_VARNAME
        !          9573: DIALER_GROUP                      DIGEST_REQD
        !          9574: DISTDIR                           DISTFILES
        !          9575: DISTINFO_FILE                     DISTNAME
        !          9576: DIST_PATH                         DIST_SUBDIR
        !          9577: DJBDNS_AXFR_USER                  DJBDNS_CACHE_USER
        !          9578: DJBDNS_DJBDNS_GROUP               DJBDNS_LOG_USER
        !          9579: DJBDNS_RBL_USER                   DJBDNS_TINY_USER
        !          9580: DLOPEN_REQUIRE_PTHREADS           DL_AUTO_VARS
        !          9581: DL_CFLAGS                         DL_LDFLAGS
        !          9582: DL_LIBS                           DNS
        !          9583: DOCOWN                            DOWNLOADED_DISTFILE
        !          9584: DQCACHE_GROUP                     DQCACHE_USER
        !          9585: DT_LAYOUT                         DYNAMIC_SITES_CMD
        !          9586: DYNAMIC_SITES_SCRIPT              ECHO
        !          9587: ECHO_N                            ELK_GUI
        !          9588: EMACS_TYPE                        EMULDIR
        !          9589: EMULSUBDIR                        EMULSUBDIRSLASH
        !          9590: EMUL_ARCH                         EMUL_DISTRO
        !          9591: EMUL_EXEC_FMT                     EMUL_IS_NATIVE
        !          9592: EMUL_MODULES                      EMUL_OPSYS
        !          9593: EMUL_PKG_FMT                      EMUL_PLATFORM
        !          9594: EMUL_PLATFORMS                    EMUL_PREFER
        !          9595: EMUL_REQD                         EMUL_TYPE
        !          9596: ERROR_MSG                         EXIM_GROUP
        !          9597: EXIM_USER                         EXPORT_SYMBOLS_LDFLAGS
        !          9598: EXTRACTOR                         EXTRACT_CMD
        !          9599: EXTRACT_CMD_DEFAULT               EXTRACT_DIR
        !          9600: EXTRACT_ELEMENTS                  EXTRACT_ENV
        !          9601: EXTRACT_ONLY                      EXTRACT_OPTS
        !          9602: EXTRACT_SUFX                      EXTRACT_USING
        !          9603: FAIL                              FAILOVER_FETCH
        !          9604: FAIL_MSG                          FAKE_NCURSES
        !          9605: FAM                               FAM_ACCEPTED
        !          9606: FAM_DEFAULT                       FAM_SERVER
        !          9607: FCPATH                            FETCH_AFTER_ARGS
        !          9608: FETCH_BEFORE_ARGS                 FETCH_CMD
        !          9609: FETCH_INSECURE                    FETCH_OUTPUT_ARGS
        !          9610: FETCH_PROXY                       FETCH_RESUME_ARGS
        !          9611: FETCH_TIMEOUT                     FETCH_USE_IPV4_ONLY
        !          9612: FETCH_USING                       FILES_SUBST
        !          9613: FILES_SUBST_SED                   FIX_SYSTEM_HEADERS
1.260     wiz      9614: FONTS_DIRS                        FONTS_VERBOSE
                   9615: FOO_HACKS_MK                      FORCE_CXX_STD
1.262   ! dholland 9616: FORCE_C_STD                       FOX_USE_XUNICODE
1.260     wiz      9617: FREEWNN_GROUP                     FREEWNN_USER
                   9618: FTP_PKG_URL_DIR                   FTP_PKG_URL_HOST
                   9619: GAMEDATAMODE                      GAMEDATA_PERMS
                   9620: GAMEDIRMODE                       GAMEDIR_PERMS
                   9621: GAMEGRP                           GAMEMODE
                   9622: GAMEOWN                           GAMES_GROUP
                   9623: GAMES_USER                        GCC
                   9624: GCCBASE                           GCC_REQD
                   9625: GCC_VERSION_SUFFIX                GEM_BUILD
                   9626: GEM_CLEANBUILD                    GEM_CLEANBUILD_EXTENSIONS
                   9627: GEM_DOCDIR                        GEM_EXTSDIR
                   9628: GEM_HOME                          GEM_KEEPBUILD
                   9629: GEM_LIBDIR                        GEM_NAME
                   9630: GEM_PATH                          GEM_PLUGINSDIR
                   9631: GEM_SPECFILE                      GENERATE_PLIST
                   9632: GHC                               GHOSTSCRIPT_REQD
                   9633: GITHUB_PROJECT                    GITHUB_RELEASE
                   9634: GITHUB_SUBMODULES                 GITHUB_TAG
                   9635: GITHUB_TYPE                       GITLAB_PROJECT
                   9636: GITLAB_RELEASE                    GITLAB_SUBMODULES
                   9637: GITLAB_TAG                        GITLAB_TYPE
1.262   ! dholland 9638: GNU                               GNU_CONFIGURE
        !          9639: GNU_CONFIGURE_ICONV               GNU_CONFIGURE_INFODIR
        !          9640: GNU_CONFIGURE_MANDIR              GNU_CONFIGURE_QUIET
        !          9641: GNU_CONFIGURE_STRICT              GODEP_REDIRECTS
        !          9642: GO_BUILD_PATTERN                  GO_DEPS
        !          9643: GO_DIST_BASE                      GO_EXTRA_MOD_DIRS
        !          9644: GO_MODULE_EXTRACT                 GO_MODULE_FILES
        !          9645: GO_SRCPATH                        GROUP_SPECIFIC_PKGS
        !          9646: GRUB_NETWORK_CARDS                GRUB_PRESET_COMMAND
        !          9647: GRUB_SCAN_ARGS                    GZIP
1.260     wiz      9648: HASKELL_DISABLE_EXECUTABLES       HASKELL_DISABLE_LIBRARIES
                   9649: HASKELL_ENABLE_DYNAMIC_EXECUTABLE HASKELL_ENABLE_HADDOCK_DOCUMENTATION
                   9650: HASKELL_ENABLE_LIBRARY_PROFILING  HASKELL_ENABLE_SHARED_LIBRARY
                   9651: HASKELL_ENABLE_TESTS              HASKELL_OPTIMIZATION_LEVEL
                   9652: HASKELL_PKG_NAME                  HASKELL_UNRESTRICT_DEPENDENCIES
1.262   ! dholland 9653: HEADER_TEMPLATES                  HOMEPAGE
        !          9654: HOST_PKGTOOLS_ARGS                HOST_SPECIFIC_PKGS
        !          9655: HOWL_GROUP                        HOWL_USER
        !          9656: ICCBASE                           ICECAST_CHROOTDIR
        !          9657: ICON_THEMES                       IDOBASE
        !          9658: IGNORE_CCACHE                     IGNORE_INFO_DIRS
        !          9659: IGNORE_INTERACTIVE_FETCH          IMAKE
        !          9660: IMAKEOPTS                         IMAKE_MAKE
        !          9661: IMAKE_MANINSTALL                  IMAP_UW_CCLIENT_MBOX_FMT
        !          9662: IMDICTDIR                         INCOMPAT_CURSES
        !          9663: INFO_DIR                          INFO_FILES
        !          9664: INFO_MSG                          INIT_SYSTEM
        !          9665: INN_DATA_DIR                      INN_GROUP
        !          9666: INN_USER                          INSTALLATION_DIRS
        !          9667: INSTALLATION_DIRS_FROM_PLIST      INSTALL_ENV
        !          9668: INSTALL_ENV_SHELL                 INSTALL_SH_OVERRIDE
        !          9669: INSTALL_SRC                       INSTALL_TEMPLATES
        !          9670: INSTALL_UNSTRIPPED                IRCD_HYBRID_IRC_GROUP
        !          9671: IRCD_HYBRID_IRC_USER              IRCD_HYBRID_MAXCONN
        !          9672: IRCD_HYBRID_NICLEN                IRCD_HYBRID_SYSLOG_EVENTS
        !          9673: IRCD_HYBRID_SYSLOG_FACILITY       IRCD_HYBRID_TOPICLEN
        !          9674: IRIX                              IRRD_USE_PGP
        !          9675: JABBERD_GROUP                     JABBERD_LOGDIR
        !          9676: JABBERD_PIDDIR                    JABBERD_SPOOLDIR
        !          9677: JABBERD_USER                      JAVA_BINPREFIX
        !          9678: JAVA_CLASSPATH                    JAVA_HOME
        !          9679: JAVA_LD_LIBRARY_PATH              JAVA_NAME
        !          9680: JAVA_UNLIMIT                      JAVA_WRAPPERS
        !          9681: JPEG_ACCEPTED                     JPEG_DEFAULT
        !          9682: KERBEROS                          KERMIT_SUID_UUCP
        !          9683: KJS_USE_PCRE                      KNEWS_DOMAIN_FILE
        !          9684: KNEWS_DOMAIN_NAME                 KRB5_ACCEPTED
        !          9685: KRB5_DEFAULT                      LANGUAGES
        !          9686: LAPACKE_LIBS                      LAPACKE_PC
        !          9687: LAPACK_LIBS                       LAPACK_PC
        !          9688: LATEX2HTML_ICONPATH               LDCONFIG_ADD_CMD
        !          9689: LDCONFIG_REMOVE_CMD               LDD
        !          9690: LEAFNODE_DATA_DIR                 LEAFNODE_GROUP
        !          9691: LEAFNODE_USER                     LIBDVDCSS_HOMEPAGE
        !          9692: LIBDVDCSS_MASTER_SITES            LIBIMAGEQUANT_TYPE
        !          9693: LIBRSVG_TYPE                      LIBTOOL
        !          9694: LIBTOOLIZE_PLIST                  LIBTOOL_M4_OVERRIDE
        !          9695: LIBUSB_TYPE                       LICENSE
        !          9696: LINKER_RPATH_FLAG                 LINK_RPATH_FLAG
1.260     wiz      9697: LINUX_LOCALES                     LOCALBASE
                   9698: LOCALBASE_LOCKTYPE                LOCALPATCHES
                   9699: LOVE_DATA                         LOVE_GAME
                   9700: LOVE_VERSION                      LOWER_OPSYS
                   9701: LOWER_OPSYS_VERSUFFIX             LOWER_VARIANT_VERSION
                   9702: LOWER_VENDOR                      LP32PLATFORMS
                   9703: LP64PLATFORMS                     LUA_BUSTED_ARGS
                   9704: LUA_CDIR                          LUA_COMPILER
                   9705: LUA_DOCDIR                        LUA_EXAMPLESDIR
                   9706: LUA_INCDIR                        LUA_INTERPRETER
                   9707: LUA_LDIR                          LUA_LINKER_MAGIC
                   9708: LUA_PKGPREFIX                     LUA_SELF_CONFLICT
                   9709: LUA_USE_BUSTED                    LUA_VERSIONS_ACCEPTED
                   9710: LUA_VERSIONS_INCOMPATIBLE         LUA_VERSION_DEFAULT
                   9711: LUA_VERSION_REQD                  Lua
                   9712: MACHINE_PLATFORM                  MAILAGENT_DOMAIN
                   9713: MAILAGENT_EMAIL                   MAILAGENT_FQDN
                   9714: MAILAGENT_ORGANIZATION            MAJORDOMO_HOMEDIR
1.262   ! dholland 9715: MAKEINFO_ARGS                     MAKE_DIRS
        !          9716: MAKE_DIRS_PERMS                   MAKE_ENV
        !          9717: MAKE_FILE                         MAKE_FLAGS
        !          9718: MAKE_JOBS                         MAKE_JOBS_SAFE
        !          9719: MAKE_PROGRAM                      MANCOMPRESSED_IF_MANZ
        !          9720: MANINSTALL                        MANZ
        !          9721: MARIADB_VERSIONS_ALL              MASTER_SITES
        !          9722: MASTER_SITE_BACKUP                MASTER_SITE_LOCAL
        !          9723: MASTER_SITE_MOZILLA               MASTER_SITE_OVERRIDE
        !          9724: MASTER_SITE_PERL_CPAN             MASTER_SORT
        !          9725: MASTER_SORT_RANDOM                MASTER_SORT_REGEX
        !          9726: MECAB_CHARSET                     MEDIATOMB_GROUP
        !          9727: MEDIATOMB_USER                    MIPSPROBASE
        !          9728: MIREDO_GROUP                      MIREDO_USER
        !          9729: MISSING_FEATURES                  MKDIR
        !          9730: MKPIE_SUPPORTED                   MLDONKEY_GROUP
        !          9731: MLDONKEY_HOME                     MLDONKEY_USER
        !          9732: MONOTONE_GROUP                    MONOTONE_USER
        !          9733: MOTIFBASE                         MOTIF_TYPE
        !          9734: MOTIF_TYPE_DEFAULT                MPI_TYPE
        !          9735: MSGFMT_STRIP_MSGCTXT              MSGFMT_STRIP_MSGID_PLURAL
        !          9736: MTOOLS_ENABLE_FLOPPYD             MV
1.260     wiz      9737: MYSQL_CHARSET                     MYSQL_DATADIR
                   9738: MYSQL_EXTRA_CHARSET               MYSQL_GROUP
                   9739: MYSQL_USER                        MYSQL_VERSION
                   9740: MYSQL_VERSIONS_ACCEPTED           MYSQL_VERSION_DEFAULT
                   9741: NAGIOSCMD_GROUP                   NAGIOSDIR
                   9742: NAGIOS_GROUP                      NAGIOS_USER
                   9743: NATIVE_EXEC_FMT                   NATIVE_LOWER_OPSYS
                   9744: NATIVE_LOWER_VENDOR               NATIVE_MACHINE_PLATFORM
                   9745: NATIVE_OBJECT_FMT                 NATIVE_OPSYS_VERSION
                   9746: NATIVE_OS_VARIANT                 NATIVE_OS_VERSION
                   9747: NBPAX_PROGRAM_PREFIX              NETBSD_LOGIN_NAME
                   9748: NMH_EDITOR                        NMH_MTA
                   9749: NMH_PAGER                         NODE_VERSIONS_ACCEPTED
                   9750: NODE_VERSIONS_INCOMPATIBLE        NODE_VERSION_DEFAULT
                   9751: NODE_VERSION_REQD                 NOLOGIN
                   9752: NOTE                              NOT_FOR_PLATFORM
                   9753: NOT_PAX_ASLR_SAFE                 NOT_PAX_MPROTECT_SAFE
                   9754: NO_BUILD                          NO_CHECKSUM
                   9755: NO_CONFIGURE                      NO_SKIP
                   9756: NSD_GROUP                         NSD_LOG_FACILITY
                   9757: NSD_USER                          NS_PREFERRED
                   9758: NULLMAILER_GROUP                  NULLMAILER_USER
                   9759: OBJECT_FMT                        OBJHOSTNAME
                   9760: OBJMACHINE                        OCAML_FINDLIB_DIRS
                   9761: OCAML_FINDLIB_REGISTER            OCAML_FINDLIB_REGISTER_VERBOSE
                   9762: OCAML_SITELIBDIR                  OMF
                   9763: ONLY_FOR_COMPILER                 ONLY_FOR_PLATFORM
                   9764: OPENSSH_CHROOT                    OPENSSH_GROUP
                   9765: OPENSSH_USER                      OPSYS
                   9766: OPSYS_EMULDIR                     OPSYS_VERSION
                   9767: OS                                OSS_TYPE
                   9768: OSX                               OSX_PATH_TO_M4
1.262   ! dholland 9769: OSX_PATH_TO_YACC                  OS_VARIANT
1.260     wiz      9770: OS_VERSION                        OTF_FONTS_DIR
                   9771: OVERRIDE_DIRDEPTH                 OVERRIDE_GEMSPEC
1.262   ! dholland 9772: OVERRIDE_GNU_CONFIG_SCRIPTS       OWN_DIRS
        !          9773: OWN_DIRS_PERMS                    P4GROUP
        !          9774: P4PORT                            P4ROOT
        !          9775: P4USER                            PACKAGES
        !          9776: PALMOS_DEFAULT_SDK                PAMBASE
        !          9777: PAM_DEFAULT                       PAPERSIZE
        !          9778: PASSIVE_FETCH                     PATCHDIR
        !          9779: PATCHFILES                        PATCH_ARGS
        !          9780: PATCH_DEBUG                       PATCH_DIST_ARGS
        !          9781: PATCH_DIST_CAT                    PATCH_DIST_STRIP
        !          9782: PATCH_FUZZ_FACTOR                 PATCH_STRIP
        !          9783: PATH                              PCCBASE
        !          9784: PEAR_CMD                          PEAR_LIB
        !          9785: PEAR_PACKAGE_XML                  PEP-518
        !          9786: PERL5                             PERL5_CONFIGURE
        !          9787: PERL5_CONFIGURE_DIRS              PERL5_LDFLAGS
        !          9788: PERL5_LICENSE                     PERL5_MODULE_TYPE
        !          9789: PERL5_PACKLIST                    PERL5_PACKLIST_DIR
        !          9790: PERL5_PERLBASE                    PERL5_SITEBASE
        !          9791: PERL5_USE_PACKLIST                PERL5_VENDORBASE
        !          9792: PFCTL                             PFVAR_H
        !          9793: PF_VERSION                        PGGROUP
        !          9794: PGHOME                            PGPKGSRCDIR
        !          9795: PGSQL_TYPE                        PGSQL_VERSION
        !          9796: PGSQL_VERSIONS_ACCEPTED           PGSQL_VERSION_DEFAULT
        !          9797: PGUSER                            PG_LIB_EXT
        !          9798: PHP                               PHPCOMMON_MK
        !          9799: PHPPKGSRCDIR                      PHP_BASE_VERS
        !          9800: PHP_EGDIR                         PHP_EXTENSION_DIR
        !          9801: PHP_INCDIR                        PHP_LIBDIR
        !          9802: PHP_MAJOR_VERS                    PHP_MINIMUM_TEENY
        !          9803: PHP_MINOR_VERS                    PHP_PKG_PREFIX
        !          9804: PHP_SHAREDIR                      PHP_VER
        !          9805: PHP_VERSION                       PHP_VERSIONS_ACCEPTED
        !          9806: PHP_VERSIONS_INCOMPATIBLE         PHP_VERSION_DEFAULT
        !          9807: PHP_VERSION_REQD                  PILRC_USE_GTK
        !          9808: PKGCONFIG_BASE                    PKGCONFIG_FILE
        !          9809: PKGCONFIG_OVERRIDE                PKGCONFIG_OVERRIDE_STAGE
        !          9810: PKGDIR                            PKGGNUDIR
        !          9811: PKGINFODIR                        PKGLOCALEDIR
        !          9812: PKGMANDIR                         PKGNAME
        !          9813: PKGNAME_REQD                      PKGPATH
        !          9814: PKGREVISION                       PKGSRC_BLAS_TYPES
        !          9815: PKGSRC_CHANGES                    PKGSRC_COMPILER
        !          9816: PKGSRC_KEEP_BIN_PKGS              PKGSRC_LOCKTYPE
        !          9817: PKGSRC_MAKE_ENV                   PKGSRC_MESSAGE_RECIPIENTS
        !          9818: PKGSRC_MKPIE                      PKGSRC_MKREPRO
        !          9819: PKGSRC_OVERRIDE_MKPIE             PKGSRC_RUN_TEST
        !          9820: PKGSRC_SETENV                     PKGSRC_SLEEPSECS
        !          9821: PKGSRC_TODO                       PKGSRC_USE_CTF
        !          9822: PKGSRC_USE_FORTIFY                PKGSRC_USE_MKTOOLS
        !          9823: PKGSRC_USE_RELRO                  PKGSRC_USE_SSP
        !          9824: PKGSRC_USE_STACK_CHECK            PKGTASKS_DATAFILE
        !          9825: PKGTOOLS_ARGS                     PKGTOOLS_ENV
        !          9826: PKG_ALTERNATIVES                  PKG_APACHE
        !          9827: PKG_APACHE_ACCEPTED               PKG_APACHE_DEFAULT
        !          9828: PKG_BEST_EXISTS                   PKG_BUILD_OPTIONS
        !          9829: PKG_COMPRESSION                   PKG_CONFIG
        !          9830: PKG_CONFIG_PERMS                  PKG_CREATE_USERGROUP
        !          9831: PKG_DBDIR                         PKG_DB_TMPDIR
        !          9832: PKG_DEBUG_LEVEL                   PKG_DEFAULT_OPTIONS
        !          9833: PKG_DESTDIR_SUPPORT               PKG_DEVELOPER
        !          9834: PKG_DISABLED_OPTIONS              PKG_FATAL_ERRORS
        !          9835: PKG_FC                            PKG_FILELIST_CMD
        !          9836: PKG_GECOS                         PKG_GID
        !          9837: PKG_GROUPS                        PKG_GROUPS_VARS
        !          9838: PKG_HOME                          PKG_INIT_SCRIPTS
        !          9839: PKG_JAVA_HOME                     PKG_JVM
        !          9840: PKG_JVMS_ACCEPTED                 PKG_JVM_DEFAULT
        !          9841: PKG_LEGACY_OPTIONS                PKG_LIBTOOL
        !          9842: PKG_MKSYMLINKS                    PKG_OPTIONS
        !          9843: PKG_OPTIONS_DEPRECATED_WARNINGS   PKG_OPTIONS_LEGACY_OPTS
        !          9844: PKG_OPTIONS_LEGACY_VARS           PKG_OPTIONS_NONEMPTY_SETS
        !          9845: PKG_OPTIONS_OPTIONAL_GROUPS       PKG_OPTIONS_REQUIRED_GROUPS
        !          9846: PKG_OPTIONS_VAR                   PKG_RCD_SCRIPTS
        !          9847: PKG_REFCOUNT_DBDIR                PKG_REGISTER_SHELLS
        !          9848: PKG_RESUME_TRANSFERS              PKG_SHELL
        !          9849: PKG_SUGGESTED_OPTIONS             PKG_SUPPORTED_OPTIONS
        !          9850: PKG_SYSCONFBASE                   PKG_SYSCONFBASEDIR
        !          9851: PKG_SYSCONFDIR                    PKG_SYSCONFDIR_PERMS
        !          9852: PKG_SYSCONFSUBDIR                 PKG_SYSCONFVAR
        !          9853: PKG_TOOLS_BIN                     PKG_UID
        !          9854: PKG_UPDATE_FONTS_DB               PKG_USERS
        !          9855: PKG_USERS_VARS                    PKG_VERBOSE
        !          9856: PLEASE                            PLIST
        !          9857: PLIST_AWK                         PLIST_AWK_ENV
        !          9858: PLIST_SRC                         PLIST_SUBST
        !          9859: PLIST_TYPE                        PLIST_VARS
        !          9860: POPTOP_USE_MPPE                   POSSIBLE_GFORTRAN_VERSION
        !          9861: POST_FETCH_HOOK                   PREFER
        !          9862: PREFER_NATIVE                     PREFER_NATIVE_PTHREADS
        !          9863: PREFER_PKGSRC                     PREFIX
        !          9864: PREPEND_PATH                      PRE_ROOT_CMD
        !          9865: PRIVILEGED_STAGES                 PS
        !          9866: PTHREAD_AUTO_VARS                 PTHREAD_CFLAGS
        !          9867: PTHREAD_LDFLAGS                   PTHREAD_LIBS
        !          9868: PTHREAD_OPTS                      PTHREAD_TYPE
        !          9869: PVM_SSH                           PYPKGPREFIX
        !          9870: PYTHON_FOR_BUILD_ONLY             PYTHON_SELF_CONFLICT
        !          9871: PYTHON_VERSION                    PYTHON_VERSIONED_DEPENDENCIES
        !          9872: PYTHON_VERSIONS_ACCEPTED          PYTHON_VERSIONS_INCOMPATIBLE
        !          9873: PYTHON_VERSION_DEFAULT            PYTHON_VERSION_REQD
        !          9874: PYVERSSUFFIX                      QMAILDIR
        !          9875: QMAIL_ALIAS_USER                  QMAIL_DAEMON_USER
        !          9876: QMAIL_LOG_USER                    QMAIL_NOFILES_GROUP
        !          9877: QMAIL_PASSWD_USER                 QMAIL_QMAIL_GROUP
        !          9878: QMAIL_QUEUE_DIR                   QMAIL_QUEUE_EXTRA
        !          9879: QMAIL_QUEUE_USER                  QMAIL_REMOTE_USER
        !          9880: QMAIL_ROOT_USER                   QMAIL_SEND_USER
        !          9881: QORE_LATEST_MODULE_API            QORE_MODULE_API
        !          9882: QORE_MODULE_DIR                   QORE_USER_MODULE_DIR
        !          9883: QORE_VERSION                      QPOPPER_FAC
        !          9884: QPOPPER_SPOOL_DIR                 QPOPPER_USER
        !          9885: RAKE_NAME                         RASMOL_DEPTH
        !          9886: RCD_SCRIPTS                       RCD_SCRIPTS_DIR
        !          9887: RCD_SCRIPTS_EXAMPLEDIR            RCD_SCRIPTS_MODE
        !          9888: RCD_SCRIPTS_SHELL                 RCD_SCRIPT_SRC
        !          9889: RDOC                              READLINE_ACCEPTED
        !          9890: READLINE_DEFAULT                  READLINE_TYPE
        !          9891: REAL_ROOT_GROUP                   REAL_ROOT_USER
        !          9892: RECURSIVE_MAKE                    RELAY_CTRL_DIR
        !          9893: RELRO_SUPPORTED                   REPLACE_AWK
        !          9894: REPLACE_BASH                      REPLACE_CSH
        !          9895: REPLACE_KSH                       REPLACE_LUA
        !          9896: REPLACE_NODEJS                    REPLACE_OCTAVE
        !          9897: REPLACE_PERL                      REPLACE_PERL6
        !          9898: REPLACE_PHP                       REPLACE_PYTHON
        !          9899: REPLACE_QORE                      REPLACE_R
        !          9900: REPLACE_RUBY                      REPLACE_RUBY_DIRS
        !          9901: REPLACE_RUBY_PAT                  REPLACE_SH
        !          9902: REPLACE_TEXLUA                    REPLACE_TOOL_PYTHON
        !          9903: REPLACE_WISH                      REQD_DIRS
        !          9904: REQD_DIRS_PERMS                   REQD_FILES
        !          9905: REQD_FILES_MODE                   REQD_FILES_PERMS
        !          9906: RESOLV_AUTO_VARS                  RESOLV_LDFLAGS
        !          9907: RESOLV_LIBS                       RM
        !          9908: ROOT_CMD                          ROOT_GROUP
        !          9909: ROOT_USER                         RPCGEN
        !          9910: RPM                               RPM2PKG_PLIST
        !          9911: RPM2PKG_PREFIX                    RPM2PKG_STAGE
        !          9912: RPM2PKG_STRIP                     RPM2PKG_SUBPREFIX
        !          9913: RPMFILES                          RPMIGNOREPATH
        !          9914: RPM_DB_PREFIX                     RSSH_CVS_PATH
        !          9915: RSSH_RDIST_PATH                   RSSH_RSYNC_PATH
        !          9916: RSSH_SCP_PATH                     RSSH_SFTP_SERVER_PATH
        !          9917: RUBY                              RUBYGEM
        !          9918: RUBYGEM_MANPAGES                  RUBYGEM_NAME
        !          9919: RUBYGEM_OPTIONS                   RUBYGEM_USE_MANPAGES
        !          9920: RUBYGEM_VERBOSE                   RUBY_ABI_VERSION
        !          9921: RUBY_ARCH                         RUBY_ARCHINC
        !          9922: RUBY_ARCHLIB                      RUBY_BASE
        !          9923: RUBY_BASERIDIR                    RUBY_BUILD_DOCUMENT
        !          9924: RUBY_DLEXT                        RUBY_DOC
        !          9925: RUBY_DYNAMIC_DIRS                 RUBY_EG
        !          9926: RUBY_ENCODING_ARG                 RUBY_EXTCONF
        !          9927: RUBY_EXTCONF_CHECK                RUBY_EXTCONF_DEBUG
        !          9928: RUBY_EXTCONF_MAKEFILE             RUBY_GEM_ARCH
        !          9929: RUBY_GEM_BASE                     RUBY_INC
        !          9930: RUBY_LIB                          RUBY_LIB_BASE
        !          9931: RUBY_NAME                         RUBY_NOVERSION
        !          9932: RUBY_PKGPREFIX                    RUBY_RAILS
        !          9933: RUBY_RAILS61_VERSION              RUBY_RAILS70_VERSION
        !          9934: RUBY_RAILS71_VERSION              RUBY_RAILS72_VERSION
        !          9935: RUBY_RAILS80_VERSION              RUBY_RAILS_ACCEPTED
        !          9936: RUBY_RAILS_DEFAULT                RUBY_RAILS_REQD
        !          9937: RUBY_RAILS_STRICT_DEP             RUBY_RIDIR
        !          9938: RUBY_SETUP                        RUBY_SHLIB
        !          9939: RUBY_SHLIBALIAS                   RUBY_SHLIBVER
        !          9940: RUBY_SIMPLE_INSTALL               RUBY_SITEARCHLIB
        !          9941: RUBY_SITELIB                      RUBY_SITELIB_BASE
        !          9942: RUBY_SITERIDIR                    RUBY_SLEXT
        !          9943: RUBY_SRCDIR                       RUBY_STATICLIB
        !          9944: RUBY_SUFFIX                       RUBY_SYSRIDIR
        !          9945: RUBY_USE_PTHREAD                  RUBY_VENDORARCHLIB
        !          9946: RUBY_VENDORLIB                    RUBY_VENDORLIB_BASE
        !          9947: RUBY_VER                          RUBY_VERSION
        !          9948: RUBY_VERSIONS_ACCEPTED            RUBY_VERSIONS_INCOMPATIBLE
        !          9949: RUBY_VERSION_DEFAULT              RUBY_VERSION_REQD
        !          9950: RUBY_VER_DIR                      RUN
        !          9951: RUN_LDCONFIG                      RUST_TYPE
        !          9952: SCO                               SCREWS_GROUP
        !          9953: SCREWS_USER                       SCRIPTS_ENV
        !          9954: SCROLLKEEPER_DATADIR              SCROLLKEEPER_REBUILDDB
        !          9955: SCROLLKEEPER_UPDATEDB             SDIST_PAWD
        !          9956: SDL12_TYPE                        SERIAL_DEVICES
        !          9957: SETGIDGAME                        SETGID_GAMES_PERMS
        !          9958: SETUID_ROOT_PERMS                 SH
        !          9959: SHLIB                             SIGN_PACKAGES
1.260     wiz      9960: SILC_CLIENT_WITH_PERL             SITE_SPECIFIC_PKGS
                   9961: SKIP_DEPENDS                      SMF_INSTANCES
                   9962: SMF_MANIFEST                      SMF_METHODS
                   9963: SMF_METHOD_SHELL                  SMF_METHOD_SRC
                   9964: SMF_NAME                          SMF_PREFIX
                   9965: SMF_SRCDIR                        SNIPROXY_GROUP
                   9966: SNIPROXY_USER                     SOURCE_BUFFSIZE
                   9967: SPECIAL_PERMS                     SPECIFIC_PKGS
                   9968: SSH_SUID                          SSLCERTBUNDLE
                   9969: SSLCERTS                          SSLDIR
                   9970: SSLKEYS                           SSP_SUPPORTED
                   9971: SSYNC_PAWD                        STEP_MSG
                   9972: STRIP                             STRIP_DBG
                   9973: STRIP_DEBUG                       STRIP_DEBUG_SUPPORTED
                   9974: STRIP_FILES_SKIP                  SU
                   9975: SUBDIR                            SUBST
                   9976: SUBST_CLASSES                     SUBST_FILES
                   9977: SUBST_FILTER_CMD                  SUBST_MESSAGE
                   9978: SUBST_NOOP_OK                     SUBST_SED
                   9979: SUBST_SHOW_DIFF                   SUBST_SKIP_TEXT_CHECK
                   9980: SUBST_STAGE                       SUBST_VARS
                   9981: SUNWSPROBASE                      SUSE_PREFER
1.262   ! dholland 9982: SU_CMD                            SYSCONFBASE
1.260     wiz      9983: TARGET_MACHINE_ARCH               TBL
                   9984: TERMCAP_TYPE                      TERMINFO_DEFAULT
                   9985: TERMINFO_TYPE                     TEST
                   9986: TEST_DEPENDS                      TEST_DIRS
                   9987: TEST_ENV                          TEST_ENV_SHELL
                   9988: TEST_MAKE_CMD                     TEST_MAKE_FLAGS
                   9989: TEST_TARGET                       TEXLIVE_IGNORE_PATTERNS
                   9990: TEXLIVE_REV                       TEXLIVE_UNVERSIONED
                   9991: TEXMFSITE                         TEX_FORMATS
                   9992: TEX_HYPHEN_DAT                    TEX_HYPHEN_DEF
                   9993: TEX_TEXMF_DIRS                    THTTPD_LOG_FACILITY
                   9994: TINYDYN_USER                      TLS
                   9995: TLSWRAPPER_CHROOT                 TO
                   9996: TOOLDIR                           TOOLS_ALIASES
                   9997: TOOLS_ALWAYS_WRAP                 TOOLS_ARGS
                   9998: TOOLS_BROKEN                      TOOLS_CMD
                   9999: TOOLS_CMDLINE_SED                 TOOLS_CREATE
                   10000: TOOLS_CROSS_DESTDIR               TOOLS_DIR
                   10001: TOOLS_FAIL                        TOOLS_GNU_MISSING
                   10002: TOOLS_LDCONFIG                    TOOLS_NOOP
                   10003: TOOLS_PATH                        TOOLS_SCRIPT
                   10004: TOOLS_USE_CROSS_COMPILE           TOOL_DEPENDS
1.262   ! dholland 10005: TTF_FONTS_DIR                     TYPE
        !          10006: UAC_REQD_EXECS                    UCSPI_SSL_GROUP
        !          10007: UCSPI_SSL_USER                    UNBOUND_GROUP
        !          10008: UNBOUND_LOG_FACILITY              UNBOUND_USER
        !          10009: UNLIMIT_RESOURCES                 UNPRIVILEGED
        !          10010: UNPRIVILEGED_GROUP                UNPRIVILEGED_GROUPS
        !          10011: UNPRIVILEGED_USER                 UNWRAP_FILES
        !          10012: UNWRAP_PATTERNS                   UPDATE_GEMSPEC
        !          10013: UPDATE_TARGET                     URI
        !          10014: USERGROUP_PHASE                   USERPPP_GROUP
        !          10015: USER_SPECIFIC_PKGS                USE_ABI_DEPENDS
        !          10016: USE_APR                           USE_BSD_MAKEFILE
        !          10017: USE_BUILTIN                       USE_CC_FEATURES
        !          10018: USE_CROSS_COMPILE                 USE_CURSES
        !          10019: USE_CWRAPPERS                     USE_CXX_FEATURES
        !          10020: USE_DB185                         USE_FEATURES
        !          10021: USE_GAMESGROUP                    USE_GCC_RUNTIME
        !          10022: USE_IMAKE                         USE_INDIRECT_DEPENDS
        !          10023: USE_JAVA                          USE_JAVA2
        !          10024: USE_LANGUAGES                     USE_LIBTOOL
        !          10025: USE_NATIVE_GCC                    USE_NETBSD_REPO
        !          10026: USE_PKGSRC_GCC                    USE_PKGSRC_GCC_RUNTIME
        !          10027: USE_PKGTASKS                      USE_PKG_ADMIN_DIGEST
        !          10028: USE_RUBY_EXTCONF                  USE_RUBY_INSTALL
        !          10029: USE_RUBY_SETUP                    USE_RUBY_SETUP_PKG
        !          10030: USE_TMPFILES                      USE_TOOLS
        !          10031: UUCP_GROUP                        UUCP_USER
        !          10032: VARBASE                           VARNAME
        !          10033: VIM_EXTRA_OPTS                    WARNING_MSG
        !          10034: WCALC_CGIDIR                      WCALC_CGIPATH
        !          10035: WCALC_HTMLDIR                     WCALC_HTMLPATH
        !          10036: WDM_MANAGERS                      WRAPPER_CC
        !          10037: WRAPPER_REORDER_CMDS              WRKDIR
        !          10038: WRKDIR_BASENAME                   WRKDIR_LOCKTYPE
        !          10039: WRKLOG                            WRKOBJDIR
        !          10040: WRKSRC                            X10_PORT
        !          10041: X11                               X11BASE
        !          10042: X11_PKGSRCDIR                     X11_TYPE
        !          10043: X509_CERTIFICATE                  X509_KEY
        !          10044: XAW_TYPE                          XLOCK_DEFAULT_MODE
        !          10045: XMKMF                             XMKMF_FLAGS
        !          10046: XXX                               YES
1.260     wiz      10047: ZSH_STATIC                        __stdc__
                   10048: _vargroups                        accept
                   10049: acquire-localbase-lock            acquire-lock
                   10050: add                               added
                   10051: administrator                     alloca
                   10052: alternatives                      aslr
                   10053: asprintf                          atlas
                   10054: autoconf                          automake
                   10055: autoreconf                        awk
                   10056: bash                              big-endian
                   10057: bin-install                       bind
                   10058: binpkg-list                       blas
                   10059: bootstrap-depends                 broken
                   10060: broken_on_platform                bsd
                   10061: bsd.prog.mk                       build
                   10062: build-env                         buildlink-directories
                   10063: buildlink-oss-soundcard-h         built-in
                   10064: builtin                           c
                   10065: c++                               ccache
                   10066: cce                               cdefs
                   10067: ceil                              changes
                   10068: changes-entry                     changes-entry-noupdate
                   10069: check                             check-clean
                   10070: check-files                       check-files-clean
                   10071: check-hackage                     check-vulnerable
                   10072: checksum                          checksum-phase
                   10073: clean                             clean-depends
                   10074: cleandir                          commit
                   10075: commit-changes-entry              compact
                   10076: compiler                          conf
                   10077: config.guess                      config.sub
                   10078: configuration                     configure
                   10079: configure-env                     configure-help
                   10080: configure_args                    connect
                   10081: cos                               cpe
                   10082: cputime                           create-usergroup
                   10083: csh                               ctf
1.262   ! dholland 10084: debug                             declaration
        !          10085: declare                           defined
        !          10086: depend                            dependencies
        !          10087: depends                           depends-checksum
        !          10088: depends-fetch                     deps
        !          10089: describe                          destdir
        !          10090: disable                           distclean
        !          10091: distfiles                         distinfo
        !          10092: dl                                dlopen
        !          10093: do-buildlink                      do-clean
        !          10094: do-configure                      do-configure-post-hook
        !          10095: do-extract                        do-fetch
1.260     wiz      10096: download                          emul
                   10097: emul-distinfo                     emul-fetch
                   10098: emulation                         emulator
                   10099: enable                            endian
1.262   ! dholland 10100: enomem                            ensurepip
        !          10101: err                               errx
        !          10102: etc                               exp
        !          10103: extract-rpm                       fabs
        !          10104: feature                           features
        !          10105: fetch                             fetch-list
        !          10106: follows                           forbids
        !          10107: form                              format
        !          10108: fortify                           fortify_source
1.260     wiz      10109: friend                            fts
                   10110: fts_close                         fts_open
                   10111: fts_read                          fts_set
                   10112: gcc                               gethostbyaddr
                   10113: gethostbyname                     gethostbyname2
                   10114: getopt_long                       getprogname
                   10115: getservbyname                     getservbyport
                   10116: getservent                        gettext
1.262   ! dholland 10117: github                            gitlab
        !          10118: glob                              gnu
        !          10119: gnu_configure_strict              go
        !          10120: go-deps                           golang
        !          10121: guess-license                     hashbang
        !          10122: heimdal                           help
1.260     wiz      10123: imake                             in-tree
                   10124: increment                         indirect
                   10125: inet_aton                         install
                   10126: install-env                       interp
                   10127: interpreter                       intl
                   10128: ip4                               ip6
                   10129: ipv4                              ipv6
                   10130: iso                               kerberos
                   10131: krb                               krb5
                   10132: ksh                               lapack
                   10133: latex                             libiconv
                   10134: libintl_bindtextdomain            libintl_gettext
                   10135: libintl_textdomain                libnbcompat
                   10136: libs                              libtool
                   10137: licence                           license
                   10138: lintl                             little-endian
                   10139: lock                              locking
                   10140: lua                               lvalue
                   10141: machine_endian                    make
                   10142: makedistinfo                      makepatchsum
                   10143: makesum                           mdi
1.262   ! dholland 10144: memory                            meta
        !          10145: meta-package                      meta_package
        !          10146: mit-krb5                          mk.conf
        !          10147: mkl                               mount
        !          10148: move                              moved
        !          10149: mprotect                          mps
        !          10150: mremap                            native
        !          10151: nb                                nbcompat
        !          10152: netlib                            network
        !          10153: node                              node.js
        !          10154: nodejs                            obstack
        !          10155: obstack_ptr_grow                  occurs
        !          10156: only                              openblas
        !          10157: options                           options.mk
        !          10158: order                             override
        !          10159: override-intltool                 override-message-intltool
        !          10160: package                           parallel
        !          10161: path                              pax
        !          10162: paxctl                            pbulk-index
        !          10163: pc                                perl
        !          10164: perl5                             perms
        !          10165: php                               pkg-build-options
        !          10166: pkg-config                        pkg_build_options
        !          10167: pkgsrc                            platform
        !          10168: plist                             post-extract
        !          10169: post-fetch                        post-wrapper
        !          10170: pre-build-checks-hook             pre-configure-checks-hook
        !          10171: pre-extract                       pre-fetch
        !          10172: print-go-deps                     print-plist
        !          10173: print-summary-data                privileged-install-hook
        !          10174: pypi                              python
        !          10175: r                                 readme-all
        !          10176: recursive                         recv
        !          10177: recvfrom                          regcomp
        !          10178: release-localbase-lock            release-lock
        !          10179: relro                             remove
        !          10180: removed                           rename
        !          10181: renamed                           reorder
        !          10182: replace                           replace_interpreter
        !          10183: reproducible                      resolv
        !          10184: root                              ruby
        !          10185: send                              sendfile
        !          10186: sendto                            setenv
        !          10187: setgid                            setprogname
        !          10188: setuid                            sh
        !          10189: shebang                           show
        !          10190: show-all                          show-build-defs
        !          10191: show-depends                      show-depends-dirs
        !          10192: show-depends-pkgpaths             show-depends-recursive
        !          10193: show-deps                         show-distfiles
        !          10194: show-downlevel                    show-subdir-var
        !          10195: show-tools                        show-var
        !          10196: show-vars                         snprintf
        !          10197: socket                            ssp
        !          10198: st_mode                           stage-install
        !          10199: strcasestr                        strict
        !          10200: strip                             strndup
        !          10201: strnlen                           strsep
        !          10202: subst                             substitutions
1.260     wiz      10203: sun                               sunpro
1.262   ! dholland 10204: sunwspro                          symlink
        !          10205: test                              test-env
        !          10206: tex                               texlive
        !          10207: tmp                               todo
        !          10208: tool                              tools
        !          10209: tools-libtool-m4-override         transitive
        !          10210: type                              ulimit
        !          10211: undefined                         undo-replace
        !          10212: unlimit                           unprivileged
        !          10213: unprivileged-install-hook         unstripped
        !          10214: update                            updated
        !          10215: upload                            upload-distfiles
        !          10216: use_tools                         user
        !          10217: utimes                            vasprintf
        !          10218: verbose                           vsnprintf
        !          10219: warn                              warning
        !          10220: warnings                          warnx
        !          10221: wattr_off                         wattr_on
        !          10222: work                              wrapper
        !          10223: wrkdir                             
1.154     rillig   10224: 
1.207     leot     10225: Appendix F. Editing guidelines for the pkgsrc guide
1.1       dsieger  10226: 
                   10227: Table of Contents
                   10228: 
1.207     leot     10229: F.1. Make targets
                   10230: F.2. Procedure
1.1       dsieger  10231: 
                   10232: This section contains information on editing the pkgsrc guide itself.
                   10233: 
1.207     leot     10234: F.1. Make targets
1.1       dsieger  10235: 
                   10236: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
                   10237: files are created from it:
                   10238: 
                   10239:   * pkgsrc/doc/pkgsrc.txt
                   10240: 
                   10241:   * pkgsrc/doc/pkgsrc.html
                   10242: 
1.174     leot     10243:   * https://www.NetBSD.org/docs/pkgsrc/
1.1       dsieger  10244: 
1.174     leot     10245:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
                   10246:     pkgsrc guide.
1.1       dsieger  10247: 
1.174     leot     10248:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2       rillig   10249:     pkgsrc guide.
1.1       dsieger  10250: 
1.207     leot     10251: F.2. Procedure
1.1       dsieger  10252: 
                   10253: The procedure to edit the pkgsrc guide is:
                   10254: 
1.190     bacon    10255:  1. Make sure you have checked out the htdocs repository into a sibling
                   10256:     directory of your pkgsrc directory. You will need the ability to commit
                   10257:     from both pkgsrc and htdocs.
                   10258: 
                   10259:  2. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46      obache   10260:     other XML-based NetBSD documentation) installed. These are automatically
                   10261:     installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1       dsieger  10262: 
1.190     bacon    10263:  3. Run cd doc/guide to get to the right directory. All further steps will take
1.1       dsieger  10264:     place here.
                   10265: 
1.190     bacon    10266:  4. Edit the XML file(s) in files/.
1.1       dsieger  10267: 
1.190     bacon    10268:  5. Run bmake to check the pkgsrc guide for valid XML and to build the final
1.1       dsieger  10269:     output files. If you get any errors at this stage, you can just edit the
                   10270:     files, as there are only symbolic links in the working directory, pointing
                   10271:     to the files in files/.
                   10272: 
1.190     bacon    10273:  6. (cd files && cvs commit)
1.1       dsieger  10274: 
1.190     bacon    10275:  7. Run bmake clean && bmake to regenerate the output files with the proper RCS
1.1       dsieger  10276:     Ids.
                   10277: 
1.190     bacon    10278:  8. Run bmake regen to install and commit the files in both pkgsrc/doc and
1.1       dsieger  10279:     htdocs.
                   10280: 
                   10281:     Note
                   10282: 
                   10283:     If you have added, removed or renamed some chapters, you need to
                   10284:     synchronize them using cvs add or cvs delete in the htdocs directory.
                   10285: 

CVSweb <webmaster@jp.NetBSD.org>