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

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.252     jnemeth    15: Copyright   1994-2024 The NetBSD Foundation, Inc
1.1       dsieger    16: 
1.252     jnemeth    17: $NetBSD: pkgsrc.xml,v 1.43 2024/01/02 07:26:32 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.232     gutterid   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.232     gutterid  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.232     gutterid  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.232     gutterid  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.232     gutterid  231:             existing package
1.154     rillig    232:             21.1.11. Substituting variable text in the package files (the SUBST
1.232     gutterid  233:             framework)
1.154     rillig    234:         21.2. The fetch phase
                    235:             21.2.1. Packages whose distfiles aren't available for plain
1.232     gutterid  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.154     rillig    244:         21.4. Programming languages
                    245:             21.4.1. C, C++, and Fortran
                    246:             21.4.2. Java
1.205     wiz       247:             21.4.3. Go
1.223     nia       248:             21.4.4. Rust
                    249:             21.4.5. Packages containing Perl scripts
                    250:             21.4.6. Packages containing shell scripts
                    251:             21.4.7. Other programming languages
1.154     rillig    252:         21.5. The build phase
                    253:             21.5.1. Compiling C and C++ code conditionally
                    254:             21.5.2. How to handle compiler bugs
1.172     rillig    255:             21.5.3. No such file or directory
                    256:             21.5.4. Undefined reference to "..."
                    257:             21.5.5. Running out of memory
1.154     rillig    258:         21.6. The install phase
                    259:             21.6.1. Creating needed directories
                    260:             21.6.2. Where to install documentation
                    261:             21.6.3. Installing highscore files
                    262:             21.6.4. Adding DESTDIR support to packages
                    263:             21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia       264:             21.6.6. Packages installing Perl modules
1.254     wiz       265:             21.6.7. Packages installing pkg-config files
                    266:             21.6.8. Packages installing info files
                    267:             21.6.9. Packages installing man pages
                    268:             21.6.10. Packages installing X11 fonts
                    269:             21.6.11. Packages installing SGML or XML data
                    270:             21.6.12. Packages installing extensions to the MIME database
                    271:             21.6.13. Packages using intltool
                    272:             21.6.14. Packages installing startup scripts
                    273:             21.6.15. Packages installing TeX modules
                    274:             21.6.16. Packages supporting running binaries in emulation
                    275:             21.6.17. Packages installing hicolor icons
                    276:             21.6.18. Packages installing desktop files
1.154     rillig    277:         21.7. Marking packages as having problems
1.184     rillig    278:     22. GNOME packaging and porting
                    279:         22.1. Meta packages
                    280:         22.2. Packaging a GNOME application
                    281:         22.3. Updating GNOME to a newer version
                    282:         22.4. Patching guidelines
1.154     rillig    283:     23. Submitting and Committing
                    284:         23.1. Submitting binary packages
                    285:         23.2. Submitting source packages (for non-NetBSD-developers)
                    286:         23.3. General notes when adding, updating, or removing packages
                    287:         23.4. Commit Messages
                    288:         23.5. Committing: Adding a package to CVS
                    289:         23.6. Updating a package to a newer version
                    290:         23.7. Renaming a package in pkgsrc
                    291:         23.8. Moving a package in pkgsrc
                    292:     24. Frequently Asked Questions
1.1       dsieger   293: III. The pkgsrc infrastructure internals
1.184     rillig    294:     25. Design of the pkgsrc infrastructure
                    295:         25.1. The meaning of variable definitions
                    296:         25.2. Avoiding problems before they arise
                    297:         25.3. Variable evaluation
                    298:             25.3.1. At load time
                    299:             25.3.2. At runtime
                    300:         25.4. How can variables be specified?
                    301:         25.5. Designing interfaces for Makefile fragments
                    302:             25.5.1. Procedures with parameters
                    303:             25.5.2. Actions taken on behalf of parameters
                    304:         25.6. The order in which files are loaded
                    305:             25.6.1. The order in bsd.prefs.mk
                    306:             25.6.2. The order in bsd.pkg.mk
                    307:     26. Regression tests
                    308:         26.1. Running the regression tests
                    309:         26.2. Adding a new regression test
                    310:             26.2.1. Overridable functions
                    311:             26.2.2. Helper functions
                    312:     27. Porting pkgsrc
                    313:         27.1. Porting pkgsrc to a new operating system
1.1       dsieger   314: A. A simple example package: bison
                    315:     A.1. files
                    316:         A.1.1. Makefile
                    317:         A.1.2. DESCR
                    318:         A.1.3. PLIST
                    319:         A.1.4. Checking a package with pkglint
                    320:     A.2. Steps for building, installing, packaging
1.207     leot      321: B. Security hardening
                    322:     B.1. Mechanisms
                    323:         B.1.1. Enabled by default
                    324:         B.1.2. Not enabled by default
                    325:     B.2. Caveats
                    326:         B.2.1. Problems with PKGSRC_MKPIE
                    327:         B.2.2. Problems with PKGSRC_USE_FORTIFY
                    328:         B.2.3. Problems with PKGSRC_USE_RELRO
                    329:         B.2.4. Problems with PKGSRC_USE_SSP
                    330:     B.3. Auditing the system
                    331:         B.3.1. Checking for PIE
                    332:         B.3.2. Checking for partial RELRO
                    333:         B.3.3. Checking for full RELRO
                    334:         B.3.4. Checking for SSP
                    335: C. Build logs
                    336:     C.1. Building figlet
                    337:     C.2. Packaging figlet
                    338: D. Directory layout of the pkgsrc FTP server
                    339:     D.1. distfiles: The distributed source files
                    340:     D.2. misc: Miscellaneous things
                    341:     D.3. packages: Binary packages
                    342:     D.4. reports: Bulk build reports
                    343:     D.5. current, stable, pkgsrc-20xxQy: source packages
                    344: E. Help topics
                    345: F. Editing guidelines for the pkgsrc guide
                    346:     F.1. Make targets
                    347:     F.2. Procedure
1.1       dsieger   348: 
                    349: List of Tables
                    350: 
                    351: 1.1. Platforms supported by pkgsrc
1.184     rillig    352: 12.1. Patching examples
                    353: 22.1. PLIST handling for GNOME packages
1.1       dsieger   354: 
                    355: Chapter 1. What is pkgsrc?
                    356: 
                    357: Table of Contents
                    358: 
                    359: 1.1. Introduction
                    360:     1.1.1. Why pkgsrc?
                    361:     1.1.2. Supported platforms
                    362: 1.2. Overview
                    363: 1.3. Terminology
                    364:     1.3.1. Roles involved in pkgsrc
                    365: 1.4. Typography
                    366: 
                    367: 1.1. Introduction
                    368: 
                    369: There is a lot of software freely available for Unix-based systems, which is
                    370: usually available in form of the source code. Before such software can be used,
                    371: it needs to be configured to the local system, compiled and installed, and this
                    372: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
                    373: some basic commands to handle binary packages, so that not every user has to
                    374: build the packages for himself, which is a time-costly task.
                    375: 
                    376: pkgsrc currently contains several thousand packages, including:
                    377: 
1.104     sevan     378:   * www/apache24 - The Apache web server
1.1       dsieger   379: 
                    380:   * www/firefox - The Firefox web browser
                    381: 
                    382:   * meta-pkgs/gnome - The GNOME Desktop Environment
                    383: 
1.102     ryoon     384:   * meta-pkgs/kde4 - The K Desktop Environment
1.1       dsieger   385: 
1.108     rillig    386: ? just to name a few.
1.1       dsieger   387: 
                    388: pkgsrc has built-in support for handling varying dependencies, such as pthreads
                    389: and X11, and extended features such as IPv6 support on a range of platforms.
                    390: 
                    391: 1.1.1. Why pkgsrc?
                    392: 
                    393: pkgsrc provides the following key features:
                    394: 
                    395:   * Easy building of software from source as well as the creation and
                    396:     installation of binary packages. The source and latest patches are
                    397:     retrieved from a master or mirror download site, checksum verified, then
                    398:     built on your system. Support for binary-only distributions is available
                    399:     for both native platforms and NetBSD emulated platforms.
                    400: 
                    401:   * All packages are installed in a consistent directory tree, including
                    402:     binaries, libraries, man pages and other documentation.
                    403: 
1.104     sevan     404:   * Tracking of package dependencies automatically, including when performing
                    405:     updates, to ensure required packages are installed. The configuration files
                    406:     of various packages are handled automatically during updates, so local
                    407:     changes are preserved.
1.1       dsieger   408: 
                    409:   * Like NetBSD, pkgsrc is designed with portability in mind and consists of
                    410:     highly portable code. This allows the greatest speed of development when
1.26      spz       411:     porting to a new platform. This portability also ensures that pkgsrc is 
1.1       dsieger   412:     consistent across all platforms.
                    413: 
                    414:   * The installation prefix, acceptable software licenses, international
                    415:     encryption requirements and build-time options for a large number of
                    416:     packages are all set in a simple, central configuration file.
                    417: 
                    418:   * The entire source (not including the distribution files) is freely
                    419:     available under a BSD license, so you may extend and adapt pkgsrc to your
                    420:     needs. Support for local packages and patches is available right out of the
                    421:     box, so you can configure it specifically for your environment.
                    422: 
                    423: The following principles are basic to pkgsrc:
                    424: 
1.198     leot      425:   * "It should only work if it's right." -- That means, if a package contains
1.1       dsieger   426:     bugs, it's better to find them and to complain about them rather than to
                    427:     just install the package and hope that it works. There are numerous checks
1.175     gutterid  428:     in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1       dsieger   429:     pkglint), build-time checks (portability of shell scripts), and
                    430:     post-installation checks (installed files, references to shared libraries,
                    431:     script interpreters).
                    432: 
1.198     leot      433:   * "If it works, it should work everywhere" -- Like NetBSD has been ported to
1.1       dsieger   434:     many hardware architectures, pkgsrc has been ported to many operating
                    435:     systems. Care is taken that packages behave the same on all platforms.
                    436: 
                    437: 1.1.2. Supported platforms
                    438: 
                    439: pkgsrc consists of both a source distribution and a binary distribution for
                    440: these operating systems. After retrieving the required source or binaries, you
                    441: can be up and running with pkgsrc in just minutes!
                    442: 
                    443: pkgsrc was derived from FreeBSD's ports system, and initially developed for
                    444: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
                    445: platforms:
                    446: 
                    447: Table 1.1. Platforms supported by pkgsrc
                    448: 
1.92      sevan     449: +-----------------------------------------------------------------------------+
1.229     gutterid  450: |              Platform               | Date Support  |         Notes         |
                    451: |                                     |     Added     |                       |
                    452: |-------------------------------------+---------------+-----------------------|
                    453: |NetBSD                               |   Aug 1997    |                       |
                    454: |-------------------------------------+---------------+-----------------------|
                    455: |Solaris                              |   Mar 1999    |README.Solaris         |
                    456: |-------------------------------------+---------------+-----------------------|
                    457: |Linux                                |   Jun 1999    |README.Linux           |
                    458: |-------------------------------------+---------------+-----------------------|
                    459: |Darwin / Mac OS X / OS X / macOS     |   Oct 2001    |README.macOS           |
                    460: |-------------------------------------+---------------+-----------------------|
                    461: |FreeBSD                              |   Nov 2002    |README.FreeBSD         |
                    462: |-------------------------------------+---------------+-----------------------|
                    463: |OpenBSD                              |   Nov 2002    |README.OpenBSD         |
                    464: |-------------------------------------+---------------+-----------------------|
                    465: |IRIX                                 |   Dec 2002    |README.IRIX            |
                    466: |-------------------------------------+---------------+-----------------------|
                    467: |BSD/OS                               |   Dec 2003    |                       |
                    468: |-------------------------------------+---------------+-----------------------|
                    469: |AIX                                  |   Dec 2003    |README.AIX             |
                    470: |-------------------------------------+---------------+-----------------------|
                    471: |Interix (Microsoft Windows Services  |   Mar 2004    |README.Interix         |
                    472: |for Unix)                            |               |                       |
                    473: |-------------------------------------+---------------+-----------------------|
                    474: |DragonFlyBSD                         |   Oct 2004    |                       |
                    475: |-------------------------------------+---------------+-----------------------|
                    476: |OSF/1                                |   Nov 2004    |README.OSF1            |
                    477: |-------------------------------------+---------------+-----------------------|
                    478: |HP-UX                                |   Apr 2007    |README.HPUX            |
                    479: |-------------------------------------+---------------+-----------------------|
                    480: |Haiku                                |   Sep 2010    |README.Haiku           |
                    481: |-------------------------------------+---------------+-----------------------|
                    482: |MirBSD                               |   Jan 2011    |                       |
                    483: |-------------------------------------+---------------+-----------------------|
                    484: |Minix3                               |   Nov 2011    |README.Minix3          |
                    485: |-------------------------------------+---------------+-----------------------|
                    486: |Cygwin                               |   Mar 2013    |README.Cygwin          |
                    487: |-------------------------------------+---------------+-----------------------|
                    488: |GNU/kFreeBSD                         |   Jul 2013    |README.GNUkFreeBSD     |
                    489: |-------------------------------------+---------------+-----------------------|
                    490: |Bitrig                               |   Jun 2014    |Removed from pkgsrc Sep|
                    491: |                                     |               |2022                   |
1.92      sevan     492: +-----------------------------------------------------------------------------+
1.1       dsieger   493: 
                    494: 
                    495: 1.2. Overview
                    496: 
                    497: This document is divided into three parts. The first, The pkgsrc user's guide,
                    498: describes how one can use one of the packages in the Package Collection, either
                    499: by installing a precompiled binary package, or by building one's own copy using
                    500: the NetBSD package system. The second part, The pkgsrc developer's guide,
                    501: explains how to prepare a package so it can be easily built by other NetBSD
                    502: users without knowing about the package's building details. The third part, The
                    503: pkgsrc infrastructure internals is intended for those who want to understand
                    504: how pkgsrc is implemented.
                    505: 
                    506: This document is available in various formats: HTML, PDF, PS, TXT.
                    507: 
                    508: 1.3. Terminology
                    509: 
                    510: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
                    511: description of all the terminology used within this document.
                    512: 
                    513: Package
                    514: 
                    515:     A set of files and building instructions that describe what's necessary to
                    516:     build a certain piece of software using pkgsrc. Packages are traditionally
1.123     wiz       517:     stored under /usr/pkgsrc, but may be stored in any location, referred to as
                    518:     PKGSRCDIR.
1.1       dsieger   519: 
                    520: The NetBSD package system
                    521: 
                    522:     This is the former name of "pkgsrc". It is part of the NetBSD operating
                    523:     system and can be bootstrapped to run on non-NetBSD operating systems as
                    524:     well. It handles building (compiling), installing, and removing of
                    525:     packages.
                    526: 
                    527: Distfile
                    528: 
                    529:     This term describes the file or files that are provided by the author of
                    530:     the piece of software to distribute his work. All the changes necessary to
                    531:     build on NetBSD are reflected in the corresponding package. Usually the
                    532:     distfile is in the form of a compressed tar-archive, but other types are
                    533:     possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
                    534: 
                    535: Port
                    536: 
                    537:     This is the term used by FreeBSD and OpenBSD people for what we call a
                    538:     package. In NetBSD terminology, "port" refers to a different architecture.
                    539: 
                    540: Precompiled/binary package
                    541: 
                    542:     A set of binaries built with pkgsrc from a distfile and stuffed together in
                    543:     a single .tgz file so it can be installed on machines of the same machine
                    544:     architecture without the need to recompile. Packages are usually generated
                    545:     in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
                    546: 
                    547:     Sometimes, this is referred to by the term "package" too, especially in the
                    548:     context of precompiled packages.
                    549: 
                    550: Program
                    551: 
                    552:     The piece of software to be installed which will be constructed from all
                    553:     the files in the distfile by the actions defined in the corresponding
                    554:     package.
                    555: 
                    556: 1.3.1. Roles involved in pkgsrc
                    557: 
                    558: pkgsrc users
                    559: 
                    560:     The pkgsrc users are people who use the packages provided by pkgsrc.
                    561:     Typically they are system administrators. The people using the software
                    562:     that is inside the packages (maybe called "end users") are not covered by
                    563:     the pkgsrc guide.
                    564: 
                    565:     There are two kinds of pkgsrc users: Some only want to install pre-built
                    566:     binary packages. Others build the pkgsrc packages from source, either for
                    567:     installing them directly or for building binary packages themselves. For
                    568:     pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
                    569:     documentation.
                    570: 
                    571: package maintainers
                    572: 
                    573:     A package maintainer creates packages as described in Part II, "The pkgsrc
                    574:     developer's guide".
                    575: 
                    576: infrastructure developers
                    577: 
                    578:     These people are involved in all those files that live in the mk/ directory
                    579:     and below. Only these people should need to read through Part III, "The
                    580:     pkgsrc infrastructure internals", though others might be curious, too.
                    581: 
                    582: 1.4. Typography
                    583: 
                    584: When giving examples for commands, shell prompts are used to show if the
                    585: command should/can be issued as root, or if "normal" user privileges are
1.115     sevan     586: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
1.229     gutterid  587: assuming they use the C-shell or tcsh and a $ for Bourne shell and derivatives.
1.1       dsieger   588: 
                    589: Part I. The pkgsrc user's guide
                    590: 
                    591: Table of Contents
                    592: 
1.154     rillig    593: 2. Getting help
                    594: 3. Where to get pkgsrc and how to keep it up-to-date
                    595:     3.1. Getting pkgsrc for the first time
                    596:         3.1.1. As tar archive
                    597:         3.1.2. Via anonymous CVS
                    598:     3.2. Keeping pkgsrc up-to-date
                    599:         3.2.1. Via tar files
                    600:         3.2.2. Via CVS
                    601: 4. Using pkgsrc on systems other than NetBSD
                    602:     4.1. Binary distribution
                    603:     4.2. Bootstrapping pkgsrc
                    604: 5. Using pkgsrc
                    605:     5.1. Using binary packages
                    606:         5.1.1. Finding binary packages
                    607:         5.1.2. Installing binary packages
1.202     nia       608:         5.1.3. Updating packages
                    609:         5.1.4. Deinstalling packages
                    610:         5.1.5. Getting information about installed packages
                    611:         5.1.6. Checking for security vulnerabilities in installed packages
                    612:         5.1.7. Finding if newer versions of your installed packages are in
1.232     gutterid  613:         pkgsrc
1.202     nia       614:         5.1.8. Other administrative functions
1.154     rillig    615:     5.2. Building packages from source
                    616:         5.2.1. Requirements
                    617:         5.2.2. Fetching distfiles
                    618:         5.2.3. How to build and install
                    619: 6. Configuring pkgsrc
                    620:     6.1. General configuration
                    621:     6.2. Variables affecting the build process
1.241     rillig    622:     6.3. Preferences for native or pkgsrc software
                    623:     6.4. Variables affecting the installation process
                    624:     6.5. Selecting and configuring the compiler
                    625:         6.5.1. Selecting the compiler
                    626:         6.5.2. Additional flags to the compiler (CFLAGS)
                    627:         6.5.3. Additional flags to the linker (LDFLAGS)
                    628:     6.6. Developer/advanced settings
                    629:     6.7. Selecting Build Options
1.154     rillig    630: 7. Creating binary packages
                    631:     7.1. Building a single binary package
                    632:     7.2. Settings for creation of binary packages
                    633: 8. Creating binary packages for everything in pkgsrc (bulk builds)
                    634:     8.1. Preparations
1.180     rillig    635:     8.2. Running a bulk build
1.154     rillig    636:         8.2.1. Configuration
                    637:     8.3. Requirements of a full bulk build
1.178     rillig    638:     8.4. Bulk build variants
1.179     rillig    639:         8.4.1. Detect unknown configure options
                    640:         8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig    641:         8.4.3. Force compiler options only in the build phase
                    642:         8.4.4. Use custom directories
                    643:         8.4.5. Turn warnings into errors
                    644:         8.4.6. Reject packages for which pkglint reports errors
                    645:         8.4.7. Reject packages that contain forbidden strings
                    646:         8.4.8. Reject packages whose self-test fails
                    647:         8.4.9. Reject packages that use undefined shell variables
                    648:         8.4.10. Turn off verbose logging
1.178     rillig    649:     8.5. Creating a multiple CD-ROM packages collection
                    650:         8.5.1. Example of cdpack
1.154     rillig    651: 9. Directory layout of the installed files
                    652:     9.1. File system layout in ${LOCALBASE}
                    653:     9.2. File system layout in ${VARBASE}
                    654: 10. Frequently Asked Questions
                    655:     10.1. Are there any mailing lists for pkg-related discussion?
                    656:     10.2. Utilities for package management (pkgtools)
                    657:     10.3. How to use pkgsrc as non-root
                    658:     10.4. How to resume transfers when fetching distfiles?
                    659:     10.5. How can I install/use modular X.org from pkgsrc?
                    660:     10.6. How to fetch files from behind a firewall
                    661:     10.7. How to fetch files from HTTPS sites
                    662:     10.8. How do I tell make fetch to do passive FTP?
                    663:     10.9. How to fetch all distfiles at once
                    664:     10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                    665:     10.11. What does "Could not find bsd.own.mk" mean?
1.221     nia       666:     10.12. Using 'sudo' or `priv` with pkgsrc
1.154     rillig    667:     10.13. How do I change the location of configuration files?
                    668:     10.14. Automated security checks
                    669:     10.15. Why do some packages ignore my CFLAGS?
                    670:     10.16. A package does not build. What shall I do?
                    671:     10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.232     gutterid  672:     conflicts" mean?
1.1       dsieger   673: 
1.154     rillig    674: Chapter 2. Getting help
                    675: 
                    676: To get help when using pkgsrc, the definitive source is this document, the
                    677: pkgsrc guide. If you don't find anything here, there are alternatives:
                    678: 
                    679:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                    680:     Run bmake help topic=? to get help for any topic, such as a variable name
                    681:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                    682:     like strcasecmp or any other topic.
                    683: 
1.207     leot      684:     The available help topics are listed in Appendix E, Help topics.
1.154     rillig    685: 
1.163     rillig    686:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                    687: 
                    688:   * To see the values of the most common variables, run bmake show-all. These
                    689:     variables are grouped by topic. To see the variables for a single topic,
                    690:     run bmake show-all-topic, for example bmake show-all-fetch.
                    691: 
1.154     rillig    692:   * The pkgsrc-users mailing list, to which you can subscribe and then ask your
                    693:     questions.
                    694: 
                    695:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                    696:     a specialized chat program such as XChat. Pick any user name and join the
                    697:     channel #pkgsrc.
                    698: 
                    699: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   700: 
                    701: Table of Contents
                    702: 
1.154     rillig    703: 3.1. Getting pkgsrc for the first time
                    704:     3.1.1. As tar archive
                    705:     3.1.2. Via anonymous CVS
                    706: 3.2. Keeping pkgsrc up-to-date
                    707:     3.2.1. Via tar files
                    708:     3.2.2. Via CVS
1.1       dsieger   709: 
                    710: Before you download and extract the files, you need to decide where you want to
                    711: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
                    712: usr/pkgsrc. You are though free to install the sources and binary packages
                    713: wherever you want in your filesystem, provided that the pathname does not
                    714: contain white-space or other characters that are interpreted specially by the
                    715: shell and some other programs. A safe bet is to use only letters, digits,
                    716: underscores and dashes.
                    717: 
1.154     rillig    718: 3.1. Getting pkgsrc for the first time
1.1       dsieger   719: 
1.25      wiz       720: Before you download any pkgsrc files, you should decide whether you want the 
1.1       dsieger   721: current branch or the stable branch. The latter is forked on a quarterly basis
                    722: from the current branch and only gets modified for security updates. The names
                    723: of the stable branches are built from the year and the quarter, for example
1.246     leot      724: 2023Q3.
1.1       dsieger   725: 
                    726: The second step is to decide how you want to download pkgsrc. You can get it as
1.24      wiz       727: a tar file or via CVS. Both ways are described here.
1.1       dsieger   728: 
1.52      asau      729: Note that tar archive contains CVS working copy. Thus you can switch to using
                    730: CVS at any later time.
1.1       dsieger   731: 
1.154     rillig    732: 3.1.1. As tar archive
1.52      asau      733: 
1.151     sevan     734: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
                    735: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
                    736: location). There are a number of subdirectories for different purposes, which
1.207     leot      737: are described in detail in Appendix D, Directory layout of the pkgsrc FTP
1.151     sevan     738: server.
1.1       dsieger   739: 
1.52      asau      740: The tar archive for the current branch is in the directory current and is
1.118     sevan     741: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52      asau      742: 
                    743: To save download time we provide bzip2- and xz-compressed archives which are
                    744: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
                    745: 
                    746: You can fetch the same files using FTP.
1.1       dsieger   747: 
1.246     leot      748: The tar file for the stable branch 2023Q3 is in the directory pkgsrc-2023Q3 and
1.59      jnemeth   749: is also called pkgsrc.tar.gz.
1.1       dsieger   750: 
1.136     leot      751: To download the latest pkgsrc stable tarball, run:
1.12      weinem    752: 
1.246     leot      753: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2023Q3/pkgsrc.tar.gz
1.12      weinem    754: 
1.78      snj       755: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52      asau      756: 
1.12      weinem    757: Then, extract it with:
                    758: 
1.78      snj       759: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12      weinem    760: 
                    761: This will create the directory pkgsrc/ in /usr/ and all the package source will
                    762: be stored under /usr/pkgsrc/.
                    763: 
                    764: To download pkgsrc-current, run:
                    765: 
                    766: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1       dsieger   767: 
1.154     rillig    768: 3.1.2. Via anonymous CVS
1.1       dsieger   769: 
1.24      wiz       770: To fetch a specific pkgsrc stable branch, run:
1.1       dsieger   771: 
1.246     leot      772: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2023Q3 -P pkgsrc
1.13      weinem    773: 
1.24      wiz       774: This will create the directory pkgsrc/ in your /usr/ directory and all the
                    775: package source will be stored under /usr/pkgsrc/.
                    776: 
                    777: To fetch the pkgsrc current branch, run:
1.1       dsieger   778: 
1.40      wiz       779: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   780: 
1.30      dholland  781: Refer to the list of available mirrors to choose a faster CVS mirror, if
                    782: needed.
1.1       dsieger   783: 
1.24      wiz       784: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1       dsieger   785: 
1.40      wiz       786: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   787: 
1.24      wiz       788: Refer to documentation on your command shell how to set CVS_RSH=ssh
                    789: permanently. For Bourne shells, you can set it in your .profile or better
                    790: globally in /etc/profile:
                    791: 
                    792: # set CVS remote shell command
                    793: CVS_RSH=ssh
                    794: export CVS_RSH
1.12      weinem    795: 
1.13      weinem    796: By default, CVS doesn't do things like most people would expect it to do. But
                    797: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12      weinem    798: directory and saving the following lines to it. This file will save you lots of
                    799: headache and some bug reports, so we strongly recommend it. You can find an
                    800: explanation of this file in the CVS documentation.
1.2       rillig    801: 
                    802: # recommended CVS configuration file from the pkgsrc guide
1.155     sevan     803: cvs -q
1.2       rillig    804: checkout -P
1.4       rillig    805: update -dP
                    806: diff -upN
1.2       rillig    807: rdiff -u
1.24      wiz       808: release -d
1.1       dsieger   809: 
1.154     rillig    810: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   811: 
                    812: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
                    813: have first installed it via a tar file). It saves bandwidth and hard disk
                    814: activity, compared to downloading the tar file again.
                    815: 
1.154     rillig    816: 3.2.1. Via tar files
1.1       dsieger   817: 
                    818: Warning
                    819: 
                    820: When updating from a tar file, you first need to completely remove the old
                    821: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
                    822: the mean time will not be removed on your local disk, resulting in
                    823: inconsistencies. When removing the old files, any changes that you have done to
                    824: the pkgsrc files will be lost after updating. Therefore updating via CVS is
                    825: strongly recommended.
                    826: 
                    827: Note that by default the distfiles and the binary packages are saved in the
                    828: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78      snj       829: configure pkgsrc to store distfiles and packages in directories outside the
1.154     rillig    830: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6, 
1.78      snj       831: Configuring pkgsrc for the details.
1.1       dsieger   832: 
                    833: To update pkgsrc from a tar file, download the tar file as explained above.
                    834: Then, make sure that you have not made any changes to the files in the pkgsrc
                    835: directory. Remove the pkgsrc directory and extract the new tar file. Done.
                    836: 
1.154     rillig    837: 3.2.2. Via CVS
1.1       dsieger   838: 
1.26      spz       839: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12      weinem    840: 
1.26      spz       841: $ cd /usr/pkgsrc && cvs update -dP
                    842: 
                    843: If you get error messages from rsh, you need to set CVS_RSH variable as
                    844: described above. E.g.:
                    845: 
                    846: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1       dsieger   847: 
1.154     rillig    848: 3.2.2.1. Switching between different pkgsrc branches
1.1       dsieger   849: 
                    850: When updating pkgsrc, the CVS program keeps track of the branch you selected.
                    851: But if you, for whatever reason, want to switch from the stable branch to the
                    852: current one, you can do it by adding the option "-A" after the "update"
1.25      wiz       853: keyword. To switch from the current branch back to the stable branch, add the "
1.246     leot      854: -rpkgsrc-2023Q3" option.
1.1       dsieger   855: 
1.154     rillig    856: 3.2.2.2. What happens to my changes when updating?
1.1       dsieger   857: 
                    858: When you update pkgsrc, the CVS program will only touch those files that are
                    859: registered in the CVS repository. That means that any packages that you created
                    860: on your own will stay unmodified. If you change files that are managed by CVS,
                    861: later updates will try to merge your changes with those that have been done by
                    862: others. See the CVS manual, chapter "update" for details.
                    863: 
1.154     rillig    864: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger   865: 
                    866: Table of Contents
                    867: 
1.154     rillig    868: 4.1. Binary distribution
                    869: 4.2. Bootstrapping pkgsrc
1.1       dsieger   870: 
1.154     rillig    871: 4.1. Binary distribution
1.1       dsieger   872: 
1.154     rillig    873: See Section 5.1, "Using binary packages".
1.1       dsieger   874: 
1.154     rillig    875: 4.2. Bootstrapping pkgsrc
1.1       dsieger   876: 
1.44      asau      877: pkgsrc can be bootstrapped for use in two different modes: privileged and
                    878: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45      asau      879: programs are installed under one particular user and cannot utilise privileged
1.44      asau      880: operations (packages don't create special users and all special file
                    881: permissions like setuid are ignored).
                    882: 
1.1       dsieger   883: Installing the bootstrap kit from source should be as simple as:
                    884: 
1.60      asau      885: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   886: # cd pkgsrc/bootstrap
                    887: # ./bootstrap
                    888: 
                    889: 
1.44      asau      890: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
                    891: 
                    892: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118     sevan     893: will be installed in, and /usr/pkg/pkgdb for the package database directory
                    894: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44      asau      895: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118     sevan     896: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44      asau      897: 
                    898: You can change default layout using command-line arguments. Run "./bootstrap
                    899: --help" to get details.
1.1       dsieger   900: 
                    901: Note
                    902: 
                    903: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
                    904: For examples in this guide, use bmake instead of "make".
                    905: 
1.44      asau      906: Note
                    907: 
                    908: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
                    909: directories. Use bmake corresponding to the installation you're working with to
                    910: build and install packages.
                    911: 
1.154     rillig    912: Chapter 5. Using pkgsrc
1.1       dsieger   913: 
                    914: Table of Contents
                    915: 
1.154     rillig    916: 5.1. Using binary packages
                    917:     5.1.1. Finding binary packages
                    918:     5.1.2. Installing binary packages
1.202     nia       919:     5.1.3. Updating packages
                    920:     5.1.4. Deinstalling packages
                    921:     5.1.5. Getting information about installed packages
                    922:     5.1.6. Checking for security vulnerabilities in installed packages
                    923:     5.1.7. Finding if newer versions of your installed packages are in pkgsrc
                    924:     5.1.8. Other administrative functions
1.154     rillig    925: 5.2. Building packages from source
                    926:     5.2.1. Requirements
                    927:     5.2.2. Fetching distfiles
                    928:     5.2.3. How to build and install
1.1       dsieger   929: 
                    930: Basically, there are two ways of using pkgsrc. The first is to only install the
                    931: package tools and to use binary packages that someone else has prepared. This
                    932: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
                    933: Then you are able to build your own packages, and you can still use binary
                    934: packages from someone else.
                    935: 
1.154     rillig    936: 5.1. Using binary packages
1.1       dsieger   937: 
1.151     sevan     938: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9       rillig    939: packages, ready to be installed. These binary packages have been built using
                    940: the default settings for the directories, that is:
                    941: 
                    942:   * /usr/pkg for LOCALBASE, where most of the files are installed,
                    943: 
                    944:   * /usr/pkg/etc for configuration files,
                    945: 
                    946:   * /var for VARBASE, where those files are installed that may change after
                    947:     installation.
                    948: 
                    949: If you cannot use these directories for whatever reasons (maybe because you're
                    950: not root), you cannot use these binary packages, but have to build the packages
1.154     rillig    951: yourself, which is explained in Section 4.2, "Bootstrapping pkgsrc".
1.1       dsieger   952: 
1.154     rillig    953: 5.1.1. Finding binary packages
1.1       dsieger   954: 
1.5       weinem    955: To install binary packages, you first need to know from where to get them. The
1.202     nia       956: first place where you should look is on the main pkgsrc CDN in the directory /
                    957: pub/pkgsrc/packages.
1.5       weinem    958: 
                    959: This directory contains binary packages for multiple platforms. First, select
1.226     gutterid  960: your operating system. Then, select your hardware architecture, and in the
                    961: third step, the OS version and the "version" of pkgsrc.
1.9       rillig    962: 
1.226     gutterid  963: In this directory, you may find a file called bootstrap.tar.gz which contains
1.9       rillig    964: the package management tools. If the file is missing, it is likely that your
                    965: operating system already provides those tools. Download the file and extract it
                    966: in the / directory. It will create the directories /usr/pkg (containing the
1.118     sevan     967: tools for managing binary packages and the database of installed packages).
1.1       dsieger   968: 
1.154     rillig    969: 5.1.2. Installing binary packages
1.1       dsieger   970: 
1.85      wiz       971: In the directory from the last section, there is a subdirectory called All/,
1.9       rillig    972: which contains all the binary packages that are available for the platform,
1.202     nia       973: excluding those that may not be distributed via HTTP or FTP.
1.9       rillig    974: 
                    975: To install packages directly from an FTP or HTTP server, run the following
                    976: commands in a Bourne-compatible shell (be sure to su to root first):
                    977: 
1.202     nia       978: # PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
                    979: # PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169     rillig    980: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9       rillig    981: # export PATH PKG_PATH
1.202     nia       982: # pkg_add pkgin
1.9       rillig    983: 
                    984: Instead of URLs, you can also use local paths, for example if you are
                    985: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
                    986: to install packages from multiple sources, you can separate them by a semicolon
                    987: in PKG_PATH.
                    988: 
                    989: After these preparations, installing a package is very easy:
                    990: 
1.202     nia       991: # pkgin search nginx
                    992: nginx-1.19.6         Lightweight HTTP server and mail proxy server
                    993: nginx-1.18.0nb8      Lightweight HTTP server and mail proxy server
                    994: # pkgin install zsh nginx-1.19.6 vim
1.1       dsieger   995: 
1.202     nia       996: Note that pkgin is a user-friendly frontend to the pkg_* tools.
1.1       dsieger   997: 
1.202     nia       998: Any prerequisite packages needed to run the package in question will be
                    999: installed, too, assuming they are present in the repository.
1.1       dsieger  1000: 
                   1001: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
                   1002: in your PATH so you can actually start the just installed program.
                   1003: 
1.202     nia      1004: 5.1.3. Updating packages
1.1       dsieger  1005: 
1.202     nia      1006: To update binary packages, it is recommended that you use pkgin upgrade. This
                   1007: will compare the remote package repository to your locally installed packages
                   1008: and safely replace any older packages.
1.1       dsieger  1009: 
1.202     nia      1010: Note that pkgsrc is released as quarterly branches. If you are updating to a
                   1011: newer quarterly branch of pkgsrc, you may need to adjust the repository in /usr
                   1012: /pkg/etc/pkgin/repositories.conf.
1.1       dsieger  1013: 
1.202     nia      1014: 5.1.4. Deinstalling packages
1.1       dsieger  1015: 
1.202     nia      1016: To deinstall a package, it does not matter whether it was installed from source
                   1017: code or from a binary package. Neither the pkgin or the pkg_delete command need
                   1018: to know.
1.1       dsieger  1019: 
1.202     nia      1020: To delete a package, you can just run pkgin remove package-name. The package
                   1021: name can be given with or without version number.
1.1       dsieger  1022: 
1.202     nia      1023: 5.1.5. Getting information about installed packages
1.1       dsieger  1024: 
                   1025: The pkg_info shows information about installed packages or binary package
1.202     nia      1026: files. As with other management tools, it works with packages installed from
                   1027: source or binaries.
1.1       dsieger  1028: 
1.202     nia      1029: 5.1.6. Checking for security vulnerabilities in installed packages
1.1       dsieger  1030: 
1.202     nia      1031: The pkgsrc Security Team and Packages Groups maintain a list of known
1.164     leot     1032: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.202     nia      1033: list is available from the NetBSD CDN at https://cdn.NetBSD.org/pub/NetBSD/
1.179     rillig   1034: packages/vulns/pkg-vulnerabilities.
1.1       dsieger  1035: 
1.202     nia      1036: Please note that not every "vulnerability" with a CVE assignment is exploitable
                   1037: in every configuration. Some bugs are marked as active simply because an fix
                   1038: was not marked as such. Operating system specific hardening and mitigation
                   1039: features may also reduce the impact of bugs.
                   1040: 
1.23      jakllsch 1041: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
                   1042: automatically, and a security audit of all packages installed on a system can
                   1043: take place.
                   1044: 
                   1045: There are two components to auditing. The first step, pkg_admin
                   1046: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
                   1047: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
                   1048: your installed packages are vulnerable. If a package is vulnerable, you will
                   1049: see output similar to the following:
1.1       dsieger  1050: 
                   1051: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174     leot     1052:     https://www.samba.org/samba/whatsnew/macroexploit.html
1.1       dsieger  1053: 
1.23      jakllsch 1054: You may wish to have the vulnerabilities file downloaded daily so that it
                   1055: remains current. This may be done by adding an appropriate entry to the root
                   1056: users crontab(5) entry. For example the entry
                   1057: 
1.121     sevan    1058: # Download vulnerabilities file
1.118     sevan    1059: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121     sevan    1060: # Audit the installed packages and email results to root
                   1061: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
                   1062:             root >/dev/null 2>&1
1.118     sevan    1063: 
                   1064: 
                   1065: will update the vulnerability list every day at 3AM, followed by an audit at
                   1066: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
                   1067: accomplished instead by adding the following line to /etc/daily.conf:
                   1068: 
                   1069: fetch_pkg_vulnerabilities=YES
                   1070: 
1.23      jakllsch 1071: 
1.118     sevan    1072: to fetch the vulnerability list from the daily security script. The system is
                   1073: set to audit the packages by default but can be set explicitly, if desired (not
1.123     wiz      1074: required), by adding the following line to /etc/security.conf:
1.23      jakllsch 1075: 
1.118     sevan    1076: check_pkg_vulnerabilities=YES
1.23      jakllsch 1077: 
                   1078: 
1.118     sevan    1079: see daily.conf(5) and security.conf(5) for more details.
1.1       dsieger  1080: 
1.202     nia      1081: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
1.1       dsieger  1082: 
1.12      weinem   1083: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
1.202     nia      1084: if any packages are stale, e.g.
1.1       dsieger  1085: 
                   1086: % lintpkgsrc -i
                   1087: ...
                   1088: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
                   1089: 
                   1090: 
1.202     nia      1091: 5.1.8. Other administrative functions
1.1       dsieger  1092: 
                   1093: The pkg_admin executes various administrative functions on the package system.
                   1094: 
1.154     rillig   1095: 5.2. Building packages from source
1.1       dsieger  1096: 
                   1097: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25      wiz      1098: organized into categories. You can browse the online index of packages, or run 
1.1       dsieger  1099: make readme from the pkgsrc directory to build local README.html files for all
                   1100: packages, viewable with any web browser such as www/lynx or www/firefox.
                   1101: 
                   1102: The default prefix for installed packages is /usr/pkg. If you wish to change
                   1103: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
                   1104: use multiple different LOCALBASE definitions on the same system (inside a
                   1105: chroot is an exception).
                   1106: 
                   1107: The rest of this chapter assumes that the package is already in pkgsrc. If it
                   1108: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
                   1109: create your own packages.
                   1110: 
1.154     rillig   1111: 5.2.1. Requirements
1.1       dsieger  1112: 
                   1113: To build packages from source, you need a working C compiler. On NetBSD, you
                   1114: need to install the "comp" and the "text" distribution sets. If you want to
                   1115: build X11-related packages, the "xbase" and "xcomp" distribution sets are
                   1116: required, too.
                   1117: 
1.154     rillig   1118: 5.2.2. Fetching distfiles
1.1       dsieger  1119: 
                   1120: The first step for building a package is downloading the distfiles (i.e. the
                   1121: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
                   1122: them automatically.
                   1123: 
                   1124: If you have all files that you need in the distfiles directory, you don't need
                   1125: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
                   1126: and add:
                   1127: 
                   1128: DISTDIR=/cdrom/pkgsrc/distfiles
                   1129: 
                   1130: to your mk.conf.
                   1131: 
                   1132: By default a list of distribution sites will be randomly intermixed to prevent
                   1133: huge load on servers which holding popular packages (for example,
                   1134: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
                   1135: distfile all the mirrors will be tried in new (random) order. You can turn this
                   1136: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
                   1137: disabled).
                   1138: 
                   1139: You can overwrite some of the major distribution sites to fit to sites that are
                   1140: close to your own. By setting one or two variables you can modify the order in
                   1141: which the master sites are accessed. MASTER_SORT contains a whitespace
                   1142: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
                   1143: contains a whitespace delimited list of regular expressions. It has higher
                   1144: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
                   1145: some examples. This may save some of your bandwidth and time.
                   1146: 
                   1147: You can change these settings either in your shell's environment, or, if you
1.4       rillig   1148: want to keep the settings, by editing the mk.conf file, and adding the
1.1       dsieger  1149: definitions there.
                   1150: 
1.132     wiz      1151: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1       dsieger  1152: process may alternate between periods of downloading source, and compiling. To
                   1153: ensure you have all the source downloaded initially you can run the command:
                   1154: 
                   1155: % make fetch-list | sh
                   1156: 
                   1157: which will output and run a set of shell commands to fetch the necessary files
                   1158: into the distfiles directory. You can also choose to download the files
                   1159: manually.
                   1160: 
1.154     rillig   1161: 5.2.3. How to build and install
1.1       dsieger  1162: 
                   1163: Once the software has downloaded, any patches will be applied, then it will be
                   1164: compiled for you. This may take some time depending on your computer, and how
                   1165: many other packages the software depends on and their compile time.
                   1166: 
                   1167: Note
                   1168: 
                   1169: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
                   1170: command instead of "make" in the examples in this guide.
                   1171: 
                   1172: For example, type
                   1173: 
                   1174: % cd misc/figlet
                   1175: % make
                   1176: 
                   1177: 
                   1178: at the shell prompt to build the various components of the package.
                   1179: 
                   1180: The next stage is to actually install the newly compiled program onto your
                   1181: system. Do this by entering:
                   1182: 
                   1183: % make install
                   1184: 
                   1185: 
                   1186: while you are still in the directory for whatever package you are installing.
                   1187: 
                   1188: Installing the package on your system may require you to be root. However,
                   1189: pkgsrc has a just-in-time-su feature, which allows you to only become root for
                   1190: the actual installation step.
                   1191: 
                   1192: That's it, the software should now be installed and setup for use. You can now
                   1193: enter:
                   1194: 
                   1195: % make clean
                   1196: 
                   1197: 
                   1198: to remove the compiled files in the work directory, as you shouldn't need them
                   1199: any more. If other packages were also added to your system (dependencies) to
                   1200: allow your program to compile, you can tidy these up also with the command:
                   1201: 
                   1202: % make clean-depends
                   1203: 
                   1204: 
                   1205: Taking the figlet utility as an example, we can install it on our system by
1.207     leot     1206: building as shown in Appendix C, Build logs.
1.1       dsieger  1207: 
                   1208: The program is installed under the default root of the packages tree - /usr/
                   1209: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
                   1210: environment, and it will use that value as the root of your packages tree. So,
                   1211: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
                   1212: that you should use a directory which is dedicated to packages and not shared
                   1213: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
                   1214: not try to add any of your own files or directories (such as src/, obj/, or
                   1215: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
                   1216: between programs and other files installed by the package system and whatever
                   1217: else may have been installed there.
                   1218: 
1.4       rillig   1219: Some packages look in mk.conf to alter some configuration options at build
1.1       dsieger  1220: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
                   1221: be set there by default. Environment variables such as LOCALBASE can be set in
1.4       rillig   1222: mk.conf to save having to remember to set them each time you want to use
1.1       dsieger  1223: pkgsrc.
                   1224: 
                   1225: Occasionally, people want to "look under the covers" to see what is going on
                   1226: when a package is building or being installed. This may be for debugging
                   1227: purposes, or out of simple curiosity. A number of utility values have been
                   1228: added to help with this.
                   1229: 
                   1230:  1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
                   1231:     amount of information will be displayed. For example,
                   1232: 
                   1233:     make patch PKG_DEBUG_LEVEL=2
                   1234: 
1.25      wiz      1235:     will show all the commands that are invoked, up to and including the "patch
                   1236:     " stage.
1.1       dsieger  1237: 
                   1238:  2. If you want to know the value of a certain make(1) definition, then the
                   1239:     VARNAME definition should be used, in conjunction with the show-var target.
                   1240:     e.g. to show the expansion of the make(1) variable LOCALBASE:
                   1241: 
                   1242:     % make show-var VARNAME=LOCALBASE
                   1243:     /usr/pkg
                   1244:     %
                   1245: 
                   1246: 
                   1247: If you want to install a binary package that you've either created yourself
                   1248: (see next section), that you put into pkgsrc/packages manually or that is
                   1249: located on a remote FTP server, you can use the "bin-install" target. This
                   1250: target will install a binary package - if available - via pkg_add(1), else do a
                   1251: make package. The list of remote FTP sites searched is kept in the variable
                   1252: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
                   1253: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
                   1254: for more details.
                   1255: 
                   1256: A final word of warning: If you set up a system that has a non-standard setting
                   1257: for LOCALBASE, be sure to set that before any packages are installed, as you
                   1258: cannot use several directories for the same purpose. Doing so will result in
                   1259: pkgsrc not being able to properly detect your installed packages, and fail
                   1260: miserably. Note also that precompiled binary packages are usually built with
                   1261: the default LOCALBASE of /usr/pkg, and that you should not install any if you
                   1262: use a non-standard LOCALBASE.
                   1263: 
1.154     rillig   1264: Chapter 6. Configuring pkgsrc
1.1       dsieger  1265: 
                   1266: Table of Contents
                   1267: 
1.154     rillig   1268: 6.1. General configuration
                   1269: 6.2. Variables affecting the build process
1.241     rillig   1270: 6.3. Preferences for native or pkgsrc software
                   1271: 6.4. Variables affecting the installation process
                   1272: 6.5. Selecting and configuring the compiler
                   1273:     6.5.1. Selecting the compiler
                   1274:     6.5.2. Additional flags to the compiler (CFLAGS)
                   1275:     6.5.3. Additional flags to the linker (LDFLAGS)
                   1276: 6.6. Developer/advanced settings
                   1277: 6.7. Selecting Build Options
1.1       dsieger  1278: 
                   1279: The whole pkgsrc system is configured in a single file, usually called mk.conf.
                   1280: In which directory pkgsrc looks for that file depends on the installation. On
                   1281: NetBSD, when you use make(1) from the base system, it is in the directory /etc
                   1282: /. In all other cases the default location is ${PREFIX}/etc/, depending on
                   1283: where you told the bootstrap program to install the binary packages.
                   1284: 
                   1285: The format of the configuration file is that of the usual BSD-style Makefiles.
                   1286: The whole pkgsrc configuration is done by setting variables in this file. Note
                   1287: that you can define all kinds of variables, and no special error checking (for
1.112     rillig   1288: example for spelling mistakes) takes place.
1.1       dsieger  1289: 
1.154     rillig   1290: 6.1. General configuration
1.1       dsieger  1291: 
1.112     rillig   1292: The following variables apply to all pkgsrc packages. A complete list of the
                   1293: variables that can be configured by the user is available in mk/defaults/
                   1294: mk.conf, together with some comments that describe each variable's intent.
1.1       dsieger  1295: 
                   1296:   * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
                   1297:     not mix binary packages with different LOCALBASEs!
                   1298: 
                   1299:   * CROSSBASE: Where "cross" category packages will be installed. The default
                   1300:     is ${LOCALBASE}/cross.
                   1301: 
1.84      wiz      1302:   * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1       dsieger  1303: 
                   1304:   * DISTDIR: Where to store the downloaded copies of the original source
                   1305:     distributions used for building pkgsrc packages. The default is $
                   1306:     {PKGSRCDIR}/distfiles.
                   1307: 
                   1308:   * PKG_DBDIR: Where the database about installed packages is stored. The
1.118     sevan    1309:     default is /usr/pkg/pkgdb.
1.1       dsieger  1310: 
                   1311:   * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
                   1312:     value.
                   1313: 
                   1314:   * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
                   1315:     files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118     sevan    1316:     respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1       dsieger  1317:     {DIST_SUBDIR}/.
                   1318: 
                   1319:   * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
                   1320:     with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
                   1321: 
1.23      jakllsch 1322:   * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
                   1323:     case-sensitive. Whenever you try to build a package whose license is not in
                   1324:     this list, you will get an error message. If the license condition is
                   1325:     simple enough, the error message will include specific instructions on how
                   1326:     to change this variable.
1.1       dsieger  1327: 
1.154     rillig   1328: 6.2. Variables affecting the build process
1.1       dsieger  1329: 
                   1330:   * PACKAGES: The top level directory for the binary packages. The default is $
                   1331:     {PKGSRCDIR}/packages.
                   1332: 
                   1333:   * WRKOBJDIR: The top level directory where, if defined, the separate working
                   1334:     directories will get created, and symbolically linked to from ${WRKDIR}
                   1335:     (see below). This is useful for building packages on several architectures,
                   1336:     then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
                   1337:     architecture. (It should be noted that PKGSRCDIR should not be set by the
1.198     leot     1338:     user -- it is an internal definition which refers to the root of the pkgsrc
1.1       dsieger  1339:     tree. It is possible to have many pkgsrc tree instances.)
                   1340: 
                   1341:   * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.184     rillig   1342:     Section 12.3, "patches/*" for more information.
1.1       dsieger  1343: 
                   1344:   * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
                   1345:     Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
                   1346:     up settings used by builds in /usr/src.
                   1347: 
1.241     rillig   1348: 6.3. Preferences for native or pkgsrc software
                   1349: 
                   1350: Whenever a package depends on a package that has a builtin.mk file, the
                   1351: dependent package can either use the built-in (native) version from the base
                   1352: system or the pkgsrc-provided version. This only affects dependencies, so it is
                   1353: still possible to build the pkgsrc package devel/pcre++ even when other
                   1354: packages depend on the native pcre++ version instead.
                   1355: 
                   1356: To force using the pkgsrc-provided version for a particular package, define "
                   1357: PREFER_PKGSRC = package-ID" in mk.conf. To force using the native package,
                   1358: define "PREFER_NATIVE = package-ID". In both cases, the package-ID is the one
                   1359: from the buildlink3.mk of the package. In most cases, this ID is the same as
                   1360: the directory name of the package, but for example, devel/pcre++ has the
                   1361: package ID "pcrexx".
                   1362: 
                   1363: For the packages that are not listed by their package ID, pkgsrc uses the
                   1364: pkgsrc-provided version if PREFER_PKGSRC contains the word "yes". Otherwise, if
                   1365: PREFER_NATIVE contains the word "yes", pkgsrc uses the native version. For
                   1366: example, to require using the pkgsrc-provided versions for all but the most
                   1367: basic bits on a NetBSD system, you can set:
                   1368: 
                   1369: PREFER_PKGSRC=  yes
                   1370: PREFER_NATIVE=  getopt skey tcp_wrappers
                   1371: 
                   1372: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
                   1373: it is simply ignored in that list.
                   1374: 
                   1375: PREFER_PKGSRC and PREFER_NATIVE should be set during bootstrap to ensure that
                   1376: the bootstrap process does not use inapropriate native tools as dependencies
                   1377: for core packages.
                   1378: 
                   1379: # ./bootstrap --prefer-pkgsrc yes --prefer-native openssl
                   1380: 
                   1381: Switching between settings globally at a later date can introduce complications
                   1382: with dependency resolution. This is caused by packages built with the opposite
                   1383: preference being installed alongside each other. Hence, when changing any of
                   1384: these variables after bootstrap, you need to rebuild all packages depending on
                   1385: those whose preference has been changed. This is not trivial and should be
                   1386: avoided.
                   1387: 
                   1388: When using pkgsrc on Linux systems, there is high risk of "leakage", where
                   1389: programs installed by pkgsrc may inadvertently use a command or library not
                   1390: installed by pkgsrc, e.g. those installed by yum or apt. Such foreign
                   1391: dependencies may be installed, removed, or upgraded to a version incompatible
                   1392: with the pkgsrc package at any time, causing pkgsrc packages to subsequently
                   1393: malfunction. Pkgsrc cannot prevent this, as it has no control over other
                   1394: package managers. Another potential problem is that under Redhat Enterprise and
                   1395: related Linux systems, yum packages are only patched and never upgraded, so
                   1396: eventually they may become too outdated for use by pkgsrc. Even intentionally
                   1397: using foreign dependencies, not considered leakage, can lead to these problems,
                   1398: so it is generally discouraged. In order to minimize such problems,
                   1399: PREFER_PKGSRC defaults to "yes" on Linux systems. This ensures that pkgsrc is
                   1400: aware of any changes to dependency packages and can rebuild or upgrade the
                   1401: entire dependency tree as needed. This default can be overridden by setting
                   1402: --prefer-pkgsrc to a list of packages and --prefer-native to "yes".
                   1403: 
                   1404: 6.4. Variables affecting the installation process
1.1       dsieger  1405: 
1.198     leot     1406:   * PKGSRC_KEEP_BIN_PKGS: By default, binary packages of built packages are
1.150     leot     1407:     preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1       dsieger  1408: 
1.107     jnemeth  1409: Packages have to support installation into a subdirectory of WRKDIR. This
                   1410: allows a package to be built, before the actual filesystem is touched. DESTDIR
                   1411: support exists in two variations:
1.4       rillig   1412: 
                   1413:   * Basic DESTDIR support means that the package installation and packaging is
                   1414:     still run as root.
                   1415: 
                   1416:   * Full DESTDIR support can run the complete build, installation and packaging
                   1417:     as normal user. Root privileges are only needed to add packages.
                   1418: 
                   1419: With basic DESTDIR support, make clean needs to be run as root.
                   1420: 
1.17      imil     1421: Considering the foo/bar package, DESTDIR full support can be tested using the
                   1422: following commands
                   1423: 
                   1424: $ id
                   1425: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
                   1426: $ mkdir $HOME/packages
                   1427: $ cd $PKGSRCDIR/foo/bar
                   1428: 
                   1429: Verify DESTDIR full support, no root privileges should be needed
                   1430: 
1.66      asau     1431: $ make stage-install
1.17      imil     1432: 
                   1433: Create a package without root privileges
                   1434: 
1.66      asau     1435: $ make PACKAGES=$HOME/packages package
1.17      imil     1436: 
                   1437: For the following command, you must be able to gain root privileges using su(1)
                   1438: 
1.66      asau     1439: $ make PACKAGES=$HOME/packages install
1.17      imil     1440: 
                   1441: Then, as a simple user
                   1442: 
                   1443: $ make clean
                   1444: 
1.241     rillig   1445: 6.5. Selecting and configuring the compiler
1.4       rillig   1446: 
1.241     rillig   1447: 6.5.1. Selecting the compiler
1.1       dsieger  1448: 
                   1449: By default, pkgsrc will use GCC to build packages. This may be overridden by
                   1450: setting the following variables in /etc/mk.conf:
                   1451: 
                   1452: PKGSRC_COMPILER:
                   1453: 
                   1454:     This is a list of values specifying the chain of compilers to invoke when
                   1455:     building packages. Valid values are:
                   1456: 
1.232     gutterid 1457:       o ccc: Compaq C Compilers (Tru64)
1.66      asau     1458: 
1.232     gutterid 1459:       o ccache: compiler cache (chainable)
1.66      asau     1460: 
1.232     gutterid 1461:       o clang: Clang C and Objective-C compiler
1.66      asau     1462: 
1.232     gutterid 1463:       o distcc: distributed C/C++ (chainable)
1.1       dsieger  1464: 
1.232     gutterid 1465:       o f2c: Fortran 77 to C compiler (chainable)
1.66      asau     1466: 
1.232     gutterid 1467:       o icc: Intel C++ Compiler (Linux)
1.66      asau     1468: 
1.232     gutterid 1469:       o ido: SGI IRIS Development Option cc (IRIX 5)
1.1       dsieger  1470: 
1.232     gutterid 1471:       o gcc: GNU C/C++ Compiler
1.1       dsieger  1472: 
1.232     gutterid 1473:       o hp: HP-UX C/aC++ compilers
1.66      asau     1474: 
1.232     gutterid 1475:       o mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1       dsieger  1476: 
1.232     gutterid 1477:       o mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1       dsieger  1478: 
1.232     gutterid 1479:       o sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1       dsieger  1480: 
1.232     gutterid 1481:       o xlc: IBM's XL C/C++ compiler suite
1.66      asau     1482: 
1.1       dsieger  1483:     The default is "gcc". You can use ccache and/or distcc with an appropriate
                   1484:     PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
                   1485:     terminated with a value for a real compiler. Note that only one real
                   1486:     compiler should be listed (e.g. "sunpro gcc" is not allowed).
                   1487: 
                   1488: GCC_REQD:
                   1489: 
                   1490:     This specifies the minimum version of GCC to use when building packages. If
                   1491:     the system GCC doesn't satisfy this requirement, then pkgsrc will build and
                   1492:     install one of the GCC packages to use instead.
                   1493: 
1.153     leot     1494: PYTHON_VERSION_DEFAULT:
1.114     maya     1495: 
                   1496:     Specifies which version of python to use when several options are
                   1497:     available.
                   1498: 
                   1499: PKGSRC_FORTRAN:
                   1500: 
1.176     gutterid 1501:     Specifies the Fortran compiler to use. The default is gfortran.
1.114     maya     1502: 
                   1503: GFORTRAN_VERSION:
                   1504: 
                   1505:     If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
                   1506:     use.
                   1507: 
1.241     rillig   1508: 6.5.2. Additional flags to the compiler (CFLAGS)
1.1       dsieger  1509: 
                   1510: If you wish to set the CFLAGS variable, please make sure to use the += operator
                   1511: instead of the = operator:
                   1512: 
                   1513: CFLAGS+=        -your -flags
                   1514: 
                   1515: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16      jnemeth  1516: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24      wiz      1517: package if you're interested in optimization specifically for the current CPU.
1.1       dsieger  1518: 
1.241     rillig   1519: 6.5.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1520: 
                   1521: If you want to pass flags to the linker, both in the configure step and the
                   1522: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
                   1523: difference between the two is that LIBS will be appended to the command line,
                   1524: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
                   1525: machines depending on the setting of USE_IMAKE or the inclusion of mk/
                   1526: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
                   1527: settings, use the += operator:
                   1528: 
                   1529: LDFLAGS+=        -your -linkerflags
                   1530: 
1.241     rillig   1531: 6.6. Developer/advanced settings
1.1       dsieger  1532: 
                   1533:   * PKG_DEVELOPER: Run some sanity checks that package developers want:
                   1534: 
1.42      asau     1535:       + make sure patches apply with zero fuzz
1.1       dsieger  1536: 
1.42      asau     1537:       + run check-shlibs to see that all binaries will find their shared libs.
1.1       dsieger  1538: 
1.232     gutterid 1539:   * CHECK_FILES_STRICT: Also check VARBASE and PKG_SYSCONFDIR values in PLIST
                   1540:     entries.
                   1541: 
1.1       dsieger  1542:   * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
                   1543:     making and installing the package. The default value for this is 0, which
                   1544:     will not display the commands as they are executed (normal, default, quiet
                   1545:     operation); the value 1 will display all shell commands before their
                   1546:     invocation, and the value 2 will display both the shell commands before
1.112     rillig   1547:     their invocation, as well as their actual execution progress with set -x.
1.1       dsieger  1548: 
1.241     rillig   1549: 6.7. Selecting Build Options
1.1       dsieger  1550: 
                   1551: Some packages have build time options, usually to select between different
                   1552: dependencies, enable optional support for big dependencies or enable
                   1553: experimental features.
                   1554: 
                   1555: To see which options, if any, a package supports, and which options are
                   1556: mutually exclusive, run make show-options, for example:
                   1557: 
                   1558:     The following options are supported by this package:
                   1559:         ssl      Enable SSL support.
                   1560:     Exactly one of the following gecko options is required:
                   1561:         firefox  Use firefox as gecko rendering engine.
                   1562:         mozilla  Use mozilla as gecko rendering engine.
                   1563:     At most one of the following database options may be selected:
                   1564:         mysql    Enable support for MySQL database.
                   1565:         pgsql    Enable support for PostgreSQL database.
                   1566: 
                   1567:     These options are enabled by default: firefox
                   1568:     These options are currently enabled: mozilla ssl
                   1569: 
1.4       rillig   1570: The following variables can be defined in mk.conf to select which options to
                   1571: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1       dsieger  1572: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
                   1573: which can be used to select or disable options specifically for package pkgbase
                   1574: . Options listed in these variables are selected, options preceded by "-" are
                   1575: disabled. A few examples:
                   1576: 
1.4       rillig   1577: $ grep "PKG.*OPTION" mk.conf
1.1       dsieger  1578: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   1579: PKG_OPTIONS.kdebase=    debug -sasl
                   1580: PKG_OPTIONS.apache=     suexec
                   1581: 
1.11      rillig   1582: It is important to note that options that were specifically suggested by the
1.19      snj      1583: package maintainer must be explicitly removed if you do not wish to include the
                   1584: option. If you are unsure you can view the current state with make show-options
                   1585: .
1.11      rillig   1586: 
1.1       dsieger  1587: The following settings are consulted in the order given, and the last setting
                   1588: that selects or disables an option is used:
                   1589: 
                   1590:  1. the default options as suggested by the package maintainer
                   1591: 
                   1592:  2. the options implied by the settings of legacy variables (see below)
                   1593: 
                   1594:  3. PKG_DEFAULT_OPTIONS
                   1595: 
                   1596:  4. PKG_OPTIONS.pkgbase
                   1597: 
                   1598: For groups of mutually exclusive options, the last option selected is used, all
                   1599: others are automatically disabled. If an option of the group is explicitly
                   1600: disabled, the previously selected option, if any, is used. It is an error if no
                   1601: option from a required group of options is selected, and building the package
                   1602: will fail.
                   1603: 
                   1604: Before the options framework was introduced, build options were selected by
1.4       rillig   1605: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
                   1606: transition to the options framework for the user, these legacy variables are
                   1607: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
                   1608: automatically. A warning is issued to prompt the user to update mk.conf to use
                   1609: the options framework directly. Support for the legacy variables will be
1.1       dsieger  1610: removed eventually.
                   1611: 
1.154     rillig   1612: Chapter 7. Creating binary packages
1.1       dsieger  1613: 
                   1614: Table of Contents
                   1615: 
1.154     rillig   1616: 7.1. Building a single binary package
                   1617: 7.2. Settings for creation of binary packages
1.1       dsieger  1618: 
1.154     rillig   1619: 7.1. Building a single binary package
1.1       dsieger  1620: 
                   1621: Once you have built and installed a package, you can create a binary package
                   1622: which can be installed on another system with pkg_add(1). This saves having to
                   1623: build the same package on a group of hosts and wasting CPU time. It also
                   1624: provides a simple means for others to install your package, should you
                   1625: distribute it.
                   1626: 
                   1627: To create a binary package, change into the appropriate directory in pkgsrc,
                   1628: and run make package:
                   1629: 
1.112     rillig   1630: $ cd misc/figlet
                   1631: $ make package
1.1       dsieger  1632: 
1.242     gutterid 1633: This will build your package (if not already done) and package it into a binary
                   1634: package. You can then use the pkg_* tools to manipulate it. Binary packages are
                   1635: created in PACKAGES, which defaults to /usr/pkgsrc/packages, in the form of a
                   1636: compressed tar file. See Section C.2, "Packaging figlet" for a continuation of
                   1637: the above misc/figlet example.
1.1       dsieger  1638: 
1.154     rillig   1639: See Chapter 23, Submitting and Committing for information on how to submit such
1.1       dsieger  1640: a binary package.
                   1641: 
1.154     rillig   1642: 7.2. Settings for creation of binary packages
1.1       dsieger  1643: 
1.184     rillig   1644: See Section 13.17, "Other helpful targets".
1.6       rillig   1645: 
1.154     rillig   1646: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig   1647: 
                   1648: Table of Contents
                   1649: 
1.154     rillig   1650: 8.1. Preparations
1.180     rillig   1651: 8.2. Running a bulk build
1.154     rillig   1652:     8.2.1. Configuration
                   1653: 8.3. Requirements of a full bulk build
1.178     rillig   1654: 8.4. Bulk build variants
1.179     rillig   1655:     8.4.1. Detect unknown configure options
                   1656:     8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig   1657:     8.4.3. Force compiler options only in the build phase
                   1658:     8.4.4. Use custom directories
                   1659:     8.4.5. Turn warnings into errors
                   1660:     8.4.6. Reject packages for which pkglint reports errors
                   1661:     8.4.7. Reject packages that contain forbidden strings
                   1662:     8.4.8. Reject packages whose self-test fails
                   1663:     8.4.9. Reject packages that use undefined shell variables
                   1664:     8.4.10. Turn off verbose logging
1.178     rillig   1665: 8.5. Creating a multiple CD-ROM packages collection
                   1666:     8.5.1. Example of cdpack
1.6       rillig   1667: 
1.175     gutterid 1668: For a number of reasons, you may want to build binary packages for a large
                   1669: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71      wiz      1670: instance, when you have multiple machines that should run the same software, it
                   1671: is wasted time if they all build their packages themselves from source. Or you
                   1672: may want to build a list of packages you want and check them before deploying
1.175     gutterid 1673: onto production systems. There is a way of getting a set of binary packages:
                   1674: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
                   1675: describes how to set it up.
1.71      wiz      1676: 
1.154     rillig   1677: 8.1. Preparations
1.71      wiz      1678: 
                   1679: First of all, you have to decide whether you build all packages or a limited
                   1680: set of them. Full bulk builds usually consume a lot more resources, both space
1.175     gutterid 1681: and time, than builds for some practical sets of packages. A number of
                   1682: particularly heavy packages exist that are not actually interesting to a wide
                   1683: audience. (The approximate resource consumption for a full bulk build is given
                   1684: in section Section 8.3, "Requirements of a full bulk build".) For limited bulk
                   1685: builds you need to make a list of packages you want to build. Note that all
                   1686: their dependencies will be built, so you don't need to track them manually.
1.71      wiz      1687: 
                   1688: During bulk builds various packages are installed and deinstalled in /usr/pkg
                   1689: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112     rillig   1690: the builds. Essentially, you should provide a fresh system, either a chroot
1.71      wiz      1691: environment or something even more restrictive, depending on what the operating
                   1692: system provides, or dedicate the whole physical machine. As a useful side
                   1693: effect this makes sure that bulk builds cannot break anything in your system.
                   1694: There have been numerous cases where certain packages tried to install files
                   1695: outside the LOCALBASE or wanted to edit some files in /etc.
1.6       rillig   1696: 
1.180     rillig   1697: 8.2. Running a bulk build
1.6       rillig   1698: 
1.180     rillig   1699: Running a bulk build works roughly as follows:
1.15      rillig   1700: 
                   1701:   * First, build the pbulk infrastructure in a fresh pkgsrc location.
                   1702: 
                   1703:   * Then, build each of the packages from a clean installation directory using
                   1704:     the infrastructure.
                   1705: 
1.154     rillig   1706: 8.2.1. Configuration
1.6       rillig   1707: 
1.112     rillig   1708: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6       rillig   1709: 
1.68      asau     1710: In order to use it, prepare a clear system (real one, chroot environment, jail,
                   1711: zone, virtual machine). Configure network access to fetch distribution files.
1.112     rillig   1712: Create a user with name "pbulk".
1.68      asau     1713: 
                   1714: Fetch and extract pkgsrc. Use a command like one of these:
                   1715: 
1.151     sevan    1716: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
                   1717: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72      wiz      1718: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68      asau     1719: 
                   1720: Or any other way that fits (e.g., curl, wget).
                   1721: 
                   1722: Deploy and configure pbulk tools, e.g.:
                   1723: 
1.118     sevan    1724: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68      asau     1725: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
                   1726: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
                   1727: 
                   1728: Note
                   1729: 
                   1730: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
                   1731: to packages you build. For instance,
                   1732: 
1.112     rillig   1733: PKG_DEVELOPER=          yes     # perform more checks
                   1734: X11_TYPE=               modular # use pkgsrc X11
                   1735: SKIP_LICENSE_CHECK=     yes     # accept all licences (useful
                   1736:                                 # when building all packages)
1.68      asau     1737: 
                   1738: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112     rillig   1739: with your list of packages, one per line without empty lines or comments. E.g.:
1.68      asau     1740: 
                   1741: www/firefox
                   1742: mail/thunderbird
                   1743: misc/libreoffice4
                   1744: 
1.69      asau     1745: At this point you can also review configuration in /usr/pbulk/etc and make
                   1746: final amendments, if wanted.
                   1747: 
1.68      asau     1748: Start it:
                   1749: 
                   1750: # /usr/pbulk/bin/bulkbuild
                   1751: 
                   1752: After it finishes, you'll have /mnt filled with distribution files, binary
                   1753: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
                   1754: 
                   1755: Note
                   1756: 
                   1757: The pbulk.sh script does not cover all possible use cases. While being ready to
                   1758: run, it serves as a good starting point to understand and build more complex
                   1759: setups. The script is kept small enough for better understanding.
                   1760: 
                   1761: Note
                   1762: 
                   1763: The pbulk.sh script supports running unprivileged bulk build and helps
1.205     wiz      1764: configuring distributed bulk builds. Distributed bulk builds support either
                   1765: building in worker chroots (each node is a path to a different chroot) that
                   1766: replicate the target system, including the pbulk prefix, or remote machines
                   1767: (each node is an IP address that must be accessible over SSH without a
                   1768: password).
1.15      rillig   1769: 
1.154     rillig   1770: 8.3. Requirements of a full bulk build
1.71      wiz      1771: 
                   1772: A complete bulk build requires lots of disk space. Some of the disk space can
                   1773: be read-only, some other must be writable. Some can be on remote filesystems
                   1774: (such as NFS) and some should be local. Some can be temporary filesystems,
                   1775: others must survive a sudden reboot.
                   1776: 
1.205     wiz      1777:   * 70 GB for the distfiles (read-write, remote, temporary)
1.71      wiz      1778: 
1.205     wiz      1779:   * 60 GB for the binary packages (read-write, remote, permanent)
1.71      wiz      1780: 
                   1781:   * 1 GB for the pkgsrc tree (read-only, remote, permanent)
                   1782: 
                   1783:   * 5 GB for LOCALBASE (read-write, local, temporary)
                   1784: 
                   1785:   * 10 GB for the log files (read-write, remote, permanent)
                   1786: 
                   1787:   * 5 GB for temporary files (read-write, local, temporary)
                   1788: 
1.178     rillig   1789: 8.4. Bulk build variants
                   1790: 
                   1791: To ensure that pkgsrc packages work in different configurations, it makes sense
                   1792: to run non-default bulk builds from time to time. This section lists some ideas
                   1793: for bulk builds that intentionally let packages fail if they don't follow the
                   1794: pkgsrc style.
                   1795: 
1.179     rillig   1796: 8.4.1. Detect unknown configure options
1.178     rillig   1797: 
                   1798: Add the following line to mk.conf.
                   1799: 
                   1800: GNU_CONFIGURE_STRICT=   yes
                   1801: 
                   1802: When a package fails this additional check, the most common cause is that the
                   1803: configure option was valid for an older version of the package but does not
                   1804: apply anymore. In that case, just remove it.
                   1805: 
1.179     rillig   1806: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.178     rillig   1807: 
                   1808: The job of a compiler is not restricted to producing executable code, most
1.179     rillig   1809: compilers also detect typical programming mistakes. The pkgsrc compiler
                   1810: wrappers make it easy to force compiler options when the package is built. This
                   1811: can be used to find typical bugs across all packages that are in pkgsrc. By
                   1812: reporting these bugs upstream, the packages will be more reliable with the next
                   1813: updates.
1.178     rillig   1814: 
1.179     rillig   1815: Add some of the following lines to mk.conf:
1.178     rillig   1816: 
                   1817: CFLAGS+=        -Werror=char-subscripts
1.179     rillig   1818: CFLAGS+=        -Werror=implicit-function-declaration
1.178     rillig   1819: 
1.179     rillig   1820: When a package fails to build using these stricter compiler options, document
                   1821: the circumstances in which the compiler produced the error message. This
                   1822: includes:
1.178     rillig   1823: 
                   1824:   * The platform (MACHINE_PLATFORM)
                   1825: 
                   1826:   * The source file
                   1827: 
                   1828:   * An excerpt of the code. GCC and Clang already do this as part of the
                   1829:     diagnostic.
                   1830: 
1.179     rillig   1831:   * The exact error message from the compiler.
1.178     rillig   1832: 
1.179     rillig   1833: If a package produces these error messages, but the package is fine, record
                   1834: this in your local mk.conf, like this, to skip this check in the next builds:
1.178     rillig   1835: 
1.179     rillig   1836: .if ${PKGPATH} == category/package
1.178     rillig   1837: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
                   1838: # error message
                   1839: # code
1.179     rillig   1840: # Reason why the code does not need to be fixed.
1.178     rillig   1841: BUILDLINK_TRANSFORM+=   rm:-Werror=char-subscripts
1.179     rillig   1842: .endif
1.178     rillig   1843: 
                   1844: If the error messages from the compiler are valid and the code needs to be
1.179     rillig   1845: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
                   1846: upstream authors of the package, providing them with the information you
                   1847: collected above.
1.178     rillig   1848: 
1.179     rillig   1849: Patches that are not essential for the package to work should only be reported
                   1850: upstream but not committed to pkgsrc, to make future updates easier.
                   1851: 
1.181     rillig   1852: 8.4.3. Force compiler options only in the build phase
                   1853: 
                   1854: When adding custom compiler flags via CFLAGS, these apply to all phases of the
                   1855: package build process. Especially in the configure phase, adding -Werror leads
                   1856: to wrong decisions. The GNU configure scripts feed many small test programs to
                   1857: the C compiler to see whether certain headers are available, functions are
                   1858: defined in a library and programs can be run. In many cases these programs
                   1859: would not survive a strict compiler run with -Wall -Wextra -Werror.
                   1860: 
                   1861: The pkgsrc infrastructure is flexible enough to support compiler options being
                   1862: added between the configure and build phases. It's a little more complicated
                   1863: than the other examples in this section but still easy enough.
                   1864: 
                   1865: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
                   1866: compiler options. The compiler wrapper's original task is to hide unwanted
                   1867: directories of include files and to normalize compiler options. It does this by
                   1868: wrapping the compiler command and rewriting the command line. To see this in
                   1869: action, run bmake patch in a package directory and examine the work/.cwrappers/
                   1870: config directory. It contains individual configurations for the C compiler and
                   1871: the related tools. The plan is to find a hook between the configure and build
                   1872: phases, and to modify these configuration files at that point.
                   1873: 
                   1874: To find this hook, have a look at mk/build/build.mk, which contains among
                   1875: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
                   1876: pre-build-hook sounds good enough.
                   1877: 
                   1878: The code to be included in mk.conf is:
                   1879: 
                   1880: # Just a few example options.
                   1881: BUILD_ONLY_CFLAGS=      -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
                   1882: 
                   1883: .if ${BUILD_ONLY_CFLAGS:U:M*}
                   1884: pre-build-checks-hook: add-build-only-cflags
                   1885: 
                   1886: add-build-only-cflags: .PHONY
                   1887:         ${RUN} cd ${CWRAPPERS_CONFIG_DIR};      \
                   1888:         ${TEST} ! -f ${.TARGET} || exit 0;      \
                   1889:         for flag in ${BUILD_ONLY_CFLAGS}; do    \
                   1890:                 ${ECHO} "append=$$flag" >> cc;  \
                   1891:         done;                                   \
                   1892:         > ${.TARGET}
                   1893: .endif
                   1894: 
                   1895: (When editing the mk.conf, make sure that the commands of the
                   1896: add-build-only-cflags target are indented with a tab, not with spaces.)
                   1897: 
                   1898: The condition in the .if statement contains the :U modifier to prevent parse
                   1899: errors if the variable should be undefined, possibly because it is only defined
                   1900: for a subset of the packages. The :M* modifier ensures that there is at least
                   1901: one compiler option, to prevent a syntax error in the shell parser.
                   1902: 
                   1903: The code around the ${.TARGET} variable ensures that the additional compiler
                   1904: options are only appended once, even if bmake build is run multiple times. To
                   1905: do this, it creates a marker file.
                   1906: 
                   1907: To verify that this setup works, run bmake configure in a package directory. Up
                   1908: to now, everything works as usual. Examine the directory work/.cwrappers/config
                   1909: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
                   1910: the file cc. Examine the tail of the work/.work.log file to see that the normal
                   1911: compiler options are used.
                   1912: 
                   1913: Now run bmake build. This will append the options to the file cc and will
                   1914: create the marker file in the same directory. After that, the build starts as
                   1915: usual, but with the added compiler options. Examine the tail of the file work
                   1916: /.work.log to see that the lines starting with [*] don't contain the compiler
                   1917: options, but the corresponding lines starting with <.> do end with these
                   1918: options.
                   1919: 
                   1920: Building packages using this setup variant and fixing the resulting bugs is the
                   1921: same as in Section 8.4.2, "Detect classes of bugs by forcing compiler warnings"
                   1922: .
                   1923: 
                   1924: 8.4.4. Use custom directories
1.178     rillig   1925: 
                   1926: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
                   1927: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
                   1928: afterwards in mk.conf.
                   1929: 
                   1930: PREFIX=         /a-random-uuid
                   1931: PKG_SYSCONFDIR= /a-random-uuid
                   1932: VARBASE=        /a-random-uuid
                   1933: PKGMANDIR=      a-random-uuid
                   1934: PKG_INFODIR=    a-random-uuid
                   1935: 
1.181     rillig   1936: 8.4.5. Turn warnings into errors
1.178     rillig   1937: 
                   1938: When building a package, warnings are typically ignored since they just flow by
                   1939: and do not cause the build to fail immediately. To find these warnings,
                   1940: redefine them to errors in mk.conf.
                   1941: 
                   1942: DELAYED_WARNING_MSG=    ${DELAYED_ERROR_MSG} "(was warning)"
                   1943: WARNING_MSG=            ${FAIL_MSG} "(was warning)"
                   1944: 
                   1945: (There are many more classes of warnings in pkgsrc, and most of them can be
                   1946: redefined with a simple definition like above.
                   1947: 
1.179     rillig   1948: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178     rillig   1949: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
                   1950: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
                   1951: 
1.181     rillig   1952: 8.4.6. Reject packages for which pkglint reports errors
1.178     rillig   1953: 
                   1954: Using pkglint as part of the regular build process is mostly a waste of time.
                   1955: If you want to fix some of the warnings, just run pkglint recursively on the
                   1956: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
                   1957: faster than a complete bulk build.
                   1958: 
1.181     rillig   1959: 8.4.7. Reject packages that contain forbidden strings
1.178     rillig   1960: 
                   1961: To ensure that the binary packages don't contain references to the build
                   1962: directory, there is already CHECK_WRKREF. If that variable includes the item
                   1963: extra, it is possible to define additional patterns that must not appear in any
                   1964: installed file. This is specified in mk.conf.
                   1965: 
                   1966: CHECK_WRKREF=                   extra
                   1967: CHECK_WRKREF_EXTRA_DIRS+=       /usr/local
                   1968: CHECK_WRKREF_EXTRA_DIRS+=       /usr/pkg
                   1969: CHECK_WRKREF_EXTRA_DIRS+=       @[A-Z][A-Z]*@
                   1970: 
                   1971: The above patterns will probably generate many false positives, therefore the
                   1972: results need to be taken with a grain of salt.
                   1973: 
1.181     rillig   1974: 8.4.8. Reject packages whose self-test fails
1.178     rillig   1975: 
                   1976: To run the test suites that come with each package, add this line to mk.conf.
                   1977: 
                   1978: PKGSRC_RUN_TEST=        yes
                   1979: 
                   1980: Be prepared that even the most basic packages fail this test. When doing a bulk
                   1981: build with this, it will often abort in the early phase where the packages are
                   1982: scanned for their dependencies since there are cyclic dependencies. There is
                   1983: still a lot to do in this area.
                   1984: 
1.181     rillig   1985: 8.4.9. Reject packages that use undefined shell variables
1.178     rillig   1986: 
                   1987: To catch typos in the shell snippets from the Makefile fragments, add the -u
                   1988: flag to most of the commands by adding this line to mk.conf.
                   1989: 
                   1990: RUN=    @set -eu;
                   1991: 
1.181     rillig   1992: After that, ensure that none of the bulk build log files (even those for
                   1993: successfully built packages) contains the string parameter not set or whatever
                   1994: error message the command sh -ceu '$undefined' outputs.
                   1995: 
1.178     rillig   1996: See mk/misc/common.mk for the existing definition.
                   1997: 
1.181     rillig   1998: 8.4.10. Turn off verbose logging
1.178     rillig   1999: 
                   2000: The build logs of a package are often quite long. This allows error messages or
                   2001: other interesting details to hide between the noise. To make the actual error
                   2002: message stand out more, add these lines to mk.conf.
                   2003: 
                   2004: GNU_CONFIGURE_QUIET=    yes
                   2005: MAKE_FLAGS+=            -s
                   2006: 
                   2007: The -s option works for both GNU Make and BSD Make. On exotic platforms with
                   2008: their own make, it may be a little different.
                   2009: 
                   2010: 8.5. Creating a multiple CD-ROM packages collection
1.1       dsieger  2011: 
                   2012: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
                   2013: of the resulting binary packages to assist in installing packages on other
                   2014: machines. The pkgtools/cdpack package provides a simple tool for creating the
                   2015: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
                   2016: keeps all the dependencies for a given package on the same CD as that package.
                   2017: 
1.178     rillig   2018: 8.5.1. Example of cdpack
1.1       dsieger  2019: 
                   2020: Complete documentation for cdpack is found in the cdpack(1) man page. The
                   2021: following short example assumes that the binary packages are left in /usr/
                   2022: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
                   2023: ISO 9660 images.
                   2024: 
                   2025: # mkdir /u2/images
                   2026: # pkg_add /usr/pkgsrc/packages/All/cdpack
                   2027: # cdpack /usr/pkgsrc/packages/All /u2/images
                   2028: 
                   2029: 
                   2030: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
                   2031: CD in the collection, then you need to create a directory which contains these
1.175     gutterid 2032: files, e.g.:
1.1       dsieger  2033: 
                   2034: # mkdir /tmp/common
                   2035: # echo "This is a README" > /tmp/common/README
                   2036: # echo "Another file" > /tmp/common/COPYING
                   2037: # mkdir /tmp/common/bin
                   2038: # echo "#!/bin/sh" > /tmp/common/bin/myscript
                   2039: # echo "echo Hello world" >> /tmp/common/bin/myscript
                   2040: # chmod 755 /tmp/common/bin/myscript
                   2041: 
                   2042: 
                   2043: Now create the images:
                   2044: 
                   2045: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
                   2046: 
                   2047: Each image will contain README, COPYING, and bin/myscript in their root
                   2048: directories.
                   2049: 
1.154     rillig   2050: Chapter 9. Directory layout of the installed files
1.1       dsieger  2051: 
                   2052: Table of Contents
                   2053: 
1.154     rillig   2054: 9.1. File system layout in ${LOCALBASE}
                   2055: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2056: 
                   2057: The files that are installed by pkgsrc are organized in a way that is similar
                   2058: to what you find in the /usr directory of the base system. But some details are
                   2059: different. This is because pkgsrc initially came from FreeBSD and had adopted
                   2060: its file system hierarchy. Later it was largely influenced by NetBSD. But no
                   2061: matter which operating system you are using pkgsrc with, you can expect the
                   2062: same layout for pkgsrc.
                   2063: 
                   2064: There are mainly four root directories for pkgsrc, which are all configurable
                   2065: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
                   2066: default locations are:
                   2067: 
                   2068: LOCALBASE=              /usr/pkg
                   2069: PKG_SYSCONFBASE=        /usr/pkg/etc
                   2070: VARBASE=                /var
1.119     sevan    2071: PKG_DBDIR=              /usr/pkg/pkgdb
1.1       dsieger  2072: 
                   2073: In unprivileged mode (when pkgsrc has been installed as any other user), the
                   2074: default locations are:
                   2075: 
                   2076: LOCALBASE=              ${HOME}/pkg
                   2077: PKG_SYSCONFBASE=        ${HOME}/pkg/etc
                   2078: VARBASE=                ${HOME}/pkg/var
1.119     sevan    2079: PKG_DBDIR=              ${HOME}/pkg/pkgdb
1.1       dsieger  2080: 
                   2081: What these four directories are for, and what they look like is explained
                   2082: below.
                   2083: 
1.25      wiz      2084:   * LOCALBASE corresponds to the /usr directory in the base system. It is the "
                   2085:     main" directory where the files are installed and contains the well-known
1.1       dsieger  2086:     subdirectories like bin, include, lib, share and sbin.
                   2087: 
                   2088:   * VARBASE corresponds to /var in the base system. Some programs (especially
                   2089:     games, network daemons) need write access to it during normal operation.
                   2090: 
                   2091:   * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
                   2092:     configuration files of the packages, as well as pkgsrc's mk.conf itself.
                   2093: 
1.154     rillig   2094: 9.1. File system layout in ${LOCALBASE}
1.1       dsieger  2095: 
                   2096: The following directories exist in a typical pkgsrc installation in $
                   2097: {LOCALBASE}.
                   2098: 
                   2099: bin
                   2100: 
                   2101:     Contains executable programs that are intended to be directly used by the
                   2102:     end user.
                   2103: 
                   2104: emul
                   2105: 
                   2106:     Contains files for the emulation layers of various other operating systems,
                   2107:     especially for NetBSD.
                   2108: 
                   2109: etc (the usual location of ${PKG_SYSCONFDIR})
                   2110: 
                   2111:     Contains the configuration files.
                   2112: 
                   2113: include
                   2114: 
                   2115:     Contains headers for the C and C++ programming languages.
                   2116: 
                   2117: info
                   2118: 
                   2119:     Contains GNU info files of various packages.
                   2120: 
                   2121: lib
                   2122: 
                   2123:     Contains shared and static libraries.
                   2124: 
                   2125: libdata
                   2126: 
                   2127:     Contains data files that don't change after installation. Other data files
                   2128:     belong into ${VARBASE}.
                   2129: 
                   2130: libexec
                   2131: 
                   2132:     Contains programs that are not intended to be used by end users, such as
                   2133:     helper programs or network daemons.
                   2134: 
                   2135: libexec/cgi-bin
                   2136: 
                   2137:     Contains programs that are intended to be executed as CGI scripts by a web
                   2138:     server.
                   2139: 
                   2140: man (the usual value of ${PKGMANDIR})
                   2141: 
                   2142:     Contains brief documentation in form of manual pages.
                   2143: 
                   2144: sbin
                   2145: 
                   2146:     Contains programs that are intended to be used only by the super-user.
                   2147: 
                   2148: share
                   2149: 
                   2150:     Contains platform-independent data files that don't change after
                   2151:     installation.
                   2152: 
                   2153: share/doc
                   2154: 
                   2155:     Contains documentation files provided by the packages.
                   2156: 
                   2157: share/examples
                   2158: 
                   2159:     Contains example files provided by the packages. Among others, the original
                   2160:     configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
                   2161:     installation.
                   2162: 
                   2163: share/examples/rc.d
                   2164: 
                   2165:     Contains the original files for rc.d scripts.
                   2166: 
                   2167: var (the usual location of ${VARBASE})
                   2168: 
                   2169:     Contains files that may be modified after installation.
                   2170: 
1.154     rillig   2171: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2172: 
                   2173: db/pkg (the usual location of ${PKG_DBDIR})
                   2174: 
                   2175:     Contains information about the currently installed packages.
                   2176: 
                   2177: games
                   2178: 
                   2179:     Contains highscore files.
                   2180: 
                   2181: log
                   2182: 
                   2183:     Contains log files.
                   2184: 
                   2185: run
                   2186: 
                   2187:     Contains informational files about daemons that are currently running.
                   2188: 
1.154     rillig   2189: Chapter 10. Frequently Asked Questions
1.1       dsieger  2190: 
                   2191: Table of Contents
                   2192: 
1.154     rillig   2193: 10.1. Are there any mailing lists for pkg-related discussion?
                   2194: 10.2. Utilities for package management (pkgtools)
                   2195: 10.3. How to use pkgsrc as non-root
                   2196: 10.4. How to resume transfers when fetching distfiles?
                   2197: 10.5. How can I install/use modular X.org from pkgsrc?
                   2198: 10.6. How to fetch files from behind a firewall
                   2199: 10.7. How to fetch files from HTTPS sites
                   2200: 10.8. How do I tell make fetch to do passive FTP?
                   2201: 10.9. How to fetch all distfiles at once
                   2202: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                   2203: 10.11. What does "Could not find bsd.own.mk" mean?
1.221     nia      2204: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154     rillig   2205: 10.13. How do I change the location of configuration files?
                   2206: 10.14. Automated security checks
                   2207: 10.15. Why do some packages ignore my CFLAGS?
                   2208: 10.16. A package does not build. What shall I do?
                   2209: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.232     gutterid 2210: conflicts" mean?
1.1       dsieger  2211: 
                   2212: This section contains hints, tips & tricks on special things in pkgsrc that we
                   2213: didn't find a better place for in the previous chapters, and it contains items
                   2214: for both pkgsrc users and developers.
                   2215: 
1.154     rillig   2216: 10.1. Are there any mailing lists for pkg-related discussion?
1.1       dsieger  2217: 
                   2218: The following mailing lists may be of interest to pkgsrc users:
                   2219: 
                   2220:   * pkgsrc-users: This is a general purpose list for most issues regarding
                   2221:     pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
                   2222:     configuration, unexpected build failures, using particular packages,
                   2223:     upgrading pkgsrc installations, questions regarding the pkgsrc release
                   2224:     branches, etc. General announcements or proposals for changes that impact
                   2225:     the pkgsrc user community, e.g. major infrastructure changes, new features,
                   2226:     package removals, etc., may also be posted.
                   2227: 
                   2228:   * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
                   2229:     discussed.
                   2230: 
                   2231:   * pkgsrc-changes: This list is for those who are interested in getting a
                   2232:     commit message for every change committed to pkgsrc. It is also available
                   2233:     in digest form, meaning one daily message containing all commit messages
                   2234:     for changes to the package source tree in that 24 hour period.
                   2235: 
                   2236: To subscribe, do:
                   2237: 
                   2238: % echo subscribe listname | mail majordomo@NetBSD.org
                   2239: 
1.174     leot     2240: Archives for all these mailing lists are available from https://
1.1       dsieger  2241: mail-index.NetBSD.org/.
                   2242: 
1.154     rillig   2243: 10.2. Utilities for package management (pkgtools)
1.1       dsieger  2244: 
                   2245: The directory pkgsrc/pkgtools contains a number of useful utilities for both
                   2246: users and developers of pkgsrc. This section attempts only to make the reader
1.121     sevan    2247: aware of some of the utilities and when they might be useful, and not to
                   2248: duplicate the documentation that comes with each package.
1.1       dsieger  2249: 
                   2250: Utilities used by pkgsrc (automatically installed when needed):
                   2251: 
                   2252:   * pkgtools/x11-links: Symlinks for use by buildlink.
                   2253: 
                   2254: OS tool augmentation (automatically installed when needed):
                   2255: 
1.121     sevan    2256:   * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1       dsieger  2257: 
                   2258:   * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
                   2259: 
                   2260:   * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
                   2261: 
                   2262:   * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
                   2263:     for use on operating systems where pkg_install is not present.
                   2264: 
                   2265: Utilities used by pkgsrc (not automatically installed):
                   2266: 
                   2267:   * pkgtools/pkg_tarup: Create a binary package from an already-installed
                   2268:     package. Used by make replace to save the old package.
                   2269: 
                   2270:   * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
                   2271:     distfiles from multiple locations. It currently supports the following
                   2272:     methods: multiple CD-ROMs and network FTP/HTTP connections.
                   2273: 
                   2274:   * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24      wiz      2275:     current CPU and compiler.
1.1       dsieger  2276: 
                   2277: Utilities for keeping track of installed packages, being up to date, etc:
                   2278: 
1.65      wiz      2279:   * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
                   2280:     and upgrade binary packages easily.
                   2281: 
1.1       dsieger  2282:   * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
                   2283:     the latest pkgsrc entries.
                   2284: 
                   2285:   * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
                   2286:     strategy for updating.
                   2287: 
                   2288:   * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
                   2289:     graphviz).
                   2290: 
1.12      weinem   2291:   * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
                   2292: 
                   2293:   * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
                   2294:     complete pkgsrc system.
1.1       dsieger  2295: 
                   2296:   * pkgtools/pkgsurvey: Report what packages you have installed.
                   2297: 
                   2298: Utilities for people maintaining or creating individual packages:
                   2299: 
                   2300:   * pkgtools/pkgdiff: Automate making and maintaining patches for a package
                   2301:     (includes pkgdiff, pkgvi, mkpatches, etc.).
                   2302: 
1.65      wiz      2303:   * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1       dsieger  2304: 
                   2305: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
                   2306: 
                   2307:   * pkgtools/pkg_comp: Build packages in a chrooted area.
                   2308: 
                   2309:   * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
                   2310: 
1.154     rillig   2311: 10.3. How to use pkgsrc as non-root
1.1       dsieger  2312: 
1.108     rillig   2313: To install packages from source as a non-root user, download pkgsrc as
1.154     rillig   2314: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108     rillig   2315: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
                   2316: 
                   2317: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
                   2318: configuration mk.conf into ~/pkg/etc.
                   2319: 
                   2320: For more details, see mk/unprivileged.mk.
1.1       dsieger  2321: 
1.154     rillig   2322: 10.4. How to resume transfers when fetching distfiles?
1.1       dsieger  2323: 
                   2324: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4       rillig   2325: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
                   2326: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1       dsieger  2327: 
1.61      wiz      2328: You can also use a different program than the platform default program by
                   2329: changing the FETCH_USING variable. You can specify the program by using of ftp,
                   2330: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
                   2331: manual. A value of custom disables the system defaults and dependency tracking
                   2332: for the fetch program. In that case you have to provide FETCH_CMD,
                   2333: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1       dsieger  2334: 
1.16      jnemeth  2335: For example, if you want to use wget to download, you'll have to use something
                   2336: like:
1.1       dsieger  2337: 
1.16      jnemeth  2338: FETCH_USING=    wget
1.1       dsieger  2339: 
1.154     rillig   2340: 10.5. How can I install/use modular X.org from pkgsrc?
1.1       dsieger  2341: 
1.4       rillig   2342: If you want to use modular X.org from pkgsrc instead of your system's own X11
                   2343: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1       dsieger  2344: mk.conf:
                   2345: 
1.4       rillig   2346: X11_TYPE=modular
1.1       dsieger  2347: 
1.154     rillig   2348: 10.6. How to fetch files from behind a firewall
1.1       dsieger  2349: 
                   2350: If you are sitting behind a firewall which does not allow direct connections to
                   2351: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
                   2352: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
                   2353: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
                   2354: the proxy port number. So the proxy environment variables are:
                   2355: 
                   2356: ftp_proxy=ftp://orpheus.amdahl.com:80/
                   2357: http_proxy=http://orpheus.amdahl.com:80/
                   2358: 
1.154     rillig   2359: 10.7. How to fetch files from HTTPS sites
1.65      wiz      2360: 
                   2361: Some fetch tools are not prepared to support HTTPS by default (for example, the
                   2362: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
                   2363: openssl dependency that low in the dependency graph).
                   2364: 
                   2365: Usually you won't notice, because distribution files are mirrored weekly to "
                   2366: ftp.NetBSD.org", but that might not be often enough if you are following
                   2367: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
                   2368: "wget", which are both compiled with HTTPS support by default. Of course, these
                   2369: tools need to be installed before you can use them this way.
                   2370: 
1.154     rillig   2371: 10.8. How do I tell make fetch to do passive FTP?
1.1       dsieger  2372: 
                   2373: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
                   2374: FETCH_CMD is assigned the first available command from the following list:
                   2375: 
                   2376:   * ${LOCALBASE}/bin/ftp
                   2377: 
                   2378:   * /usr/bin/ftp
                   2379: 
                   2380: On a default NetBSD installation, this will be /usr/bin/ftp, which
                   2381: automatically tries passive connections first, and falls back to active
                   2382: connections if the server refuses to do passive. For the other tools, add the
1.4       rillig   2383: following to your mk.conf file: PASSIVE_FETCH=1.
1.1       dsieger  2384: 
                   2385: Having that option present will prevent /usr/bin/ftp from falling back to
                   2386: active transfers.
                   2387: 
1.154     rillig   2388: 10.9. How to fetch all distfiles at once
1.1       dsieger  2389: 
                   2390: You would like to download all the distfiles in a single batch from work or
                   2391: university, where you can't run a make fetch. There is an archive of distfiles
                   2392: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
                   2393: 
                   2394: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
                   2395: subdirectories, carry the resulting list to your machine at work/school and use
                   2396: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
                   2397: don't forget to set FETCH_CMD to something that fetches a URL:
                   2398: 
                   2399: At home:
                   2400: 
                   2401: % cd /usr/pkgsrc
                   2402: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
                   2403: % scp /tmp/fetch.sh work:/tmp
                   2404: 
                   2405: At work:
                   2406: 
                   2407: % sh /tmp/fetch.sh
                   2408: 
                   2409: then tar up /tmp/distfiles and take it home.
                   2410: 
                   2411: If you have a machine running NetBSD, and you want to get all distfiles (even
                   2412: ones that aren't for your machine architecture), you can do so by using the
                   2413: above-mentioned make fetch-list approach, or fetch the distfiles directly by
                   2414: running:
                   2415: 
                   2416: % make mirror-distfiles
                   2417: 
                   2418: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
                   2419: everything by running:
                   2420: 
                   2421: % make fetch NO_SKIP=yes
                   2422: 
1.154     rillig   2423: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1       dsieger  2424: 
                   2425: When compiling the pkgtools/pkg_install package, you get the error from make
                   2426: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
                   2427: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
                   2428: distribution on your machine. It is recommended to do that to format man pages.
                   2429: 
                   2430: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4       rillig   2431: NOMAN=YES either in the environment or in mk.conf.
1.1       dsieger  2432: 
1.154     rillig   2433: 10.11. What does "Could not find bsd.own.mk" mean?
1.1       dsieger  2434: 
                   2435: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
                   2436: machine. Please get and install it, by extracting it in /:
                   2437: 
                   2438: # cd /
                   2439: # tar --unlink -zxvpf .../comp.tgz
                   2440: 
                   2441: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
                   2442: release (determine via uname -r).
                   2443: 
1.221     nia      2444: 10.12. Using 'sudo' or `priv` with pkgsrc
1.1       dsieger  2445: 
                   2446: When installing packages as non-root user and using the just-in-time su(1)
                   2447: feature of pkgsrc, it can become annoying to type in the root password for each
                   2448: required package installed. To avoid this, the sudo package can be used, which
1.221     nia      2449: does password caching over a limited time. To use it, install sudo or priv
                   2450: (either as binary package, from security/priv, or security/sudo) and then put
                   2451: the following into your mk.conf, somewhere after the definition of the
                   2452: LOCALBASE variable:
1.1       dsieger  2453: 
                   2454: .if exists(${LOCALBASE}/bin/sudo)
                   2455: SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   2456: .endif
                   2457: 
1.154     rillig   2458: 10.13. How do I change the location of configuration files?
1.1       dsieger  2459: 
                   2460: As the system administrator, you can choose where configuration files are
                   2461: installed. The default settings make all these files go into ${PREFIX}/etc or
                   2462: some of its subdirectories; this may be suboptimal depending on your
                   2463: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
                   2464: configuration of the provided packages).
                   2465: 
                   2466: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4       rillig   2467: (in mk.conf) to point to your preferred configuration directory; some common
                   2468: examples include /etc or /etc/pkg.
1.1       dsieger  2469: 
                   2470: Furthermore, you can change this value on a per-package basis by setting the
                   2471: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
                   2472: matches the name of the package you would like to modify, that is, the contents
                   2473: of PKGBASE.
                   2474: 
                   2475: Note that after changing these settings, you must rebuild and reinstall any
                   2476: affected packages.
                   2477: 
1.154     rillig   2478: 10.14. Automated security checks
1.1       dsieger  2479: 
                   2480: Please be aware that there can often be bugs in third-party software, and some
                   2481: of these bugs can leave a machine vulnerable to exploitation by attackers. In
                   2482: an effort to lessen the exposure, the NetBSD packages team maintains a database
                   2483: of known-exploits to packages which have at one time been included in pkgsrc.
                   2484: The database can be downloaded automatically, and a security audit of all
1.14      jmcneill 2485: packages installed on a system can take place. To do this, refer to the
                   2486: following two tools (installed as part of the pkgtools/pkg_install package):
1.1       dsieger  2487: 
1.21      snj      2488:  1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
                   2489:     security vulnerabilities information. This list is kept up to date by the
1.26      spz      2490:     pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1       dsieger  2491: 
1.177     leot     2492:     https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1       dsieger  2493: 
1.21      snj      2494:  2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24      wiz      2495:     known vulnerability. If a vulnerable package is installed, it will be shown
                   2496:     by output to stdout, including a description of the type of vulnerability,
                   2497:     and a URL containing more information.
1.1       dsieger  2498: 
1.202     nia      2499: Use of these tools is strongly recommended! See Section 5.1.6, "Checking for
1.121     sevan    2500: security vulnerabilities in installed packages" for instructions on how to
                   2501: automate checking and reporting.
                   2502: 
                   2503: If this database is installed, pkgsrc builds will use it to perform a security
                   2504: check before building any package.
1.1       dsieger  2505: 
1.154     rillig   2506: 10.15. Why do some packages ignore my CFLAGS?
1.1       dsieger  2507: 
                   2508: When you add your own preferences to the CFLAGS variable in your mk.conf, these
                   2509: flags are passed in environment variables to the ./configure scripts and to
                   2510: make(1). Some package authors ignore the CFLAGS from the environment variable
                   2511: by overriding them in the Makefiles of their package.
                   2512: 
                   2513: Currently there is no solution to this problem. If you really need the package
                   2514: to use your CFLAGS you should run make patch in the package directory and then
                   2515: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
                   2516: Usually you can remove these lines. But be aware that some "smart" programmers
                   2517: write so bad code that it only works for the specific combination of CFLAGS
                   2518: they have chosen.
                   2519: 
1.172     rillig   2520: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
                   2521: 
                   2522: CPPFLAGS+=              -Dpkgsrc___CPPFLAGS
                   2523: CFLAGS+=                -Dpkgsrc___CFLAGS
                   2524: CXXFLAGS+=              -Dpkgsrc___CXXFLAGS
                   2525: 
                   2526: Then run bmake show-all-configure show-all-build to see whether the above flags
                   2527: are passed to the actual build commands in general.
                   2528: 
                   2529: To find out whether the flags are passed to individual compiler commands, have
                   2530: a look at the file work/.work.log. In most cases, the flags from the original
                   2531: command lines (the lines starting with [*]) are passed unmodified to the actual
                   2532: compiler (the lines starting with <.>). If the flag is missing from the actual
                   2533: compiler command, it must have been removed by the pkgsrc compiler wrappers.
                   2534: 
1.154     rillig   2535: 10.16. A package does not build. What shall I do?
1.1       dsieger  2536: 
                   2537:  1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
                   2538:     is that people only update pkgsrc in parts, because of performance reasons.
                   2539:     Since pkgsrc is one large system, not a collection of many small systems,
                   2540:     there are sometimes changes that only work when the whole pkgsrc tree is
                   2541:     updated.
                   2542: 
1.25      wiz      2543:  2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
                   2544:     >>>>>>" in all your pkgsrc files.
1.1       dsieger  2545: 
1.25      wiz      2546:  3. Make sure that you don't have old copies of the packages extracted. Run 
1.1       dsieger  2547:     make clean clean-depends to verify this.
                   2548: 
1.108     rillig   2549:  4. If you are a package developer who wants to invest some work, have a look
1.154     rillig   2550:     at Chapter 21, Making your package work.
1.108     rillig   2551: 
                   2552:  5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1       dsieger  2553: 
1.154     rillig   2554: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1       dsieger  2555: conflicts" mean?
                   2556: 
                   2557: You have modified a file from pkgsrc, and someone else has modified that same
                   2558: file afterwards in the CVS repository. Both changes are in the same region of
                   2559: the file, so when you updated pkgsrc, the cvs command marked the conflicting
                   2560: changes in the file. Because of these markers, the file is no longer a valid
                   2561: Makefile.
                   2562: 
                   2563: Have a look at that file, and if you don't need your local changes anymore, you
                   2564: can remove that file and run cvs -q update -dP in that directory to download
                   2565: the current version.
                   2566: 
                   2567: Part II. The pkgsrc developer's guide
                   2568: 
                   2569: This part of the book deals with creating and modifying packages. It starts
                   2570: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
                   2571: more like a reference manual for pkgsrc.
                   2572: 
                   2573: Table of Contents
                   2574: 
1.154     rillig   2575: 11. Getting help
1.184     rillig   2576: 12. Package components - files, directories and contents
                   2577:     12.1. Makefile
                   2578:     12.2. distinfo
                   2579:     12.3. patches/*
                   2580:         12.3.1. Structure of a single patch file
                   2581:         12.3.2. Creating patch files
                   2582:         12.3.3. Sources where the patch files come from
                   2583:         12.3.4. Patching guidelines
                   2584:         12.3.5. Feedback to the author
                   2585:     12.4. Other mandatory files
                   2586:     12.5. Optional files
                   2587:         12.5.1. Files affecting the binary package
                   2588:         12.5.2. Files affecting the build process
                   2589:         12.5.3. Files affecting nothing at all
                   2590:     12.6. work*
                   2591:     12.7. files/*
                   2592: 13. The build process
                   2593:     13.1. Introduction
                   2594:     13.2. Program location
                   2595:     13.3. Directories used during the build process
                   2596:     13.4. Running a phase
                   2597:     13.5. The fetch phase
                   2598:         13.5.1. What to fetch and where to get it from
                   2599:         13.5.2. How are the files fetched?
                   2600:     13.6. The checksum phase
                   2601:     13.7. The extract phase
                   2602:     13.8. The patch phase
                   2603:     13.9. The tools phase
                   2604:     13.10. The wrapper phase
                   2605:     13.11. The configure phase
                   2606:     13.12. The build phase
                   2607:     13.13. The test phase
                   2608:     13.14. The install phase
                   2609:     13.15. The package phase
                   2610:     13.16. Cleaning up
                   2611:     13.17. Other helpful targets
                   2612: 14. Creating a new pkgsrc package from scratch
                   2613:     14.1. Common types of packages
1.219     nia      2614:         14.1.1. Python modules and programs
                   2615:         14.1.2. R packages
                   2616:         14.1.3. TeXlive packages
1.184     rillig   2617:     14.2. Examples
                   2618:         14.2.1. How the www/nvu package came into pkgsrc
                   2619: 15. Programming in Makefiles
                   2620:     15.1. Caveats
                   2621:     15.2. Makefile variables
                   2622:         15.2.1. Naming conventions
                   2623:     15.3. Code snippets
                   2624:         15.3.1. Adding things to a list
                   2625:         15.3.2. Echoing a string exactly as-is
                   2626:         15.3.3. Passing CFLAGS to GNU configure scripts
                   2627:         15.3.4. Handling possibly empty variables
1.229     gutterid 2628:         15.3.5. Testing yes/no variables in conditions
1.184     rillig   2629: 16. Options handling
                   2630:     16.1. Global default options
                   2631:     16.2. Converting packages to use bsd.options.mk
                   2632:     16.3. Option Names
                   2633:     16.4. Determining the options of dependencies
                   2634: 17. Tools needed for building or running
                   2635:     17.1. Tools for pkgsrc builds
                   2636:     17.2. Tools needed by packages
                   2637:     17.3. Tools provided by platforms
                   2638: 18. Buildlink methodology
                   2639:     18.1. Converting packages to use buildlink3
                   2640:     18.2. Writing buildlink3.mk files
                   2641:         18.2.1. Anatomy of a buildlink3.mk file
                   2642:         18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
1.232     gutterid 2643:         pkg in buildlink3.mk files
1.184     rillig   2644:     18.3. Writing builtin.mk files
                   2645:         18.3.1. Anatomy of a builtin.mk file
                   2646: 19. PLIST issues
                   2647:     19.1. RCS ID
                   2648:     19.2. Semi-automatic PLIST generation
                   2649:     19.3. Tweaking output of make print-PLIST
                   2650:     19.4. Variable substitution in PLIST
                   2651:     19.5. Man page compression
                   2652:     19.6. Changing PLIST source with PLIST_SRC
                   2653:     19.7. Platform-specific and differing PLISTs
                   2654:     19.8. Build-specific PLISTs
                   2655:     19.9. Sharing directories between packages
                   2656: 20. The pkginstall framework
                   2657:     20.1. Files and directories outside the installation prefix
                   2658:         20.1.1. Directory manipulation
                   2659:         20.1.2. File manipulation
                   2660:     20.2. Configuration files
                   2661:         20.2.1. How PKG_SYSCONFDIR is set
                   2662:         20.2.2. Telling the software where configuration files are
1.239     dholland 2663:         20.2.3. Patching installation
                   2664:         20.2.4. Declaring configuration files
                   2665:         20.2.5. Disabling handling of configuration files
1.184     rillig   2666:     20.3. System startup scripts
                   2667:         20.3.1. Disabling handling of system startup scripts
                   2668:     20.4. System users and groups
                   2669:     20.5. System shells
                   2670:         20.5.1. Disabling shell registration
                   2671:     20.6. Fonts
                   2672:         20.6.1. Disabling automatic update of the fonts databases
1.154     rillig   2673: 21. Making your package work
                   2674:     21.1. General operation
                   2675:         21.1.1. How to pull in user-settable variables from mk.conf
                   2676:         21.1.2. User interaction
                   2677:         21.1.3. Handling licenses
                   2678:         21.1.4. Restricted packages
                   2679:         21.1.5. Handling dependencies
                   2680:         21.1.6. Handling conflicts with other packages
                   2681:         21.1.7. Packages that cannot or should not be built
                   2682:         21.1.8. Packages which should not be deleted, once installed
                   2683:         21.1.9. Handling packages with security problems
                   2684:         21.1.10. How to handle incrementing versions when fixing an existing
1.232     gutterid 2685:         package
1.154     rillig   2686:         21.1.11. Substituting variable text in the package files (the SUBST
1.232     gutterid 2687:         framework)
1.154     rillig   2688:     21.2. The fetch phase
                   2689:         21.2.1. Packages whose distfiles aren't available for plain downloading
                   2690:         21.2.2. How to handle modified distfiles with the 'old' name
                   2691:         21.2.3. Packages hosted on github.com
                   2692:     21.3. The configure phase
                   2693:         21.3.1. Shared libraries - libtool
                   2694:         21.3.2. Using libtool on GNU packages that already support libtool
                   2695:         21.3.3. GNU Autoconf/Automake
1.223     nia      2696:         21.3.4. Meson / ninja
1.154     rillig   2697:     21.4. Programming languages
                   2698:         21.4.1. C, C++, and Fortran
                   2699:         21.4.2. Java
1.205     wiz      2700:         21.4.3. Go
1.223     nia      2701:         21.4.4. Rust
                   2702:         21.4.5. Packages containing Perl scripts
                   2703:         21.4.6. Packages containing shell scripts
                   2704:         21.4.7. Other programming languages
1.154     rillig   2705:     21.5. The build phase
                   2706:         21.5.1. Compiling C and C++ code conditionally
                   2707:         21.5.2. How to handle compiler bugs
1.172     rillig   2708:         21.5.3. No such file or directory
                   2709:         21.5.4. Undefined reference to "..."
                   2710:         21.5.5. Running out of memory
1.154     rillig   2711:     21.6. The install phase
                   2712:         21.6.1. Creating needed directories
                   2713:         21.6.2. Where to install documentation
                   2714:         21.6.3. Installing highscore files
                   2715:         21.6.4. Adding DESTDIR support to packages
                   2716:         21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia      2717:         21.6.6. Packages installing Perl modules
1.254     wiz      2718:         21.6.7. Packages installing pkg-config files
                   2719:         21.6.8. Packages installing info files
                   2720:         21.6.9. Packages installing man pages
                   2721:         21.6.10. Packages installing X11 fonts
                   2722:         21.6.11. Packages installing SGML or XML data
                   2723:         21.6.12. Packages installing extensions to the MIME database
                   2724:         21.6.13. Packages using intltool
                   2725:         21.6.14. Packages installing startup scripts
                   2726:         21.6.15. Packages installing TeX modules
                   2727:         21.6.16. Packages supporting running binaries in emulation
                   2728:         21.6.17. Packages installing hicolor icons
                   2729:         21.6.18. Packages installing desktop files
1.154     rillig   2730:     21.7. Marking packages as having problems
1.184     rillig   2731: 22. GNOME packaging and porting
                   2732:     22.1. Meta packages
                   2733:     22.2. Packaging a GNOME application
                   2734:     22.3. Updating GNOME to a newer version
                   2735:     22.4. Patching guidelines
1.154     rillig   2736: 23. Submitting and Committing
                   2737:     23.1. Submitting binary packages
                   2738:     23.2. Submitting source packages (for non-NetBSD-developers)
                   2739:     23.3. General notes when adding, updating, or removing packages
                   2740:     23.4. Commit Messages
                   2741:     23.5. Committing: Adding a package to CVS
                   2742:     23.6. Updating a package to a newer version
                   2743:     23.7. Renaming a package in pkgsrc
                   2744:     23.8. Moving a package in pkgsrc
                   2745: 24. Frequently Asked Questions
                   2746: 
                   2747: Chapter 11. Getting help
                   2748: 
                   2749: To get help when developing pkgsrc, the definitive source is this document, the
                   2750: pkgsrc guide. If you don't find anything here, there are alternatives:
                   2751: 
                   2752:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                   2753:     Run bmake help topic=? to get help for any topic, such as a variable name
                   2754:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                   2755:     like strcasecmp or any other topic.
                   2756: 
1.207     leot     2757:     The available help topics are listed in Appendix E, Help topics.
1.154     rillig   2758: 
1.163     rillig   2759:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                   2760: 
                   2761:   * To see the values of the most common variables, run bmake show-all. These
                   2762:     variables are grouped by topic. To see the variables for a single topic,
                   2763:     run bmake show-all-topic, for example bmake show-all-fetch.
                   2764: 
1.154     rillig   2765:   * The tech-pkg mailing list, to which you can subscribe and then ask your
                   2766:     questions.
                   2767: 
                   2768:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                   2769:     a specialized chat program such as XChat. Pick any user name and join the
                   2770:     channel #pkgsrc.
1.1       dsieger  2771: 
1.184     rillig   2772: Chapter 12. Package components - files, directories and contents
1.1       dsieger  2773: 
                   2774: Table of Contents
                   2775: 
1.184     rillig   2776: 12.1. Makefile
                   2777: 12.2. distinfo
                   2778: 12.3. patches/*
                   2779:     12.3.1. Structure of a single patch file
                   2780:     12.3.2. Creating patch files
                   2781:     12.3.3. Sources where the patch files come from
                   2782:     12.3.4. Patching guidelines
                   2783:     12.3.5. Feedback to the author
                   2784: 12.4. Other mandatory files
                   2785: 12.5. Optional files
                   2786:     12.5.1. Files affecting the binary package
                   2787:     12.5.2. Files affecting the build process
                   2788:     12.5.3. Files affecting nothing at all
                   2789: 12.6. work*
                   2790: 12.7. files/*
1.1       dsieger  2791: 
1.184     rillig   2792: Whenever you're preparing a package, there are a number of files involved which
                   2793: are described in the following sections.
1.1       dsieger  2794: 
1.184     rillig   2795: 12.1. Makefile
1.1       dsieger  2796: 
1.184     rillig   2797: Building, installation and creation of a binary package are all controlled by
                   2798: the package's Makefile. The Makefile describes various things about a package,
                   2799: for example from where to get it, how to configure, build, and install it.
1.1       dsieger  2800: 
1.184     rillig   2801: A package Makefile contains several sections that describe the package.
1.1       dsieger  2802: 
1.184     rillig   2803: In the first section there are the following variables, which should appear
                   2804: exactly in the order given here. The order and grouping of the variables is
                   2805: mostly historical and has no further meaning.
1.1       dsieger  2806: 
1.184     rillig   2807:   * DISTNAME is the basename of the distribution file to be downloaded from the
                   2808:     package's website.
1.1       dsieger  2809: 
1.184     rillig   2810:   * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
                   2811:     it if DISTNAME (which is the default) is not a good name for the package in
                   2812:     pkgsrc or DISTNAME is not provided (no distribution file is required).
                   2813:     Usually it is the pkgsrc directory name together with the version number.
                   2814:     It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
                   2815:     is, it starts with a letter or digit, and contains only letters, digits,
1.204     nia      2816:     dashes, underscores, dots and plus signs. New packages should have entirely
                   2817:     lower-case names, with the exception of some that must follow pre-existing
                   2818:     conventions (e.g. R packages begin with R-). You can use the :tl variable
                   2819:     modifier to lower-case the package name.
1.26      spz      2820: 
1.184     rillig   2821:   * CATEGORIES is a list of categories which the package fits in. You can
                   2822:     choose any of the top-level directories of pkgsrc for it.
1.1       dsieger  2823: 
1.184     rillig   2824:     Currently the following values are available for CATEGORIES. If more than
                   2825:     one is used, they need to be separated by spaces:
1.1       dsieger  2826: 
1.184     rillig   2827:     archivers     cross         geography     meta-pkgs     security
                   2828:     audio         databases     graphics      misc          shells
                   2829:     benchmarks    devel         ham           multimedia    sysutils
                   2830:     biology       editors       inputmethod   net           textproc
                   2831:     cad           emulators     lang          news          time
                   2832:     chat          finance       mail          parallel      wm
                   2833:     comms         fonts         math          pkgtools      www
                   2834:     converters    games         mbone         print         x11
1.1       dsieger  2835: 
1.184     rillig   2836:   * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
                   2837:     are discussed in detail in Section 13.5, "The fetch phase".
1.1       dsieger  2838: 
1.184     rillig   2839: The second section contains information about separately downloaded patches, if
                   2840: any.
1.1       dsieger  2841: 
1.184     rillig   2842:   * PATCHFILES: Name(s) of additional files that contain distribution patches.
                   2843:     There is no default. pkgsrc will look for them at PATCH_SITES. They will
                   2844:     automatically be uncompressed before patching if the names end with .gz or
                   2845:     .Z.
1.1       dsieger  2846: 
1.184     rillig   2847:   * PATCH_SITES: Primary location(s) for distribution patch files (see
                   2848:     PATCHFILES above) if not found locally.
1.1       dsieger  2849: 
1.184     rillig   2850:   * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
                   2851:     count to help find the correct files to patch. It defaults to -p0.
1.1       dsieger  2852: 
1.184     rillig   2853: The third section contains the following variables.
1.1       dsieger  2854: 
1.253     gutterid 2855:   * MAINTAINER is the email address of the person who is currently responsible
                   2856:     for this package. In theory, the maintainer will be aware of upstream
                   2857:     release, keep it updated, and generally resolve problems. Others
                   2858:     contemplating significant changes should ask the maintainer for advice or
                   2859:     review of a proposed change. This is not necessary for micro updates, bug
                   2860:     fixes, pkgsrc-wide changes affecting many packages, and other things
                   2861:     expected to be uncontroversial. It goes with this "should ask" that the
                   2862:     maintainer should respond to inquiries reasonably promptly (most of the
                   2863:     time), and either approve changes or provide reasons why not. Typically,
                   2864:     when packaging a new program, set MAINTAINER to yourself. If you don't
                   2865:     intend to maintain the package (especially if you feel you have no special
                   2866:     insight), set it to <pkgsrc-users@NetBSD.org>. This special value is a code
                   2867:     point indicating that there is no maintainer, but the variable is
                   2868:     mandatory, absent OWNER.
                   2869: 
                   2870:   * OWNER can be used instead of MAINTAINER in relatively rare circumstances
                   2871:     when the package is such that modifying it is riskier than normal. This is
                   2872:     a stronger form of being the maintainer, with an expectation that others
                   2873:     will ask for almost all changes, except revbumps and accommodating
                   2874:     structural changes. Someone who becomes OWNER has a strong obligation to
                   2875:     keep the package very well maintained, to answer queries promptly and to be
                   2876:     a steward of the package on behalf of users. In this case, MAINTAINER
                   2877:     should be omitted.
                   2878: 
                   2879:     Because of the friction that OWNER adds, PMC may downgrade it to MAINTAINER
                   2880:     at any time.
1.1       dsieger  2881: 
1.184     rillig   2882:   * HOMEPAGE is a URL where users can find more information about the package.
1.1       dsieger  2883: 
1.184     rillig   2884:   * COMMENT is a one-line description of the package (should not include the
                   2885:     package name).
1.1       dsieger  2886: 
1.184     rillig   2887:   * LICENSE indicates the license(s) applicable for the package. See
                   2888:     Section 21.1.3, "Handling licenses" for further details.
1.1       dsieger  2889: 
1.184     rillig   2890: Other variables that affect the build:
1.1       dsieger  2891: 
1.184     rillig   2892:   * WRKSRC: The directory where the interesting distribution files of the
                   2893:     package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
                   2894:     most packages.
1.1       dsieger  2895: 
1.184     rillig   2896:     If a package doesn't create a subdirectory for itself (most GNU software
                   2897:     does, for instance), but extracts itself in the current directory, you
                   2898:     should set WRKSRC=${WRKDIR}.
1.1       dsieger  2899: 
1.184     rillig   2900:     If a package doesn't create a subdirectory with the name of DISTNAME but
                   2901:     some different name, set WRKSRC to point to the proper name in ${WRKDIR},
                   2902:     for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
                   2903:     other examples.
1.17      imil     2904: 
1.184     rillig   2905:     The name of the working directory created by pkgsrc is taken from the
                   2906:     WRKDIR_BASENAME variable. By default, its value is work. If you want to use
                   2907:     the same pkgsrc tree for building different kinds of binary packages, you
                   2908:     can change the variable according to your needs. Two other variables handle
                   2909:     common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
                   2910:     defined in mk.conf, the first component of the host's name is attached to
                   2911:     the directory name. If OBJMACHINE is defined, the platform name is
                   2912:     attached, which might look like work.i386 or work.sparc.
1.17      imil     2913: 
1.184     rillig   2914: Please pay attention to the following gotchas:
1.17      imil     2915: 
1.184     rillig   2916:   * Add MANCOMPRESSED if man pages are installed in compressed form by the
                   2917:     package. For packages using BSD-style makefiles which honor MANZ, there is
                   2918:     MANCOMPRESSED_IF_MANZ.
1.17      imil     2919: 
1.184     rillig   2920:   * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
1.103     wiz      2921: 
1.254     wiz      2922:   * If the package installs any info files, see Section 21.6.8, "Packages
1.184     rillig   2923:     installing info files".
1.103     wiz      2924: 
1.184     rillig   2925: 12.2. distinfo
1.17      imil     2926: 
1.184     rillig   2927: The distinfo file contains the message digest, or checksum, of each distfile
                   2928: needed for the package. This ensures that the distfiles retrieved from the
                   2929: Internet have not been corrupted during transfer or altered by a malign force
                   2930: to introduce a security hole. To provide maximum security, all distfiles are
1.243     gutterid 2931: protected using two different message digest algorithms (BLAKE2s and SHA512),
                   2932: as well as the file size.
1.17      imil     2933: 
1.184     rillig   2934: The distinfo file also contains the checksums for all the patches found in the
                   2935: patches directory (see Section 12.3, "patches/*"). These checksums ensure that
                   2936: patches are only applied intentionally and that they don't accidentally change,
                   2937: e.g. when merging different changes together. They also make sure that new
                   2938: patches are actually added to CVS and old ones are removed. Too see whether the
                   2939: patches and the distinfo file match, run pkglint after changing the patches.
1.17      imil     2940: 
1.184     rillig   2941: To regenerate the distinfo file, use the make distinfo command.
1.17      imil     2942: 
1.184     rillig   2943: Some packages have different sets of distfiles depending on the platform, for
                   2944: example lang/openjdk8. These are kept in the same distinfo file and care should
                   2945: be taken when upgrading such a package to ensure distfile information is not
                   2946: lost.
1.17      imil     2947: 
1.184     rillig   2948: 12.3. patches/*
1.63      wiz      2949: 
1.184     rillig   2950: Some packages don't work out-of-the box on the various platforms that are
                   2951: supported by pkgsrc. These packages need to be patched to make them work. The
                   2952: patch files can be found in the patches/ directory.
1.17      imil     2953: 
1.184     rillig   2954: In the patch phase, these patches are applied to the files in WRKSRC directory
                   2955: after extracting them, in alphabetic order.
1.160     brook    2956: 
1.184     rillig   2957: 12.3.1. Structure of a single patch file
1.160     brook    2958: 
1.184     rillig   2959: The patch-* files should be in diff -bu format, and apply without a fuzz to
                   2960: avoid problems. (To force patches to apply with fuzz you can set
                   2961: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
                   2962: a single file, and no file should be patched by more than one patch file. This
                   2963: helps to keep future modifications simple.
1.160     brook    2964: 
1.184     rillig   2965: Each patch file is structured as follows: In the first line, there is the RCS
                   2966: Id of the patch itself. The second line should be empty for aesthetic reasons.
                   2967: After that, there should be a comment for each change that the patch does.
                   2968: There are a number of standard cases:
1.160     brook    2969: 
1.184     rillig   2970:   * Patches for commonly known vulnerabilities should mention the vulnerability
                   2971:     ID (CAN, CVE).
1.160     brook    2972: 
1.184     rillig   2973:   * Patches that change source code should mention the platform and other
                   2974:     environment (for example, the compiler) that the patch is needed for.
1.160     brook    2975: 
1.184     rillig   2976: The patch should be commented so that any developer who knows the code of the
                   2977: application can make some use of the patch. Special care should be taken for
                   2978: the upstream developers, since we generally want that they accept our patches,
                   2979: so we have less work in the future.
1.160     brook    2980: 
1.184     rillig   2981: 12.3.2. Creating patch files
1.160     brook    2982: 
1.184     rillig   2983: One important thing to mention is to pay attention that no RCS IDs get stored
                   2984: in the patch files, as these will cause problems when later checked into the
                   2985: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
                   2986: avoid these problems.
1.160     brook    2987: 
1.184     rillig   2988: For even more automation, we recommend using mkpatches from the same package to
1.222     gutterid 2989: make a whole set of patches. You just have to back up files before you edit
                   2990: them to filename.orig, e.g., with cp -p filename filename.orig or, easier, by
                   2991: using pkgvi again from the same package. If you upgrade a package this way, you
                   2992: can easily compare the new set of patches with the previously existing one with
1.184     rillig   2993: patchdiff. The files in patches are replaced by new files, so carefully check
                   2994: if you want to take all the changes.
1.160     brook    2995: 
1.184     rillig   2996: When you have finished a package, remember to generate the checksums for the
                   2997: patch files by using the make makepatchsum command, see Section 12.2,
                   2998: "distinfo".
1.1       dsieger  2999: 
1.184     rillig   3000: When adding a patch that corrects a problem in the distfile (rather than e.g.
                   3001: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
                   3002: report to the maintainer. This benefits non-pkgsrc users of the package, and
                   3003: usually makes it possible to remove the patch in future version.
1.1       dsieger  3004: 
1.184     rillig   3005: The file names of the patch files are usually of the form patch-
                   3006: path_to_file__with__underscores.c. Many packages still use the previous
                   3007: convention patch-[a-z][a-z], but new patches should be of the form containing
                   3008: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
                   3009: automatically.
1.1       dsieger  3010: 
1.222     gutterid 3011: When updating pre-existing patch files, if a file uses the old patch-[a-z][a-z]
                   3012: convention, it's best not to change it to the new form, as that will just cause
                   3013: churn that makes it harder to track changes to patching over time. Similarly,
                   3014: if a patch now applies at different line offsets, but still applies cleanly
                   3015: as-is, there's no need to update it, as that also unnecessarily complicates the
                   3016: patch history.
                   3017: 
1.184     rillig   3018: 12.3.3. Sources where the patch files come from
1.1       dsieger  3019: 
1.184     rillig   3020: If you want to share patches between multiple packages in pkgsrc, e.g. because
                   3021: they use the same distfiles, set PATCHDIR to the path where the patch files can
                   3022: be found, e.g.:
1.1       dsieger  3023: 
1.184     rillig   3024: PATCHDIR=       ../../editors/xemacs/patches
1.1       dsieger  3025: 
1.184     rillig   3026: Patch files that are distributed by the author or other maintainers can be
                   3027: listed in PATCHFILES.
1.1       dsieger  3028: 
1.184     rillig   3029: If it is desired to store any patches that should not be committed into pkgsrc,
                   3030: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
                   3031: directory tree there is expected to have the same "category/package" structure
                   3032: as pkgsrc, and patches are expected to be stored inside these dirs (also known
                   3033: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
                   3034: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
                   3035: files in the named directory are expected to be patch files, and they are
                   3036: applied after pkgsrc patches are applied.
1.1       dsieger  3037: 
1.184     rillig   3038: 12.3.4. Patching guidelines
1.1       dsieger  3039: 
1.184     rillig   3040: When fixing a portability issue in the code do not use preprocessor magic to
                   3041: check for the current operating system nor platform. Doing so hurts portability
                   3042: to other platforms because the OS-specific details are not abstracted
                   3043: appropriately.
1.1       dsieger  3044: 
1.184     rillig   3045: The general rule to follow is: instead of checking for the operating system the
                   3046: application is being built on, check for the specific features you need. For
                   3047: example, instead of assuming that kqueue is available under NetBSD and using
                   3048: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
1.198     leot     3049: kqueue itself -- yes, this generally involves patching the configure script.
1.184     rillig   3050: There is absolutely nothing that prevents some OSes from adopting interfaces
                   3051: from other OSes (e.g. Linux implementing kqueue), something that the above
                   3052: checks cannot take into account.
1.1       dsieger  3053: 
1.184     rillig   3054: Of course, checking for features generally involves more work on the
                   3055: developer's side, but the resulting changes are cleaner and there are chances
                   3056: they will work on many other platforms. Not to mention that there are higher
                   3057: chances of being later integrated into the mainstream sources. Remember: It
                   3058: doesn't work unless it is right!
1.1       dsieger  3059: 
1.184     rillig   3060: Some typical examples:
1.121     sevan    3061: 
1.184     rillig   3062: Table 12.1. Patching examples
1.1       dsieger  3063: 
1.184     rillig   3064: +-------------------------------------------------------------------------------------------+
                   3065: |  Where  |        Incorrect         |                       Correct                        |
                   3066: |---------+--------------------------+------------------------------------------------------|
                   3067: |         |case ${target_os} in      |                                                      |
                   3068: |configure|netbsd*) have_kvm=yes ;;  |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
                   3069: |script   |*)       have_kvm=no  ;;  |                                                      |
                   3070: |         |esac                      |                                                      |
                   3071: |---------+--------------------------+------------------------------------------------------|
                   3072: |C source |#if defined(__NetBSD__)   |#if defined(HAVE_SYS_EVENT_H)                         |
                   3073: |file     |#  include <sys/event.h>  |#  include <sys/event.h>                              |
                   3074: |         |#endif                    |#endif                                                |
                   3075: |---------+--------------------------+------------------------------------------------------|
                   3076: |         |int                       |int                                                   |
                   3077: |         |monitor_file(...)         |monitor_file(...)                                     |
                   3078: |         |{                         |{                                                     |
                   3079: |         |#if defined(__NetBSD__)   |#if defined(HAVE_KQUEUE)                              |
                   3080: |C source |        int fd = kqueue();|        int fd = kqueue();                            |
                   3081: |file     |        ...               |        ...                                           |
                   3082: |         |#else                     |#else                                                 |
                   3083: |         |        ...               |        ...                                           |
                   3084: |         |#endif                    |#endif                                                |
                   3085: |         |}                         |}                                                     |
                   3086: +-------------------------------------------------------------------------------------------+
1.1       dsieger  3087: 
                   3088: 
1.184     rillig   3089: 12.3.5. Feedback to the author
1.1       dsieger  3090: 
1.184     rillig   3091: Always, always, always feed back any portability fixes or improvements you do
                   3092: to a package to the mainstream developers. This is the only way to get their
                   3093: attention on portability issues and to ensure that future versions can be built
                   3094: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
                   3095: get the fixes straight from the packaged code.
1.1       dsieger  3096: 
1.184     rillig   3097: This generally involves cleaning up the patches (because sometimes the patches
                   3098: that are added to pkgsrc are quick hacks), filing bug reports in the
                   3099: appropriate trackers for the projects and working with the mainstream authors
                   3100: to accept your changes. It is extremely important that you do it so that the
                   3101: packages in pkgsrc are kept simple and thus further changes can be done without
                   3102: much hassle.
1.1       dsieger  3103: 
1.184     rillig   3104: When you have done this, please add a URL to the upstream bug report to the
                   3105: patch comment.
1.1       dsieger  3106: 
1.184     rillig   3107: Support the idea of free software!
1.1       dsieger  3108: 
1.184     rillig   3109: 12.4. Other mandatory files
1.1       dsieger  3110: 
1.184     rillig   3111: DESCR
1.1       dsieger  3112: 
1.184     rillig   3113:     A multi-line description of the piece of software. This should include any
                   3114:     credits where they are due. Please bear in mind that others do not share
                   3115:     your sense of humour (or spelling idiosyncrasies), and that others will
                   3116:     read everything that you write here.
1.1       dsieger  3117: 
1.184     rillig   3118: PLIST
1.1       dsieger  3119: 
1.184     rillig   3120:     This file governs the files that are installed on your system: all the
                   3121:     binaries, manual pages, etc. There are other directives which may be
                   3122:     entered in this file, to control the creation and deletion of directories,
                   3123:     and the location of inserted files. See Chapter 19, PLIST issues for more
                   3124:     information.
1.1       dsieger  3125: 
1.184     rillig   3126: 12.5. Optional files
1.1       dsieger  3127: 
1.184     rillig   3128: 12.5.1. Files affecting the binary package
1.1       dsieger  3129: 
1.184     rillig   3130: INSTALL
1.1       dsieger  3131: 
1.184     rillig   3132:     This shell script is invoked twice by pkg_add(1). First time after package
                   3133:     extraction and before files are moved in place, the second time after the
                   3134:     files to install are moved in place. This can be used to do any custom
                   3135:     procedures not possible with @exec commands in PLIST. See pkg_add(1) and
                   3136:     pkg_create(1) for more information. See also Section 20.1, "Files and
                   3137:     directories outside the installation prefix". Please note that you can
                   3138:     modify variables in it easily by using FILES_SUBST in the package's
                   3139:     Makefile:
1.1       dsieger  3140: 
1.184     rillig   3141:     FILES_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3142: 
1.184     rillig   3143:     replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
                   3144:     substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
                   3145:     few others, type make help topic=FILES_SUBST for a complete list.
1.1       dsieger  3146: 
1.184     rillig   3147: DEINSTALL
1.1       dsieger  3148: 
1.184     rillig   3149:     This script is executed before and after any files are removed. It is this
                   3150:     script's responsibility to clean up any additional messy details around the
                   3151:     package's installation, since all pkg_delete knows is how to delete the
                   3152:     files created in the original distribution. See pkg_delete(1) and
                   3153:     pkg_create(1) for more information. The same methods to replace variables
                   3154:     can be used as for the INSTALL file.
1.1       dsieger  3155: 
1.184     rillig   3156: MESSAGE
1.1       dsieger  3157: 
1.198     leot     3158:     This file is displayed after installation of the package. While this was
                   3159:     used often in the past, it has two problems: the display will be missed if
1.257     jkoshy   3160:     many packages are installed at once, and the person installing the package
1.198     leot     3161:     and the one using or configuring it may be different. It should therefore
                   3162:     be used only in exceptional circumstances where lasting negative
                   3163:     consequences would result from someone not reading it.
                   3164: 
                   3165:     MESSAGE should not be used for:
                   3166: 
1.232     gutterid 3167:       o exhortations to read the documentation
1.198     leot     3168: 
1.232     gutterid 3169:       o reminders to install rc.d files and set variables
1.198     leot     3170: 
1.232     gutterid 3171:       o anything that should be explained in the installation/configuration
1.198     leot     3172:         documentation that should come with the package
                   3173: 
                   3174:     If the documentation provided by upstream needs enhancing, create e.g.
                   3175:     files/README.pkgsrc and install it in the package's documentation
                   3176:     directory.
                   3177: 
                   3178:     Note that MESSAGE is shown for all operating systems and all init systems.
                   3179:     If a MESSAGE is necessary, it should be narrowed to only those operating
                   3180:     systems and init systems to which it applies.
                   3181: 
                   3182:     Note that you can modify variables in it easily by using MESSAGE_SUBST in
                   3183:     the package's Makefile:
1.1       dsieger  3184: 
1.184     rillig   3185:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3186: 
1.184     rillig   3187:     replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
                   3188:     is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
                   3189:     PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1       dsieger  3190: 
1.184     rillig   3191:     You can display a different or additional files by setting the MESSAGE_SRC
                   3192:     variable. Its default is MESSAGE, if the file exists.
1.1       dsieger  3193: 
1.184     rillig   3194: ALTERNATIVES
1.1       dsieger  3195: 
1.184     rillig   3196:     This file is used by the alternatives framework. It creates, configures,
                   3197:     and destroys generic wrappers used to run programs with similar interfaces.
                   3198:     See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
                   3199:     information.
1.1       dsieger  3200: 
1.184     rillig   3201:     Each line of the file contains two filenames, first the wrapper and then
                   3202:     the alternative provided by the package. Both paths are relative to PREFIX.
1.1       dsieger  3203: 
1.184     rillig   3204: 12.5.2. Files affecting the build process
1.1       dsieger  3205: 
1.184     rillig   3206: Makefile.common
1.1       dsieger  3207: 
1.184     rillig   3208:     This file contains arbitrary things that could also go into a Makefile, but
                   3209:     its purpose is to be used by more than one package. This file should only
                   3210:     be used when the packages that will use the file are known in advance. For
                   3211:     other purposes it is often better to write a *.mk file and give it a good
                   3212:     name that describes what it does.
1.1       dsieger  3213: 
1.184     rillig   3214: buildlink3.mk
1.1       dsieger  3215: 
1.184     rillig   3216:     This file contains the dependency information for the buildlink3 framework
                   3217:     (see Chapter 18, Buildlink methodology).
1.1       dsieger  3218: 
1.184     rillig   3219: hacks.mk
1.1       dsieger  3220: 
1.184     rillig   3221:     This file contains workarounds for compiler bugs and similar things. It is
                   3222:     included automatically by the pkgsrc infrastructure, so you don't need an
                   3223:     extra .include line for it.
1.1       dsieger  3224: 
1.184     rillig   3225: options.mk
1.1       dsieger  3226: 
1.184     rillig   3227:     This file contains the code for the package-specific options (see
                   3228:     Chapter 16, Options handling) that can be selected by the user. If a
                   3229:     package has only one or two options, it is equally acceptable to put the
                   3230:     code directly into the Makefile.
1.1       dsieger  3231: 
1.184     rillig   3232: 12.5.3. Files affecting nothing at all
1.1       dsieger  3233: 
1.184     rillig   3234: README*
1.1       dsieger  3235: 
1.184     rillig   3236:     These files do not take place in the creation of a package and thus are
                   3237:     purely informative to the package developer.
1.1       dsieger  3238: 
1.184     rillig   3239: TODO
1.1       dsieger  3240: 
1.184     rillig   3241:     This file contains things that need to be done to make the package even
                   3242:     better.
1.1       dsieger  3243: 
1.184     rillig   3244: 12.6. work*
1.1       dsieger  3245: 
1.184     rillig   3246: When you type make, the distribution files are unpacked into the directory
                   3247: denoted by WRKDIR. It can be removed by running make clean. Besides the
                   3248: sources, this directory is also used to keep various timestamp files. The
                   3249: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
                   3250: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
1.1       dsieger  3251: 
1.184     rillig   3252: 12.7. files/*
1.80      wiz      3253: 
1.184     rillig   3254: If you have any files that you wish to be placed in the package prior to
                   3255: configuration or building, you can place these files here and use a ${CP}
                   3256: command in the "post-extract" target to achieve this.
1.1       dsieger  3257: 
1.184     rillig   3258: If you want to share files in this way with other packages, set the FILESDIR
                   3259: variable to point to the other package's files directory, e.g.:
1.1       dsieger  3260: 
1.184     rillig   3261: FILESDIR=       ../../editors/xemacs/files
1.14      jmcneill 3262: 
1.184     rillig   3263: Chapter 13. The build process
1.1       dsieger  3264: 
1.184     rillig   3265: Table of Contents
1.1       dsieger  3266: 
1.184     rillig   3267: 13.1. Introduction
                   3268: 13.2. Program location
                   3269: 13.3. Directories used during the build process
                   3270: 13.4. Running a phase
                   3271: 13.5. The fetch phase
                   3272:     13.5.1. What to fetch and where to get it from
                   3273:     13.5.2. How are the files fetched?
                   3274: 13.6. The checksum phase
                   3275: 13.7. The extract phase
                   3276: 13.8. The patch phase
                   3277: 13.9. The tools phase
                   3278: 13.10. The wrapper phase
                   3279: 13.11. The configure phase
                   3280: 13.12. The build phase
                   3281: 13.13. The test phase
                   3282: 13.14. The install phase
                   3283: 13.15. The package phase
                   3284: 13.16. Cleaning up
                   3285: 13.17. Other helpful targets
1.1       dsieger  3286: 
1.184     rillig   3287: 13.1. Introduction
1.122     leot     3288: 
1.184     rillig   3289: This chapter gives a detailed description on how a package is built. Building a
                   3290: package is separated into different phases (for example fetch, build, install),
                   3291: all of which are described in the following sections. Each phase is split into
                   3292: so-called stages, which take the name of the containing phase, prefixed by one
                   3293: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
                   3294: actual work is done in the do-* stages.
1.1       dsieger  3295: 
1.184     rillig   3296: Never override the regular targets (like fetch), if you have to, override the
                   3297: do-* ones instead.
1.1       dsieger  3298: 
1.184     rillig   3299: The basic steps for building a program are always the same. First the program's
                   3300: source (distfile) must be brought to the local system and then extracted. After
                   3301: any pkgsrc-specific patches to compile properly are applied, the software can
                   3302: be configured, then built (usually by compiling), and finally the generated
                   3303: binaries, etc. can be put into place on the system.
1.1       dsieger  3304: 
1.184     rillig   3305: To get more details about what is happening at each step, you can set the
                   3306: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
                   3307: more details about the patch step.
1.1       dsieger  3308: 
1.184     rillig   3309: 13.2. Program location
1.1       dsieger  3310: 
1.184     rillig   3311: Before outlining the process performed by the NetBSD package system in the next
                   3312: section, here's a brief discussion on where programs are installed, and which
                   3313: variables influence this.
1.1       dsieger  3314: 
1.184     rillig   3315: The automatic variable PREFIX indicates where all files of the final program
                   3316: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
                   3317: pkgs in the cross category. The value of PREFIX needs to be put into the
                   3318: various places in the program's source where paths to these files are encoded.
                   3319: See Section 12.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
                   3320: for more details.
1.1       dsieger  3321: 
1.184     rillig   3322: When choosing which of these variables to use, follow the following rules:
1.1       dsieger  3323: 
1.184     rillig   3324:   * PREFIX always points to the location where the current pkg will be
                   3325:     installed. When referring to a pkg's own installation path, use "${PREFIX}"
                   3326:     .
1.1       dsieger  3327: 
1.223     nia      3328:   * LOCALBASE is where all pkgs are installed. If you need to construct a -I or
                   3329:     -L argument to the compiler to find includes and libraries installed by
                   3330:     another pkg, use "${LOCALBASE}". The name LOCALBASE stems from FreeBSD,
                   3331:     which installed all packages in /usr/local. As pkgsrc leaves /usr/local for
                   3332:     the system administrator, this variable is a misnomer.
1.1       dsieger  3333: 
1.184     rillig   3334:   * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
                   3335:     installed. When looking for standard X11 includes (not those installed by a
                   3336:     package), use "${X11BASE}".
1.1       dsieger  3337: 
1.184     rillig   3338:   * X11-based packages using imake must set USE_IMAKE to be installed correctly
                   3339:     under LOCALBASE.
1.1       dsieger  3340: 
1.184     rillig   3341:   * Within ${PREFIX}, packages should install files according to hier(7), with
                   3342:     the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
                   3343:     man.
1.1       dsieger  3344: 
1.184     rillig   3345: 13.3. Directories used during the build process
1.2       rillig   3346: 
1.184     rillig   3347: When building a package, various directories are used to store source files,
                   3348: temporary files, pkgsrc-internal files, and so on. These directories are
                   3349: explained here.
1.1       dsieger  3350: 
1.184     rillig   3351: Some of the directory variables contain relative pathnames. There are two
                   3352: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
                   3353: used for directories that are pkgsrc-specific. WRKSRC is used for directories
                   3354: inside the package itself.
1.1       dsieger  3355: 
1.184     rillig   3356: PKGSRCDIR
1.1       dsieger  3357: 
1.184     rillig   3358:     This is an absolute pathname that points to the pkgsrc root directory.
                   3359:     Generally, you don't need it.
1.1       dsieger  3360: 
1.184     rillig   3361: PKGDIR
1.1       dsieger  3362: 
1.184     rillig   3363:     This is an absolute pathname that points to the current package.
1.1       dsieger  3364: 
1.184     rillig   3365: PKGPATH
1.1       dsieger  3366: 
1.184     rillig   3367:     This is a pathname relative to PKGSRCDIR that points to the current
1.228     gutterid 3368:     package. It is defined after including bsd.prefs.mk and can be used in
                   3369:     makefile fragments that are used by several packages to distinguish between
                   3370:     these packages. Other variables that would serve the same purpose are
                   3371:     PKGBASE and PKGNAME, but these are only defined after including bsd.pkg.mk,
                   3372:     which is too late.
                   3373: 
                   3374:     In mk.conf, the pkgsrc user can use PKGPATH to tweak variables like
                   3375:     MAKE_JOBS and CFLAGS.
1.1       dsieger  3376: 
1.184     rillig   3377: WRKDIR
1.1       dsieger  3378: 
1.184     rillig   3379:     This is an absolute pathname pointing to the directory where all work takes
                   3380:     place. The distfiles are extracted to this directory. It also contains
                   3381:     temporary directories and log files used by the various pkgsrc frameworks,
                   3382:     like buildlink or the wrappers.
1.1       dsieger  3383: 
1.184     rillig   3384: WRKSRC
1.1       dsieger  3385: 
1.184     rillig   3386:     This is an absolute pathname pointing to the directory where the distfiles
                   3387:     are extracted. It is usually a direct subdirectory of WRKDIR, and often
                   3388:     it's the only directory entry that isn't hidden. This variable may be
                   3389:     changed by a package Makefile.
1.1       dsieger  3390: 
1.184     rillig   3391: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
                   3392: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
                   3393: created in the pkgsrc entry's directory. If users would like to have their
                   3394: pkgsrc trees behave in a read-only manner, then the value of
                   3395: CREATE_WRKDIR_SYMLINK should be set to no.
1.1       dsieger  3396: 
1.184     rillig   3397: 13.4. Running a phase
1.1       dsieger  3398: 
1.184     rillig   3399: You can run a particular phase by typing make phase, where phase is the name of
                   3400: the phase. This will automatically run all phases that are required for this
                   3401: phase. The default phase is build, that is, when you run make without
                   3402: parameters in a package directory, the package will be built, but not
                   3403: installed.
1.1       dsieger  3404: 
1.184     rillig   3405: 13.5. The fetch phase
1.1       dsieger  3406: 
1.184     rillig   3407: The first step in building a package is to fetch the distribution files
                   3408: (distfiles) from the sites that are providing them. This is the task of the 
                   3409: fetch phase.
1.25      wiz      3410: 
1.184     rillig   3411: 13.5.1. What to fetch and where to get it from
1.1       dsieger  3412: 
1.184     rillig   3413: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
                   3414: name is derived from the DISTNAME variable, is fetched. The more complicated
                   3415: cases are described below.
1.1       dsieger  3416: 
1.184     rillig   3417: The variable DISTFILES specifies the list of distfiles that have to be fetched.
                   3418: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
                   3419: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
                   3420: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
                   3421: your package requires additional distfiles to the default one, you cannot just
                   3422: append the additional filenames using the += operator, but you have write for
                   3423: example:
1.1       dsieger  3424: 
1.184     rillig   3425: DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1       dsieger  3426: 
1.184     rillig   3427: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
                   3428: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
                   3429: can set SITES.distfile to the list of URLs where the file distfile (including
                   3430: the suffix) can be found.
1.1       dsieger  3431: 
1.184     rillig   3432: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   3433: DISTFILES+=     foo-file.tar.gz
                   3434: SITES.foo-file.tar.gz= \
                   3435: https://www.somewhere.com/somehow/ \
                   3436: https://www.somewhereelse.com/mirror/somehow/
1.1       dsieger  3437: 
1.184     rillig   3438: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
                   3439: gets the name of each distfile appended to it, without an intermediate slash.
                   3440: Therefore, all site values have to end with a slash or other separator
                   3441: character. This allows for example to set MASTER_SITES to a URL of a CGI script
                   3442: that gets the name of the distfile as a parameter. In this case, the definition
                   3443: would look like:
1.1       dsieger  3444: 
1.184     rillig   3445: MASTER_SITES=   https://www.example.com/download.cgi?file=
1.1       dsieger  3446: 
1.184     rillig   3447: The exception to this rule are URLs starting with a dash. In that case the URL
                   3448: is taken as is, fetched and the result stored under the name of the distfile.
                   3449: You can use this style for the case when the download URL style does not match
                   3450: the above common case. For example, if permanent download URL is a redirector
                   3451: to the real download URL, or the download file name is offered by an HTTP
                   3452: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
                   3453: created instead of the default v1.0.0.tar.gz.
1.1       dsieger  3454: 
1.184     rillig   3455: DISTNAME=       foo-1.0.0
                   3456: MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
1.29      wiz      3457: 
1.184     rillig   3458: There are some predefined values for MASTER_SITES, which can be used in
                   3459: packages. The names of the variables should speak for themselves.
1.29      wiz      3460: 
1.225     gutterid 3461: MASTER_SITE_APACHE        MASTER_SITE_BACKUP
                   3462: MASTER_SITE_CRATESIO      MASTER_SITE_CYGWIN
                   3463: MASTER_SITE_DEBIAN        MASTER_SITE_FREEBSD
                   3464: MASTER_SITE_FREEBSD_LOCAL MASTER_SITE_GENTOO
                   3465: MASTER_SITE_GITHUB        MASTER_SITE_GITLAB
                   3466: MASTER_SITE_GNOME         MASTER_SITE_GNU
                   3467: MASTER_SITE_GNUSTEP       MASTER_SITE_HASKELL_HACKAGE
                   3468: MASTER_SITE_IFARCHIVE     MASTER_SITE_KDE
                   3469: MASTER_SITE_MOZILLA       MASTER_SITE_MOZILLA_ALL
                   3470: MASTER_SITE_MYSQL         MASTER_SITE_NETLIB
                   3471: MASTER_SITE_OPENBSD       MASTER_SITE_OPENOFFICE
                   3472: MASTER_SITE_OSDN          MASTER_SITE_PERL_CPAN
                   3473: MASTER_SITE_PGSQL         MASTER_SITE_PYPI
                   3474: MASTER_SITE_RUBYGEMS      MASTER_SITE_R_CRAN
                   3475: MASTER_SITE_SOURCEFORGE   MASTER_SITE_SUNSITE
                   3476: MASTER_SITE_SUSE          MASTER_SITE_TEX_CTAN
                   3477: MASTER_SITE_XCONTRIB      MASTER_SITE_XEMACS
                   3478: MASTER_SITE_XORG           
1.1       dsieger  3479: 
1.184     rillig   3480: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
                   3481: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
                   3482: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
                   3483: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
                   3484: distfiles/LOCAL_PORTS/.
1.1       dsieger  3485: 
1.184     rillig   3486: If you choose one of these predefined sites, you may want to specify a
                   3487: subdirectory of that site. Since these macros may expand to more than one
                   3488: actual site, you must use the following construct to specify a subdirectory:
1.1       dsieger  3489: 
1.184     rillig   3490: MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   3491: MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1       dsieger  3492: 
1.184     rillig   3493: Note the trailing slash after the subdirectory name.
1.1       dsieger  3494: 
1.184     rillig   3495: 13.5.2. How are the files fetched?
1.1       dsieger  3496: 
1.184     rillig   3497: The fetch phase makes sure that all the distfiles exist in a local directory
                   3498: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
                   3499: are fetched using commands of the form
1.1       dsieger  3500: 
1.184     rillig   3501: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
1.1       dsieger  3502: 
1.184     rillig   3503: where ${site} varies through several possibilities in turn: first,
                   3504: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
                   3505: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
                   3506: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
                   3507: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
                   3508: MASTER_SORT_AWK or MASTER_SORT_REGEX.
1.1       dsieger  3509: 
1.184     rillig   3510: The specific command and arguments used depend on the FETCH_USING parameter.
                   3511: The example above is for FETCH_USING=custom.
1.66      asau     3512: 
1.184     rillig   3513: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
                   3514: target to mirror the distfiles, if they are freely distributable. Packages
                   3515: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
                   3516: distfiles mirrored.
1.1       dsieger  3517: 
1.184     rillig   3518: 13.6. The checksum phase
1.1       dsieger  3519: 
1.184     rillig   3520: After the distfile(s) are fetched, their checksum is generated and compared
                   3521: with the checksums stored in the distinfo file. If the checksums don't match,
                   3522: the build is aborted. This is to ensure the same distfile is used for building,
                   3523: and that the distfile wasn't changed, e.g. by some malign force, deliberately
                   3524: changed distfiles on the master distribution site or network lossage.
1.1       dsieger  3525: 
1.184     rillig   3526: 13.7. The extract phase
1.1       dsieger  3527: 
1.184     rillig   3528: When the distfiles are present on the local system, they need to be extracted,
                   3529: as they usually come in the form of some compressed archive format.
1.1       dsieger  3530: 
1.184     rillig   3531: By default, all DISTFILES are extracted. If you only need some of them, you can
                   3532: set the EXTRACT_ONLY variable to the list of those files.
1.1       dsieger  3533: 
1.184     rillig   3534: Extracting the files is usually done by a little program, mk/extract/extract,
                   3535: which already knows how to extract various archive formats, so most likely you
                   3536: will not need to change anything here. But if you need, the following variables
                   3537: may help you:
1.1       dsieger  3538: 
1.184     rillig   3539: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
1.1       dsieger  3540: 
1.184     rillig   3541:     Use these variables to override the default options for an extract command,
                   3542:     which are defined in mk/extract/extract.
1.1       dsieger  3543: 
1.184     rillig   3544: EXTRACT_USING
1.1       dsieger  3545: 
1.184     rillig   3546:     This variable can be set to bsdtar, gtar, nbtar (which is the default
                   3547:     value), pax, or an absolute pathname pointing to the command with which tar
                   3548:     archives should be extracted. It is preferred to choose bsdtar over gtar if
                   3549:     NetBSD's pax-as-tar is not good enough.
1.1       dsieger  3550: 
1.184     rillig   3551: If the extract program doesn't serve your needs, you can also override the
                   3552: EXTRACT_CMD variable, which holds the command used for extracting the files.
                   3553: This command is executed in the ${WRKSRC} directory. During execution of this
                   3554: command, the shell variable extract_file holds the absolute pathname of the
                   3555: file that is going to be extracted.
1.1       dsieger  3556: 
1.184     rillig   3557: And if that still does not suffice, you can override the do-extract target in
                   3558: the package Makefile.
1.1       dsieger  3559: 
1.184     rillig   3560: 13.8. The patch phase
1.1       dsieger  3561: 
1.184     rillig   3562: After extraction, all the patches named by the PATCHFILES, those present in the
                   3563: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
                   3564: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
                   3565: are uncompressed before they are applied, files ending in .orig or .rej are
                   3566: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
                   3567: Section 12.3, "patches/*" for more details.
1.1       dsieger  3568: 
1.184     rillig   3569: By default patch(1) is given special arguments to make it fail if the expected
                   3570: text from the patch context is not found in the patched file. If that happens,
                   3571: fix the patch file by comparing it with the actual text in the file to be
                   3572: patched.
1.1       dsieger  3573: 
1.184     rillig   3574: 13.9. The tools phase
1.1       dsieger  3575: 
1.184     rillig   3576: This is covered in Chapter 17, Tools needed for building or running.
1.1       dsieger  3577: 
1.184     rillig   3578: 13.10. The wrapper phase
1.1       dsieger  3579: 
1.184     rillig   3580: This phase creates wrapper programs for the compilers and linkers. The
                   3581: following variables can be used to tweak the wrappers.
1.1       dsieger  3582: 
1.184     rillig   3583: ECHO_WRAPPER_MSG
1.1       dsieger  3584: 
1.184     rillig   3585:     The command used to print progress messages. Does nothing by default. Set
                   3586:     to ${ECHO} to see the progress messages.
1.1       dsieger  3587: 
1.184     rillig   3588: WRAPPER_DEBUG
1.1       dsieger  3589: 
1.184     rillig   3590:     This variable can be set to yes (default) or no, depending on whether you
                   3591:     want additional information in the wrapper log file.
1.1       dsieger  3592: 
1.184     rillig   3593: WRAPPER_UPDATE_CACHE
1.1       dsieger  3594: 
1.184     rillig   3595:     This variable can be set to yes or no, depending on whether the wrapper
                   3596:     should use its cache, which will improve the speed. The default value is
                   3597:     yes, but is forced to no if the platform does not support it.
1.1       dsieger  3598: 
1.184     rillig   3599: WRAPPER_REORDER_CMDS
1.1       dsieger  3600: 
1.184     rillig   3601:     A list of reordering commands. A reordering command has the form reorder:l:
                   3602:     lib1:lib2. It ensures that that -llib1 occurs before -llib2.
1.1       dsieger  3603: 
1.184     rillig   3604: 13.11. The configure phase
1.1       dsieger  3605: 
1.184     rillig   3606: Most pieces of software need information on the header files, system calls, and
                   3607: library routines which are available on the platform they run on. The process
                   3608: of determining this information is known as configuration, and is usually
                   3609: automated. In most cases, a script is supplied with the distfiles, and its
                   3610: invocation results in generation of header files, Makefiles, etc.
1.1       dsieger  3611: 
1.184     rillig   3612: If the package contains a configure script, this can be invoked by setting
                   3613: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
1.187     rillig   3614: should set GNU_CONFIGURE to "yes" instead.
1.1       dsieger  3615: 
1.187     rillig   3616: In the do-configure stage, a rough equivalent of the following command is run.
                   3617: See mk/configure/configure.mk, target do-configure-script for the exact
                   3618: definition.
                   3619: 
                   3620: .for dir in ${CONFIGURE_DIRS}
                   3621:         cd ${WRKSRC} && cd ${dir} \
                   3622:         && env ${CONFIGURE_ENV} \
                   3623:             ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
1.184     rillig   3624: .endfor
1.1       dsieger  3625: 
1.184     rillig   3626: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
                   3627: each of these directories, the configure script is run with the environment
                   3628: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
                   3629: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
                   3630: by the package.
1.1       dsieger  3631: 
1.184     rillig   3632: If the program uses the Perl way of configuration (mainly Perl modules, but not
                   3633: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
                   3634: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
                   3635: (e.g., MAKE_PARAMS+=foo=bar
1.1       dsieger  3636: 
1.184     rillig   3637: If the program uses an Imakefile for configuration, the appropriate steps can
                   3638: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
                   3639: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
                   3640: SCRIPTS_ENV variable.
1.1       dsieger  3641: 
1.184     rillig   3642: If the program uses cmake for configuration, the appropriate steps can be
1.233     wiz      3643: invoked by including ../../devel/cmake/build.mk. You can add variables to
                   3644: cmake's environment by adding them to the CONFIGURE_ENV variable and arguments
1.256     wiz      3645: to cmake by adding them to the CMAKE_CONFIGURE_ARGS variable. If you want to
                   3646: add arguments only for particular stages, you can use the CMAKE_CONFIGURE_ARGS,
1.233     wiz      3647: CMAKE_BUILD_ARGS, and CMAKE_INSTALL_ARGS variables. You can set the
                   3648: CONFIGURE_DIRS variable to the directories in which CMake should be run,
                   3649: relative to WRKSRC. This defaults to to ".".
1.1       dsieger  3650: 
1.256     wiz      3651: Any package using the now-deprecated USE_CMAKE=yes should be converted.
                   3652: Essentially, replace with an include of ../../devel/cmake/build.mk, prune
                   3653: creation of a build directory and settings to use it, and check/fix settings
                   3654: that intend to perform the build in a subdirectory.
                   3655: 
1.184     rillig   3656: If there is no configure step at all, set NO_CONFIGURE to "yes".
1.1       dsieger  3657: 
1.184     rillig   3658: 13.12. The build phase
1.1       dsieger  3659: 
1.187     rillig   3660: For building a package, a rough equivalent of the following code is executed;
                   3661: see mk/build/build.mk, target do-build for the exact definition.
1.154     rillig   3662: 
1.187     rillig   3663: .for dir in ${BUILD_DIRS}
                   3664:         cd ${WRKSRC} && cd ${dir} \
1.184     rillig   3665:         && env ${MAKE_ENV} \
1.187     rillig   3666:             ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
1.184     rillig   3667:                 -f ${MAKE_FILE} \
                   3668:                 ${BUILD_TARGET}
                   3669: .endfor
1.1       dsieger  3670: 
1.184     rillig   3671: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
                   3672: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
                   3673: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
                   3674: and BUILD_TARGET may all be changed by the package.
1.1       dsieger  3675: 
1.184     rillig   3676: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
                   3677: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
                   3678: defaults to "all".
1.1       dsieger  3679: 
1.184     rillig   3680: If there is no build step at all, set NO_BUILD to "yes".
1.1       dsieger  3681: 
1.184     rillig   3682: 13.13. The test phase
1.1       dsieger  3683: 
1.184     rillig   3684: [TODO]
1.1       dsieger  3685: 
1.184     rillig   3686: 13.14. The install phase
1.1       dsieger  3687: 
1.184     rillig   3688: Once the build stage has completed, the final step is to install the software
                   3689: in public directories, so users can access the programs and files.
1.1       dsieger  3690: 
1.187     rillig   3691: In the install phase, a rough equivalent of the following code is executed; see
                   3692: mk/install/install.mk, target do-install for the exact definition.
                   3693: Additionally, before and after this code, several consistency checks are run
                   3694: against the files-to-be-installed, see mk/check/*.mk for details.
                   3695: 
                   3696: .for dir in ${INSTALL_DIRS}
                   3697:         cd ${WRKSRC} && cd ${dir} \
                   3698:         && env ${INSTALL_ENV} ${MAKE_ENV} \
                   3699:             ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \
                   3700:                 -f ${MAKE_FILE} ${INSTALL_TARGET}
1.184     rillig   3701: .endfor
1.1       dsieger  3702: 
1.184     rillig   3703: The variable's meanings are analogous to the ones in the build phase.
                   3704: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
                   3705: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
                   3706: defined.
1.1       dsieger  3707: 
1.184     rillig   3708: In the install phase, the following variables are useful. They are all
                   3709: variations of the install(1) command that have the owner, group and permissions
                   3710: preset. INSTALL is the plain install command. The specialized variants,
                   3711: together with their intended use, are:
1.1       dsieger  3712: 
1.184     rillig   3713: INSTALL_PROGRAM_DIR
1.1       dsieger  3714: 
1.184     rillig   3715:     directories that contain binaries
1.1       dsieger  3716: 
1.184     rillig   3717: INSTALL_SCRIPT_DIR
1.1       dsieger  3718: 
1.184     rillig   3719:     directories that contain scripts
1.1       dsieger  3720: 
1.184     rillig   3721: INSTALL_LIB_DIR
1.1       dsieger  3722: 
1.184     rillig   3723:     directories that contain shared and static libraries
1.1       dsieger  3724: 
1.184     rillig   3725: INSTALL_DATA_DIR
1.108     rillig   3726: 
1.184     rillig   3727:     directories that contain data files
1.108     rillig   3728: 
1.184     rillig   3729: INSTALL_MAN_DIR
1.108     rillig   3730: 
1.184     rillig   3731:     directories that contain man pages
1.108     rillig   3732: 
1.184     rillig   3733: INSTALL_GAME_DIR
1.108     rillig   3734: 
1.184     rillig   3735:     directories that contain data files for games
1.108     rillig   3736: 
1.184     rillig   3737: INSTALL_PROGRAM
1.108     rillig   3738: 
1.184     rillig   3739:     binaries that can be stripped from debugging symbols
1.108     rillig   3740: 
1.184     rillig   3741: INSTALL_SCRIPT
1.108     rillig   3742: 
1.184     rillig   3743:     binaries that cannot be stripped
1.108     rillig   3744: 
1.184     rillig   3745: INSTALL_GAME
1.108     rillig   3746: 
1.184     rillig   3747:     game binaries
1.108     rillig   3748: 
1.184     rillig   3749: INSTALL_LIB
1.108     rillig   3750: 
1.184     rillig   3751:     shared and static libraries
1.108     rillig   3752: 
1.184     rillig   3753: INSTALL_DATA
1.108     rillig   3754: 
1.184     rillig   3755:     data files
1.1       dsieger  3756: 
1.184     rillig   3757: INSTALL_GAME_DATA
1.1       dsieger  3758: 
1.184     rillig   3759:     data files for games
1.108     rillig   3760: 
1.184     rillig   3761: INSTALL_MAN
1.108     rillig   3762: 
1.184     rillig   3763:     man pages
1.1       dsieger  3764: 
1.184     rillig   3765: Some other variables are:
1.1       dsieger  3766: 
1.184     rillig   3767: INSTALL_UNSTRIPPED
1.1       dsieger  3768: 
1.184     rillig   3769:     If set to yes, do not run strip(1) when installing binaries. Any debugging
                   3770:     sections and symbols present in binaries will be preserved.
1.1       dsieger  3771: 
1.184     rillig   3772: INSTALLATION_DIRS
1.1       dsieger  3773: 
1.184     rillig   3774:     A list of directories relative to PREFIX that are created by pkgsrc at the
                   3775:     beginning of the install phase. The package is supposed to create all
                   3776:     needed directories itself before installing files to it and list all other
                   3777:     directories here.
1.1       dsieger  3778: 
1.184     rillig   3779: In the rare cases that a package shouldn't install anything, set NO_INSTALL to 
                   3780: "yes". This is mostly relevant for packages in the regress category.
1.1       dsieger  3781: 
1.184     rillig   3782: 13.15. The package phase
1.121     sevan    3783: 
1.184     rillig   3784: Once the install stage has completed, a binary package of the installed files
                   3785: can be built. These binary packages can be used for quick installation without
                   3786: previous compilation, e.g. by the make bin-install or by using pkg_add.
1.1       dsieger  3787: 
1.184     rillig   3788: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
                   3789: created in ${PACKAGES}/category, one for each category in the CATEGORIES
                   3790: variable. PACKAGES defaults to pkgsrc/packages.
1.1       dsieger  3791: 
1.184     rillig   3792: 13.16. Cleaning up
1.1       dsieger  3793: 
1.184     rillig   3794: Once you're finished with a package, you can clean the work directory by
                   3795: running make clean. If you want to clean the work directories of all
                   3796: dependencies too, use make clean-depends.
1.1       dsieger  3797: 
1.184     rillig   3798: 13.17. Other helpful targets
1.1       dsieger  3799: 
1.184     rillig   3800: pre/post-*
1.1       dsieger  3801: 
1.184     rillig   3802:     For any of the main targets described in the previous section (configure,
                   3803:     build, install, etc.), two auxiliary targets exist with "pre-" and "post-"
                   3804:     used as a prefix for the main target's name. These targets are invoked
                   3805:     before and after the main target is called, allowing extra configuration or
                   3806:     installation steps be performed from a package's Makefile, for example,
                   3807:     which a program's configure script or install target omitted.
                   3808: 
                   3809:     About 5% of the pkgsrc packages define their custom post-extract target,
                   3810:     another 5% define pre-configure, and 10% define post-install. The other pre
                   3811:     /post-* targets are defined even less often.
1.1       dsieger  3812: 
1.184     rillig   3813: do-*
1.182     leot     3814: 
1.184     rillig   3815:     Should one of the main targets do the wrong thing, and should there be no
                   3816:     variable to fix this, you can redefine it with the do-* target. (Note that
                   3817:     redefining the target itself instead of the do-* target is a bad idea, as
                   3818:     the pre-* and post-* targets won't be called anymore, etc.)
1.1       dsieger  3819: 
1.184     rillig   3820:     About 15% of the pkgsrc packages override the default do-install, the other
                   3821:     do-* targets are overridden even less often.
1.1       dsieger  3822: 
1.184     rillig   3823: reinstall
1.1       dsieger  3824: 
1.184     rillig   3825:     If you did a make install and you noticed some file was not installed
                   3826:     properly, you can repeat the installation with this target, which will
                   3827:     ignore the "already installed" flag.
1.1       dsieger  3828: 
1.184     rillig   3829:     This is the default value of DEPENDS_TARGET except in the case of make
                   3830:     update and make package, where the defaults are "package" and "update",
                   3831:     respectively.
1.1       dsieger  3832: 
1.184     rillig   3833: deinstall
1.1       dsieger  3834: 
1.184     rillig   3835:     This target does a pkg_delete(1) in the current directory, effectively
                   3836:     de-installing the package. The following variables can be used to tune the
                   3837:     behaviour:
1.1       dsieger  3838: 
1.184     rillig   3839:     PKG_VERBOSE
1.1       dsieger  3840: 
1.184     rillig   3841:         Add a "-v" to the pkg_delete(1) command.
1.1       dsieger  3842: 
1.184     rillig   3843:     DEINSTALLDEPENDS
1.1       dsieger  3844: 
1.184     rillig   3845:         Remove all packages that require (depend on) the given package. This
                   3846:         can be used to remove any packages that may have been pulled in by a
                   3847:         given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
                   3848:         pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
                   3849:         " to the pkg_delete(1) command line.
1.1       dsieger  3850: 
1.184     rillig   3851: bin-install
1.1       dsieger  3852: 
1.184     rillig   3853:     Install a binary package from local disk and via FTP from a list of sites
                   3854:     (see the BINPKG_SITES variable), and do a make package if no binary package
                   3855:     is available anywhere. The arguments given to pkg_add can be set via
                   3856:     BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
1.1       dsieger  3857: 
1.184     rillig   3858: install-clean
1.1       dsieger  3859: 
1.184     rillig   3860:     This target removes the state files for the "install" and later phases so
                   3861:     that the "install" target may be re-invoked. This can be used after editing
                   3862:     the PLIST to install the package without rebuilding it.
1.1       dsieger  3863: 
1.184     rillig   3864: build-clean
1.18      mishka   3865: 
1.184     rillig   3866:     This target removes the state files for the "build" and later phases so
                   3867:     that the "build" target may be re-invoked.
1.18      mishka   3868: 
1.184     rillig   3869: update
1.18      mishka   3870: 
1.184     rillig   3871:     This target causes the current package to be updated to the latest version.
                   3872:     The package and all depending packages first get de-installed, then current
                   3873:     versions of the corresponding packages get compiled and installed. This is
                   3874:     similar to manually noting which packages are currently installed, then
                   3875:     performing a series of make deinstall and make install (or whatever
                   3876:     UPDATE_TARGET is set to) for these packages.
1.18      mishka   3877: 
1.184     rillig   3878:     You can use the "update" target to resume package updating in case a
                   3879:     previous make update was interrupted for some reason. However, in this
                   3880:     case, make sure you don't call make clean or otherwise remove the list of
                   3881:     dependent packages in WRKDIR. Otherwise, you lose the ability to
                   3882:     automatically update the current package along with the dependent packages
                   3883:     you have installed.
1.121     sevan    3884: 
1.184     rillig   3885:     Resuming an interrupted make update will only work as long as the package
                   3886:     tree remains unchanged. If the source code for one of the packages to be
                   3887:     updated has been changed, resuming make update will most certainly fail!
1.1       dsieger  3888: 
1.184     rillig   3889:     The following variables can be used either on the command line or in
                   3890:     mk.conf to alter the behaviour of make update:
1.1       dsieger  3891: 
1.184     rillig   3892:     UPDATE_TARGET
1.1       dsieger  3893: 
1.184     rillig   3894:         Install target to recursively use for the updated package and the
                   3895:         dependent packages. Defaults to DEPENDS_TARGET if set, "install"
                   3896:         otherwise for make update. Other good targets are "package" or "
                   3897:         bin-install". Do not set this to "update" or you will get stuck in an
                   3898:         endless loop!
1.1       dsieger  3899: 
1.184     rillig   3900:     NOCLEAN
1.1       dsieger  3901: 
1.184     rillig   3902:         Don't clean up after updating. Useful if you want to leave the work
                   3903:         sources of the updated packages around for inspection or other
                   3904:         purposes. Be sure you eventually clean up the source tree (see the "
                   3905:         clean-update" target below) or you may run into troubles with old
                   3906:         source code still lying around on your next make or make update.
1.1       dsieger  3907: 
1.184     rillig   3908:     REINSTALL
1.1       dsieger  3909: 
1.184     rillig   3910:         Deinstall each package before installing (making DEPENDS_TARGET). This
                   3911:         may be necessary if the "clean-update" target (see below) was called
                   3912:         after interrupting a running make update.
1.1       dsieger  3913: 
1.184     rillig   3914:     DEPENDS_TARGET
1.1       dsieger  3915: 
1.184     rillig   3916:         Allows you to disable recursion and hardcode the target for packages.
                   3917:         The default is "update" for the update target, facilitating a recursive
                   3918:         update of prerequisite packages. Only set DEPENDS_TARGET if you want to
                   3919:         disable recursive updates. Use UPDATE_TARGET instead to just set a
                   3920:         specific target for each package to be installed during make update
                   3921:         (see above).
1.1       dsieger  3922: 
1.184     rillig   3923: clean-update
1.1       dsieger  3924: 
1.184     rillig   3925:     Clean the source tree for all packages that would get updated if make
                   3926:     update was called from the current directory. This target should not be
                   3927:     used if the current package (or any of its depending packages) have already
                   3928:     been de-installed (e.g., after calling make update) or you may lose some
                   3929:     packages you intended to update. As a rule of thumb: only use this target 
                   3930:     before the first time you run make update and only if you have a dirty
                   3931:     package tree (e.g., if you used NOCLEAN).
1.86      wiz      3932: 
1.184     rillig   3933:     If you are unsure about whether your tree is clean, you can either perform
                   3934:     a make clean at the top of the tree, or use the following sequence of
                   3935:     commands from the directory of the package you want to update (before
                   3936:     running make update for the first time, otherwise you lose all the packages
                   3937:     you wanted to update!):
1.86      wiz      3938: 
1.184     rillig   3939:     # make clean-update
                   3940:     # make clean CLEANDEPENDS=YES
                   3941:     # make update
1.86      wiz      3942: 
                   3943: 
1.184     rillig   3944:     The following variables can be used either on the command line or in
                   3945:     mk.conf to alter the behaviour of make clean-update:
1.86      wiz      3946: 
1.184     rillig   3947:     CLEAR_DIRLIST
1.86      wiz      3948: 
1.184     rillig   3949:         After make clean, do not reconstruct the list of directories to update
                   3950:         for this package. Only use this if make update successfully installed
                   3951:         all packages you wanted to update. Normally, this is done automatically
                   3952:         on make update, but may have been suppressed by the NOCLEAN variable
                   3953:         (see above).
1.1       dsieger  3954: 
1.184     rillig   3955: replace
1.1       dsieger  3956: 
1.184     rillig   3957:     Update the installation of the current package. This differs from update in
                   3958:     that it does not replace dependent packages. You will need to install
                   3959:     pkgtools/pkg_tarup for this target to work.
1.1       dsieger  3960: 
1.184     rillig   3961:     Be careful when using this target! There are no guarantees that dependent
                   3962:     packages will still work, in particular they will most certainly break if
                   3963:     you make replace a library package whose shared library major version
                   3964:     changed between your installed version and the new one. For this reason,
                   3965:     this target is not officially supported and only recommended for advanced
                   3966:     users.
1.1       dsieger  3967: 
1.184     rillig   3968: info
1.1       dsieger  3969: 
1.184     rillig   3970:     This target invokes pkg_info(1) for the current package. You can use this
                   3971:     to check which version of a package is installed.
1.86      wiz      3972: 
1.184     rillig   3973: index
1.1       dsieger  3974: 
1.184     rillig   3975:     This is a top-level command, i.e. it should be used in the pkgsrc
                   3976:     directory. It creates a database of all packages in the local pkgsrc tree,
                   3977:     including dependencies, comment, maintainer, and some other useful
                   3978:     information. Individual entries are created by running make describe in the
                   3979:     packages' directories. This index file is saved as pkgsrc/INDEX. It can be
                   3980:     displayed in verbose format by running make print-index. You can search in
                   3981:     it with make search key=something. You can extract a list of all packages
                   3982:     that depend on a particular one by running make show-deps PKG=somepackage.
1.1       dsieger  3983: 
1.184     rillig   3984:     Running this command takes a very long time, some hours even on fast
                   3985:     machines!
1.1       dsieger  3986: 
1.184     rillig   3987: readme
1.1       dsieger  3988: 
1.199     nia      3989:     This target generates a index.html file, which can be viewed using a
1.184     rillig   3990:     browser such as www/firefox or www/links. The generated files contain
                   3991:     references to any packages which are in the PACKAGES directory on the local
                   3992:     host. The generated files can be made to refer to URLs based on
                   3993:     FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
1.199     nia      3994:     index.html files which pointed to binary packages on the local machine, in
1.184     rillig   3995:     the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
                   3996:     FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
                   3997:     subdirectories will be searched for all the binary packages.
1.1       dsieger  3998: 
1.184     rillig   3999:     The target can be run at the toplevel or in category directories, in which
                   4000:     case it descends recursively.
1.1       dsieger  4001: 
1.184     rillig   4002: readme-all
1.1       dsieger  4003: 
1.184     rillig   4004:     This is a top-level command, run it in pkgsrc. Use this target to create a
                   4005:     file README-all.html which contains a list of all packages currently
                   4006:     available in the NetBSD Packages Collection, together with the category
                   4007:     they belong to and a short description. This file is compiled from the
1.199     nia      4008:     pkgsrc/*/index.html files, so be sure to run this after a make readme.
1.1       dsieger  4009: 
1.184     rillig   4010: cdrom-readme
1.1       dsieger  4011: 
1.184     rillig   4012:     This is very much the same as the "readme" target (see above), but is to be
                   4013:     used when generating a pkgsrc tree to be written to a CD-ROM. This target
1.199     nia      4014:     also produces index.html files, and can be made to refer to URLs based on
1.184     rillig   4015:     CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
1.1       dsieger  4016: 
1.184     rillig   4017: show-distfiles
1.1       dsieger  4018: 
1.184     rillig   4019:     This target shows which distfiles and patchfiles are needed to build the
                   4020:     package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
                   4021:     patches/*).
1.1       dsieger  4022: 
1.184     rillig   4023: show-downlevel
1.1       dsieger  4024: 
1.184     rillig   4025:     This target shows nothing if the package is not installed. If a version of
                   4026:     this package is installed, but is not the version provided in this version
                   4027:     of pkgsrc, then a warning message is displayed. This target can be used to
                   4028:     show which of your installed packages are downlevel, and so the old
                   4029:     versions can be deleted, and the current ones added.
1.1       dsieger  4030: 
1.184     rillig   4031: show-pkgsrc-dir
1.1       dsieger  4032: 
1.184     rillig   4033:     This target shows the directory in the pkgsrc hierarchy from which the
                   4034:     package can be built and installed. This may not be the same directory as
                   4035:     the one from which the package was installed. This target is intended to be
                   4036:     used by people who may wish to upgrade many packages on a single host, and
                   4037:     can be invoked from the top-level pkgsrc Makefile by using the "
                   4038:     show-host-specific-pkgs" target.
1.1       dsieger  4039: 
1.184     rillig   4040: show-installed-depends
1.1       dsieger  4041: 
1.184     rillig   4042:     This target shows which installed packages match the current package's
                   4043:     DEPENDS. Useful if out of date dependencies are causing build problems.
1.1       dsieger  4044: 
1.184     rillig   4045: print-build-depends-list
1.1       dsieger  4046: 
1.184     rillig   4047:     This target shows the list of packages that the current package depends on
                   4048:     for building.
1.1       dsieger  4049: 
1.184     rillig   4050: print-run-depends-list
1.1       dsieger  4051: 
1.184     rillig   4052:     This target shows the list of packages that the current package depends on
                   4053:     for running.
1.1       dsieger  4054: 
1.184     rillig   4055: check-shlibs
1.1       dsieger  4056: 
1.184     rillig   4057:     After a package is installed, check all its binaries and (on ELF platforms)
                   4058:     shared libraries to see if they find the shared libs they need. Run by
                   4059:     default if PKG_DEVELOPER is set in mk.conf.
1.1       dsieger  4060: 
1.184     rillig   4061: print-PLIST
1.1       dsieger  4062: 
1.184     rillig   4063:     After a "make install" from a new or upgraded pkg, this prints out an
                   4064:     attempt to generate a new PLIST from a find -newer work/.extract_done. An
                   4065:     attempt is made to care for shared libs etc., but it is strongly
                   4066:     recommended to review the result before putting it into PLIST. On upgrades,
                   4067:     it's useful to diff the output of this command against an already existing
                   4068:     PLIST file.
1.1       dsieger  4069: 
1.184     rillig   4070:     If the package installs files via tar(1) or other methods that don't update
                   4071:     file access times, be sure to add these files manually to your PLIST, as
                   4072:     the "find -newer" command used by this target won't catch them!
1.56      ryoon    4073: 
1.184     rillig   4074:     See Section 19.3, "Tweaking output of make print-PLIST" for more
                   4075:     information on this target.
1.1       dsieger  4076: 
1.255     wiz      4077: rebuild
                   4078: 
                   4079:     If you did a make build and you noticed some further modifications of
                   4080:     sources are needed, you can repeat the build with this target, which will
                   4081:     ignore the "already built" flag. This target is helpful while working with
                   4082:     patches.
                   4083: 
                   4084: repackage
                   4085: 
                   4086:     If you did a make package and you noticed some further modifications of
                   4087:     sources are needed, you can repeat the package with this target, which will
                   4088:     ignore the "already packaged" flag. This target is helpful while working
                   4089:     with patches, PLIST* files etc.
                   4090: 
                   4091: retest
                   4092: 
                   4093:     If you did a make test and you noticed some further modifications of
                   4094:     sources are needed, you can repeat the test with this target, which will
                   4095:     ignore the "already tested" flag. This target is helpful while working with
                   4096:     patches.
                   4097: 
1.184     rillig   4098: Chapter 14. Creating a new pkgsrc package from scratch
1.1       dsieger  4099: 
1.184     rillig   4100: Table of Contents
1.1       dsieger  4101: 
1.184     rillig   4102: 14.1. Common types of packages
1.219     nia      4103:     14.1.1. Python modules and programs
                   4104:     14.1.2. R packages
                   4105:     14.1.3. TeXlive packages
1.184     rillig   4106: 14.2. Examples
                   4107:     14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  4108: 
1.184     rillig   4109: When you find a package that is not yet in pkgsrc, you most likely have a URL
                   4110: from where you can download the source code. Starting with this URL, creating a
                   4111: package involves only a few steps.
1.1       dsieger  4112: 
1.184     rillig   4113:  1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
1.1       dsieger  4114: 
1.184     rillig   4115:  2. Install the package meta-pkgs/pkg_developer, which among others will
                   4116:     install the utilities url2pkg, pkglint, pkgvi and mkpatches:
1.1       dsieger  4117: 
1.184     rillig   4118:     $ cd /usr/pkgsrc
                   4119:     $ (cd meta-pkgs/pkg_developer && bmake update)
1.1       dsieger  4120: 
1.184     rillig   4121:  3. Choose one of the top-level directories as the category in which you want
                   4122:     to place your package. You can also create a directory of your own (maybe
1.219     nia      4123:     called local). Change into that category directory:
1.1       dsieger  4124: 
1.219     nia      4125:     $ cd category
1.1       dsieger  4126: 
1.219     nia      4127:  4. Run the program url2pkg, passing as argument the URL of the distribution
                   4128:     file (in most cases a .tar.gz file). This will download the distribution
                   4129:     file and create the necessary files of the package, based on what's in the
                   4130:     distribution file:
1.1       dsieger  4131: 
1.184     rillig   4132:     $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
1.1       dsieger  4133: 
1.184     rillig   4134:  5. Examine the extracted files to determine the dependencies of your package.
                   4135:     Ideally, this is mentioned in some README file, but things may differ. For
                   4136:     each of these dependencies, look where it exists in pkgsrc, and if there is
                   4137:     a file called buildlink3.mk in that directory, add a line to your package
                   4138:     Makefile which includes that file just before the last line. If the
                   4139:     buildlink3.mk file does not exist, it must be created first. The
                   4140:     buildlink3.mk file makes sure that the package's include files and
                   4141:     libraries are provided.
1.1       dsieger  4142: 
1.219     nia      4143:     If you just need binaries from a dependent package, add a DEPENDS line to
                   4144:     the Makefile, which specifies the version of the dependency and where it
                   4145:     can be found in pkgsrc. This line should be placed in the third paragraph.
                   4146:     If the dependency is only needed for building the package, but not when
                   4147:     using it, use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The
                   4148:     difference between TOOL_DEPENDS and BUILD_DEPENDS occurs when
                   4149:     cross-compiling: TOOL_DEPENDS are native packages, i.e. packages for the
                   4150:     platform where the package is built; BUILD_DEPENDS are target packages,
                   4151:     i.e. packages for the platform for which the package is built. There is
                   4152:     also TEST_DEPENDS, which specifies a dependency used only for testing the
                   4153:     resulting package built, using the upstream project's included test suite,
                   4154:     on the native platform. Your package may then look like this:
1.1       dsieger  4155: 
1.184     rillig   4156:     [...]
1.1       dsieger  4157: 
1.184     rillig   4158:     TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
                   4159:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   4160:     DEPENDS+=       screen>=4.0:../../misc/screen
1.1       dsieger  4161: 
1.184     rillig   4162:     [...]
1.1       dsieger  4163: 
1.184     rillig   4164:     .include "../../category/package/buildlink3.mk"
                   4165:     .include "../../devel/glib2/buildlink3.mk"
                   4166:     .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4167: 
1.184     rillig   4168:  6. Run pkglint to see what things still need to be done to make your package a
                   4169:     "good" one. If you don't know what pkglint's warnings want to tell you, try
                   4170:     pkglint --explain or pkglint -e, which outputs additional explanations.
1.1       dsieger  4171: 
1.184     rillig   4172:  7. In many cases the package is not yet ready to build. You can find
                   4173:     instructions for the most common cases in the next section, Section 14.1,
                   4174:     "Common types of packages". After you have followed the instructions over
                   4175:     there, you can hopefully continue here.
1.1       dsieger  4176: 
1.184     rillig   4177:  8. Run bmake clean to clean the working directory from the extracted files.
1.219     nia      4178:     Besides these files, a lot of cache files and other system information have
                   4179:     been saved in the working directory, which may have become outdated after
                   4180:     you edited the Makefile.
1.1       dsieger  4181: 
1.184     rillig   4182:  9. Now, run bmake to build the package. For the various things that can go
                   4183:     wrong in this phase, consult Chapter 21, Making your package work.
1.1       dsieger  4184: 
1.184     rillig   4185:     If the extracted files from the package need to be fixed, run multiple
                   4186:     rounds of these commands:
1.1       dsieger  4187: 
1.219     nia      4188:     $ bmake
1.184     rillig   4189:     $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
                   4190:     $ mkpatches
1.219     nia      4191:     $ bmake mps
                   4192:     $ bmake clean
1.1       dsieger  4193: 
1.184     rillig   4194: 10. When the package builds fine, the next step is to install the package. Run 
                   4195:     bmake install and hope that everything works.
1.1       dsieger  4196: 
1.184     rillig   4197: 11. Up to now, the file PLIST, which contains a list of the files that are
                   4198:     installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
                   4199:     generate a probably correct list. Check the file using your preferred text
                   4200:     editor to see if the list of files looks plausible.
1.1       dsieger  4201: 
1.184     rillig   4202: 12. Run pkglint again to see if the generated PLIST contains garbage or not.
1.1       dsieger  4203: 
1.184     rillig   4204: 13. When you ran bmake install, the package had been registered in the database
                   4205:     of installed files, but with an empty list of files. To fix this, run bmake
                   4206:     deinstall and bmake install again. Now the package is registered with the
                   4207:     list of files from PLIST.
1.48      wiz      4208: 
1.219     nia      4209: 14. Run bmake clean update to run everything from above again in a single step,
1.184     rillig   4210:     making sure that the PLIST is correct and the whole package is created as
                   4211:     intended.
1.48      wiz      4212: 
1.219     nia      4213: 15. Run pkglint to see if there's anything left to do.
1.48      wiz      4214: 
1.219     nia      4215: 16. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
1.184     rillig   4216:     and Committing.
1.50      wiz      4217: 
1.184     rillig   4218: 14.1. Common types of packages
1.1       dsieger  4219: 
1.219     nia      4220: 14.1.1. Python modules and programs
1.1       dsieger  4221: 
1.184     rillig   4222: Python modules and programs packages are easily created using a set of
                   4223: predefined variables.
1.1       dsieger  4224: 
1.184     rillig   4225: If some Python versions are not supported by the software, set the
                   4226: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
                   4227: supported, e.g.
1.1       dsieger  4228: 
1.184     rillig   4229: PYTHON_VERSIONS_INCOMPATIBLE=       27
1.1       dsieger  4230: 
1.249     gutterid 4231: If the packaged software is a Python module, include ../../lang/python/
1.258   ! wiz      4232: wheel.mk. Note per PEP-518, the minimum and default requirement to create .whl
        !          4233: files is devel/py-setuptools; however, there are various other possible tools
        !          4234: that projects can use. Thus inclusion of wheel.mk does not imply these defaults
        !          4235: are defined as TOOL_DEPENDS. Whatever the project specifically requires as
        !          4236: packaging tools must be defined in the package Makefile.
1.1       dsieger  4237: 
1.248     wiz      4238: The package directory should be called "py-software" and PKGNAME should be set
                   4239: to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.1       dsieger  4240: 
1.184     rillig   4241: DISTNAME=   foopymodule-1.2.10
                   4242: PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
1.1       dsieger  4243: 
1.226     gutterid 4244: For software in PyPi, the name should match what PyPi specifies for "pip
                   4245: install software".
                   4246: 
1.184     rillig   4247: If it is an application, include "../../lang/python/application.mk". In order
                   4248: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
                   4249: variable and set it to the list of files (paths relative to WRKSRC) that must
                   4250: be corrected. For example:
1.1       dsieger  4251: 
1.184     rillig   4252: REPLACE_PYTHON=   *.py
1.1       dsieger  4253: 
1.219     nia      4254: 14.1.2. R packages
1.1       dsieger  4255: 
1.184     rillig   4256: Simple R packages from CRAN are handled automatically by R2pkg, which is
                   4257: available in pkgtools/R2pkg. Individual packages (and optionally their
                   4258: dependencies) may be created and updated. R packages generally follow the same
                   4259: form, and most of the relevant information needed is contained in a DESCRIPTION
                   4260: file as part of each R package on CRAN. Consequently, R2pkg downloads that
                   4261: information and creates or updates a package in the canonical form. The
                   4262: resulting package should be reviewed for correctness.
1.1       dsieger  4263: 
1.219     nia      4264: 14.1.3. TeXlive packages
1.1       dsieger  4265: 
1.184     rillig   4266: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
                   4267: available in pkgtools/texlive2pkg.
1.1       dsieger  4268: 
1.184     rillig   4269: If the TeXlive package name is not known, it may be useful to search CTAN. A "
                   4270: Contained in" field on the package page typically identifies the basename of
                   4271: the package file in the TeXlive archive.
1.1       dsieger  4272: 
1.184     rillig   4273: If the TeXlive package name is known, download the files from the TeXlive
                   4274: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
                   4275: packages also have associated documentation packages, so download
                   4276: foo.doc.tar.xz at the same time. These files should be placed in the
                   4277: appropriate category directory, which is often but not always print. Then run
                   4278: the following command in the category directory.
1.1       dsieger  4279: 
1.184     rillig   4280: texlive2pkg foo.tar.xz foo.doc.tar.xz
1.1       dsieger  4281: 
1.184     rillig   4282: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
                   4283: both packages are correct.
1.1       dsieger  4284: 
1.184     rillig   4285: Finally, CTAN currently does not include version information in package
                   4286: filenames and changes their contents periodically when updates occur.
                   4287: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
                   4288: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
                   4289: e.g., the main one and the corresponding documentation, upload the distfiles
                   4290: with the following command in each package directory.
1.1       dsieger  4291: 
1.184     rillig   4292: make upload-distfiles
1.117     sevan    4293: 
1.184     rillig   4294: 14.2. Examples
1.117     sevan    4295: 
1.184     rillig   4296: 14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  4297: 
1.184     rillig   4298: 14.2.1.1. The initial package
1.1       dsieger  4299: 
1.184     rillig   4300: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
                   4301: been imported into pkgsrc. As the description says it has to do with the web,
                   4302: the obvious choice for the category is "www".
1.1       dsieger  4303: 
1.184     rillig   4304: $ mkdir www/nvu
                   4305: $ cd www/nvu
1.1       dsieger  4306: 
1.184     rillig   4307: The web site says that the sources are available as a tar file, so I fed that
                   4308: URL to the url2pkg program:
1.1       dsieger  4309: 
1.184     rillig   4310: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
1.1       dsieger  4311: 
1.184     rillig   4312: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
                   4313: package name should not have the word "sources" in it. I also filled in the
                   4314: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
                   4315: that:
1.1       dsieger  4316: 
1.184     rillig   4317: # $NetBSD $
                   4318: #
1.1       dsieger  4319: 
1.184     rillig   4320: DISTNAME=       nvu-1.0-sources
                   4321: PKGNAME=        nvu-1.0
                   4322: CATEGORIES=     www
                   4323: MASTER_SITES=   http://cvs.nvu.com/download/
                   4324: EXTRACT_SUFX=   .tar.bz2
1.1       dsieger  4325: 
1.184     rillig   4326: MAINTAINER=     rillig@NetBSD.org
                   4327: HOMEPAGE=       http://cvs.nvu.com/
                   4328: COMMENT=        Web Authoring System
1.1       dsieger  4329: 
1.184     rillig   4330: # url2pkg-marker (please do not remove this line.)
                   4331: .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4332: 
1.184     rillig   4333: On the first line of output above, an artificial space has been added between
                   4334: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
                   4335: the guide.
1.1       dsieger  4336: 
1.184     rillig   4337: Then, I quit the editor and watched pkgsrc downloading a large source archive:
1.1       dsieger  4338: 
1.184     rillig   4339: url2pkg> Running "make makesum" ...
                   4340: => Required installed package digest>=20010302: digest-20060826 found
                   4341: => Fetching nvu-1.0-sources.tar.bz2
                   4342: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   4343: 100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
                   4344: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
                   4345: url2pkg> Running "make extract" ...
                   4346: => Required installed package digest>=20010302: digest-20060826 found
                   4347: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4348: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4349: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
                   4350: ===> Installing dependencies for nvu-1.0
                   4351: ===> Overriding tools for nvu-1.0
                   4352: ===> Extracting for nvu-1.0
                   4353: url2pkg> Adjusting the Makefile.
1.1       dsieger  4354: 
1.184     rillig   4355: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
1.1       dsieger  4356: 
1.184     rillig   4357: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
1.1       dsieger  4358: 
1.184     rillig   4359: 14.2.1.2. Fixing all kinds of problems to make the package work
1.1       dsieger  4360: 
1.184     rillig   4361: Now that the package has been extracted, let's see what's inside it. The
                   4362: package has a README.txt, but that only says something about mozilla, so it's
                   4363: probably useless for seeing what dependencies this package has. But since there
                   4364: is a GNU configure script in the package, let's hope that it will complain
                   4365: about everything it needs.
1.1       dsieger  4366: 
1.184     rillig   4367: $ bmake
                   4368: => Required installed package digest>=20010302: digest-20060826 found
                   4369: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4370: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4371: ===> Patching for nvu-1.0
                   4372: ===> Creating toolchain wrappers for nvu-1.0
                   4373: ===> Configuring for nvu-1.0
                   4374: [...]
                   4375: configure: error: Perl 5.004 or higher is required.
                   4376: [...]
                   4377: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
                   4378: [...]
1.1       dsieger  4379: 
1.184     rillig   4380: That worked quite well. So I opened the package Makefile in my editor, and
                   4381: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
                   4382: dependencies of the package have changed now, and since a perl wrapper is
                   4383: automatically installed in the "tools" phase, I need to build the package from
                   4384: scratch.
1.1       dsieger  4385: 
1.184     rillig   4386: $ bmake clean
                   4387: ===> Cleaning for nvu-1.0
                   4388: $ bmake
                   4389: [...]
                   4390: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
                   4391: GNU Make.  You will not be able to build Mozilla without GNU Make.
                   4392: [...]
1.1       dsieger  4393: 
1.184     rillig   4394: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
1.1       dsieger  4395: 
1.184     rillig   4396: [...]
                   4397: checking for GTK - version >= 1.2.0... no
                   4398: *** Could not run GTK test program, checking why...
                   4399: [...]
1.1       dsieger  4400: 
1.184     rillig   4401: Now to the other dependencies. The first question is: Where is the GTK package
                   4402: hidden in pkgsrc?
1.1       dsieger  4403: 
1.184     rillig   4404: $ echo ../../*/gtk*
                   4405: [many packages ...]
                   4406: $ echo ../../*/gtk
                   4407: ../../x11/gtk
                   4408: $ echo ../../*/gtk2
                   4409: ../../x11/gtk2
                   4410: $ echo ../../*/gtk2/bui*
                   4411: ../../x11/gtk2/buildlink3.mk
1.1       dsieger  4412: 
1.184     rillig   4413: The first try was definitely too broad. The second one had exactly one result,
                   4414: which is very good. But there is one pitfall with GNOME packages. Before GNOME
                   4415: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
                   4416: able to continue to use these packages, the GNOME 2 packages were imported as
                   4417: separate packages, and their names usually have a "2" appended. So I checked
                   4418: whether this was the case here, and indeed it was.
1.1       dsieger  4419: 
1.184     rillig   4420: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
                   4421: easy. I just inserted an .include line before the last line of the package
                   4422: Makefile, so that it now looks like this:
1.1       dsieger  4423: 
1.184     rillig   4424: [...]
                   4425: .include "../../x11/gtk2/buildlink3.mk"
                   4426: .include "../../mk/bsd.pkg.mk
1.1       dsieger  4427: 
1.184     rillig   4428: After another bmake clean && bmake, the answer was:
1.108     rillig   4429: 
1.184     rillig   4430: [...]
                   4431: checking for gtk-config... /home/roland/pkg/bin/gtk-config
                   4432: checking for GTK - version >= 1.2.0... no
                   4433: *** Could not run GTK test program, checking why...
                   4434: *** The test program failed to compile or link. See the file config.log for the
                   4435: *** exact error that occured. This usually means GTK was incorrectly installed
                   4436: *** or that you have moved GTK since it was installed. In the latter case, you
                   4437: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
                   4438: configure: error: Test for GTK failed.
                   4439: [...]
1.1       dsieger  4440: 
1.184     rillig   4441: In this particular case, the assumption that "every package prefers GNOME 2"
                   4442: had been wrong. The first of the lines above told me that this package really
                   4443: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
                   4444: it would have looked for pkg-config instead of gtk-config. So I changed the x11
                   4445: /gtk2 to x11/gtk in the package Makefile, and tried again.
1.1       dsieger  4446: 
1.184     rillig   4447: [...]
                   4448: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
                   4449: In file included from xpidl.c:42:
                   4450: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
                   4451: In file included from xpidl.c:42:
                   4452: xpidl.h:132: error: parse error before "IDL_ns"
                   4453: [...]
1.1       dsieger  4454: 
1.184     rillig   4455: The package still does not find all of its dependencies. Now the question is:
                   4456: Which package provides the libIDL/IDL.h header file?
1.1       dsieger  4457: 
1.184     rillig   4458: $ echo ../../*/*idl*
                   4459: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
                   4460: $ echo ../../*/*IDL*
                   4461: ../../net/libIDL
1.1       dsieger  4462: 
1.184     rillig   4463: Let's take the one from the second try. So I included the ../../net/libIDL/
                   4464: buildlink3.mk file and tried again. But the error didn't change. After digging
                   4465: through some of the code, I concluded that the build process of the package was
                   4466: broken and couldn't have ever worked, but since the Mozilla source tree is
                   4467: quite large, I didn't want to fix it. So I added the following to the package
                   4468: Makefile and tried again:
1.1       dsieger  4469: 
1.184     rillig   4470: CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
                   4471: BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
1.1       dsieger  4472: 
1.184     rillig   4473: The latter line is needed because the package expects the library libIDL.so,
                   4474: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
                   4475: that on the fly.
1.1       dsieger  4476: 
1.184     rillig   4477: The next problem was related to a recent change of the FreeType interface. I
                   4478: looked up in www/seamonkey which patch files were relevant for this issue and
                   4479: copied them to the patches directory. Then I retried, fixed the patches so that
                   4480: they applied cleanly and retried again. This time, everything worked.
1.1       dsieger  4481: 
1.184     rillig   4482: 14.2.1.3. Installing the package
1.1       dsieger  4483: 
1.184     rillig   4484: $ bmake CHECK_FILES=no install
                   4485: [...]
                   4486: $ bmake print-PLIST >PLIST
                   4487: $ bmake deinstall
                   4488: $ bmake install
1.1       dsieger  4489: 
1.184     rillig   4490: Chapter 15. Programming in Makefiles
1.1       dsieger  4491: 
1.184     rillig   4492: Table of Contents
1.1       dsieger  4493: 
1.184     rillig   4494: 15.1. Caveats
                   4495: 15.2. Makefile variables
                   4496:     15.2.1. Naming conventions
                   4497: 15.3. Code snippets
                   4498:     15.3.1. Adding things to a list
                   4499:     15.3.2. Echoing a string exactly as-is
                   4500:     15.3.3. Passing CFLAGS to GNU configure scripts
                   4501:     15.3.4. Handling possibly empty variables
1.229     gutterid 4502:     15.3.5. Testing yes/no variables in conditions
1.1       dsieger  4503: 
1.184     rillig   4504: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
                   4505: part of the pkgsrc system. Using the make(1) system as a programming language
                   4506: for a big system like pkgsrc requires some discipline to keep the code correct
                   4507: and understandable.
1.1       dsieger  4508: 
1.184     rillig   4509: The basic ingredients for Makefile programming are variables and shell
                   4510: commands. Among these shell commands may even be more complex ones like awk(1)
                   4511: programs. To make sure that every shell command runs as intended it is
                   4512: necessary to quote all variables correctly when they are used.
1.1       dsieger  4513: 
1.184     rillig   4514: This chapter describes some patterns that appear quite often in Makefiles,
                   4515: including the pitfalls that come along with them.
1.1       dsieger  4516: 
1.184     rillig   4517: 15.1. Caveats
1.1       dsieger  4518: 
1.184     rillig   4519:   * When you are creating a file as a target of a rule, always write the data
                   4520:     to a temporary file first and finally rename that file. Otherwise there
                   4521:     might occur an error in the middle of generating the file, and when the
                   4522:     user runs make(1) for the second time, the file exists and will not be
                   4523:     regenerated properly. Example:
1.1       dsieger  4524: 
1.184     rillig   4525:     wrong:
                   4526:             @echo "line 1" > ${.TARGET}
                   4527:             @echo "line 2" >> ${.TARGET}
                   4528:             @false
1.1       dsieger  4529: 
1.184     rillig   4530:     correct:
                   4531:             @echo "line 1" > ${.TARGET}.tmp
                   4532:             @echo "line 2" >> ${.TARGET}.tmp
                   4533:             @false
                   4534:             @mv ${.TARGET}.tmp ${.TARGET}
1.1       dsieger  4535: 
1.184     rillig   4536:     When you run make wrong twice, the file wrong will exist, although there
                   4537:     was an error message in the first run. On the other hand, running make
                   4538:     correct gives an error message twice, as expected.
1.1       dsieger  4539: 
1.184     rillig   4540:     You might remember that make(1) sometimes removes ${.TARGET} in case of
                   4541:     error, but this only happens when it is interrupted, for example by
                   4542:     pressing Ctrl+C. This does not happen when one of the commands fails (like
                   4543:     false(1) above).
1.1       dsieger  4544: 
1.184     rillig   4545: 15.2. Makefile variables
1.1       dsieger  4546: 
1.184     rillig   4547: Makefile variables contain strings that can be processed using the five
                   4548: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1       dsieger  4549: 
1.184     rillig   4550: When a variable's value is parsed from a Makefile, the hash character # and the
                   4551: backslash character \ are handled specially. If a backslash is the last
                   4552: character in a line, that backslash is removed from the line and the line
                   4553: continues with the next line of the file.
1.1       dsieger  4554: 
1.184     rillig   4555: The # character starts a comment that reaches until the end of the line. To get
                   4556: an actual # character, such as in a URL, write \# instead.
1.1       dsieger  4557: 
1.184     rillig   4558: The evaluation of variables either happens immediately or lazy. It happens
                   4559: immediately when the variable occurs on the right-hand side of the := or the !=
                   4560: operator, in a .if condition or a .for loop. In the other cases, it is
                   4561: evaluated lazily.
1.1       dsieger  4562: 
1.184     rillig   4563: Some of the modifiers split the string into words and then operate on the
                   4564: words, others operate on the string as a whole. When a string is split into
                   4565: words, double quotes and single quotes are interpreted as delimiters, just like
                   4566: in sh(1).
1.1       dsieger  4567: 
1.184     rillig   4568: 15.2.1. Naming conventions
1.1       dsieger  4569: 
1.184     rillig   4570:   * All variable names starting with an underscore are reserved for use by the
                   4571:     pkgsrc infrastructure. They shall not be used by packages.
1.1       dsieger  4572: 
1.184     rillig   4573:   * In .for loops you should use lowercase variable names for the iteration
                   4574:     variables.
1.1       dsieger  4575: 
1.184     rillig   4576:   * All list variables should have a plural name, such as PKG_OPTIONS or
                   4577:     DISTFILES.
1.1       dsieger  4578: 
1.184     rillig   4579: 15.3. Code snippets
1.1       dsieger  4580: 
1.184     rillig   4581: 15.3.1. Adding things to a list
1.1       dsieger  4582: 
1.184     rillig   4583: When adding a string that possibly contains whitespace or quotes to a list
                   4584: (example 1), it must be quoted using the :Q modifier.
1.1       dsieger  4585: 
1.184     rillig   4586: When adding another list to a list (example 2), it must not be quoted, since
                   4587: its elements are already quoted.
1.1       dsieger  4588: 
1.184     rillig   4589: STRING=         foo * bar `date`
                   4590: LIST=           # empty
                   4591: ANOTHER_LIST=   a=b c=d
1.1       dsieger  4592: 
1.184     rillig   4593: LIST+=          ${STRING:Q}       # 1
                   4594: LIST+=          ${ANOTHER_LIST}   # 2
1.1       dsieger  4595: 
1.184     rillig   4596: 15.3.2. Echoing a string exactly as-is
1.1       dsieger  4597: 
1.184     rillig   4598: Echoing a string containing special characters needs special work.
1.1       dsieger  4599: 
1.184     rillig   4600: STRING=         foo bar <    > * `date` $$HOME ' "
                   4601: EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
1.1       dsieger  4602: 
1.184     rillig   4603: all:
                   4604:         echo ${STRING}                  # 1
                   4605:         echo ${STRING:Q}                # 2
                   4606:         printf '%s\n' ${STRING:Q}''     # 3
                   4607:         env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
1.1       dsieger  4608: 
1.184     rillig   4609: Example 1 leads to a syntax error in the shell, as the characters are just
                   4610: copied.
1.1       dsieger  4611: 
1.184     rillig   4612: Example 2 quotes the string so that the shell interprets it correctly. But the
                   4613: echo command may additionally interpret strings with a leading dash or those
                   4614: containing backslashes.
1.1       dsieger  4615: 
1.184     rillig   4616: Example 3 can handle arbitrary strings, since printf(1) only interprets the
                   4617: format string, but not the next argument. The trailing single quotes handle the
                   4618: case when the string is empty. In that case, the :Q modifier would result in an
                   4619: empty string too, which would then be skipped by the shell. For printf(1) this
                   4620: doesn't make a difference, but other programs may care.
1.1       dsieger  4621: 
1.184     rillig   4622: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
                   4623: has already been done when adding elements to the list.
1.1       dsieger  4624: 
1.184     rillig   4625: 15.3.3. Passing CFLAGS to GNU configure scripts
1.1       dsieger  4626: 
1.184     rillig   4627: When passing CFLAGS or similar variables to a GNU-style configure script
                   4628: (especially those that call other configure scripts), it must not have leading
                   4629: or trailing whitespace, since otherwise the configure script gets confused. To
                   4630: trim leading and trailing whitespace, use the :M modifier, as in the following
                   4631: example:
1.1       dsieger  4632: 
1.184     rillig   4633: CPPFLAGS=               # empty
                   4634: CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
                   4635: CPPFLAGS+=              ${MY_CPPFLAGS}
1.1       dsieger  4636: 
1.184     rillig   4637: CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
1.1       dsieger  4638: 
1.184     rillig   4639: all:
                   4640:         echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   4641:         echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
1.1       dsieger  4642: 
1.184     rillig   4643: In this example, CPPFLAGS has both leading and trailing whitespace because the
                   4644: += operator always adds a space.
1.1       dsieger  4645: 
1.184     rillig   4646: 15.3.4. Handling possibly empty variables
1.1       dsieger  4647: 
1.184     rillig   4648: When a possibly empty variable is used in a shell program, it may lead to a
                   4649: syntax error.
1.1       dsieger  4650: 
1.184     rillig   4651: EGFILES=        # empty
1.1       dsieger  4652: 
1.184     rillig   4653: install-examples:   # produces a syntax error in the shell
                   4654:         for egfile in ${EGFILES}; do            \
                   4655:                 echo "Installing $$egfile";     \
                   4656:         done
1.1       dsieger  4657: 
1.184     rillig   4658: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
                   4659: with an empty string by make(1). To fix this syntax error, use one of the
                   4660: snippets below.
1.1       dsieger  4661: 
1.229     gutterid 4662: EGFILES=        # empty
1.1       dsieger  4663: 
1.184     rillig   4664: install-examples:
                   4665:         for egfile in ${EGFILES} ""; do         \
                   4666:                 [ -n "$$egfile" ] || continue;  \
                   4667:                 echo "Installing $$egfile";     \
                   4668:         done
1.1       dsieger  4669: 
1.184     rillig   4670: In this case, an empty string is appended to the iteration list (to prevent the
                   4671: syntax error) and filtered out later.
1.1       dsieger  4672: 
1.184     rillig   4673: EGFILES=        # empty
1.1       dsieger  4674: 
1.184     rillig   4675: install-examples:
                   4676: .for egfile in ${EGFILES}
                   4677:         echo "Installing ${egfile}"
                   4678: .endfor
1.1       dsieger  4679: 
1.184     rillig   4680: If one of the filenames contains special characters, it should be enclosed in
                   4681: single or double quotes.
1.1       dsieger  4682: 
1.184     rillig   4683: To have a shell command test whether a make variable is empty, use the
                   4684: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1       dsieger  4685: 
1.229     gutterid 4686: 15.3.5. Testing yes/no variables in conditions
                   4687: 
                   4688: When a variable can have the values yes or no, use the following pattern to
                   4689: test the variable:
                   4690: 
                   4691: .if ${VAR:U:tl} == "yes"
                   4692: # do something
                   4693: .endif
                   4694: 
                   4695: The :U modifier is only necessary if the variable can be undefined. If the
                   4696: variable is guaranteed to be defined, the :U can be omitted.
                   4697: 
                   4698: The :tl modifier converts the variable value to lowercase, allowing for the
                   4699: values yes, Yes, YES.
                   4700: 
1.184     rillig   4701: Chapter 16. Options handling
1.1       dsieger  4702: 
                   4703: Table of Contents
                   4704: 
1.184     rillig   4705: 16.1. Global default options
                   4706: 16.2. Converting packages to use bsd.options.mk
                   4707: 16.3. Option Names
                   4708: 16.4. Determining the options of dependencies
1.1       dsieger  4709: 
                   4710: Many packages have the ability to be built to support different sets of
                   4711: features. bsd.options.mk is a framework in pkgsrc that provides generic
                   4712: handling of those options that determine different ways in which the packages
                   4713: can be built. It's possible for the user to specify exactly which sets of
                   4714: options will be built into a package or to allow a set of global default
                   4715: options apply.
                   4716: 
1.7       rillig   4717: There are two broad classes of behaviors that one might want to control via
                   4718: options. One is whether some particular feature is enabled in a program that
                   4719: will be built anyway, often by including or not including a dependency on some
                   4720: other package. The other is whether or not an additional program will be built
                   4721: as part of the package. Generally, it is better to make a split package for
                   4722: such additional programs instead of using options, because it enables binary
                   4723: packages to be built which can then be added separately. For example, the foo
                   4724: package might have minimal dependencies (those packages without which foo
                   4725: doesn't make sense), and then the foo-gfoo package might include the GTK
                   4726: frontend program gfoo. This is better than including a gtk option to foo that
                   4727: adds gfoo, because either that option is default, in which case binary users
                   4728: can't get foo without gfoo, or not default, in which case they can't get gfoo.
                   4729: With split packages, they can install foo without having GTK, and later decide
                   4730: to install gfoo (pulling in GTK at that time). This is an advantage to source
                   4731: users too, avoiding the need for rebuilds.
                   4732: 
                   4733: Plugins with widely varying dependencies should usually be split instead of
                   4734: options.
                   4735: 
                   4736: It is often more work to maintain split packages, especially if the upstream
                   4737: package does not support this. The decision of split vs. option should be made
                   4738: based on the likelihood that users will want or object to the various pieces,
                   4739: the size of the dependencies that are included, and the amount of work.
                   4740: 
                   4741: A further consideration is licensing. Non-free parts, or parts that depend on
                   4742: non-free dependencies (especially plugins) should almost always be split if
                   4743: feasible.
                   4744: 
1.184     rillig   4745: 16.1. Global default options
1.1       dsieger  4746: 
                   4747: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
                   4748: the options that should be built into every package if that option is
1.4       rillig   4749: supported. This variable should be set in mk.conf.
1.1       dsieger  4750: 
1.184     rillig   4751: 16.2. Converting packages to use bsd.options.mk
1.1       dsieger  4752: 
                   4753: The following example shows how bsd.options.mk should be used by the
                   4754: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
                   4755: e.g. options.mk, that is included by the main package Makefile.
                   4756: 
                   4757: PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   4758: PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   4759: PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   4760: PKG_OPTIONS_GROUP.database=     mysql pgsql
                   4761: PKG_SUGGESTED_OPTIONS=          wibble-foo
                   4762: PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   4763: PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
                   4764: 
                   4765: .include "../../mk/bsd.prefs.mk"
                   4766: 
                   4767: # this package was previously named wibble2
                   4768: .if defined(PKG_OPTIONS.wibble2)
                   4769: PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   4770: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
                   4771:         "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
                   4772: .endif
                   4773: 
                   4774: .include "../../mk/bsd.options.mk"
                   4775: 
                   4776: # Package-specific option-handling
                   4777: 
                   4778: ###
                   4779: ### FOO support
                   4780: ###
                   4781: .if !empty(PKG_OPTIONS:Mwibble-foo)
                   4782: CONFIGURE_ARGS+=    --enable-foo
                   4783: .endif
                   4784: 
                   4785: ###
                   4786: ### LDAP support
                   4787: ###
                   4788: .if !empty(PKG_OPTIONS:Mldap)
                   4789: .  include "../../databases/openldap-client/buildlink3.mk"
                   4790: CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
                   4791: .endif
                   4792: 
                   4793: ###
                   4794: ### database support
                   4795: ###
                   4796: .if !empty(PKG_OPTIONS:Mmysql)
                   4797: .  include "../../mk/mysql.buildlink3.mk"
                   4798: .endif
                   4799: .if !empty(PKG_OPTIONS:Mpgsql)
                   4800: .  include "../../mk/pgsql.buildlink3.mk"
                   4801: .endif
                   4802: 
                   4803: The first section contains the information about which build options are
                   4804: supported by the package, and any default options settings if needed.
                   4805: 
                   4806:  1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
                   4807:     to override the default options. It should be set to PKG_OPTIONS.pkgbase.
                   4808:     Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
                   4809:     the point where the options are processed.
                   4810: 
                   4811:  2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
                   4812: 
                   4813:  3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
                   4814:     exclusive options. The options in each group are listed in
                   4815:     PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
                   4816:     the group takes precedence over all other options in the group. Options
                   4817:     from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
                   4818: 
                   4819:  4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
                   4820:     building the packages will fail if no option from the group is selected.
                   4821: 
                   4822:  5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
                   4823:     one option from each set must be selected. The options in each set are
                   4824:     listed in PKG_OPTIONS_SET.setname. Options from the sets will be
                   4825:     automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
                   4826:     fail if no option from the set is selected.
                   4827: 
                   4828:  6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
                   4829:     default.
                   4830: 
                   4831:  7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4       rillig   4832:     legacy mk.conf variables to their option counterparts. Pairs should be
1.1       dsieger  4833:     added with "+=" to keep the listing of global legacy variables. A warning
                   4834:     will be issued if the user uses a legacy variable.
                   4835: 
                   4836:  8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
                   4837:     options that have been renamed to their new counterparts. Pairs should be
                   4838:     added with "+=" to keep the listing of global legacy options. A warning
                   4839:     will be issued if the user uses a legacy option.
                   4840: 
                   4841:  9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
                   4842:     used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
                   4843:     PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
                   4844: 
                   4845: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
                   4846:     variables or options used, and what to use instead.
                   4847: 
                   4848: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
                   4849: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
                   4850: options, use PKG_SUGGESTED_OPTIONS.
                   4851: 
                   4852: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
                   4853: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
                   4854: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
                   4855: options if none of them is supported on the current platform), PKG_OPTIONS is
                   4856: set to the empty list and the package is otherwise treated as not using the
                   4857: options framework.
                   4858: 
                   4859: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
                   4860: list of selected build options, properly filtered to remove unsupported and
                   4861: duplicate options.
                   4862: 
                   4863: The remaining sections contain the logic that is specific to each option. The
                   4864: correct way to check for an option is to check whether it is listed in
                   4865: PKG_OPTIONS:
                   4866: 
                   4867: .if !empty(PKG_OPTIONS:Moption)
                   4868: 
1.184     rillig   4869: 16.3. Option Names
1.1       dsieger  4870: 
                   4871: Options that enable similar features in different packages (like optional
                   4872: support for a library) should use a common name in all packages that support it
                   4873: (like the name of the library). If another package already has an option with
                   4874: the same meaning, use the same name.
                   4875: 
                   4876: Options that enable features specific to one package, where it's unlikely that
                   4877: another (unrelated) package has the same (or a similar) optional feature,
                   4878: should use a name prefixed with pkgname-.
                   4879: 
                   4880: If a group of related packages share an optional feature specific to that
                   4881: group, prefix it with the name of the "main" package (e. g.
                   4882: djbware-errno-hack).
                   4883: 
                   4884: For new options, add a line to mk/defaults/options.description. Lines have two
                   4885: fields, separated by tab. The first field is the option name, the second its
                   4886: description. The description should be a whole sentence (starting with an
                   4887: uppercase letter and ending with a period) that describes what enabling the
                   4888: option does. E. g. "Enable ispell support." The file is sorted by option names.
                   4889: 
1.184     rillig   4890: 16.4. Determining the options of dependencies
1.7       rillig   4891: 
                   4892: When writing buildlink3.mk files, it is often necessary to list different
                   4893: dependencies based on the options with which the package was built. For
                   4894: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
                   4895: A typical example looks like this:
                   4896: 
                   4897: pkgbase := libpurple
                   4898: .include "../../mk/pkg-build-options.mk"
                   4899: 
                   4900: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
                   4901: ...
                   4902: .endif
                   4903: 
                   4904: Including pkg-build-options.mk here will set the variable
                   4905: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
                   4906: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
                   4907: pkg-build-options.mk for more details.
                   4908: 
1.184     rillig   4909: Chapter 17. Tools needed for building or running
                   4910: 
                   4911: Table of Contents
                   4912: 
                   4913: 17.1. Tools for pkgsrc builds
                   4914: 17.2. Tools needed by packages
                   4915: 17.3. Tools provided by platforms
                   4916: 
                   4917: The USE_TOOLS definition is used both internally by pkgsrc and also for
                   4918: individual packages to define what commands are needed for building a package
                   4919: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
                   4920: DEPENDS). If the native system provides an adequate tool, then in many cases, a
                   4921: pkgsrc package will not be used.
                   4922: 
                   4923: When building a package, the replacement tools are made available in a
                   4924: directory (as symlinks or wrapper scripts) that is early in the executable
                   4925: search path. Just like the buildlink system, this helps with consistent builds.
                   4926: 
                   4927: A tool may be needed to help build a specific package. For example, perl, GNU
                   4928: make (gmake) or yacc may be needed.
                   4929: 
                   4930: Also a tool may be needed, for example, because the native system's supplied
                   4931: tool may be inefficient for building a package with pkgsrc. For example, a
                   4932: package may need GNU awk, bison (instead of yacc) or a better sed.
                   4933: 
                   4934: The tools used by a package can be listed by running make show-tools.
                   4935: 
                   4936: 17.1. Tools for pkgsrc builds
                   4937: 
                   4938: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
                   4939: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
                   4940: seen by running: make show-var VARNAME=USE_TOOLS.
                   4941: 
                   4942: If a package needs a specific program to build then the USE_TOOLS variable can
                   4943: be used to define the tools needed.
                   4944: 
                   4945: 17.2. Tools needed by packages
                   4946: 
                   4947: In the following examples, the :run means that it is needed at run-time (and
                   4948: becomes a DEPENDS). The default is a build dependency which can be set with
                   4949: :build. (So in this example, it is the same as gmake:build and
                   4950: pkg-config:build.)
                   4951: 
                   4952: USE_TOOLS+=     gmake perl:run pkg-config
                   4953: 
                   4954: When using the tools framework, a TOOLS_PATH.foo variable is defined which
                   4955: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
                   4956: could be "/bin/bash" on Linux systems.
                   4957: 
                   4958: If you always need a pkgsrc version of the tool at run-time, then just use
                   4959: DEPENDS instead.
                   4960: 
                   4961: 17.3. Tools provided by platforms
                   4962: 
                   4963: When improving or porting pkgsrc to a new platform, have a look at (or create)
                   4964: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
                   4965: tools.${OPSYS}.mk which defines the name of the common tools. For example:
                   4966: 
                   4967: .if exists(/usr/bin/bzcat)
                   4968: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   4969: .elif exists(/usr/bin/bzip2)
                   4970: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   4971: .endif
                   4972: 
                   4973: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   4974: 
                   4975: Chapter 18. Buildlink methodology
1.1       dsieger  4976: 
                   4977: Table of Contents
                   4978: 
1.184     rillig   4979: 18.1. Converting packages to use buildlink3
                   4980: 18.2. Writing buildlink3.mk files
                   4981:     18.2.1. Anatomy of a buildlink3.mk file
                   4982:     18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.232     gutterid 4983:     buildlink3.mk files
1.184     rillig   4984: 18.3. Writing builtin.mk files
                   4985:     18.3.1. Anatomy of a builtin.mk file
                   4986: 
                   4987: Buildlink is a framework in pkgsrc that controls what headers and libraries are
                   4988: seen by a package's configure and build processes. This is implemented in a two
                   4989: step process:
                   4990: 
                   4991:  1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
                   4992:     default is a subdirectory of WRKDIR.
                   4993: 
                   4994:  2. Create wrapper scripts that are used in place of the normal compiler tools
                   4995:     that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
                   4996:     references to BUILDLINK_DIR. The wrapper scripts also make native compiler
                   4997:     on some operating systems look like GCC, so that packages that expect GCC
                   4998:     won't require modifications to build with those native compilers.
                   4999: 
                   5000: This normalizes the environment in which a package is built so that the package
                   5001: may be built consistently despite what other software may be installed. Please
                   5002: note that the normal system header and library paths, e.g. /usr/include, /usr/
                   5003: lib, etc., are always searched -- buildlink3 is designed to insulate the
                   5004: package build from non-system-supplied software.
                   5005: 
                   5006: 18.1. Converting packages to use buildlink3
1.1       dsieger  5007: 
1.184     rillig   5008: The process of converting packages to use the buildlink3 framework ("bl3ifying"
                   5009: ) is fairly straightforward. The things to keep in mind are:
1.1       dsieger  5010: 
1.184     rillig   5011:  1. Ensure that the build always calls the wrapper scripts instead of the
                   5012:     actual toolchain. Some packages are tricky, and the only way to know for
                   5013:     sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
                   5014:     invoked.
1.1       dsieger  5015: 
1.184     rillig   5016:  2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
                   5017:     standalone shells, etc., because the code to symlink files into $
                   5018:     {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
1.1       dsieger  5019: 
1.184     rillig   5020:  3. Remember that only the buildlink3.mk files that you list in a package's
                   5021:     Makefile are added as dependencies for that package.
1.1       dsieger  5022: 
1.184     rillig   5023: If a dependency on a particular package is required for its libraries and
                   5024: headers, then we replace:
1.1       dsieger  5025: 
1.184     rillig   5026: DEPENDS+=       foo>=1.1.0:../../category/foo
1.1       dsieger  5027: 
1.184     rillig   5028: with
1.1       dsieger  5029: 
1.184     rillig   5030: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5031: 
1.184     rillig   5032: The buildlink3.mk files usually define the required dependencies. If you need a
                   5033: newer version of the dependency when using buildlink3.mk files, then you can
                   5034: define it in your Makefile; for example:
1.1       dsieger  5035: 
1.184     rillig   5036: BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
                   5037: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5038: 
1.184     rillig   5039: There are several buildlink3.mk files in pkgsrc/mk that handle special package
                   5040: issues:
1.1       dsieger  5041: 
1.184     rillig   5042:   * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
                   5043:     implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
1.1       dsieger  5044: 
1.184     rillig   5045:   * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
                   5046:     this will take care to install the devel/ncurses package.
1.1       dsieger  5047: 
1.184     rillig   5048:   * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
                   5049:     a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
                   5050:     implementation.
1.1       dsieger  5051: 
1.184     rillig   5052:   * motif.buildlink3.mk checks for a system-provided Motif installation or adds
                   5053:     a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
                   5054:     dt", "lesstif" or "motif" to choose which Motif version will be used.
1.1       dsieger  5055: 
1.184     rillig   5056:   * readline.buildlink3.mk checks for a system-provided GNU readline or
                   5057:     editline (libedit) installation, or adds a dependency on devel/readline,
                   5058:     devel/editline. The user can set READLINE_DEFAULT to choose readline
                   5059:     implementation. If your package really needs GNU readline library, its
                   5060:     Makefile should include devel/readline/buildlink3.mk instead of
                   5061:     readline.buildlink3.mk.
1.1       dsieger  5062: 
1.184     rillig   5063:   * oss.buildlink3.mk defines several variables that may be used by packages
                   5064:     that use the Open Sound System (OSS) API.
1.1       dsieger  5065: 
1.184     rillig   5066:   * pgsql.buildlink3.mk will accept any of the Postgres versions in the
                   5067:     variable PGSQL_VERSIONS_ACCEPTED and default to the version
                   5068:     PGSQL_VERSION_DEFAULT. See the file for more information.
1.1       dsieger  5069: 
1.184     rillig   5070:   * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
                   5071:     pthreads or adds a dependency on devel/pth as needed.
1.1       dsieger  5072: 
1.184     rillig   5073:   * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
                   5074:     widgets library.
1.1       dsieger  5075: 
1.184     rillig   5076: The comments in those buildlink3.mk files provide a more complete description
                   5077: of how to use them properly.
1.1       dsieger  5078: 
1.184     rillig   5079: 18.2. Writing buildlink3.mk files
1.1       dsieger  5080: 
1.184     rillig   5081: A package's buildlink3.mk file is included by Makefiles to indicate the need to
                   5082: compile and link against header files and libraries provided by the package. A
                   5083: buildlink3.mk file should always provide enough information to add the correct
                   5084: type of dependency relationship and include any other buildlink3.mk files that
                   5085: it needs to find headers and libraries that it needs in turn.
1.1       dsieger  5086: 
1.184     rillig   5087: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
                   5088: pkgtools/createbuildlink package is highly recommended. For most packages, the
                   5089: following command will generate a good starting point for buildlink3.mk files:
1.1       dsieger  5090: 
1.184     rillig   5091: % cd pkgsrc/category/pkgdir
                   5092: % createbuildlink >buildlink3.mk
1.1       dsieger  5093: 
                   5094: 
1.184     rillig   5095: 18.2.1. Anatomy of a buildlink3.mk file
1.1       dsieger  5096: 
1.184     rillig   5097: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
                   5098: tiff:
1.14      jmcneill 5099: 
1.184     rillig   5100: BUILDLINK_TREE+=        tiff
1.1       dsieger  5101: 
1.184     rillig   5102: .if !defined(TIFF_BUILDLINK3_MK)
                   5103: TIFF_BUILDLINK3_MK:=
1.1       dsieger  5104: 
1.184     rillig   5105: BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
                   5106: BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
                   5107: BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
1.1       dsieger  5108: 
1.184     rillig   5109: .include "../../devel/zlib/buildlink3.mk"
                   5110: .include "../../graphics/jpeg/buildlink3.mk"
                   5111: .endif # TIFF_BUILDLINK3_MK
1.1       dsieger  5112: 
1.184     rillig   5113: BUILDLINK_TREE+=        -tiff
1.1       dsieger  5114: 
1.184     rillig   5115: The header and footer manipulate BUILDLINK_TREE, which is common across all
                   5116: buildlink3.mk files and is used to track the dependency tree.
1.1       dsieger  5117: 
1.184     rillig   5118: The main section is protected from multiple inclusion and controls how the
                   5119: dependency on pkg is added. Several important variables are set in the section:
1.1       dsieger  5120: 
1.185     wiz      5121:   * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
1.184     rillig   5122:     installed package; this should always be set using += to ensure that we're
                   5123:     appending to any pre-existing list of values. This variable should be set
1.185     wiz      5124:     to the last version of the package that had an backwards-incompatible API
1.184     rillig   5125:     change.
1.1       dsieger  5126: 
1.184     rillig   5127:   * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
1.1       dsieger  5128: 
1.184     rillig   5129:   * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
1.236     gutterid 5130:     BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
                   5131:     is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
                   5132:     full dependency is used.
1.1       dsieger  5133: 
1.184     rillig   5134:   * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
                   5135:     of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
                   5136:     library search paths. These default to "include" and "lib" respectively.
1.1       dsieger  5137: 
1.184     rillig   5138:   * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
                   5139:     to add to CPPFLAGS, which are passed on to the configure and build phases.
                   5140:     The "-I" option should be avoided and instead be handled using
                   5141:     BUILDLINK_INCDIRS.pkg as above.
1.66      asau     5142: 
1.184     rillig   5143: The following variables are all optionally defined within this second section
                   5144: (protected against multiple inclusion) and control which package files are
                   5145: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
                   5146: symlinking:
1.23      jakllsch 5147: 
1.184     rillig   5148:   * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
                   5149:     {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
                   5150:     *.h.
1.1       dsieger  5151: 
1.184     rillig   5152:   * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
                   5153:     to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
                   5154:     resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
                   5155:     takes the +CONTENTS of a pkg and filters it through $
                   5156:     {BUILDLINK_CONTENTS_FILTER.pkg}.
1.1       dsieger  5157: 
1.184     rillig   5158:   * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
                   5159:     filters +CONTENTS input into a list of files relative to $
                   5160:     {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
                   5161:     outputs the contents of the include and lib directories in the package
                   5162:     +CONTENTS.
1.1       dsieger  5163: 
1.184     rillig   5164:   * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
                   5165:     used to transform the name of the source filename into a destination
                   5166:     filename, e.g. -e "s|/curses.h|/ncurses.h|g".
1.1       dsieger  5167: 
1.184     rillig   5168: This section can additionally include any buildlink3.mk needed for pkg's
                   5169: library dependencies. Including these buildlink3.mk files means that the
                   5170: headers and libraries for these dependencies are also symlinked into $
                   5171: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
                   5172: are only added for directly include buildlink3.mk files.
1.1       dsieger  5173: 
1.184     rillig   5174: When providing a buildlink3.mk and including other buildlink3.mk files in it,
                   5175: please only add necessary ones, i.e., those whose libraries or header files are
                   5176: automatically exposed when the package is use.
1.1       dsieger  5177: 
1.184     rillig   5178: In particular, if only an executable (bin/foo) is linked against a library,
                   5179: that library does not need to be propagated in the buildlink3.mk file.
1.1       dsieger  5180: 
1.184     rillig   5181: The following steps should help you decide if a buildlink3.mk file needs to be
                   5182: included:
1.1       dsieger  5183: 
1.184     rillig   5184:   * Look at the installed header files: What headers do they include? The
                   5185:     packages providing these files must be buildlinked.
1.1       dsieger  5186: 
1.184     rillig   5187:   * Run ldd on all installed libraries and look against what other libraries
                   5188:     they link. Some of the packages providing these probably need to be
                   5189:     buildlinked; however, it's not automatic, since e.g. GTK on some systems
                   5190:     pulls in the X libraries, so they will show up in the ldd output, while on
                   5191:     others (like OS X) it won't. ldd output can thus only be used as a hint.
1.1       dsieger  5192: 
1.184     rillig   5193: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
                   5194: buildlink3.mk files
1.16      jnemeth  5195: 
1.185     wiz      5196: Both variables set lower bounds for a version of this package. The two
                   5197: variables differ in that one describes source compatibility (API) and the other
                   5198: binary compatibility (ABI). The difference is that a change in the API breaks
                   5199: compilation of programs while changes in the ABI stop compiled programs from
                   5200: running.
                   5201: 
                   5202: The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
                   5203: very rarely. (One possible scenario: If all packages using this package need a
                   5204: higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
                   5205: could be updated to that higher version.)
                   5206: 
                   5207: On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
                   5208: variable will need to be updated every time the major version of one of its
                   5209: shared libraries is changed, or any other change where a binary built against
                   5210: the previous version of the package will not run against the new version any
                   5211: longer.
                   5212: 
                   5213: In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
                   5214: require the new package version. Then the PKGREVISION of all packages foo that
                   5215: depend on this package need to be increased, and if they have buildlink3.mk
                   5216: files, BUILDLINK_ABI_DEPENDS.foo in their buildlink3.mk files must be increased
                   5217: to the new version as well. This is required so that a package will pull in the
                   5218: versions of the packages that use the new ABI and that the packages'
                   5219: PKGREVISIONs uniquely identify the packages built against the new ABI. The
                   5220: pkgtools/revbump package can help with these updates.
1.1       dsieger  5221: 
1.184     rillig   5222: See Section 21.1.5, "Handling dependencies" for more information about
1.185     wiz      5223: dependencies on other packages, including the BUILDLINK_API_DEPENDS
                   5224: definitions.
1.1       dsieger  5225: 
1.184     rillig   5226: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
1.185     wiz      5227: BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
                   5228: unneeded package deletions and rebuilds. In many cases, new versions of
                   5229: packages work just fine with older dependencies.
1.1       dsieger  5230: 
1.211     gutterid 5231: Also, it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
1.184     rillig   5232: BUILDLINK_API_DEPENDS.pkg.
1.1       dsieger  5233: 
1.211     gutterid 5234: Note there is also the distinction that users are able to disable enforcement
                   5235: of ABI dependencies using the USE_ABI_DEPENDS variable, but there is no
                   5236: equivalent option for API dependencies.
                   5237: 
1.184     rillig   5238: 18.3. Writing builtin.mk files
1.1       dsieger  5239: 
1.184     rillig   5240: Some packages in pkgsrc install headers and libraries that coincide with
                   5241: headers and libraries present in the base system. Aside from a buildlink3.mk
                   5242: file, these packages should also include a builtin.mk file that includes the
                   5243: necessary checks to decide whether using the built-in software or the pkgsrc
                   5244: software is appropriate.
1.1       dsieger  5245: 
1.184     rillig   5246: The only requirements of a builtin.mk file for pkg are:
1.1       dsieger  5247: 
1.184     rillig   5248:  1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
1.1       dsieger  5249: 
1.184     rillig   5250:  2. It should not override any USE_BUILTIN.pkg which is already set before the
                   5251:     builtin.mk file is included.
1.1       dsieger  5252: 
1.184     rillig   5253:  3. It should be written to allow multiple inclusion. This is very important
                   5254:     and takes careful attention to Makefile coding.
1.1       dsieger  5255: 
1.184     rillig   5256: 18.3.1. Anatomy of a builtin.mk file
1.1       dsieger  5257: 
1.184     rillig   5258: The following is the recommended template for builtin.mk files:
1.1       dsieger  5259: 
1.184     rillig   5260: .if !defined(IS_BUILTIN.foo)
                   5261: #
                   5262: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   5263: # genuinely exists in the system or not.
                   5264: #
                   5265: IS_BUILTIN.foo?=        no
1.1       dsieger  5266: 
1.184     rillig   5267: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   5268: # version can be determined.
                   5269: #
                   5270: .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   5271: BUILTIN_PKG.foo?=       foo-1.0
                   5272: .  endif
                   5273: .endif  # IS_BUILTIN.foo
1.1       dsieger  5274: 
1.184     rillig   5275: .if !defined(USE_BUILTIN.foo)
                   5276: USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   5277: .  if defined(BUILTIN_PKG.foo)
                   5278: .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   5279: .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   5280: USE_BUILTIN.foo!=                                                       \
                   5281:         ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
                   5282:         && ${ECHO} "yes" || ${ECHO} "no"
                   5283: .      endif
                   5284: .    endfor
                   5285: .  endif
                   5286: .endif  # USE_BUILTIN.foo
1.1       dsieger  5287: 
1.184     rillig   5288: CHECK_BUILTIN.foo?=     no
                   5289: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   5290: #
                   5291: # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   5292: # "yes" or "no".
                   5293: #
                   5294: .endif  # CHECK_BUILTIN.foo
1.1       dsieger  5295: 
1.184     rillig   5296: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
                   5297: base system. This should not be a base system software with similar
                   5298: functionality to pkg; it should only be "yes" if the actual package is included
                   5299: as part of the base system. This variable is only used internally within the
                   5300: builtin.mk file.
1.1       dsieger  5301: 
1.184     rillig   5302: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
                   5303: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
                   5304: internally within the builtin.mk file.
1.1       dsieger  5305: 
1.184     rillig   5306: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
                   5307: The code in this section must make the determination whether the built-in
                   5308: software is adequate to satisfy the dependencies listed in
                   5309: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
                   5310: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg 
                   5311: must be set to the correct value by the end of the builtin.mk file. Note that
                   5312: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
                   5313: the determination that the built-in version of the software is similar enough
                   5314: to be used as a replacement.
1.1       dsieger  5315: 
1.184     rillig   5316: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
                   5317: the value of USE_BUILTIN.pkg set in the previous section. This typically
                   5318: includes, e.g., adding additional dependency restrictions and listing
                   5319: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
1.1       dsieger  5320: 
1.184     rillig   5321: Chapter 19. PLIST issues
1.1       dsieger  5322: 
1.184     rillig   5323: Table of Contents
1.1       dsieger  5324: 
1.184     rillig   5325: 19.1. RCS ID
                   5326: 19.2. Semi-automatic PLIST generation
                   5327: 19.3. Tweaking output of make print-PLIST
                   5328: 19.4. Variable substitution in PLIST
                   5329: 19.5. Man page compression
                   5330: 19.6. Changing PLIST source with PLIST_SRC
                   5331: 19.7. Platform-specific and differing PLISTs
                   5332: 19.8. Build-specific PLISTs
                   5333: 19.9. Sharing directories between packages
1.1       dsieger  5334: 
1.184     rillig   5335: The PLIST file contains a package's "packing list", i.e. a list of files that
                   5336: belong to the package (relative to the ${PREFIX} directory it's been installed
                   5337: in) plus some additional statements - see the pkg_create(1) man page for a full
                   5338: list. This chapter addresses some issues that need attention when dealing with
                   5339: the PLIST file (or files, see below!).
1.1       dsieger  5340: 
1.184     rillig   5341: 19.1. RCS ID
1.1       dsieger  5342: 
1.184     rillig   5343: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
1.1       dsieger  5344: 
1.184     rillig   5345: @comment $NetBSD $
1.1       dsieger  5346: 
1.184     rillig   5347: An artificial space has been added between NetBSD and $, this is a workaround
                   5348: here to prevent CVS expanding to the filename of the guide. When adding the RCS
                   5349: ID the space should be omitted.
1.38      wiz      5350: 
1.184     rillig   5351: 19.2. Semi-automatic PLIST generation
1.1       dsieger  5352: 
1.184     rillig   5353: You can use the make print-PLIST command to output a PLIST that matches any new
                   5354: files since the package was extracted. See Section 13.17, "Other helpful
                   5355: targets" for more information on this target.
1.11      rillig   5356: 
1.184     rillig   5357: 19.3. Tweaking output of make print-PLIST
1.1       dsieger  5358: 
1.184     rillig   5359: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
                   5360: used to filter the output of print-PLIST. You can append any chunk of AWK
                   5361: scripting you like to it, but be careful with quoting.
1.1       dsieger  5362: 
1.184     rillig   5363: For example, to get all files inside the libdata/foo directory removed from the
                   5364: resulting PLIST:
1.1       dsieger  5365: 
1.184     rillig   5366: PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
1.1       dsieger  5367: 
1.185     wiz      5368: The PRINT_PLIST_AWK transformations are evaluated after the file list and
                   5369: directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
                   5370: it operates before the file list and directory list are sorted.
                   5371: 
1.184     rillig   5372: 19.4. Variable substitution in PLIST
1.1       dsieger  5373: 
1.184     rillig   5374: A number of variables are substituted automatically in PLISTs when a package is
                   5375: installed on a system. This includes the following variables:
1.1       dsieger  5376: 
1.184     rillig   5377: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
1.1       dsieger  5378: 
1.184     rillig   5379:     Some packages like emacs and perl embed information about which
                   5380:     architecture they were built on into the pathnames where they install their
                   5381:     files. To handle this case, PLIST will be preprocessed before actually
                   5382:     used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
                   5383:     gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
                   5384:     PLIST somewhere - use this on packages that have GNU autoconf-created
                   5385:     configure scripts.
1.1       dsieger  5386: 
1.184     rillig   5387:     Legacy note
1.1       dsieger  5388: 
1.184     rillig   5389:     There used to be a symbol "$ARCH" that was replaced by the output of uname
                   5390:     -m, but that's no longer supported and has been removed.
1.1       dsieger  5391: 
1.184     rillig   5392: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
1.1       dsieger  5393: 
1.184     rillig   5394:     Some packages want to embed the OS name and version into some paths. To do
                   5395:     this, use these variables in the PLIST:
1.1       dsieger  5396: 
1.232     gutterid 5397:       o ${OPSYS} - output of "uname -s"
1.1       dsieger  5398: 
1.232     gutterid 5399:       o ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1       dsieger  5400: 
1.232     gutterid 5401:       o ${OS_VERSION} - "uname -r"
1.1       dsieger  5402: 
1.184     rillig   5403: For a list of values which are replaced by default, the output of make help
                   5404: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
                   5405: PLIST_SUBST should help.
1.1       dsieger  5406: 
1.184     rillig   5407: If you want to change other variables not listed above, you can add variables
                   5408: and their expansions to this variable in the following way, similar to
                   5409: MESSAGE_SUBST (see Section 12.5, "Optional files"):
1.1       dsieger  5410: 
1.184     rillig   5411: PLIST_SUBST+=   SOMEVAR="somevalue"
1.1       dsieger  5412: 
1.184     rillig   5413: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
1.1       dsieger  5414: 
1.184     rillig   5415: The PLIST_VARS variable can be used to simplify the common case of
                   5416: conditionally including some PLIST entries. It can be done by adding
                   5417: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
                   5418: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
                   5419: either """" or ""@comment "". For example, in Makefile:
1.1       dsieger  5420: 
1.184     rillig   5421: PLIST_VARS+=    foo
                   5422: .if condition
                   5423: PLIST.foo=      yes
                   5424: .else
1.1       dsieger  5425: 
1.184     rillig   5426: And then in PLIST:
1.1       dsieger  5427: 
1.184     rillig   5428: @comment $NetBSD $
                   5429: bin/bar
                   5430: man/man1/bar.1
                   5431: ${PLIST.foo}bin/foo
                   5432: ${PLIST.foo}man/man1/foo.1
                   5433: ${PLIST.foo}share/bar/foo.data
1.1       dsieger  5434: 
1.184     rillig   5435: An artificial space has been added between NetBSD and $, this is a workaround
                   5436: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.195     gutterid 5437: ID the space should be omitted.
1.1       dsieger  5438: 
1.184     rillig   5439: 19.5. Man page compression
1.1       dsieger  5440: 
1.184     rillig   5441: Man pages should be installed in compressed form if MANZ is set (in
                   5442: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
                   5443: suffix ".gz" is appended/removed automatically for man pages according to MANZ
                   5444: and MANCOMPRESSED being set or not, see above for details. This modification of
                   5445: the PLIST file is done on a copy of it, not PLIST itself.
1.100     leot     5446: 
1.184     rillig   5447: 19.6. Changing PLIST source with PLIST_SRC
1.100     leot     5448: 
1.184     rillig   5449: To use one or more files as source for the PLIST used in generating the binary
                   5450: package, set the variable PLIST_SRC to the names of that file(s). The files are
                   5451: later concatenated using cat(1), and the order of things is important. The
                   5452: default for PLIST_SRC is ${PKGDIR}/PLIST.
1.1       dsieger  5453: 
1.184     rillig   5454: 19.7. Platform-specific and differing PLISTs
1.1       dsieger  5455: 
1.184     rillig   5456: Some packages decide to install a different set of files based on the operating
                   5457: system being used. These differences can be automatically handled by using the
                   5458: following files:
1.1       dsieger  5459: 
1.184     rillig   5460:   * PLIST.common
1.1       dsieger  5461: 
1.184     rillig   5462:   * PLIST.${OPSYS}
1.1       dsieger  5463: 
1.184     rillig   5464:   * PLIST.${MACHINE_ARCH}
1.1       dsieger  5465: 
1.184     rillig   5466:   * PLIST.${OPSYS}-${MACHINE_ARCH}
1.1       dsieger  5467: 
1.184     rillig   5468:   * PLIST.common_end
1.1       dsieger  5469: 
1.184     rillig   5470: 19.8. Build-specific PLISTs
1.1       dsieger  5471: 
1.184     rillig   5472: Some packages decide to generate hard-to-guess file names during installation
                   5473: that are hard to wire down.
1.1       dsieger  5474: 
1.184     rillig   5475: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
                   5476: (with a semicolon) that will output PLIST entries which will be appended to the
                   5477: PLIST
1.1       dsieger  5478: 
1.184     rillig   5479: You can find one example in editors/xemacs:
1.1       dsieger  5480: 
1.184     rillig   5481: GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.1       dsieger  5482: 
1.184     rillig   5483: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
1.1       dsieger  5484: 
1.184     rillig   5485: 19.9. Sharing directories between packages
1.1       dsieger  5486: 
1.184     rillig   5487: A "shared directory" is a directory where multiple (and unrelated) packages
                   5488: install files. These directories were problematic because you had to add
                   5489: special tricks in the PLIST to conditionally remove them, or have some
                   5490: centralized package handle them.
1.106     tnn      5491: 
1.184     rillig   5492: In pkgsrc, it is now easy: Each package should create directories and install
                   5493: files as needed; pkg_delete will remove any directories left empty after
                   5494: uninstalling a package.
1.106     tnn      5495: 
1.184     rillig   5496: If a package needs an empty directory to work, create the directory during
                   5497: installation as usual, and also add an entry to the PLIST:
1.1       dsieger  5498: 
1.184     rillig   5499: @pkgdir path/to/empty/directory
1.1       dsieger  5500: 
1.184     rillig   5501: or take a look at MAKE_DIRS and OWN_DIRS.
1.1       dsieger  5502: 
1.184     rillig   5503: Chapter 20. The pkginstall framework
1.1       dsieger  5504: 
1.184     rillig   5505: Table of Contents
1.1       dsieger  5506: 
1.184     rillig   5507: 20.1. Files and directories outside the installation prefix
                   5508:     20.1.1. Directory manipulation
                   5509:     20.1.2. File manipulation
                   5510: 20.2. Configuration files
                   5511:     20.2.1. How PKG_SYSCONFDIR is set
                   5512:     20.2.2. Telling the software where configuration files are
1.239     dholland 5513:     20.2.3. Patching installation
                   5514:     20.2.4. Declaring configuration files
                   5515:     20.2.5. Disabling handling of configuration files
1.184     rillig   5516: 20.3. System startup scripts
                   5517:     20.3.1. Disabling handling of system startup scripts
                   5518: 20.4. System users and groups
                   5519: 20.5. System shells
                   5520:     20.5.1. Disabling shell registration
                   5521: 20.6. Fonts
                   5522:     20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  5523: 
1.184     rillig   5524: This chapter describes the framework known as pkginstall, whose key features
                   5525: are:
1.1       dsieger  5526: 
1.184     rillig   5527:   * Generic installation and manipulation of directories and files outside the
                   5528:     pkgsrc-handled tree, LOCALBASE.
1.1       dsieger  5529: 
1.184     rillig   5530:   * Automatic handling of configuration files during installation, provided
                   5531:     that packages are correctly designed.
1.1       dsieger  5532: 
1.184     rillig   5533:   * Generation and installation of system startup scripts.
1.1       dsieger  5534: 
1.184     rillig   5535:   * Registration of system users and groups.
1.1       dsieger  5536: 
1.184     rillig   5537:   * Registration of system shells.
1.1       dsieger  5538: 
1.184     rillig   5539:   * Automatic updating of fonts databases.
1.1       dsieger  5540: 
1.184     rillig   5541: The following sections inspect each of the above points in detail.
1.1       dsieger  5542: 
1.184     rillig   5543: You may be thinking that many of the things described here could be easily done
                   5544: with simple code in the package's post-installation target (post-install). This
                   5545: is incorrect, as the code in them is only executed when building from source.
                   5546: Machines using binary packages could not benefit from it at all (as the code
                   5547: itself could be unavailable). Therefore, the only way to achieve any of the
                   5548: items described above is by means of the installation scripts, which are
                   5549: automatically generated by pkginstall.
1.1       dsieger  5550: 
1.184     rillig   5551: 20.1. Files and directories outside the installation prefix
1.95      wiz      5552: 
1.184     rillig   5553: As you already know, the PLIST file holds a list of files and directories that
                   5554: belong to a package. The names used in it are relative to the installation
                   5555: prefix (${PREFIX}), which means that it cannot register files outside this
                   5556: directory (absolute path names are not allowed). Despite this restriction, some
                   5557: packages need to install files outside this location; e.g., under ${VARBASE} or
                   5558: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
                   5559: installation time by using installation scripts.
1.95      wiz      5560: 
1.184     rillig   5561: The generic installation scripts are shell scripts that can contain arbitrary
                   5562: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
                   5563: which defaults to INSTALL. A similar variable exists for package removal
                   5564: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
                   5565: commands, so they have the potential to create and manage files anywhere in the
                   5566: file system.
1.95      wiz      5567: 
1.184     rillig   5568: Using these general installation files is not recommended, but may be needed in
                   5569: some special cases. One reason for avoiding them is that the user has to trust
                   5570: the packager that there is no unwanted or simply erroneous code included in the
                   5571: installation script. Also, previously there were many similar scripts for the
                   5572: same functionality, and fixing a common error involved finding and changing all
                   5573: of them.
1.95      wiz      5574: 
1.184     rillig   5575: The pkginstall framework offers another, standardized way. It provides generic
                   5576: scripts to abstract the manipulation of such files and directories based on
                   5577: variables set in the package's Makefile. The rest of this section describes
                   5578: these variables.
1.1       dsieger  5579: 
1.184     rillig   5580: 20.1.1. Directory manipulation
1.1       dsieger  5581: 
1.184     rillig   5582: The following variables can be set to request the creation of directories
                   5583: anywhere in the file system:
1.1       dsieger  5584: 
1.184     rillig   5585:   * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
                   5586:     and should attempt to be destroyed by the installation scripts. The
                   5587:     difference between the two is that the latter prompts the administrator to
                   5588:     remove any directories that may be left after deinstallation (because they
                   5589:     were not empty), while the former does not. Example:
1.1       dsieger  5590: 
1.184     rillig   5591:     MAKE_DIRS+=             ${VARBASE}/foo/private
1.1       dsieger  5592: 
1.184     rillig   5593:   * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
                   5594:     which directories should be created and should attempt to be destroyed by
                   5595:     the installation scripts. Each tuple holds the following values, separated
                   5596:     by spaces: the directory name, its owner, its group and its numerical mode.
                   5597:     For example:
1.1       dsieger  5598: 
1.184     rillig   5599:     MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
                   5600:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5601: 
1.184     rillig   5602:     The difference between the two is exactly the same as their non-PERMS
                   5603:     counterparts.
1.1       dsieger  5604: 
1.184     rillig   5605: 20.1.2. File manipulation
1.1       dsieger  5606: 
1.184     rillig   5607: Creating non-empty files outside the installation prefix is tricky because the
                   5608: PLIST forces all files to be inside it. To overcome this problem, the only
1.239     dholland 5609: solution is to extract the file in a known place (i.e., inside the installation
                   5610: prefix) and copy it to the appropriate location during installation (done by
                   5611: the installation scripts generated by pkginstall). We will call the former the 
                   5612: reference file in the following paragraphs, which describe the variables that
                   5613: can be used to automatically and consistently handle files outside the
                   5614: installation prefix:
                   5615: 
                   5616:   * REQD_FILES is a list of pairs of reference and target files. At
                   5617:     installation time, the reference file is copied to the target if and only
                   5618:     if the latter does not exist. Upon deinstallation, the reference file is
1.184     rillig   5619:     removed provided that it was not modified by the installation.
1.1       dsieger  5620: 
1.239     dholland 5621:   * REQD_FILES_PERMS contains tuples describing reference files and targets,
                   5622:     including owner, group, and numeric permissions that should be set. For
                   5623:     example:
1.1       dsieger  5624: 
1.184     rillig   5625:     REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
                   5626:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5627: 
1.239     dholland 5628:   * CONF_FILES and CONF_FILES_PERMS have the same syntax as REQD_FILES and
                   5629:     REQD_FILES_PERMS respectively. The difference is that these variables are
                   5630:     specifically intended for handling configuration files, for which
                   5631:     additional conventions and constraints apply. See Section 20.2,
                   5632:     "Configuration files" for further discussion. Note in particular that while
                   5633:     handling of configuration files can be disabled by the user (see
                   5634:     Section 20.2.5, "Disabling handling of configuration files"), this setting
                   5635:     does not affect REQD_FILES and REQD_FILES_PERMS.
                   5636: 
                   5637: To install an empty file, one can use these macros and /dev/null as the
                   5638: reference file.
1.1       dsieger  5639: 
1.184     rillig   5640: 20.2. Configuration files
1.1       dsieger  5641: 
1.239     dholland 5642: There are two principles that govern the handling of configuration files in
                   5643: pkgsrc: first, the user's configuration must not be lost or overwritten by
                   5644: upgrades or reinstallations; and second, the default configuration should
                   5645: always be available for reference. To that end, pkgsrc has a framework
                   5646: specifically for handling configuration files. In general, configuration files
                   5647: are installed into ${PREFIX}/share/examples, and copied from there to the
                   5648: pertinent etc directory as a separate step and only as needed.
                   5649: 
                   5650: To make this work, there are three things that need to happen, any of which may
                   5651: require patching. First, the package must be told to read its configuration
                   5652: from the correct place at runtime; this place is ${PKG_SYSCONFDIR} (or possibly
                   5653: a subdirectory of it) which is often but not always ${PREFIX}/etc. Second, the
                   5654: package must be taught to install its default configuration files in ${PREFIX}/
                   5655: share/examples/${PKGBASE}; this is the point at which patching often becomes
                   5656: required because it is not the same place as the runtime location. Third, the
                   5657: configuration files need to be declared in the package makefile; this is the
                   5658: easy part.
                   5659: 
                   5660: With those elements in place, the right things will happen: the package install
                   5661: phase and resulting binary package will not touch ${PKG_SYSCONFDIR}, and the
                   5662: default configuration will be copied into place by the pkgsrc framework only if
                   5663: not already present. Similarly, upon deinstall the configuration will not be
                   5664: removed if it has been modified. (This means that in the case of reinstallation
                   5665: and upgrades, unmodified configuration files are updated but modifications are
                   5666: never discarded.)
                   5667: 
                   5668: The following sections describe how to make these things happen and document
                   5669: other relevant knobs available in the pkgsrc infrastructure.
1.1       dsieger  5670: 
1.184     rillig   5671: 20.2.1. How PKG_SYSCONFDIR is set
1.1       dsieger  5672: 
1.184     rillig   5673: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
                   5674: shall be installed. Its contents are set based upon the following variables:
1.1       dsieger  5675: 
1.184     rillig   5676:   * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
1.239     dholland 5677:     etc although it may be overridden by the user to point to their preferred
1.184     rillig   5678:     location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
1.1       dsieger  5679: 
1.184     rillig   5680:   * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
                   5681:     configuration files for the package being built shall be installed. The
                   5682:     definition of this variable only makes sense in the package's Makefile
                   5683:     (i.e., it is not user-customizable).
1.1       dsieger  5684: 
1.184     rillig   5685:     As an example, consider the Apache package, www/apache24, which places its
                   5686:     configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
                   5687:     should be set in the package Makefile.
1.1       dsieger  5688: 
1.184     rillig   5689:   * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
                   5690:     package's configuration directory (if different from PKG_SYSCONFBASE). It
                   5691:     defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
1.1       dsieger  5692: 
1.184     rillig   5693:   * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
                   5694:     configuration files for the package identified by PKG_SYSCONFVAR's shall be
                   5695:     placed.
1.1       dsieger  5696: 
1.184     rillig   5697: Based on the above variables, pkginstall determines the value of
1.239     dholland 5698: PKG_SYSCONFDIR, which is the only variable that may be used within a package to
1.184     rillig   5699: refer to its configuration directory. The algorithm used to set its value is
                   5700: basically the following:
1.1       dsieger  5701: 
1.184     rillig   5702:  1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
1.1       dsieger  5703: 
1.184     rillig   5704:  2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
                   5705:     package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
                   5706:     {PKG_SYSCONFSUBDIR}.
1.1       dsieger  5707: 
1.184     rillig   5708:  3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
1.1       dsieger  5709: 
1.184     rillig   5710: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.239     dholland 5711: OWN_DIRS. This causes it to be automatically created if needed. See
                   5712: Section 20.1.1, "Directory manipulation" for further details. This does not
                   5713: apply to subdirectories of ${PKG_SYSCONFDIR}; they must be manually created
                   5714: with OWN_DIRS or MAKE_DIRS.
1.1       dsieger  5715: 
1.184     rillig   5716: 20.2.2. Telling the software where configuration files are
1.1       dsieger  5717: 
1.184     rillig   5718: Given that pkgsrc (and users!) expect configuration files to be in a known
1.239     dholland 5719: place, you need to teach each package where to install its files. In some cases
                   5720: you will have to patch the package Makefiles to achieve it. If you are lucky,
                   5721: though, it may be as easy as passing an extra flag to the configuration script.
                   5722: This is the case for packages using GNU autoconf:
1.1       dsieger  5723: 
1.184     rillig   5724: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1       dsieger  5725: 
1.184     rillig   5726: Note that this specifies where the package has to look for its configuration
1.239     dholland 5727: files, not where they will be installed. Fortunately, there is a different way
1.240     gutterid 5728: to specify the latter, as seen in the next section, although the combination is
                   5729: rather confusing at first glance.
1.1       dsieger  5730: 
1.239     dholland 5731: 20.2.3. Patching installation
1.1       dsieger  5732: 
1.239     dholland 5733: As discussed above, packages themselves must not touch the contents of $
1.184     rillig   5734: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
                   5735: will, out of the box, mess with the contents of that directory. So what is the
                   5736: correct procedure to fix this issue?
1.1       dsieger  5737: 
1.184     rillig   5738: You must teach the package (usually by manually patching it) to install any
                   5739: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
                   5740: This way, the PLIST registers them and the administrator always has the
                   5741: original copies available.
1.1       dsieger  5742: 
1.239     dholland 5743: It turns out that for packages using GNU autoconf it is possible to create the
                   5744: desired effect by setting sysconfdir on the make command line at install time.
                   5745: Consider this example taken from mail/mutt:
                   5746: 
                   5747: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5748: INSTALL_MAKE_FLAGS=     ${MAKE_FLAGS} sysconfdir=${EGDIR}
                   5749: 
                   5750: Note that the EGDIR variable, though commonly used for this purpose, is local
                   5751: to that package and has no meaning outside it.
1.1       dsieger  5752: 
1.239     dholland 5753: 20.2.4. Declaring configuration files
1.1       dsieger  5754: 
1.239     dholland 5755: Once the required configuration files are in place (i.e., under the examples
                   5756: hierarchy), the pkginstall framework can use them as reference copies during
                   5757: the package installation to update what is in ${PKG_SYSCONFDIR}. To achieve
                   5758: this, the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
                   5759: Section 20.1.2, "File manipulation" for further information about their syntax
                   5760: and their purpose. Here is an example, taken from the mail/mutt package:
                   5761: 
                   5762: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5763: CONF_FILES=             ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
                   5764: 
                   5765: Note that (as in the previous section's example) the EGDIR variable is specific
                   5766: to the package and has no meaning outside it.
                   5767: 
                   5768: For reference, the complete example from Mutt is as follows:
                   5769: 
                   5770: CONFIGURE_ARGS+=        --sysconfdir=${PKG_SYSCONFDIR}
                   5771: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5772: CONF_FILES=             ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
                   5773: INSTALLATION_DIRS+=     ${EGDIR}
                   5774: INSTALL_MAKE_FLAGS=     ${MAKE_FLAGS} sysconfdir=${EGDIR}
1.1       dsieger  5775: 
1.239     dholland 5776: 20.2.5. Disabling handling of configuration files
1.1       dsieger  5777: 
1.184     rillig   5778: The automatic copying of config files can be toggled by setting the environment
                   5779: variable PKG_CONFIG prior to package installation.
1.1       dsieger  5780: 
1.184     rillig   5781: 20.3. System startup scripts
1.1       dsieger  5782: 
1.184     rillig   5783: System startup scripts are special files because they must be installed in a
                   5784: place known by the underlying OS, usually outside the installation prefix.
                   5785: Therefore, the same rules described in Section 20.1, "Files and directories
                   5786: outside the installation prefix" apply, and the same solutions can be used.
                   5787: However, pkginstall provides a special mechanism to handle these files.
1.1       dsieger  5788: 
1.184     rillig   5789: In order to provide system startup scripts, the package has to:
1.1       dsieger  5790: 
1.184     rillig   5791:  1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
1.223     nia      5792:     Considering the print/cups-base package as an example, it has a cupsd.sh in
                   5793:     its files directory.
1.95      wiz      5794: 
1.184     rillig   5795:  2. Tell pkginstall to handle it, appending the name of the script, without its
                   5796:     extension, to the RCD_SCRIPTS variable. Continuing the previous example:
1.95      wiz      5797: 
1.184     rillig   5798:     RCD_SCRIPTS+=   cupsd
1.95      wiz      5799: 
1.184     rillig   5800: Once this is done, pkginstall will do the following steps for each script in an
                   5801: automated fashion:
1.95      wiz      5802: 
1.184     rillig   5803:  1. Process the file found in the files directory applying all the
                   5804:     substitutions described in the FILES_SUBST variable.
1.1       dsieger  5805: 
1.184     rillig   5806:  2. Copy the script from the files directory to the examples hierarchy, $
1.239     dholland 5807:     {PREFIX}/share/examples/rc.d/. Note that this reference file must be
1.184     rillig   5808:     explicitly registered in the PLIST.
1.1       dsieger  5809: 
1.184     rillig   5810:  3. Add code to the installation scripts to copy the startup script from the
                   5811:     examples hierarchy into the system-wide startup scripts directory.
1.1       dsieger  5812: 
1.184     rillig   5813: 20.3.1. Disabling handling of system startup scripts
1.1       dsieger  5814: 
1.184     rillig   5815: The automatic copying of config files can be toggled by setting the environment
                   5816: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
                   5817: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
                   5818: rc.d/, no matter what the value of this variable is.
1.1       dsieger  5819: 
1.184     rillig   5820: 20.4. System users and groups
1.1       dsieger  5821: 
1.184     rillig   5822: If a package needs to create special users and/or groups during installation,
                   5823: it can do so by using the pkginstall framework.
1.1       dsieger  5824: 
1.184     rillig   5825: Users can be created by adding entries to the PKG_USERS variable. Each entry
                   5826: has the following syntax:
1.1       dsieger  5827: 
1.184     rillig   5828: user:group
1.1       dsieger  5829: 
1.184     rillig   5830: Further specification of user details may be done by setting per-user
                   5831: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
                   5832: user's description or comment. PKG_HOME.user is the user's home directory, and
                   5833: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
                   5834: and defaults to /sbin/nologin if not specified.
1.1       dsieger  5835: 
1.184     rillig   5836: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
                   5837: whose syntax is:
1.1       dsieger  5838: 
1.184     rillig   5839: group
1.1       dsieger  5840: 
1.184     rillig   5841: The numeric GID of the group may be set by defining PKG_GID.group.
1.1       dsieger  5842: 
1.184     rillig   5843: If a package needs to create the users and groups at an earlier stage, then it
                   5844: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
                   5845: the phase before which the users and groups are created. In this case, the
                   5846: numeric UIDs and GIDs of the created users and groups are automatically
                   5847: hardcoded into the final installation scripts.
1.1       dsieger  5848: 
1.184     rillig   5849: 20.5. System shells
1.1       dsieger  5850: 
1.184     rillig   5851: Packages that install system shells should register them in the shell database,
                   5852: /etc/shells, to make things easier to the administrator. This must be done from
                   5853: the installation scripts to keep binary packages working on any system.
                   5854: pkginstall provides an easy way to accomplish this task.
1.1       dsieger  5855: 
1.184     rillig   5856: When a package provides a shell interpreter, it has to set the PKG_SHELL
                   5857: variable to its absolute file name. This will add some hooks to the
                   5858: installation scripts to handle it. Consider the following example, taken from
                   5859: shells/zsh:
1.1       dsieger  5860: 
1.184     rillig   5861: PKG_SHELL=      ${PREFIX}/bin/zsh
1.1       dsieger  5862: 
1.184     rillig   5863: 20.5.1. Disabling shell registration
1.1       dsieger  5864: 
1.184     rillig   5865: The automatic registration of shell interpreters can be disabled by the
                   5866: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
1.1       dsieger  5867: 
1.184     rillig   5868: 20.6. Fonts
1.1       dsieger  5869: 
1.184     rillig   5870: Packages that install X11 fonts should update the database files that index the
                   5871: fonts within each fonts directory. This can easily be accomplished within the
                   5872: pkginstall framework.
1.1       dsieger  5873: 
1.184     rillig   5874: When a package installs X11 fonts, it must list the directories in which fonts
                   5875: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
                   5876: "type1" or "x11". This will add hooks to the installation scripts to run the
                   5877: appropriate commands to update the fonts database files within each of those
                   5878: directories. For convenience, if the directory path is relative, it is taken to
                   5879: be relative to the package's installation prefix. Consider the following
                   5880: example, taken from fonts/dbz-ttf:
1.1       dsieger  5881: 
1.184     rillig   5882: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1       dsieger  5883: 
1.184     rillig   5884: 20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  5885: 
1.184     rillig   5886: The automatic update of fonts databases can be disabled by the administrator by
                   5887: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
1.1       dsieger  5888: 
1.154     rillig   5889: Chapter 21. Making your package work
1.1       dsieger  5890: 
                   5891: Table of Contents
                   5892: 
1.154     rillig   5893: 21.1. General operation
                   5894:     21.1.1. How to pull in user-settable variables from mk.conf
                   5895:     21.1.2. User interaction
                   5896:     21.1.3. Handling licenses
                   5897:     21.1.4. Restricted packages
                   5898:     21.1.5. Handling dependencies
                   5899:     21.1.6. Handling conflicts with other packages
                   5900:     21.1.7. Packages that cannot or should not be built
                   5901:     21.1.8. Packages which should not be deleted, once installed
                   5902:     21.1.9. Handling packages with security problems
                   5903:     21.1.10. How to handle incrementing versions when fixing an existing
1.232     gutterid 5904:     package
1.154     rillig   5905:     21.1.11. Substituting variable text in the package files (the SUBST
1.232     gutterid 5906:     framework)
1.154     rillig   5907: 21.2. The fetch phase
                   5908:     21.2.1. Packages whose distfiles aren't available for plain downloading
                   5909:     21.2.2. How to handle modified distfiles with the 'old' name
                   5910:     21.2.3. Packages hosted on github.com
                   5911: 21.3. The configure phase
                   5912:     21.3.1. Shared libraries - libtool
                   5913:     21.3.2. Using libtool on GNU packages that already support libtool
                   5914:     21.3.3. GNU Autoconf/Automake
1.223     nia      5915:     21.3.4. Meson / ninja
1.154     rillig   5916: 21.4. Programming languages
                   5917:     21.4.1. C, C++, and Fortran
                   5918:     21.4.2. Java
1.205     wiz      5919:     21.4.3. Go
1.223     nia      5920:     21.4.4. Rust
                   5921:     21.4.5. Packages containing Perl scripts
                   5922:     21.4.6. Packages containing shell scripts
                   5923:     21.4.7. Other programming languages
1.154     rillig   5924: 21.5. The build phase
                   5925:     21.5.1. Compiling C and C++ code conditionally
                   5926:     21.5.2. How to handle compiler bugs
1.172     rillig   5927:     21.5.3. No such file or directory
                   5928:     21.5.4. Undefined reference to "..."
                   5929:     21.5.5. Running out of memory
1.154     rillig   5930: 21.6. The install phase
                   5931:     21.6.1. Creating needed directories
                   5932:     21.6.2. Where to install documentation
                   5933:     21.6.3. Installing highscore files
                   5934:     21.6.4. Adding DESTDIR support to packages
                   5935:     21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia      5936:     21.6.6. Packages installing Perl modules
1.254     wiz      5937:     21.6.7. Packages installing pkg-config files
                   5938:     21.6.8. Packages installing info files
                   5939:     21.6.9. Packages installing man pages
                   5940:     21.6.10. Packages installing X11 fonts
                   5941:     21.6.11. Packages installing SGML or XML data
                   5942:     21.6.12. Packages installing extensions to the MIME database
                   5943:     21.6.13. Packages using intltool
                   5944:     21.6.14. Packages installing startup scripts
                   5945:     21.6.15. Packages installing TeX modules
                   5946:     21.6.16. Packages supporting running binaries in emulation
                   5947:     21.6.17. Packages installing hicolor icons
                   5948:     21.6.18. Packages installing desktop files
1.154     rillig   5949: 21.7. Marking packages as having problems
1.1       dsieger  5950: 
1.154     rillig   5951: 21.1. General operation
1.1       dsieger  5952: 
                   5953: One appealing feature of pkgsrc is that it runs on many different platforms. As
                   5954: a result, it is important to ensure, where possible, that packages in pkgsrc
                   5955: are portable. This chapter mentions some particular details you should pay
                   5956: attention to while working on pkgsrc.
                   5957: 
1.154     rillig   5958: 21.1.1. How to pull in user-settable variables from mk.conf
1.1       dsieger  5959: 
                   5960: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4       rillig   5961: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
                   5962: those variables in the preprocessor directives of make(1) (for example .if or
                   5963: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
                   5964: loads the user preferences.
1.1       dsieger  5965: 
                   5966: But note that some variables may not be completely defined after ../../mk/
                   5967: bsd.prefs.mk has been included, as they may contain references to variables
1.108     rillig   5968: that are not yet defined. In shell commands (the lines in Makefile that are
                   5969: indented with a tab) this is no problem, since variables are only expanded when
                   5970: they are used. But in the preprocessor directives mentioned above and in
                   5971: dependency lines (of the form target: dependencies) the variables are expanded
                   5972: at load time.
1.1       dsieger  5973: 
                   5974: Note
                   5975: 
1.108     rillig   5976: To check whether a variable can be used at load time, run pkglint -Wall on your
                   5977: package.
1.1       dsieger  5978: 
1.154     rillig   5979: 21.1.2. User interaction
1.1       dsieger  5980: 
                   5981: Occasionally, packages require interaction from the user, and this can be in a
                   5982: number of ways:
                   5983: 
                   5984:   * When fetching the distfiles, some packages require user interaction such as
                   5985:     entering username/password or accepting a license on a web page.
                   5986: 
                   5987:   * When extracting the distfiles, some packages may ask for passwords.
                   5988: 
                   5989:   * help to configure the package before it is built
                   5990: 
                   5991:   * help during the build process
                   5992: 
                   5993:   * help during the installation of a package
                   5994: 
1.108     rillig   5995: A package can set the INTERACTIVE_STAGE variable to define which stages need
                   5996: interaction. This should be done in the package's Makefile, e.g.:
1.1       dsieger  5997: 
                   5998: INTERACTIVE_STAGE=      configure install
                   5999: 
                   6000: The user can then decide to skip this package by setting the BATCH variable.
1.108     rillig   6001: Packages that require interaction are also excluded from bulk builds.
1.1       dsieger  6002: 
1.154     rillig   6003: 21.1.3. Handling licenses
1.1       dsieger  6004: 
                   6005: Authors of software can choose the licence under which software can be copied.
1.111     sevan    6006: The Free Software Foundation has declared some licenses "Free", and the Open
                   6007: Source Initiative has a definition of "Open Source".
                   6008: 
                   6009: By default, pkgsrc allows packages with Free or Open Source licenses to be
                   6010: built. To allow packages with other licenses to be built as well, the pkgsrc
                   6011: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
                   6012: . Note that this variable only affects which packages may be built, while the
                   6013: license terms often also restrict the actual use of the package and its
                   6014: redistribution.
1.1       dsieger  6015: 
                   6016: One might want to only install packages with a BSD license, or the GPL, and not
1.20      jnemeth  6017: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111     sevan    6018: variable. The pkgsrc user can override the default by setting the
                   6019: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
                   6020: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
                   6021: pkgsrc/mk/license.mk.
1.1       dsieger  6022: 
                   6023: The license tag mechanism is intended to address copyright-related issues
                   6024: surrounding building, installing and using a package, and not to address
1.20      jnemeth  6025: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
                   6026: redistribution restrictions should set these tags.
1.1       dsieger  6027: 
                   6028: Denoting that a package may be copied according to a particular license is done
                   6029: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
                   6030: string identifying the license, e.g. in graphics/xv:
                   6031: 
                   6032: LICENSE=        xv-license
                   6033: 
                   6034: When trying to build, the user will get a notice that the package is covered by
                   6035: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
                   6036: 
                   6037: % make
                   6038: ===> xv-3.10anb9 has an unacceptable license: xv-license.
                   6039: ===>     To view the license, enter "/usr/bin/make show-license".
                   6040: ===>     To indicate acceptance, add this line to your /etc/mk.conf:
                   6041: ===>     ACCEPTABLE_LICENSES+=xv-license
                   6042: *** Error code 1
                   6043: 
                   6044: The license can be viewed with make show-license, and if the user so chooses,
1.4       rillig   6045: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1       dsieger  6046: should not in the future fail because of that license:
                   6047: 
                   6048: ACCEPTABLE_LICENSES+=xv-license
                   6049: 
1.111     sevan    6050: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
                   6051: is deprecated because it does not crisply refer to a particular license text.
                   6052: Another problem with such usage is that it does not enable a user to tell
                   6053: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
                   6054: for all packages with that tag.
                   6055: 
1.154     rillig   6056: 21.1.3.1. Adding a package with a new license
1.1       dsieger  6057: 
1.49      rodent   6058: When adding a package with a new license, the following steps are required:
                   6059: 
1.111     sevan    6060:  1. Check whether the license qualifies as Free or Open Source by referencing
                   6061:     Various Licenses and Comments about Them and Licenses by Name | Open Source
                   6062:     Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
                   6063:     need the -license suffix, and the license name should be added to:
1.49      rodent   6064: 
                   6065:       + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
                   6066: 
                   6067:       + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
                   6068:         license.c
                   6069: 
                   6070:  2. The license text should be added to pkgsrc/licenses for displaying. A list
                   6071:     of known licenses can be seen in this directory.
1.1       dsieger  6072: 
1.154     rillig   6073: 21.1.3.2. Change to the license
1.1       dsieger  6074: 
1.111     sevan    6075: When the license changes (in a way other than formatting), make sure that the
                   6076: new license has a different name (e.g., append the version number if it exists,
                   6077: or the date). Just because a user told pkgsrc to build programs under a
                   6078: previous version of a license does not mean that pkgsrc should build programs
                   6079: under the new licenses. The higher-level point is that pkgsrc does not evaluate
                   6080: licenses for reasonableness; the only test is a mechanistic test of whether a
                   6081: particular text has been approved by either of two bodies (FSF or OSI).
1.1       dsieger  6082: 
1.154     rillig   6083: 21.1.4. Restricted packages
1.1       dsieger  6084: 
1.111     sevan    6085: Some licenses restrict how software may be re-distributed. By declaring the
                   6086: restrictions, package tools can automatically refrain from e.g. placing binary
                   6087: packages on FTP sites.
                   6088: 
                   6089: There are four possible restrictions, which are the cross product of sources
                   6090: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
                   6091: this is rarely the exact language in any license, and because non-Free licenses
                   6092: tend to be different from each other, pkgsrc adopts a definition of FTP and
                   6093: CD-ROM. "FTP" means making the source or binary file available over the
                   6094: Internet at no charge. "CD-ROM" means making the source or binary available on
                   6095: some kind of media, together with other source and binary packages, which is
                   6096: sold for a distribution charge.
1.1       dsieger  6097: 
                   6098: In order to encode these restrictions, the package system defines five make
                   6099: variables that can be set to note these restrictions:
                   6100: 
                   6101:   * RESTRICTED
                   6102: 
                   6103:     This variable should be set whenever a restriction exists (regardless of
                   6104:     its kind). Set this variable to a string containing the reason for the
                   6105:     restriction. It should be understood that those wanting to understand the
                   6106:     restriction will have to read the license, and perhaps seek advice of
                   6107:     counsel.
                   6108: 
                   6109:   * NO_BIN_ON_CDROM
                   6110: 
                   6111:     Binaries may not be placed on CD-ROM containing other binary packages, for
                   6112:     which a distribution charge may be made. In this case, set this variable to
                   6113:     ${RESTRICTED}.
                   6114: 
                   6115:   * NO_BIN_ON_FTP
                   6116: 
                   6117:     Binaries may not made available on the Internet without charge. In this
                   6118:     case, set this variable to ${RESTRICTED}. If this variable is set, binary
                   6119:     packages will not be included on ftp.NetBSD.org.
                   6120: 
                   6121:   * NO_SRC_ON_CDROM
                   6122: 
                   6123:     Distfiles may not be placed on CD-ROM, together with other distfiles, for
                   6124:     which a fee may be charged. In this case, set this variable to $
                   6125:     {RESTRICTED}.
                   6126: 
                   6127:   * NO_SRC_ON_FTP
                   6128: 
                   6129:     Distfiles may not made available via FTP at no charge. In this case, set
                   6130:     this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
                   6131:     will not be mirrored on ftp.NetBSD.org.
                   6132: 
1.111     sevan    6133: Please note that packages will be removed from pkgsrc when the distfiles are
1.33      wiz      6134: not distributable and cannot be obtained for a period of one full quarter
1.111     sevan    6135: branch. Packages with manual/interactive fetch must have a maintainer and it is
                   6136: his/her responsibility to ensure this.
1.33      wiz      6137: 
1.154     rillig   6138: 21.1.5. Handling dependencies
1.1       dsieger  6139: 
1.175     gutterid 6140: Your package may depend on some other package being present, and there are
                   6141: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
                   6142: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
                   6143: definition, as well as dependencies via buildlink3.mk, which is the preferred
                   6144: way to handle dependencies, and which uses the variables named above. See
1.184     rillig   6145: Chapter 18, Buildlink methodology for more information.
1.175     gutterid 6146: 
                   6147: The basic difference is that the DEPENDS definition registers that
                   6148: pre-requisite in the binary package so it will be pulled in when the binary
                   6149: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
                   6150: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
1.184     rillig   6151: building or testing the resulting package. See also Chapter 14, Creating a new
1.175     gutterid 6152: pkgsrc package from scratch for more information.
                   6153: 
                   6154: This means that if you only need a package present whilst you are building or
                   6155: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
                   6156: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
                   6157: architecture where the package is built; BUILD_DEPENDS are target packages,
                   6158: i.e., packages for the architecture for which the package is built.
1.1       dsieger  6159: 
1.175     gutterid 6160: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
                   6161: definition is:
1.1       dsieger  6162: 
                   6163: <pre-req-package-name>:../../<category>/<pre-req-package>
                   6164: 
                   6165: Please note that the "pre-req-package-name" may include any of the wildcard
                   6166: version numbers recognized by pkg_info(1).
                   6167: 
1.55      wiz      6168:  1. If your package needs another package's binaries or libraries to build and
1.1       dsieger  6169:     run, and if that package has a buildlink3.mk file available, use it:
                   6170: 
                   6171:     .include "../../graphics/jpeg/buildlink3.mk"
                   6172: 
1.55      wiz      6173:  2. If your package needs another package's binaries or libraries only for
                   6174:     building, and if that package has a buildlink3.mk file available, use it:
                   6175: 
                   6176:     .include "../../graphics/jpeg/buildlink3.mk"
                   6177: 
                   6178:     but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
                   6179:     This case is rather rare.
                   6180: 
                   6181:  3. If your package needs binaries from another package to build, use the
1.156     leot     6182:     TOOL_DEPENDS definition:
                   6183: 
                   6184:     TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1       dsieger  6185: 
1.156     leot     6186:  4. If your package needs static libraries to link against, header files to
                   6187:     include, etc. from another package to build, use the BUILD_DEPENDS
                   6188:     definition.
1.1       dsieger  6189: 
1.156     leot     6190:  5. If your package needs a library with which to link and there is no
1.26      spz      6191:     buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
                   6192:     because the include files and libraries will be hidden from the compiler.
1.1       dsieger  6193: 
1.156     leot     6194:  6. If your package needs some executable to be able to run correctly and if
1.26      spz      6195:     there's no buildlink3.mk file, this is specified using the DEPENDS
                   6196:     variable. The print/lyx package needs to be able to execute the latex
1.129     wiz      6197:     binary from the tex-latex-bin package when it runs, and that is specified:
1.1       dsieger  6198: 
1.129     wiz      6199:     DEPENDS+=        tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1       dsieger  6200: 
1.175     gutterid 6201:  7. If your package includes a test suite that has extra dependencies only
                   6202:     required for this purpose (frequently this can be run as a "make test"
                   6203:     target), use the TEST_DEPENDS variable.
                   6204: 
                   6205:  8. You can use wildcards in package dependencies. Note that such wildcard
1.26      spz      6206:     dependencies are retained when creating binary packages. The dependency is
                   6207:     checked when installing the binary package and any package which matches
                   6208:     the pattern will be used. Wildcard dependencies should be used with care.
1.1       dsieger  6209: 
                   6210:     The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
                   6211:     matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
                   6212: 
                   6213:     Wildcards can also be used to specify that a package will only build
                   6214:     against a certain minimum version of a pre-requisite:
                   6215: 
1.26      spz      6216:     DEPENDS+=       ImageMagick>=6.0:../../graphics/ImageMagick
1.1       dsieger  6217: 
1.26      spz      6218:     This means that the package will build using version 6.0 of ImageMagick or
                   6219:     newer. Such a dependency may be warranted if, for example, the command line
                   6220:     options of an executable have changed.
                   6221: 
1.183     wiz      6222:     If you need to depend on minimum versions of libraries, set
                   6223:     BUILDLINK_API_DEPENDS.pkg to the appropriate pattern before including its
                   6224:     buildlink3.mk file, e.g.
                   6225: 
                   6226:     BUILDLINK_API_DEPENDS.jpeg+=    jpeg>=9.0
                   6227:     .include "../../graphics/jpeg/buildlink3.mk"
1.1       dsieger  6228: 
                   6229:     For security fixes, please update the package vulnerabilities file. See
1.154     rillig   6230:     Section 21.1.9, "Handling packages with security problems" for more
1.1       dsieger  6231:     information.
                   6232: 
                   6233: If your package needs files from another package to build, add the relevant
                   6234: distribution files to DISTFILES, so they will be extracted automatically. See
                   6235: the print/ghostscript package for an example. (It relies on the jpeg sources
                   6236: being present in source form during the build.)
                   6237: 
1.154     rillig   6238: 21.1.6. Handling conflicts with other packages
1.1       dsieger  6239: 
1.226     gutterid 6240: Your package may conflict with other packages users might already have
                   6241: installed on their system, e.g., if your package installs the same set of files
1.227     wiz      6242: as another package in the pkgsrc tree.
1.1       dsieger  6243: 
1.142     leot     6244: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
                   6245: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1       dsieger  6246: 
1.142     leot     6247: CONFLICTS=      Xaw-Xpm-[0-9]*
1.1       dsieger  6248: 
1.142     leot     6249: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1       dsieger  6250: 
1.142     leot     6251: CONFLICTS=      libXaw3d-[0-9]*
1.1       dsieger  6252: 
1.142     leot     6253: pkg_add(1) is able to detect attempts to install packages that conflict with
                   6254: existing packages and abort. However, in many situations this is too late in
                   6255: the process. Binary package managers will not know about the conflict until
                   6256: they attempt to install the package after already downloading it and all its
                   6257: dependencies. Users may also waste time building a package and its dependencies
                   6258: only to find out at the end that it conflicts with another package they have
                   6259: installed.
                   6260: 
                   6261: To avoid these issues CONFLICTS entries should be added in all cases where it
                   6262: is known that packages conflict with each other. These CONFLICTS entries are
                   6263: exported in pkg_summary(5) files and consumed by binary package managers to
                   6264: inform users that packages cannot be installed onto the target system.
1.1       dsieger  6265: 
1.154     rillig   6266: 21.1.7. Packages that cannot or should not be built
1.1       dsieger  6267: 
                   6268: There are several reasons why a package might be instructed to not build under
                   6269: certain circumstances. If the package builds and runs on most platforms, the
1.83      dholland 6270: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
                   6271: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
                   6272: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
                   6273: (OS-version-platform) that can use glob-style wildcards.
                   6274: 
1.114     maya     6275: If a package is not appropriate for some platforms (as opposed to merely
1.83      dholland 6276: broken), a different set of variables should be used as this affects failure
                   6277: reporting and statistics. If the package is appropriate for most platforms, the
                   6278: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
                   6279: for only a small handful of platforms (often exactly one), set
                   6280: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
                   6281: triples (OS-version-platform) that can use glob-style wildcards.
1.1       dsieger  6282: 
                   6283: Some packages are tightly bound to a specific version of an operating system,
                   6284: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
                   6285: with other versions of the OS, and should be uploaded to a version specific
                   6286: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
                   6287: to "yes". This variable is not currently used by any of the package system
                   6288: internals, but may be used in the future.
                   6289: 
                   6290: If the package should be skipped (for example, because it provides
                   6291: functionality already provided by the system), set PKG_SKIP_REASON to a
                   6292: descriptive message. If the package should fail because some preconditions are
                   6293: not met, set PKG_FAIL_REASON to a descriptive message.
                   6294: 
1.154     rillig   6295: 21.1.8. Packages which should not be deleted, once installed
1.1       dsieger  6296: 
                   6297: To ensure that a package may not be deleted, once it has been installed, the
                   6298: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25      wiz      6299: carried into any binary package that is made from this pkgsrc entry. A "
                   6300: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1       dsieger  6301: option is used.
                   6302: 
1.154     rillig   6303: 21.1.9. Handling packages with security problems
1.1       dsieger  6304: 
1.247     wiz      6305: When a vulnerability is found, this should be noted in pkgsrc/doc/
                   6306: pkg-vulnerabilities. Entries in that file consist of three parts:
1.205     wiz      6307: 
                   6308:   * package version pattern
                   6309: 
                   6310:   * type of vulnerability (please cut'n'paste an existing one where possible)
                   6311: 
                   6312:   * URL providing additional information about the issue
                   6313: 
                   6314: For the package version pattern please always use `<' to mark an upper bound
                   6315: (not `<='!). This will avoid possible problems due unrelated PKGREVISION bumps
                   6316: not related to security fixes. Lower bounds can be added too, using '>' or '>=
1.206     wiz      6317: '. For example, "foo>=1<1.2" would mark versions 1.0 (included) to 1.2
1.205     wiz      6318: (excluded) of "foo" as affected by the security issue.
                   6319: 
                   6320: Entries should always be added at the bottom of the file.
                   6321: 
                   6322: When fixing packages, please modify the upper bound of the corresponding entry.
                   6323: To continue the previous example, if a fix was backported to version 1.1nb2,
1.206     wiz      6324: change the previous pattern to "foo>=1<1.1nb2".
1.205     wiz      6325: 
                   6326: To locally test a package version pattern against a PKGNAME you can use the 
                   6327: pkg_admin pmatch command.
                   6328: 
                   6329: The URL should be as permanent as possible and provide as much information
                   6330: about the issue as possible. CVE entries are preferred.
                   6331: 
                   6332: After committing that file, ask pkgsrc-security@NetBSD.org to update the file
                   6333: on ftp.NetBSD.org.
1.1       dsieger  6334: 
                   6335: After fixing the vulnerability by a patch, its PKGREVISION should be increased
                   6336: (this is of course not necessary if the problem is fixed by using a newer
1.32      wiz      6337: release of the software), and the pattern in the pkg-vulnerabilities file must
                   6338: be updated.
1.1       dsieger  6339: 
                   6340: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
                   6341: submit a pullup request!
                   6342: 
                   6343: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
                   6344: a weekly cron job.
                   6345: 
1.205     wiz      6346: In case a security issue is disputed, please contact
                   6347: pkgsrc-security@NetBSD.org.
                   6348: 
1.154     rillig   6349: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1       dsieger  6350: 
                   6351: When making fixes to an existing package it can be useful to change the version
                   6352: number in PKGNAME. To avoid conflicting with future versions by the original
                   6353: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
                   6354: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
                   6355: e.g.
                   6356: 
                   6357: DISTNAME=       foo-17.42
                   6358: PKGREVISION=    9
                   6359: 
                   6360: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
                   6361: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
                   6362: PKGNAME_NOREV.
                   6363: 
                   6364: When a new release of the package is released, the PKGREVISION should be
                   6365: removed, e.g. on a new minor release of the above package, things should be
                   6366: like:
                   6367: 
                   6368: DISTNAME=       foo-17.43
                   6369: 
                   6370: PKGREVISION should be incremented for any non-trivial change in the resulting
                   6371: binary package. Without a PKGREVISION bump, someone with the previous version
                   6372: installed has no way of knowing that their package is out of date. Thus,
                   6373: changes without increasing PKGREVISION are essentially labeled "this is so
                   6374: trivial that no reasonable person would want to upgrade", and this is the rough
                   6375: test for when increasing PKGREVISION is appropriate. Examples of changes that
                   6376: do not merit increasing PKGREVISION are:
                   6377: 
1.14      jmcneill 6378:   * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1       dsieger  6379: 
                   6380:   * Changing build variables if the resulting binary package is the same.
                   6381: 
                   6382:   * Changing DESCR.
                   6383: 
                   6384:   * Adding PKG_OPTIONS if the default options don't change.
                   6385: 
                   6386: Examples of changes that do merit an increase to PKGREVISION include:
                   6387: 
                   6388:   * Security fixes
                   6389: 
                   6390:   * Changes or additions to a patch file
                   6391: 
                   6392:   * Changes to the PLIST
                   6393: 
1.12      weinem   6394:   * A dependency is changed or renamed.
                   6395: 
1.1       dsieger  6396: PKGREVISION must also be incremented when dependencies have ABI changes.
                   6397: 
1.154     rillig   6398: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1       dsieger  6399: 
1.180     rillig   6400: When you want to replace the same text in multiple files, or multiple times in
                   6401: the same file, it is cumbersome to maintain a patch file for this. This is
                   6402: where the SUBST framework steps in. It provides an easy-to-use interface for
                   6403: replacing text in files. It just needs the following information:
1.172     rillig   6404: 
1.180     rillig   6405:   * In which phase of the package build cycle should the replacement happen?
1.172     rillig   6406: 
1.180     rillig   6407:   * In which files should the replacement happen?
1.172     rillig   6408: 
                   6409:   * Which text should be replaced with what?
                   6410: 
1.180     rillig   6411: This information is encoded in a block of SUBST variables. A minimal example
                   6412: is:
                   6413: 
                   6414: SUBST_CLASSES+=         paths
                   6415: SUBST_STAGE.paths=      pre-configure
                   6416: SUBST_FILES.paths=      src/*.c
                   6417: SUBST_SED.paths=        -e 's,/usr/local,${PREFIX},g'
                   6418: 
                   6419: Translated into English, it means: In the pre-configure stage (that is, after
                   6420: applying the patches from the patches/ directory and before running the
                   6421: configure script and the portability check), replace the text /usr/local with
                   6422: the content of the variable PREFIX.
                   6423: 
                   6424: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
                   6425: =). This identifier can be chosen freely by the package. If there should ever
                   6426: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
                   6427: early, so don't worry about name collisions.
                   6428: 
                   6429: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
                   6430: using this identifier. In the remainder of this section, these parameterized
                   6431: variables are written as SUBST_STAGE.*.
                   6432: 
                   6433: SUBST_CLASSES+=         paths
                   6434: SUBST_STAGE.paths=      pre-configure
                   6435: SUBST_MESSAGE.paths=    Fixing absolute paths.
                   6436: SUBST_FILES.paths=      src/*.c
                   6437: SUBST_FILES.paths+=     scripts/*.sh
                   6438: SUBST_SED.paths=        -e 's,"/usr/local,"${PREFIX},g'
                   6439: SUBST_SED.paths+=       -e 's,"/var/log,"${VARBASE}/log,g'
                   6440: SUBST_VARS.paths=       LOCALBASE PREFIX PKGVERSION
                   6441: 
                   6442: To get a complete picture about the SUBST substitutions, run bmake
                   6443: show-all-subst. If something doesn't work as expected, run pkglint on the
                   6444: package, which detects several typical mistakes surrounding the SUBST blocks.
                   6445: For any questions that might remain after this, have a look at mk/subst.mk.
                   6446: 
                   6447: 21.1.11.1. Choosing the time where the substitutions happen
                   6448: 
                   6449: The SUBST_STAGE.* is one of {pre,do,post}-
                   6450: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
                   6451: most often, by far. The most popular stages are, in chronological order:
                   6452: 
                   6453: post-extract
                   6454: 
                   6455:     The substitutions are applied immediately after the distfiles are
                   6456:     extracted. Running bmake extract on the package will leave no traces of the
                   6457:     original files.
                   6458: 
                   6459:     When the substitution applies to files for which there is also a patch in
                   6460:     the patches/ directory, this means that the patches will be computed based
                   6461:     on the result of the substitution. When these patches are sent to the
                   6462:     upstream maintainer later, to be fixed in the upstream package, these
                   6463:     patches may no longer match what the upstream author is used to. Because of
                   6464:     this, pre-configure is often a better choice.
                   6465: 
                   6466: pre-configure
                   6467: 
                   6468:     The substitutions are applied after the patches from the patches/
                   6469:     directory. This makes it possible to run bmake patch on the package, after
                   6470:     which the patches can be edited using the tools pkgvi and mkpatches from
                   6471:     the pkgtools/pkgdiff package.
                   6472: 
                   6473:     When updating the patches, it is helpful to explicitly separate the bmake
                   6474:     patch from the bmake configure, and to only edit the patches between these
                   6475:     commands. Otherwise the substitutions from the SUBST block will end up in
                   6476:     the patch file. When this happens in really obvious ways, pkglint will
                   6477:     complain about patches that contain a hard-coded /usr/pkg instead of the
                   6478:     correct and intended @PREFIX@, but it can only detect these really obvious
                   6479:     cases.
                   6480: 
                   6481: do-configure
                   6482: 
                   6483:     This stage should only be used if the package defines a pre-configure
                   6484:     action itself, and the substitution must happen after that. Typical
                   6485:     examples are packages that use the pre-configure stage to regenerate the
                   6486:     GNU configure script from configure.ac.
                   6487: 
                   6488: post-configure
                   6489: 
                   6490:     This stage is used to fix up any mistakes by the configure stage.
                   6491: 
                   6492: pre-build
                   6493: 
                   6494:     This stage should only be used for substitutions that are clearly related
                   6495:     to building the package, not for fixing the configuration. Substitutions
                   6496:     for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
                   6497:     (such as replacing @MY_USER@ with the actual username) belong in
                   6498:     pre-configure or post-configure instead.
                   6499: 
                   6500: post-build
                   6501: 
                   6502:     Just as with pre-build, this stage should only be used for substitutions
                   6503:     that are clearly related to building the package, not for fixing the
                   6504:     configuration. Substitutions for pathnames (such as replacing /usr/local
                   6505:     with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
                   6506:     username) belong in pre-configure or post-configure instead.
                   6507: 
                   6508:     A typical use is to update pkg-config files to include the rpath compiler
                   6509:     options.
                   6510: 
                   6511: pre-install
                   6512: 
                   6513:     In general, the install phase should be as simple as possible. As with the
                   6514:     pre-build and post-build stages, it should not be used to fix pathnames or
                   6515:     user names, these belong in pre-configure instead. There are only few
                   6516:     legitimate use cases for applying substitutions in this stage.
                   6517: 
1.181     rillig   6518: 21.1.11.2. Choosing the files where the substitutions happen
1.180     rillig   6519: 
                   6520: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
                   6521: are relative to WRKSRC since that is where most substitutions happen. A typical
                   6522: example is:
                   6523: 
                   6524: SUBST_FILES.path=       Makefile */Makefile */*/Makefile *.[ch]
                   6525: 
                   6526: The above patterns, especially the last, are quite broad. The SUBST
                   6527: implementation checks that each filename pattern that is mentioned here has an
                   6528: effect. For example, if none of the */*/Makefile files contains the patterns to
                   6529: be found and substituted, that filename pattern is redundant and should be left
1.181     rillig   6530: out. By default, the SUBST framework will complain with an error message. If
                   6531: the text to be substituted occurs in some of the files from a single pattern,
                   6532: but not in all of them, that is totally ok, and the SUBST framework will only
                   6533: print an INFO message for those files.
1.180     rillig   6534: 
                   6535: If there is a good reason for having redundant filename patterns, set
1.181     rillig   6536: SUBST_NOOP_OK.* to yes.
1.180     rillig   6537: 
                   6538: Another popular way of choosing the files for the substitutions is via a shell
                   6539: command, like this:
                   6540: 
1.181     rillig   6541: C_FILES_CMD=            cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180     rillig   6542: SUBST_FILES.path=       ${C_FILES_CMD:sh}
                   6543: 
                   6544: The variable name C_FILES_CMD in this example is freely chosen and independent
                   6545: of the SUBST framework.
                   6546: 
                   6547: In this variant, the SUBST_FILES.* variable lists each file individually.
                   6548: Thereby chances are higher that there are filename patterns in which no
                   6549: substitution happens. Since the SUBST framework cannot know whether the
                   6550: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
                   6551: (where any redundant filename pattern would be suspicious) or been generated by
                   6552: a shell command (in which redundant filename patterns are more likely and to be
                   6553: expected), it will complain about these redundant filename patterns. Therefore,
                   6554: SUBST blocks that use a shell command to generate the list of filename patterns
                   6555: often need to set SUBST_NOOP_OK.* to yes.
                   6556: 
                   6557: 21.1.11.3. Choosing what to substitute
                   6558: 
                   6559: In most cases, the substitutions are given using one or more sed(1) commands,
                   6560: like this:
                   6561: 
                   6562: SUBST_SED.path=         -e 's|/usr/local|${PREFIX}|g'
                   6563: 
                   6564: Each of the sed commands needs to be preceded by the -e option and should be
                   6565: specified on a line of its own, to avoid hiding short sed commands at the end
                   6566: of a line.
                   6567: 
                   6568: Since the sed commands often contain shell metacharacters as the separator (the
                   6569: | in the above example), it is common to enclose them in single quotes.
                   6570: 
                   6571: A common substitution is to replace placeholders of the form @VARNAME@ with
                   6572: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
                   6573: 
                   6574: SUBST_VARS.path=        PREFIX
                   6575: 
1.181     rillig   6576: This type of substitutions is typically done by the GNU configure scripts
                   6577: during the do-configure stage, but in some cases these need to be overridden.
                   6578: The same pattern is also used when a package defines patches that replace
                   6579: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
                   6580: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
                   6581: In many of these cases, it works equally well to just use the SUBST framework
                   6582: to directly replace /usr/local with ${PREFIX}, thereby omitting the
                   6583: intermediate patch file.
1.180     rillig   6584: 
                   6585: If the above is not flexible enough, it is possible to not use sed at all for
                   6586: the substitution but to specify an entirely different command, like this:
                   6587: 
                   6588: SUBST_FILTER_CMD.path=  LC_ALL=C ${TR} -d '\r'
1.1       dsieger  6589: 
1.180     rillig   6590: This is used for the few remaining packages in which the distributed files use
                   6591: Windows-style line endings that need to be converted to UNIX-style line
                   6592: endings.
1.1       dsieger  6593: 
1.180     rillig   6594: 21.1.11.4. Other SUBST variables
1.172     rillig   6595: 
1.180     rillig   6596: When a SUBST block is applied during a package build, a message is logged. The
                   6597: default message is fine for most purposes but can be overridden by setting
                   6598: SUBST_MESSAGE.* to an individual message.
1.1       dsieger  6599: 
1.154     rillig   6600: 21.2. The fetch phase
1.1       dsieger  6601: 
1.154     rillig   6602: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1       dsieger  6603: 
                   6604: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
                   6605: a make fetch will call files/getsite.sh with the name of each file to download
                   6606: as an argument, expecting it to output the URL of the directory from which to
                   6607: download it. graphics/ns-cult3d is an example of this usage.
                   6608: 
                   6609: If the download can't be automated, because the user must submit personal
                   6610: information to apply for a password, or must pay for the source, or whatever,
                   6611: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
                   6612: before aborting the build. Example:
                   6613: 
                   6614: FETCH_MESSAGE=  "Please download the files"
                   6615: FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   6616: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   6617: 
1.154     rillig   6618: 21.2.2. How to handle modified distfiles with the 'old' name
1.1       dsieger  6619: 
                   6620: Sometimes authors of a software package make some modifications after the
                   6621: software was released, and they put up a new distfile without changing the
                   6622: package's version number. If a package is already in pkgsrc at that time, the
                   6623: checksum will no longer match. The contents of the new distfile should be
                   6624: compared against the old one before changing anything, to make sure the
                   6625: distfile was really updated on purpose, and that no trojan horse or so crept
                   6626: in. Please mention that the distfiles were compared and what was found in your
1.54      rodent   6627: commit message.
                   6628: 
                   6629: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109     wiz      6630: directory name, usually based on PKGNAME_NOREV (but take care with python or
                   6631: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
                   6632: PATCHFILES for this package will be put in that subdirectory of the local
1.154     rillig   6633: distfiles directory. (See Section 21.1.10, "How to handle incrementing versions
1.109     wiz      6634: when fixing an existing package" for more details.) In case this happens more
                   6635: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
                   6636: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54      rodent   6637: 
                   6638: DIST_SUBDIR is also used when a distfile's name does not contain a version and
                   6639: the distfile is apt to change. In cases where the likelihood of this is very
                   6640: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
                   6641: removed unless the distfile name changes, even if a package is being moved or
                   6642: renamed.
                   6643: 
                   6644: Do not forget regenerating the distinfo file after that, since it contains the
                   6645: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
                   6646: installed package is different. Furthermore, a mail to the package's authors
                   6647: seems appropriate telling them that changing distfiles after releases without
                   6648: changing the file names is not good practice.
1.1       dsieger  6649: 
1.154     rillig   6650: 21.2.3. Packages hosted on github.com
1.88      tnn      6651: 
1.90      tnn      6652: Helper methods exist for packages hosted on github.com which will often have
                   6653: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
                   6654: of the three recipes from below:
1.88      tnn      6655: 
1.154     rillig   6656: 21.2.3.1. Fetch based on a tagged release
1.88      tnn      6657: 
1.189     bacon    6658: If your distfile URL looks similar to https://github.com/username/example/
                   6659: archive/v1.0.zip, then you are packaging a tagged release.
1.88      tnn      6660: 
1.189     bacon    6661: DISTNAME=       example-1.0
1.90      tnn      6662: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
1.189     bacon    6663: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
1.90      tnn      6664: GITHUB_TAG=     v${PKGVERSION_NOREV}
1.88      tnn      6665: EXTRACT_SUFX=   .zip
                   6666: 
1.230     gutterid 6667: Here, DISTNAME combined with use of GITHUB_TAG leads the file fetching
                   6668: infrastructure to save the resulting file locally as example-1.0.zip.
                   6669: 
1.189     bacon    6670: 21.2.3.2. Fetch based on a specific commit before the first release
                   6671: 
                   6672: If your distfile looks similar to https://github.com/username/example/archive/
                   6673: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit before the first
                   6674: release, then set the package version to 0.0.0.N, where N is the number of
                   6675: commits to the repository, and set GITHUB_TAG to the commit hash. This will
                   6676: (almost) ensure that the first tagged release will have a version greater than
                   6677: this one so that package upgrades will function properly.
                   6678: 
                   6679: DISTNAME=       example-0.0.0.347
                   6680: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6681: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
                   6682: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
                   6683: 
                   6684: 21.2.3.3. Fetch based on a specific commit after a release
1.88      tnn      6685: 
1.189     bacon    6686: If your distfile looks similar to https://github.com/username/example/archive/
                   6687: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit after a release,
                   6688: then include the last release version and the commit count since that release
                   6689: in the package version and set GITHUB_TAG to the commit hash. The latest
                   6690: release and commit count are shown in the output of "git describe --tags":
                   6691: 
                   6692: # git clone https://github.com/username/example
                   6693: # cd example
                   6694: # git describe --tags
                   6695: 1.2.3-5-g988881a
1.88      tnn      6696: 
1.189     bacon    6697: DISTNAME=       example-1.2.3.5
                   6698: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6699: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
1.90      tnn      6700: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88      tnn      6701: 
1.189     bacon    6702: 21.2.3.4. Fetch based on release
1.88      tnn      6703: 
1.189     bacon    6704: If your distfile URL looks similar to https://github.com/username/example/
                   6705: releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
1.88      tnn      6706: 
1.90      tnn      6707: DISTNAME=       offensive-1.6
1.88      tnn      6708: PKGNAME=        ${DISTNAME:S/offensive/proper/}
1.90      tnn      6709: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
1.189     bacon    6710: GITHUB_PROJECT= example
1.90      tnn      6711: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
                   6712: EXTRACT_SUFX=   .zip
1.88      tnn      6713: 
1.154     rillig   6714: 21.3. The configure phase
1.1       dsieger  6715: 
1.154     rillig   6716: 21.3.1. Shared libraries - libtool
1.1       dsieger  6717: 
                   6718: pkgsrc supports many different machines, with different object formats like
                   6719: a.out and ELF, and varying abilities to do shared library and dynamic loading
                   6720: at all. To accompany this, varying commands and options have to be passed to
                   6721: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
                   6722: especially if you don't have all the machines at your hand to test things. The
                   6723: devel/libtool pkg can help here, as it just "knows" how to build both static
                   6724: and dynamic libraries from a set of source files, thus being
                   6725: platform-independent.
                   6726: 
                   6727: Here's how to use libtool in a package in seven simple steps:
                   6728: 
                   6729:  1. Add USE_LIBTOOL=yes to the package Makefile.
                   6730: 
                   6731:  2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
                   6732:     {CC}". You could even add it to the definition of CC, if only libraries are
                   6733:     being built in a given Makefile. This one command will build both PIC and
                   6734:     non-PIC library objects, so you need not have separate shared and
                   6735:     non-shared library rules.
                   6736: 
                   6737:  3. For the linking of the library, remove any "ar", "ranlib", and "ld
                   6738:     -Bshareable" commands, and instead use:
                   6739: 
                   6740:     ${LIBTOOL} --mode=link \
                   6741:         ${CC} -o ${.TARGET:.a=.la} \
                   6742:             ${OBJS:.o=.lo} \
                   6743:             -rpath ${PREFIX}/lib \
                   6744:             -version-info major:minor
                   6745: 
                   6746:     Note that the library is changed to have a .la extension, and the objects
                   6747:     are changed to have a .lo extension. Change OBJS as necessary. This
                   6748:     automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
                   6749:     necessary) in the build directory. Be sure to include "-version-info",
                   6750:     especially when major and minor are zero, as libtool will otherwise strip
                   6751:     off the shared library version.
                   6752: 
                   6753:     From the libtool manual:
                   6754: 
                   6755:     So, libtool library versions are described by three integers:
                   6756: 
                   6757:     CURRENT
                   6758:     The most recent interface number that this library implements.
                   6759: 
                   6760:     REVISION
                   6761:     The implementation number of the CURRENT interface.
                   6762: 
                   6763:     AGE
                   6764:     The difference between the newest and oldest interfaces that
                   6765:     this library implements.  In other words, the library implements
                   6766:     all the interface numbers in the range from number `CURRENT -
                   6767:     AGE' to `CURRENT'.
                   6768: 
                   6769:     If two libraries have identical CURRENT and AGE numbers, then the
                   6770:     dynamic linker chooses the library with the greater REVISION number.
                   6771: 
                   6772:     The "-release" option will produce different results for a.out and ELF
1.25      wiz      6773:     (excluding symlinks) in only one case. An ELF library of the form "
                   6774:     libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1       dsieger  6775:     platform. This is handled automatically.
                   6776: 
                   6777:     The "-rpath argument" is the install directory of the library being built.
                   6778: 
                   6779:     In the PLIST, include only the .la file, the other files will be added
                   6780:     automatically.
                   6781: 
                   6782:  4. When linking shared object (.so) files, i.e. files that are loaded via
                   6783:     dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
                   6784:     them getting version tacked on.
                   6785: 
                   6786:     The PLIST file gets the foo.so entry.
                   6787: 
                   6788:  5. When linking programs that depend on these libraries before they are
                   6789:     installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
                   6790:     and it will find the correct libraries (static or shared), but please be
                   6791:     aware that libtool will not allow you to specify a relative path in -L
                   6792:     (such as "-L../somelib"), because it expects you to change that argument to
                   6793:     be the .la file. e.g.
                   6794: 
                   6795:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   6796: 
                   6797:     should be changed to:
                   6798: 
                   6799:     ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
                   6800: 
                   6801:     and it will do the right thing with the libraries.
                   6802: 
                   6803:  6. When installing libraries, preface the install(1) or cp(1) command with "$
                   6804:     {LIBTOOL} --mode=install", and change the library name to .la. e.g.
                   6805: 
1.23      jakllsch 6806:     ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1       dsieger  6807: 
                   6808:     This will install the static .a, shared library, any needed symlinks, and
                   6809:     run ldconfig(8).
                   6810: 
                   6811:  7. In your PLIST, include only the .la file (this is a change from previous
                   6812:     behaviour).
                   6813: 
1.154     rillig   6814: 21.3.2. Using libtool on GNU packages that already support libtool
1.1       dsieger  6815: 
                   6816: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
                   6817: own libtool in most cases. For older libtool using packages, libtool is made by
                   6818: ltconfig script during the do-configure step; you can check the libtool script
                   6819: location by doing make configure; find work*/ -name libtool.
                   6820: 
                   6821: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
                   6822: override. By default, it is set to "libtool */libtool */*/libtool". If this
                   6823: does not match the location of the package's libtool script(s), set it as
                   6824: appropriate.
                   6825: 
                   6826: If you do not need *.a static libraries built and installed, then use
                   6827: SHLIBTOOL_OVERRIDE instead.
                   6828: 
                   6829: If your package makes use of the platform-independent library for loading
                   6830: dynamic shared objects, that comes with libtool (libltdl), you should include
                   6831: devel/libltdl/buildlink3.mk.
                   6832: 
                   6833: Some packages use libtool incorrectly so that the package may not work or build
                   6834: in some circumstances. Some of the more common errors are:
                   6835: 
                   6836:   * The inclusion of a shared object (-module) as a dependent library in an
                   6837:     executable or library. This in itself isn't a problem if one of two things
                   6838:     has been done:
                   6839: 
                   6840:      1. The shared object is named correctly, i.e. libfoo.la, not foo.la
                   6841: 
                   6842:      2. The -dlopen option is used when linking an executable.
                   6843: 
                   6844:   * The use of libltdl without the correct calls to initialisation routines.
                   6845:     The function lt_dlinit() should be called and the macro
                   6846:     LTDL_SET_PRELOADED_SYMBOLS included in executables.
                   6847: 
1.154     rillig   6848: 21.3.3. GNU Autoconf/Automake
1.1       dsieger  6849: 
                   6850: If a package needs GNU autoconf or automake to be executed to regenerate the
1.223     nia      6851: configure script and Makefile.in makefile templates from configure.ac and
                   6852: Makefile.am, then they should be executed in a pre-configure target:
1.1       dsieger  6853: 
1.223     nia      6854: USE_TOOLS+=     autoconf automake autoreconf
                   6855: GNU_CONFIGURE=  yes
1.1       dsieger  6856: ...
                   6857: 
                   6858: pre-configure:
1.223     nia      6859:         set -e; cd ${WRKSRC} && autoreconf -fi
1.1       dsieger  6860: ...
                   6861: 
1.223     nia      6862: Packages which use GNU Automake will sometimes require GNU Make (gmake in
                   6863: USE_TOOLS), but not always. Note that autoreconf only needs to be executed if
                   6864: configure.ac or Makefiles are modified, or configure is not present.
1.1       dsieger  6865: 
                   6866: There are times when the configure process makes additional changes to the
                   6867: generated files, which then causes the build process to try to re-execute the
                   6868: automake sequence. This is prevented by touching various files in the configure
                   6869: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
                   6870: NO in the package Makefile.
                   6871: 
1.223     nia      6872: 21.3.4. Meson / ninja
                   6873: 
                   6874: Packages using Meson to configure need to include:
                   6875: 
                   6876: .include "../../devel/meson/build.mk"
                   6877: 
                   6878: In nearly all cases (any program with dependencies), pkg-config needs to be
                   6879: added to USE_TOOLS. If the package installs translation files for non-English
                   6880: languages, also add msgfmt and xgettext:
                   6881: 
                   6882: USE_TOOLS+=     pkg-config msgfmt xgettext
                   6883: 
                   6884: If any options need to be passed to Meson, use MESON_ARGS instead of
                   6885: CONFIGURE_ARGS:
                   6886: 
                   6887: MESON_ARGS+=    -Dx11=false
                   6888: 
1.154     rillig   6889: 21.4. Programming languages
1.1       dsieger  6890: 
1.154     rillig   6891: 21.4.1. C, C++, and Fortran
1.1       dsieger  6892: 
1.244     gutterid 6893: Compilers for the C and C++ languages come with the NetBSD base system. By
1.223     nia      6894: default, pkgsrc assumes that a package is written in C and will hide all other
                   6895: compilers (via the wrapper framework, see Chapter 18, Buildlink methodology).
1.1       dsieger  6896: 
1.243     gutterid 6897: To declare which languages should be made available through pkgsrc's compiler
                   6898: wrappers, use the USE_LANGUAGES variable. Allowed values currently are:
1.212     wiz      6899: 
1.244     gutterid 6900: c, c++, fortran, fortran77, java, objc, obj-c++, and ada.
1.212     wiz      6901: 
                   6902: (and any combination). The default is "c". Packages using GNU configure
                   6903: scripts, even if written in C++, usually need a C compiler for the configure
1.244     gutterid 6904: phase.
1.243     gutterid 6905: 
1.250     jnemeth  6906: To declare which features a package requires from the compiler, set either
1.243     gutterid 6907: USE_CC_FEATURES or USE_CXX_FEATURES. Allowed values for USE_CC_FEATURES are
                   6908: currently:
                   6909: 
                   6910: c11, c99, has_include
                   6911: 
                   6912: Allowed values for USE_CXX_FEATURES are currently:
                   6913: 
                   6914: c++11, c++14, c++17, c++20, has_include, regex, filesystem,
                   6915: charconv, parallelism_ts, unique_ptr, put_time,
                   6916: is_trivially_copy_constructible
1.1       dsieger  6917: 
1.251     gutterid 6918: Note at present these variables only affect use of GCC, not other compilers.
                   6919: 
1.244     gutterid 6920: Language variants like gnu99 and c++11 can be specified in FORCE_C_STD and
                   6921: FORCE_CXX_STD if the package does not explicitly set -std=... when compiling
                   6922: (i.e. the package assumes the compiler defaults to C++11 or some other
                   6923: standard). This is a common bug in upstream build systems.
                   6924: 
                   6925: Allowed values for FORCE_C_STD are currently:
                   6926: 
                   6927: c90, c99, c11, gnu90, gnu99, gnu11
                   6928: 
                   6929: Allowed values for FORCE_CXX_STD are currently:
                   6930: 
                   6931: c++03, c++11, c++14, c++17, c++20,
                   6932: gnu++03, gnu++11, gnu++14, gnu++17, gnu++20
                   6933: 
1.251     gutterid 6934: Note at present these variables only affect use of GCC and Clang.
                   6935: 
1.154     rillig   6936: 21.4.2. Java
1.1       dsieger  6937: 
                   6938: If a program is written in Java, use the Java framework in pkgsrc. The package
                   6939: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
                   6940: variables:
                   6941: 
                   6942:   * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
                   6943:     set to "run", then there is only a runtime dependency on the JDK. The
                   6944:     default is "yes", which also adds a build dependency on the JDK.
                   6945: 
                   6946:   * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
                   6947:     supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
                   6948:     implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
                   6949:     accepts versions 1.5 or above. This variable is not set by default.
                   6950: 
1.25      wiz      6951:   * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
                   6952:     implementation dependency. It may be used to set JAVA_HOME to a good value
                   6953:     if the program needs this variable to be defined.
                   6954: 
1.205     wiz      6955: 21.4.3. Go
                   6956: 
                   6957: If a program is written in Go and has any dependencies on other Go modules,
                   6958: have the package include ../../lang/go/go-module.mk.
                   6959: 
                   6960:  1. Generate a list of those dependencies with make clean && make patch && make
                   6961:     show-go-modules > go-modules.mk.
                   6962: 
1.223     nia      6963:  2. Prepend .include "go-modules.mk" to any other .includes.
                   6964: 
                   6965:  3. Incorporate these modules in distinfo with make makesum.
1.205     wiz      6966: 
1.223     nia      6967: 21.4.4. Rust
1.205     wiz      6968: 
1.223     nia      6969: If a program is written in Rust and uses Cargo to build, have the package
                   6970: include ../../lang/rust/cargo.mk.
1.205     wiz      6971: 
1.223     nia      6972:  1. Generate a list of those dependencies with make CARGO_ARGS="build
                   6973:     --release" build && make print-cargo-depends > cargo-depends.mk.
1.205     wiz      6974: 
1.223     nia      6975:  2. Prepend .include "cargo-depends.mk" to any other .includes.
1.205     wiz      6976: 
                   6977:  3. Incorporate these modules in distinfo with make makesum.
                   6978: 
1.223     nia      6979: 21.4.5. Packages containing Perl scripts
1.1       dsieger  6980: 
1.203     nia      6981: If your package contains interpreted Perl scripts, add "perl" to the USE_TOOLS
1.1       dsieger  6982: variable and set REPLACE_PERL to ensure that the proper interpreter path is
                   6983: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74      wiz      6984: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
1.210     gutterid 6985: replaced with the full path to the Perl executable.
1.1       dsieger  6986: 
1.210     gutterid 6987: If a particular version of Perl is needed, set the PERL5_REQD variable to the
1.1       dsieger  6988: version number. The default is "5.0".
                   6989: 
1.203     nia      6990: See Section 21.6.6, "Packages installing Perl modules" for information about
1.210     gutterid 6991: handling Perl modules.
                   6992: 
                   6993: There is also the REPLACE_PERL6 variable for the language now known as Raku.
1.1       dsieger  6994: 
1.223     nia      6995: 21.4.6. Packages containing shell scripts
1.41      wiz      6996: 
                   6997: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
1.225     gutterid 6998: shell she-bangs in files. Please use the appropriate one, preferring REPLACE_SH
                   6999: when this shell is sufficient. Each should contain a list of scripts, relative
                   7000: to WRKSRC, that you want adjusted. Every occurrence of the matching shell in a
                   7001: she-bang line will be replaced with the full path to the shell executable. When
                   7002: using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41      wiz      7003: 
1.223     nia      7004: 21.4.7. Other programming languages
1.1       dsieger  7005: 
1.210     gutterid 7006: There are further similar REPLACE variables available, e.g., REPLACE_AWK for
                   7007: packages containing awk scripts, and REPLACE_R for R. These two, like the
1.211     gutterid 7008: others noted above, have their actions defined centrally in mk/configure/
                   7009: replace-interpreter.mk. Other languages define the actions of these variables
                   7010: within their own dedicated part of the tree, e.g., REPLACE_PHP is actioned in
1.245     gutterid 7011: lang/php/replace.mk, and REPLACE_PYTHON is actioned in lang/python/
1.211     gutterid 7012: application.mk. For other languages, consult the mk files found within their
1.216     gutterid 7013: specific directories (the naming convention varies), or check the list found in
                   7014: Appendix E, Help topics.
1.210     gutterid 7015: 
                   7016: Currently, special handling for other languages varies in pkgsrc. If a compiler
                   7017: package provides a buildlink3.mk file, include that, otherwise just add a
                   7018: (build) dependency on the appropriate compiler package.
1.1       dsieger  7019: 
1.154     rillig   7020: 21.5. The build phase
1.1       dsieger  7021: 
                   7022: The most common failures when building a package are that some platforms do not
                   7023: provide certain header files, functions or libraries, or they provide the
                   7024: functions in a library that the original package author didn't know. To work
                   7025: around this, you can rewrite the source code in most cases so that it does not
                   7026: use the missing functions or provides a replacement function.
                   7027: 
1.154     rillig   7028: 21.5.1. Compiling C and C++ code conditionally
1.1       dsieger  7029: 
                   7030: If a package already comes with a GNU configure script, the preferred way to
                   7031: fix the build failure is to change the configure script, not the code. In the
                   7032: other cases, you can utilize the C preprocessor, which defines certain macros
                   7033: depending on the operating system and hardware architecture it compiles for.
                   7034: These macros can be queried using for example #if defined(__i386). Almost every
                   7035: operating system, hardware architecture and compiler has its own macro. For
                   7036: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
                   7037: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
                   7038: GCC.
                   7039: 
                   7040: The list of the following macros for hardware and operating system depends on
                   7041: the compiler that is used. For example, if you want to conditionally compile
                   7042: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
                   7043: Use __sun instead.
                   7044: 
1.154     rillig   7045: 21.5.1.1. C preprocessor macros to identify the operating system
1.1       dsieger  7046: 
1.223     nia      7047: To distinguish between specific NetBSD versions, you should use the following
                   7048: code.
                   7049: 
                   7050: #ifdef __NetBSD__
                   7051: #include <sys/param.h>
                   7052: #if __NetBSD_Prereq__(9,99,17)
                   7053: /* use a newer feature */
                   7054: #else
                   7055: /* older code */
                   7056: #endif
                   7057: #endif
                   7058: 
                   7059: #ifndef _WIN32
                   7060: /* Unix-like specific code */
                   7061: #endif
                   7062: 
1.1       dsieger  7063: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
                   7064: should use the following code.
                   7065: 
                   7066: #include <sys/param.h>
                   7067: #if (defined(BSD) && BSD >= 199306)
                   7068: /* BSD-specific code goes here */
                   7069: #else
                   7070: /* non-BSD-specific code goes here */
                   7071: #endif
                   7072: 
1.223     nia      7073: You can also test for the following macros:
1.1       dsieger  7074: 
1.46      obache   7075: Cygwin      __CYGWIN__
                   7076: DragonFly   __DragonFly__
1.1       dsieger  7077: FreeBSD     __FreeBSD__
1.46      obache   7078: Haiku       __HAIKU__
1.1       dsieger  7079: Interix     __INTERIX
                   7080: IRIX        __sgi (TODO: get a definite source for this)
1.223     nia      7081: Linux       __linux
1.83      dholland 7082: Mac OS X    __APPLE__
1.46      obache   7083: MirBSD      __MirBSD__ (__OpenBSD__ is also defined)
                   7084: Minix3      __minix
1.1       dsieger  7085: NetBSD      __NetBSD__
                   7086: OpenBSD     __OpenBSD__
                   7087: Solaris     sun, __sun
                   7088: 
1.154     rillig   7089: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1       dsieger  7090: 
                   7091: i386        i386, __i386, __i386__
1.223     nia      7092: x86-64      __amd64__, __x86_64__
                   7093: ARM         __arm__
1.1       dsieger  7094: MIPS        __mips
                   7095: SPARC       sparc, __sparc
1.223     nia      7096: PowerPC     __powerpc
1.1       dsieger  7097: 
1.154     rillig   7098: 21.5.1.3. C preprocessor macros to identify the compiler
1.1       dsieger  7099: 
                   7100: GCC         __GNUC__ (major version), __GNUC_MINOR__
                   7101: MIPSpro     _COMPILER_VERSION (0x741 for MIPSpro 7.41)
                   7102: SunPro      __SUNPRO_C (0x570 for Sun C 5.7)
                   7103: SunPro C++  __SUNPRO_CC (0x580 for Sun C++ 5.8)
                   7104: 
1.154     rillig   7105: 21.5.2. How to handle compiler bugs
1.1       dsieger  7106: 
                   7107: Some source files trigger bugs in the compiler, based on combinations of
                   7108: compiler version and architecture and almost always relation to optimisation
                   7109: being enabled. Common symptoms are gcc internal errors or never finishing
                   7110: compiling a file.
                   7111: 
                   7112: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87      tnn      7113: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
                   7114: 
                   7115: This used to be a big problem in the past, but is rarely needed now as compiler
                   7116: technology has matured. If you still need to add a compiler specific
                   7117: workaround, please do so in the file hacks.mk and describe the symptom and
                   7118: compiler version as detailed as possible.
1.1       dsieger  7119: 
1.172     rillig   7120: 21.5.3. No such file or directory
                   7121: 
                   7122: Compilation sometimes fails with an error message like this:
                   7123: 
                   7124: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
                   7125:     fatal error: pango/pango.h: No such file or directory
                   7126: 
                   7127: The proper way to fix this problem depends on the type of the header, which is
                   7128: described in the following sections.
                   7129: 
                   7130: 21.5.3.1. Headers from other packages
                   7131: 
                   7132: If the header name looks like it comes from a different package, that other
                   7133: package should be included via the buildlink3 framework.
                   7134: 
                   7135: First, look whether the header is somewhere in the buildlink3 directory below
                   7136: WRKDIR. In the above case of the missing Pango header:
                   7137: 
                   7138: $ find work/.buildlink/ -print | grep -F pango/pango.h
                   7139: 
                   7140: In the case of Pango, the output is:
                   7141: 
                   7142: work/.buildlink/include/pango-1.0/pango/pango.h
                   7143: 
                   7144: If the pango/pango.h file were placed directly in the .buildlink directory, it
                   7145: would have been found automatically. There is an extra pango-1.0 path component
                   7146: though, which means that the compiler command line must contain an option of
                   7147: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
                   7148: option is generated by the configure script, which can be examined using:
                   7149: 
                   7150: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
                   7151: -I/usr/pkg/include/pango-1.0
                   7152: -I/usr/pkg/include/pango-1.0
                   7153: -I/usr/pkg/include/pango-1.0
                   7154: -I/usr/pkg/include/pango-1.0
                   7155: -I/usr/pkg/include/pango-1.0
                   7156: 
                   7157: This looks good. These options are transformed by the buildlink wrapper to
                   7158: refer to the correct path inside work/.buildlink.
                   7159: 
                   7160: Since the compilation fails though, examine the compiler command lines in work
                   7161: /.work.log to see whether the -I option is included in the particular command
                   7162: line.
                   7163: 
                   7164: To further analyze the situation, run bmake build-env, which sets up an
                   7165: interactive, realistic environment including all the pkgsrc wrapper commands
                   7166: and environment variables. From there, try to compile some simple example
                   7167: programs that use the header.
                   7168: 
                   7169: 21.5.3.2. Headers generated during the build
                   7170: 
                   7171: If the name of the header seems to come from the package itself, and if the
                   7172: build is run with parallel jobs, the package may have some undeclared
                   7173: dependencies between the .c and the .h files, and a C file is compiled before
                   7174: its required header is generated.
                   7175: 
                   7176: To see whether the build runs with parallel jobs, run bmake show-all-build |
                   7177: grep JOBS. Its output looks like this:
                   7178: 
                   7179:   usr   MAKE_JOBS=              7
                   7180:   pkg   MAKE_JOBS_SAFE          # undefined
                   7181:   def   _MAKE_JOBS_N=           7
                   7182: 
                   7183: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
                   7184: parallel (MAKE_JOBS). The package could have disabled parallel builds by
                   7185: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
                   7186: 
                   7187: To see whether the build failure is caused by parallel builds, first save the
                   7188: exact error message and a bit of context, maybe you need it later for reporting
                   7189: a bug. Next, run:
                   7190: 
                   7191: MAKE_JOBS_SAFE=no bmake clean build
                   7192: 
                   7193: If that succeeds, file a bug report against the pkgsrc package, including the
                   7194: exact error message and the contents of your mk.conf file.
                   7195: 
1.173     rillig   7196: 21.5.3.3. Symlinks
                   7197: 
                   7198: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
                   7199: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
                   7200: in symlink-based directories. Existing pkgsrc installations are not checked for
                   7201: symlinks though.
                   7202: 
                   7203: The "No such file or directory" error messages are a typical symptom of
                   7204: symlinks, and it's quite difficult to find out that this is the actual cause.
                   7205: 
                   7206: 21.5.3.4. Stale working directories
                   7207: 
                   7208: When building a hierarchy of packages, it may happen that one package is built
                   7209: and then pkgsrc is updated. This situation can provoke various hard to diagnose
                   7210: build errors. To clean up the situation:
                   7211: 
1.223     nia      7212: $ (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work)
1.173     rillig   7213: 
1.223     nia      7214: (The only purpose of the bsd.pkg.mk is to prevent running this command in the
                   7215: wrong directory.)
1.173     rillig   7216: 
                   7217: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
                   7218: 
                   7219: 21.5.3.5. Other possible reasons
                   7220: 
                   7221: On platforms other than BSD, third-party packages are installed in /usr/
                   7222: include, together with the base system. This means that pkgsrc cannot
                   7223: distinguish between headers provided by the base system (which it needs) and
                   7224: headers from third-party packages (which are often included in pkgsrc as well).
                   7225: This can lead to subtle version mismatches.
                   7226: 
                   7227: In pkgsrc installations that have been active for several years, it may happen
                   7228: that some files are manually deleted. To exclude this unlikely reason, run 
                   7229: pkg_admin check.
                   7230: 
                   7231: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
                   7232: 
                   7233: If all of the above doesn't help, see Chapter 2, Getting help for contact
                   7234: information. Be prepared to describe what you have tried so far and what any
                   7235: error messages were.
                   7236: 
1.172     rillig   7237: 21.5.4. Undefined reference to "..."
1.1       dsieger  7238: 
                   7239: This error message often means that a package did not link to a shared library
                   7240: it needs. The following functions are known to cause this error message over
                   7241: and over.
                   7242: 
                   7243: +-----------------------------------------------------+
                   7244: |        Function         |Library |Affected platforms|
                   7245: |-------------------------+--------+------------------|
                   7246: |accept, bind, connect    |-lsocket|Solaris           |
                   7247: |-------------------------+--------+------------------|
                   7248: |crypt                    |-lcrypt |DragonFly, NetBSD |
                   7249: |-------------------------+--------+------------------|
                   7250: |dlopen, dlsym            |-ldl    |Linux             |
                   7251: |-------------------------+--------+------------------|
                   7252: |gethost*                 |-lnsl   |Solaris           |
                   7253: |-------------------------+--------+------------------|
                   7254: |inet_aton                |-lresolv|Solaris           |
                   7255: |-------------------------+--------+------------------|
                   7256: |nanosleep, sem_*, timer_*|-lrt    |Solaris           |
                   7257: |-------------------------+--------+------------------|
                   7258: |openpty                  |-lutil  |Linux             |
                   7259: +-----------------------------------------------------+
                   7260: 
1.223     nia      7261: To fix these linker errors, it is often sufficient to add LIBS.OperatingSystem+
                   7262: = -lfoo to the package Makefile and then run bmake clean; bmake.
1.1       dsieger  7263: 
1.223     nia      7264: 21.5.4.1. The SunPro compiler and inline functions
1.1       dsieger  7265: 
                   7266: When you are using the SunPro compiler, there is another possibility. That
                   7267: compiler cannot handle the following code:
                   7268: 
                   7269: extern int extern_func(int);
                   7270: 
                   7271: static inline int
                   7272: inline_func(int x)
                   7273: {
                   7274:         return extern_func(x);
                   7275: }
                   7276: 
                   7277: int main(void)
                   7278: {
                   7279:         return 0;
                   7280: }
                   7281: 
                   7282: It generates the code for inline_func even if that function is never used. This
                   7283: code then refers to extern_func, which can usually not be resolved. To solve
                   7284: this problem you can try to tell the package to disable inlining of functions.
                   7285: 
1.228     gutterid 7286: 21.5.4.2. Missing atomic functions
                   7287: 
                   7288: When building for older machine architectures (e.g., i386, PowerPC), builds may
                   7289: fail because the package expects modern 64-bit atomic functions which the
                   7290: underlying hardware either doesn't support, or will only support with specific
                   7291: compiler flags. This is generally handled via inclusion of mk/atomic64.mk.
                   7292: 
1.172     rillig   7293: 21.5.5. Running out of memory
1.1       dsieger  7294: 
                   7295: Sometimes packages fail to build because the compiler runs into an operating
                   7296: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.223     nia      7297: told to unlimit the resources. The allowed values are any combination of "
                   7298: cputime", "datasize", "memorysize", "stacksize" and "virtualsize". Setting this
                   7299: variable is similar to running the shell builtin ulimit command to raise the
                   7300: maximum data segment size or maximum stack size of a process, respectively, to
                   7301: their hard limits.
1.1       dsieger  7302: 
1.154     rillig   7303: 21.6. The install phase
1.1       dsieger  7304: 
1.154     rillig   7305: 21.6.1. Creating needed directories
1.1       dsieger  7306: 
                   7307: The BSD-compatible install supplied with some operating systems cannot create
                   7308: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
                   7309: like this:
                   7310: 
                   7311: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   7312: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
                   7313: 
1.223     nia      7314: Instead of running the install commands directly, you can also append "dir1
                   7315: dir2" to the INSTALLATION_DIRS variable, which will automatically do the right
                   7316: thing.
1.1       dsieger  7317: 
1.154     rillig   7318: 21.6.2. Where to install documentation
1.1       dsieger  7319: 
                   7320: In general, documentation should be installed into ${PREFIX}/share/doc/$
1.223     nia      7321: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME_NOREV} (the latter includes the
                   7322: version number of the package).
1.1       dsieger  7323: 
                   7324: Many modern packages using GNU autoconf allow to set the directory where HTML
                   7325: documentation is installed with the "--with-html-dir" option. Sometimes using
                   7326: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
1.223     nia      7327: share/doc/html or other places. In pkgsrc, the HTML documentation should go
                   7328: into the package-specific directory, just like any other documentation.
1.1       dsieger  7329: 
                   7330: An exception to the above is that library API documentation generated with the
                   7331: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
                   7332: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
                   7333: can be recognized from files ending in .devhelp or .devhelp2. (It is also
                   7334: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
                   7335: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
                   7336: then, no additional subdirectory level is allowed in this case. This is usually
                   7337: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
                   7338: gtk-doc is preferred though.)
                   7339: 
1.154     rillig   7340: 21.6.3. Installing highscore files
1.1       dsieger  7341: 
                   7342: Certain packages, most of them in the games category, install a score file that
                   7343: allows all users on the system to record their highscores. In order for this to
                   7344: work, the binaries need to be installed setgid and the score files owned by the
1.36      wiz      7345: appropriate group and/or owner (traditionally the "games" user/group). Set
                   7346: USE_GAMESGROUP to yes to support this. The following variables, documented in
                   7347: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100     leot     7348: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
                   7349: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
                   7350: 
                   7351: An example that illustrates some of the variables described above is games/
                   7352: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
                   7353: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
                   7354: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
                   7355: to install setgid the game binary:
                   7356: 
                   7357: USE_GAMESGROUP=         yes
                   7358: 
                   7359: BUILD_DEFS+=            VARBASE
                   7360: 
                   7361: OWN_DIRS_PERMS+=        ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
                   7362: REQD_FILES_PERMS+=      /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
                   7363: SPECIAL_PERMS+=         ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
                   7364: 
                   7365: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
                   7366: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
                   7367: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1       dsieger  7368: 
1.14      jmcneill 7369: A package should therefore never hard code file ownership or access permissions
1.100     leot     7370: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
                   7371: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1       dsieger  7372: 
1.154     rillig   7373: 21.6.4. Adding DESTDIR support to packages
1.4       rillig   7374: 
1.14      jmcneill 7375: DESTDIR support means that a package installs into a staging directory, not the
                   7376: final location of the files. Then a binary package is created which can be used
                   7377: for installation as usual. There are two ways: Either the package must install
1.25      wiz      7378: as root ("destdir") or the package can install as non-root user ("user-destdir"
                   7379: ).
1.14      jmcneill 7380: 
1.113     leot     7381:   * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
                   7382:     default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
                   7383:     potential packaging problems. If bsd.prefs.mk is included in the Makefile,
                   7384:     PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14      jmcneill 7385: 
1.4       rillig   7386:   * All installation operations have to be prefixed with ${DESTDIR}.
                   7387: 
                   7388:   * automake gets this DESTDIR mostly right automatically. Many manual rules
                   7389:     and pre/post-install often are incorrect; fix them.
                   7390: 
1.17      imil     7391:   * If files are installed with special owner/group use SPECIAL_PERMS.
1.4       rillig   7392: 
                   7393:   * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
                   7394: 
1.154     rillig   7395: 21.6.5. Packages with hardcoded paths to other interpreters
1.1       dsieger  7396: 
                   7397: Your package may also contain scripts with hardcoded paths to other
1.203     nia      7398: interpreters besides (or as well as) Perl. To correct the full pathname to the
1.1       dsieger  7399: script interpreter, you need to set the following definitions in your Makefile
                   7400: (we shall use tclsh in this example):
                   7401: 
                   7402: REPLACE_INTERPRETER+=   tcl
                   7403: REPLACE.tcl.old=        .*/bin/tclsh
                   7404: REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   7405: REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   7406: # relative to ${WRKSRC}, just as in REPLACE_PERL
                   7407: 
1.203     nia      7408: 21.6.6. Packages installing Perl modules
1.1       dsieger  7409: 
                   7410: Makefiles of packages providing perl5 modules should include the Makefile
                   7411: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
                   7412: standard perl configuration for such modules as well as various hooks to tune
                   7413: this configuration. See comments in this file for details.
                   7414: 
                   7415: Perl5 modules will install into different places depending on the version of
                   7416: perl used during the build process. To address this, pkgsrc will append lines
                   7417: to the PLIST corresponding to the files listed in the installed .packlist file
                   7418: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48      wiz      7419: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
                   7420: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1       dsieger  7421: 
1.48      wiz      7422: PERL5_PACKLIST= auto/Pg/.packlist
1.1       dsieger  7423: 
1.48      wiz      7424: The perl5 config variables installarchlib, installscript, installvendorbin,
                   7425: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
                   7426: and installvendorman3dir represent those locations in which components of perl5
                   7427: modules may be installed, provided as variable with uppercase and prefixed with
                   7428: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
                   7429: have a packlist. These variables are also substituted for in the PLIST as
                   7430: uppercase prefixed with PERL5_SUB_.
1.1       dsieger  7431: 
1.254     wiz      7432: 21.6.7. Packages installing pkg-config files
                   7433: 
                   7434: Some packages, usually those providing libraries, install pkg-config files so
                   7435: that their headers and libraries can easily be found. The file names end with
                   7436: .pc.
                   7437: 
                   7438: Most of the time, these files only provide the linker flags for the library,
                   7439: but do not include the flags for setting the rpath so the libraries can also be
                   7440: found at runtime. Since this is so common, pkgsrc provides PKGCONFIG_OVERRIDE
                   7441: for this. Many packages generate the .pc from .pc.in, in that case add those
                   7442: files to the PKGCONFIG_OVERRIDE variable:
                   7443: 
                   7444: PKGCONFIG_OVERRIDE+=   foo.pc.in
                   7445: 
                   7446: 
                   7447: For packages using meson, the files are generated during build and you also
                   7448: need to change the phase in which the replacement is done. For example:
                   7449: 
                   7450: PKGCONFIG_OVERRIDE+=            output/meson-private/foo.pc
                   7451: PKGCONFIG_OVERRIDE_STAGE=       post-build
                   7452: 
                   7453: 
                   7454: 21.6.8. Packages installing info files
1.1       dsieger  7455: 
                   7456: Some packages install info files or use the "makeinfo" or "install-info"
                   7457: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
                   7458: and DEINSTALL scripts will be generated to handle registration of the info
                   7459: files in the Info directory file. The "install-info" command used for the info
                   7460: files registration is either provided by the system, or by a special purpose
                   7461: package automatically added as dependency if needed.
                   7462: 
                   7463: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
                   7464: located. PKGINFODIR defaults to "info" and can be overridden by the user.
                   7465: 
                   7466: The info files for the package should be listed in the package PLIST; however
                   7467: any split info files need not be listed.
                   7468: 
                   7469: A package which needs the "makeinfo" command at build time must add "makeinfo"
                   7470: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
                   7471: needed it should be noted with the TEXINFO_REQD variable in the package
                   7472: Makefile. By default, a minimum version of 3.12 is required. If the system does
                   7473: not provide a makeinfo command or if it does not match the required minimum, a
                   7474: build dependency on the devel/gtexinfo package will be added automatically.
                   7475: 
                   7476: The build and installation process of the software provided by the package
                   7477: should not use the install-info command as the registration of info files is
1.25      wiz      7478: the task of the package INSTALL script, and it must use the appropriate 
1.1       dsieger  7479: makeinfo command.
                   7480: 
                   7481: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
                   7482: the install-info and makeinfo commands in a directory listed early in PATH.
                   7483: 
                   7484: The script overriding install-info has no effect except the logging of a
                   7485: message. The script overriding makeinfo logs a message and according to the
                   7486: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
                   7487: error.
                   7488: 
1.254     wiz      7489: 21.6.9. Packages installing man pages
1.1       dsieger  7490: 
                   7491: All packages that install manual pages should install them into the same
                   7492: directory, so that there is one common place to look for them. In pkgsrc, this
                   7493: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25      wiz      7494: packages. The default for PKGMANDIR is "man". Another often-used value is "
                   7495: share/man".
1.1       dsieger  7496: 
                   7497: Note
                   7498: 
                   7499: The support for a custom PKGMANDIR is far from complete.
                   7500: 
                   7501: The PLIST files can just use man/ as the top level directory for the man page
                   7502: file entries, and the pkgsrc framework will convert as needed. In all other
                   7503: places, the correct PKGMANDIR must be used.
                   7504: 
                   7505: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
                   7506: use the ./configure --mandir switch to set where the man pages should be
                   7507: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
                   7508: {PKGMANDIR}.
                   7509: 
                   7510: Packages that use GNU_CONFIGURE but do not use --mandir, can set
                   7511: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
                   7512: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
                   7513: 
1.184     rillig   7514: See Section 19.5, "Man page compression" for information on installation of
1.1       dsieger  7515: compressed manual pages.
                   7516: 
1.254     wiz      7517: 21.6.10. Packages installing X11 fonts
1.1       dsieger  7518: 
                   7519: If a package installs font files, you will need to rebuild the fonts database
                   7520: in the directory where they get installed at installation and deinstallation
                   7521: time. This can be automatically done by using the pkginstall framework.
                   7522: 
                   7523: You can list the directories where fonts are installed in the FONTS_DIRS.type
                   7524: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
                   7525: that the database file fonts.dir is not listed in the PLIST.
                   7526: 
                   7527: Note that you should not create new directories for fonts; instead use the
                   7528: standard ones to avoid that the user needs to manually configure his X server
                   7529: to find them.
                   7530: 
1.254     wiz      7531: 21.6.11. Packages installing SGML or XML data
1.1       dsieger  7532: 
                   7533: If a package installs SGML or XML data files that need to be registered in
                   7534: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
                   7535: extra steps:
                   7536: 
                   7537:  1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
                   7538:     care of registering those files in system-wide catalogs at installation and
                   7539:     deinstallation time.
                   7540: 
                   7541:  2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
                   7542:     package.
                   7543: 
                   7544:  3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
                   7545:     package.
                   7546: 
                   7547:  4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
                   7548:     These come in groups of three strings; see xmlcatmgr(1) for more
                   7549:     information (specifically, arguments recognized by the 'add' action). Note
                   7550:     that you will normally not use this variable.
                   7551: 
                   7552:  5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
                   7553:     come in groups of three strings; see xmlcatmgr(1) for more information
                   7554:     (specifically, arguments recognized by the 'add' action). Note that you
                   7555:     will normally not use this variable.
                   7556: 
1.254     wiz      7557: 21.6.12. Packages installing extensions to the MIME database
1.1       dsieger  7558: 
                   7559: If a package provides extensions to the MIME database by installing .xml files
                   7560: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
                   7561: ensure that the database is kept consistent with respect to these new files:
                   7562: 
                   7563:  1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
                   7564:     buildlink3.mk file from this same directory, which is reserved for
                   7565:     inclusion from other buildlink3.mk files). It takes care of rebuilding the
                   7566:     MIME database at installation and deinstallation time, and disallows any
                   7567:     access to it directly from the package.
                   7568: 
1.25      wiz      7569:  2. Check the PLIST and remove any entries under the share/mime directory, 
1.1       dsieger  7570:     except for files saved under share/mime/packages. The former are handled
                   7571:     automatically by the update-mime-database program, but the latter are
                   7572:     package-dependent and must be removed by the package that installed them in
                   7573:     the first place.
                   7574: 
                   7575:  3. Remove any share/mime/* directories from the PLIST. They will be handled by
                   7576:     the shared-mime-info package.
                   7577: 
1.254     wiz      7578: 21.6.13. Packages using intltool
1.1       dsieger  7579: 
                   7580: If a package uses intltool during its build, add intltool to the USE_TOOLS,
                   7581: which forces it to use the intltool package provided by pkgsrc, instead of the
                   7582: one bundled with the distribution file.
                   7583: 
                   7584: This tracks intltool's build-time dependencies and uses the latest available
                   7585: version; this way, the package benefits of any bug fixes that may have appeared
                   7586: since it was released.
                   7587: 
1.254     wiz      7588: 21.6.14. Packages installing startup scripts
1.1       dsieger  7589: 
1.256     wiz      7590: If a package contains an rc.d script, it won't be copied into the startup
                   7591: directory (/etc/rc.d) by default, but you can enable copying by setting the
                   7592: option PKG_RCD_SCRIPTS=YES in mk.conf. With PKG_RCD_SCRIPTS=YES, rc.d scripts
                   7593: will be copied into /etc/rc.d when a package is installed, but only if the
                   7594: target does not already exist. Copies in /etc/rc.d will be automatically
                   7595: removed only if they have not been modified.
                   7596: 
                   7597: Note that this alone does not enable the service: It must still be added to /
                   7598: etc/rc.conf.
1.1       dsieger  7599: 
1.254     wiz      7600: 21.6.15. Packages installing TeX modules
1.1       dsieger  7601: 
                   7602: If a package installs TeX packages into the texmf tree, the ls-R database of
                   7603: the tree needs to be updated.
                   7604: 
                   7605: Note
                   7606: 
1.23      jakllsch 7607: Except the main TeX packages such as kpathsea, packages should install files
                   7608: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1       dsieger  7609: 
1.23      jakllsch 7610:  1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
                   7611:     ls-R database at installation and deinstallation time.
1.1       dsieger  7612: 
1.23      jakllsch 7613:  2. If your package installs files into a texmf tree other than the one at $
                   7614:     {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
                   7615:     trees that need database update.
1.1       dsieger  7616: 
                   7617:     If your package also installs font map files that need to be registered
1.30      dholland 7618:     using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
                   7619:     and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then 
                   7620:     updmap will be run automatically at installation/deinstallation to enable/
                   7621:     disable font map files for TeX output drivers.
1.1       dsieger  7622: 
                   7623:  3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30      dholland 7624:     be removed only by the kpathsea package.
1.1       dsieger  7625: 
1.254     wiz      7626: 21.6.16. Packages supporting running binaries in emulation
1.1       dsieger  7627: 
                   7628: There are some packages that provide libraries and executables for running
                   7629: binaries from a one operating system on a different one (if the latter supports
                   7630: it). One example is running Linux binaries on NetBSD.
                   7631: 
                   7632: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
                   7633: 
                   7634: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
                   7635: if all libraries for each installed executable can be found by the dynamic
                   7636: linker. Since the standard dynamic linker is run, this fails for emulation
                   7637: packages, because the libraries used by the emulation are not in the standard
                   7638: directories.
                   7639: 
1.254     wiz      7640: 21.6.17. Packages installing hicolor icons
1.1       dsieger  7641: 
                   7642: If a package installs images under the share/icons/hicolor and/or updates the
                   7643: share/icons/hicolor/icon-theme.cache database, you need to take some extra
                   7644: steps to make sure that the shared theme directory is handled appropriately and
                   7645: that the cache database is rebuilt:
                   7646: 
                   7647:  1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
                   7648: 
                   7649:  2. Check the PLIST and remove the entry that refers to the theme cache.
                   7650: 
                   7651:  3. Ensure that the PLIST does not remove the shared icon directories from the
                   7652:     share/icons/hicolor hierarchy because they will be handled automatically.
                   7653: 
                   7654: The best way to verify that the PLIST is correct with respect to the last two
                   7655: points is to regenerate it using make print-PLIST.
                   7656: 
1.254     wiz      7657: 21.6.18. Packages installing desktop files
1.1       dsieger  7658: 
                   7659: If a package installs .desktop files under share/applications and these include
1.54      rodent   7660: MIME information (MimeType key), you need to take extra steps to ensure that
                   7661: they are registered into the MIME database:
1.1       dsieger  7662: 
                   7663:  1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
                   7664: 
                   7665:  2. Check the PLIST and remove the entry that refers to the share/applications/
                   7666:     mimeinfo.cache file. It will be handled automatically.
                   7667: 
                   7668: The best way to verify that the PLIST is correct with respect to the last point
                   7669: is to regenerate it using make print-PLIST.
                   7670: 
1.154     rillig   7671: 21.7. Marking packages as having problems
1.1       dsieger  7672: 
1.23      jakllsch 7673: In some cases one does not have the time to solve a problem immediately. In
                   7674: this case, one can plainly mark a package as broken. For this, one just sets
                   7675: the variable BROKEN to the reason why the package is broken (similar to the
1.162     rillig   7676: PKG_FAIL_REASON variable). A user trying to build the package will immediately
                   7677: be shown this message, and the build will not be even tried.
1.1       dsieger  7678: 
1.23      jakllsch 7679: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1       dsieger  7680: 
1.184     rillig   7681: Chapter 22. GNOME packaging and porting
                   7682: 
                   7683: Table of Contents
                   7684: 
                   7685: 22.1. Meta packages
                   7686: 22.2. Packaging a GNOME application
                   7687: 22.3. Updating GNOME to a newer version
                   7688: 22.4. Patching guidelines
                   7689: 
                   7690: Quoting GNOME's web site:
                   7691: 
                   7692:     The GNOME project provides two things: The GNOME desktop environment, an
                   7693:     intuitive and attractive desktop for users, and the GNOME development
                   7694:     platform, an extensive framework for building applications that integrate
                   7695:     into the rest of the desktop.
                   7696: 
                   7697: pkgsrc provides a seamless way to automatically build and install a complete
                   7698: GNOME environment under many different platforms. We can say with confidence
                   7699: that pkgsrc is one of the most advanced build and packaging systems for GNOME
                   7700: due to its included technologies buildlink3, the wrappers and tools framework
                   7701: and automatic configuration file management. Lots of efforts are put into
                   7702: achieving a completely clean deinstallation of installed software components.
                   7703: 
                   7704: Given that pkgsrc is NetBSD's official packaging system, the above also means
                   7705: that great efforts are put into making GNOME work under this operating system.
                   7706: 
                   7707: This chapter is aimed at pkgsrc developers and other people interested in
                   7708: helping our GNOME porting and packaging efforts. It provides instructions on
                   7709: how to manage the existing packages and some important information regarding
                   7710: their internals.
                   7711: 
                   7712: 22.1. Meta packages
                   7713: 
                   7714: pkgsrc includes three GNOME-related meta packages:
                   7715: 
                   7716:   * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
                   7717:     includes the necessary bits to get it to boot correctly, although it may
                   7718:     lack important functionality for daily operation. The idea behind this
                   7719:     package is to let end users build their own configurations on top of this
                   7720:     one, first installing this meta package to achieve a functional setup and
                   7721:     then adding individual applications.
                   7722: 
                   7723:   * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
                   7724:     desktop as defined by the GNOME project; this is based on the components
                   7725:     distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
                   7726:     directories of the official FTP server. Developer-only tools found in those
                   7727:     directories are not installed unless required by some other component to
                   7728:     work properly. Similarly, packages from the bindings set (bindings/x.y/
                   7729:     x.y.z/sources) are not pulled in unless required as a dependency for an
                   7730:     end-user component. This package "extends" meta-pkgs/gnome-base.
                   7731: 
                   7732:   * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
                   7733:     component when fetched from the CVS repository. These are required to let
                   7734:     the autogen.sh scripts work appropriately.
                   7735: 
                   7736: In all these packages, the DEPENDS lines are sorted in a way that eases
                   7737: updates: a package may depend on other packages listed before it but not on any
                   7738: listed after it. It is very important to keep this order to ease updates so... 
                   7739: do not change it to alphabetical sorting!
                   7740: 
                   7741: 22.2. Packaging a GNOME application
                   7742: 
                   7743: Almost all GNOME applications are written in C and use a common set of tools as
                   7744: their build system. Things get different with the new bindings to other
                   7745: languages (such as Python), but the following will give you a general idea on
                   7746: the minimum required tools:
                   7747: 
                   7748:   * Almost all GNOME applications use the GNU Autotools as their build system.
                   7749:     As a general rule you will need to tell this to your package:
                   7750: 
1.223     nia      7751:     GNU_CONFIGURE=  yes
                   7752:     USE_LIBTOOL=    yes
                   7753:     USE_TOOLS+=     gmake
1.184     rillig   7754: 
                   7755:   * If the package uses pkg-config to detect dependencies, add this tool to the
                   7756:     list of required utilities:
                   7757: 
1.223     nia      7758:     USE_TOOLS+=     pkg-config
1.184     rillig   7759: 
                   7760:     Also use pkgtools/verifypc at the end of the build process to ensure that
                   7761:     you did not miss to specify any dependency in your package and that the
                   7762:     version requirements are all correct.
                   7763: 
                   7764:   * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
                   7765:     handle dependencies and to force the package to use the latest available
                   7766:     version.
                   7767: 
                   7768:   * If the package uses gtk-doc (a documentation generation utility), do not
                   7769:     add a dependency on it. The tool is rather big and the distfile should come
                   7770:     with pregenerated documentation anyway; if it does not, it is a bug that
                   7771:     you ought to report. For such packages you should disable gtk-doc (unless
                   7772:     it is the default):
                   7773: 
1.223     nia      7774:     CONFIGURE_ARGS+=        --disable-gtk-doc
1.184     rillig   7775: 
                   7776:     The default location of installed HTML files (share/gtk-doc/<package-name>)
                   7777:     is correct and should not be changed unless the package insists on
                   7778:     installing them somewhere else. Otherwise programs as devhelp will not be
                   7779:     able to open them. You can do that with an entry similar to:
1.1       dsieger  7780: 
1.223     nia      7781:     CONFIGURE_ARGS+=        --with-html-dir=${PREFIX}/share/gtk-doc/...
1.1       dsieger  7782: 
1.184     rillig   7783: GNOME uses multiple shared directories and files under the installation prefix
                   7784: to maintain databases. In this context, shared means that those exact same
                   7785: directories and files are used among several different packages, leading to
                   7786: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
                   7787: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
                   7788: your file lists and omitting shared files from them. If you find yourself doing
                   7789: those, your package is most likely incorrect.
1.1       dsieger  7790: 
1.184     rillig   7791: The following table lists the common situations that result in using shared
                   7792: directories or files. For each of them, the appropriate solution is given.
                   7793: After applying the solution be sure to regenerate the package's file list with 
                   7794: make print-PLIST and ensure it is correct.
1.1       dsieger  7795: 
1.184     rillig   7796: Table 22.1. PLIST handling for GNOME packages
1.1       dsieger  7797: 
1.184     rillig   7798: +-----------------------------------------------------------------------------+
                   7799: |             If the package...             |             Then...             |
                   7800: |-------------------------------------------+---------------------------------|
1.254     wiz      7801: |Installs icons under the share/icons/      |See Section 21.6.17, "Packages   |
1.203     nia      7802: |hicolor hierarchy or updates share/icons/  |installing hicolor icons".       |
1.184     rillig   7803: |hicolor/icon-theme.cache.                  |                                 |
                   7804: |-------------------------------------------+---------------------------------|
1.254     wiz      7805: |                                           |See Section 21.6.12, "Packages   |
1.184     rillig   7806: |Installs files under share/mime/packages.  |installing extensions to the MIME|
                   7807: |                                           |database".                       |
                   7808: |-------------------------------------------+---------------------------------|
1.254     wiz      7809: |Installs .desktop files under share/       |See Section 21.6.18, "Packages   |
1.184     rillig   7810: |applications and these include MIME        |installing desktop files".       |
                   7811: |information.                               |                                 |
                   7812: +-----------------------------------------------------------------------------+
1.1       dsieger  7813: 
                   7814: 
1.184     rillig   7815: 22.3. Updating GNOME to a newer version
1.1       dsieger  7816: 
1.184     rillig   7817: When seeing GNOME as a whole, there are two kinds of updates:
1.1       dsieger  7818: 
1.184     rillig   7819: Major update
1.1       dsieger  7820: 
1.184     rillig   7821:     Given that there is still a very long way for GNOME 3 (if it ever appears),
                   7822:     we consider a major update one that goes from a 2.X version to a 2.Y one,
                   7823:     where Y is even and greater than X. These are hard to achieve because they
                   7824:     introduce lots of changes in the components' code and almost all GNOME
                   7825:     distfiles are updated to newer versions. Some of them can even break API
                   7826:     and ABI compatibility with the previous major version series. As a result,
                   7827:     the update needs to be done all at once to minimize breakage.
1.1       dsieger  7828: 
1.184     rillig   7829:     A major update typically consists of around 80 package updates and the
                   7830:     addition of some new ones.
1.1       dsieger  7831: 
1.184     rillig   7832: Minor update
1.1       dsieger  7833: 
1.184     rillig   7834:     We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
                   7835:     one where Y is greater than X. These are easy to achieve because they do
                   7836:     not update all GNOME components, can be done in an incremental way and do
                   7837:     not break API nor ABI compatibility.
1.1       dsieger  7838: 
1.184     rillig   7839:     A minor update typically consists of around 50 package updates, although
                   7840:     the numbers here may vary a lot.
1.1       dsieger  7841: 
1.184     rillig   7842: In order to update the GNOME components in pkgsrc to a new stable release
                   7843: (either major or minor), the following steps should be followed:
1.1       dsieger  7844: 
1.184     rillig   7845:  1. Get a list of all the tarballs that form the new release by using the
                   7846:     following commands. These will leave the full list of the components'
                   7847:     distfiles into the list.txt file:
1.1       dsieger  7848: 
1.184     rillig   7849:     % echo ls "*.tar.bz2" | \
                   7850:         ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   7851:         awk '{ print $9 }' >list.txt
                   7852:     % echo ls "*.tar.bz2" | \
                   7853:         ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   7854:         awk '{ print $9 }' >>list.txt
1.1       dsieger  7855: 
1.184     rillig   7856:  2. Open each meta package's Makefile and bump their version to the release you
                   7857:     are updating them to. The three meta packages should be always consistent
                   7858:     with versioning. Obviously remove any PKGREVISIONs that might be in them.
1.1       dsieger  7859: 
1.184     rillig   7860:  3. For each meta package, update all its DEPENDS lines to match the latest
                   7861:     versions as shown by the above commands. Do not list any newer version
                   7862:     (even if found in the FTP) because the meta packages are supposed to list
                   7863:     the exact versions that form a specific GNOME release. Exceptions are
                   7864:     permitted here if a newer version solves a serious issue in the overall
                   7865:     desktop experience; these typically come in the form of a revision bump in
                   7866:     pkgsrc, not in newer versions from the developers.
1.1       dsieger  7867: 
1.184     rillig   7868:     Packages not listed in the list.txt file should be updated to the latest
                   7869:     version available (if found in pkgsrc). This is the case, for example, of
                   7870:     the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
                   7871:     package.
1.1       dsieger  7872: 
1.184     rillig   7873:  4. Generate a patch from the modified meta packages and extract the list of
                   7874:     "new" lines. This will provide you an outline on what packages need to be
                   7875:     updated in pkgsrc and in what order:
1.1       dsieger  7876: 
1.184     rillig   7877:     % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
1.1       dsieger  7878: 
1.184     rillig   7879:  5. For major desktop updates it is recommended to zap all your installed
                   7880:     packages and start over from scratch at this point.
1.1       dsieger  7881: 
1.184     rillig   7882:  6. Now comes the longest step by far: iterate over the contents of todo.txt
                   7883:     and update the packages listed in it in order. For major desktop updates
                   7884:     none of these should be committed until the entire set is completed because
                   7885:     there are chances of breaking not-yet-updated packages.
1.1       dsieger  7886: 
1.184     rillig   7887:  7. Once the packages are up to date and working, commit them to the tree one
                   7888:     by one with appropriate log messages. At the end, commit the three meta
                   7889:     package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
                   7890:     and pkgsrc/doc/TODO files.
1.1       dsieger  7891: 
1.184     rillig   7892: 22.4. Patching guidelines
1.1       dsieger  7893: 
1.184     rillig   7894: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
                   7895: it is very important that you always, always, always feed back any portability
                   7896: fixes you do to a GNOME package to the mainstream developers (see
                   7897: Section 12.3.5, "Feedback to the author"). This is the only way to get their
                   7898: attention on portability issues and to ensure that future versions can be built
                   7899: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
                   7900: updates are. Those developers in charge of issuing major GNOME updates will be
                   7901: grateful if you do that.
1.1       dsieger  7902: 
1.200     cirnatda 7903: The most common places to report bugs are the GNOME's GitLab and the
                   7904: freedesktop.org's GitLab. Not all components use these to track bugs, but most
                   7905: of them do. Do not be short on your reports: always provide detailed
1.184     rillig   7906: explanations of the current failure, how it can be improved to achieve maximum
1.200     cirnatda 7907: portability and, if at all possible, provide a patch against the main Git
                   7908: branch. The more verbose you are, the higher chances of your patch being
                   7909: accepted.
1.1       dsieger  7910: 
1.184     rillig   7911: Also, please avoid using preprocessor magic to fix portability issues. While
                   7912: the FreeBSD GNOME people are doing a great job in porting GNOME to their
                   7913: operating system, the official GNOME sources are now plagued by conditionals
                   7914: that check for __FreeBSD__ and similar macros. This hurts portability. Please
                   7915: see our patching guidelines (Section 12.3.4, "Patching guidelines") for more
                   7916: details.
1.1       dsieger  7917: 
1.154     rillig   7918: Chapter 23. Submitting and Committing
1.1       dsieger  7919: 
                   7920: Table of Contents
                   7921: 
1.154     rillig   7922: 23.1. Submitting binary packages
                   7923: 23.2. Submitting source packages (for non-NetBSD-developers)
                   7924: 23.3. General notes when adding, updating, or removing packages
                   7925: 23.4. Commit Messages
                   7926: 23.5. Committing: Adding a package to CVS
                   7927: 23.6. Updating a package to a newer version
                   7928: 23.7. Renaming a package in pkgsrc
                   7929: 23.8. Moving a package in pkgsrc
1.1       dsieger  7930: 
1.154     rillig   7931: 23.1. Submitting binary packages
1.1       dsieger  7932: 
                   7933: Our policy is that we accept binaries only from pkgsrc developers to guarantee
                   7934: that the packages don't contain any trojan horses etc. This is not to annoy
                   7935: anyone but rather to protect our users! You're still free to put up your
                   7936: home-made binary packages and tell the world where to get them. NetBSD
1.154     rillig   7937: developers doing bulk builds and wanting to upload them please see Chapter 8, 
1.66      asau     7938: Creating binary packages for everything in pkgsrc (bulk builds).
1.1       dsieger  7939: 
1.154     rillig   7940: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1       dsieger  7941: 
1.218     nia      7942: Firstly, you can import new packages into pkgsrc-wip ("pkgsrc work-in-progress"
                   7943: ); see the homepage at https://pkgsrc.org/wip/ for details.
                   7944: 
                   7945: Next, check that your package is complete, compiles and runs well; see
1.184     rillig   7946: Chapter 14, Creating a new pkgsrc package from scratch and the rest of this
1.218     nia      7947: document. Run the pkgtools/pkglint tool and fix any errors that appear.
                   7948: 
                   7949: Finally, send a report to the pkgsrc bug tracking system, either with the
                   7950: send-pr(1) command, or if you don't have that, go to the web page https://
                   7951: www.NetBSD.org/support/send-pr.html, which contains some instructions and a
                   7952: link to a form where you can submit packages. The sysutils/gtk-send-pr package
                   7953: is also available as a substitute for either of the above two tools.
1.1       dsieger  7954: 
                   7955: In the form of the problem report, the category should be "pkg", the synopsis
                   7956: should include the package name and version number, and the description field
                   7957: should contain a short description of your package (contents of the COMMENT
1.218     nia      7958: variable or DESCR file are OK).
1.1       dsieger  7959: 
1.154     rillig   7960: 23.3. General notes when adding, updating, or removing packages
1.1       dsieger  7961: 
                   7962: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
                   7963: CHANGES-YYYY. It's very important to keep this file up to date and conforming
                   7964: to the existing format, because it will be used by scripts to automatically
                   7965: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
                   7966: doc/TODO file and remove the entry for the package you updated or removed, in
                   7967: case it was mentioned there.
                   7968: 
                   7969: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
                   7970: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
                   7971: that result from a dependency being updated should not be mentioned. In all
                   7972: other cases it's the developer's decision.
                   7973: 
                   7974: There is a make target that helps in creating proper CHANGES-YYYY entries: make
                   7975: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
                   7976: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
                   7977: (to avoid having to resolve conflicts later-on) and then to cd to the package
                   7978: directory. For package updates, make changes-entry is enough. For new packages,
                   7979: or package moves or removals, set the CTYPE variable on the command line to
1.4       rillig   7980: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23      jakllsch 7981: your local login name is not the same as your NetBSD login name. The target
                   7982: also automatically removes possibly existing entries for the package in the
                   7983: TODO file. Don't forget to commit the changes, e.g. by using make
1.66      asau     7984: commit-changes-entry! If you are not using a checkout directly from
1.23      jakllsch 7985: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
                   7986: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1       dsieger  7987: 
1.154     rillig   7988: 23.4. Commit Messages
1.130     wiz      7989: 
                   7990: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
1.257     jkoshy   7991: Standard practice when using these tools is to make the first line of a commit
1.130     wiz      7992: message function as a summary that can be read without the rest, such as is
                   7993: commonly done with "git log --oneline". For this reason, we have the following
                   7994: guidelines for pkgsrc commit messages:
                   7995: 
1.131     wiz      7996:   * Start the commit message with a line that explains the big picture in 65
1.130     wiz      7997:     characters or less. When a commit is for one package, include the name of
                   7998:     the package. For updates, include the version to which it is updated.
                   7999: 
                   8000:   * Leave the next line empty.
                   8001: 
                   8002:   * Then come the details for the commit (changes in that package, reason for a
                   8003:     change) and any relevant PRs. Wrap this section.
                   8004: 
                   8005: Here is an example:
                   8006: 
1.238     wiz      8007: libxslt: update to 1.0.30
1.130     wiz      8008: 
1.238     wiz      8009: Changes since 1.0.29:
                   8010: ...
1.130     wiz      8011: 
                   8012: Here is another example:
                   8013: 
1.238     wiz      8014: mk/bsd.pkg.mk: enable SSP by default on NetBSD
1.130     wiz      8015: 
1.238     wiz      8016: (rationale)
1.130     wiz      8017: 
                   8018: Commit messages are final: no "cvs admin" is allowed on the pkgsrc repository
                   8019: to change commit messages.
                   8020: 
1.154     rillig   8021: 23.5. Committing: Adding a package to CVS
1.1       dsieger  8022: 
                   8023: This section is only of interest for pkgsrc developers with write access to the
1.34      wiz      8024: pkgsrc repository.
                   8025: 
                   8026: When the package is finished, "cvs add" the files. Start by adding the
                   8027: directory and then files in the directory. Don't forget to add the new package
                   8028: to the category's Makefile. Make sure you don't forget any files; you can check
                   8029: by running "cvs status". An example:
                   8030: 
                   8031: $ cd .../pkgsrc/category
                   8032: $ cvs add pkgname
                   8033: $ cd pkgname
                   8034: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
                   8035: $ cvs add patches/p*
                   8036: $ cvs status | less
1.35      wiz      8037: $ cvs commit
1.34      wiz      8038: $ cd ..
1.236     gutterid 8039: $ vi Makefile # add SUBDIR+=pkgname line
1.35      wiz      8040: $ cvs commit Makefile
1.66      asau     8041: $ cd pkgname
1.73      jnemeth  8042: $ make CTYPE=Added commit-changes-entry
1.1       dsieger  8043: 
                   8044: The commit message of the initial import should include part of the DESCR file,
                   8045: so people reading the mailing lists know what the package is/does.
                   8046: 
1.34      wiz      8047: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
                   8048: 
                   8049: Previously, "cvs import" was suggested, but it was much easier to get wrong
                   8050: than "cvs add".
1.1       dsieger  8051: 
1.154     rillig   8052: 23.6. Updating a package to a newer version
1.1       dsieger  8053: 
                   8054: Please always put a concise, appropriate and relevant summary of the changes
                   8055: between old and new versions into the commit log when updating a package. There
                   8056: are various reasons for this:
                   8057: 
                   8058:   * A URL is volatile, and can change over time. It may go away completely or
                   8059:     its information may be overwritten by newer information.
                   8060: 
                   8061:   * Having the change information between old and new versions in our CVS
                   8062:     repository is very useful for people who use either cvs or anoncvs.
                   8063: 
                   8064:   * Having the change information between old and new versions in our CVS
                   8065:     repository is very useful for people who read the pkgsrc-changes mailing
                   8066:     list, so that they can make tactical decisions about when to upgrade the
                   8067:     package.
                   8068: 
                   8069: Please also recognize that, just because a new version of a package has been
                   8070: released, it should not automatically be upgraded in the CVS repository. We
                   8071: prefer to be conservative in the packages that are included in pkgsrc -
                   8072: development or beta packages are not really the best thing for most places in
                   8073: which pkgsrc is used. Please use your judgement about what should go into
                   8074: pkgsrc, and bear in mind that stability is to be preferred above new and
                   8075: possibly untested features.
                   8076: 
1.154     rillig   8077: 23.7. Renaming a package in pkgsrc
1.21      snj      8078: 
                   8079: Renaming packages is not recommended.
                   8080: 
1.175     gutterid 8081: When renaming packages, be sure to fix any references to the old name in other
1.21      snj      8082: Makefiles, options, buildlink files, etc.
                   8083: 
1.175     gutterid 8084: Also, when renaming a package, please add the package name and version pattern
1.167     leot     8085: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
                   8086: renames. The new package would be an exact replacement. Example:
                   8087: 
                   8088: SUPERSEDES+=    p5-IO-Compress-Zlib<2.017
                   8089: SUPERSEDES+=    optcomp-[0-9]*
1.21      snj      8090: 
                   8091: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
                   8092: supersedes, as that successor may not be an exact replacement but is a
                   8093: suggestion for the replaced functionality.
                   8094: 
1.154     rillig   8095: 23.8. Moving a package in pkgsrc
1.21      snj      8096: 
                   8097: It is preferred that packages are not renamed or moved, but if needed please
                   8098: follow these steps.
1.1       dsieger  8099: 
                   8100:  1. Make a copy of the directory somewhere else.
                   8101: 
                   8102:  2. Remove all CVS dirs.
                   8103: 
                   8104:     Alternatively to the first two steps you can also do:
                   8105: 
                   8106:     % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
                   8107: 
                   8108:     and use that for further work.
                   8109: 
1.25      wiz      8110:  3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of 
1.1       dsieger  8111:     "../../category/package".
                   8112: 
1.21      snj      8113:  4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
                   8114:     previous category/package pathname. The PREV_PKGPATH can be used by tools
                   8115:     for doing an update using pkgsrc building; for example, it can search the
                   8116:     pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
                   8117:     the corresponding new PKGPATH for that moved package. Note that it may have
                   8118:     multiple matches, so the tool should also check on the PKGBASE too. The
                   8119:     PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
                   8120:     PKGBASE stays the same.
                   8121: 
1.237     gutterid 8122:  5. cvs add the modified package in the new place.
1.1       dsieger  8123: 
1.21      snj      8124:  6. Check if any package depends on it:
1.1       dsieger  8125: 
                   8126:     % cd /usr/pkgsrc
                   8127:     % grep /package */*/Makefile* */*/buildlink*
                   8128: 
1.21      snj      8129:  7. Fix paths in packages from step 5 to point to new location.
1.1       dsieger  8130: 
1.21      snj      8131:  8. cvs rm (-f) the package at the old location.
1.1       dsieger  8132: 
1.21      snj      8133:  9. Remove from oldcategory/Makefile.
1.1       dsieger  8134: 
1.21      snj      8135: 10. Add to newcategory/Makefile.
1.1       dsieger  8136: 
1.21      snj      8137: 11. Commit the changed and removed files:
1.1       dsieger  8138: 
                   8139:     % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
                   8140: 
                   8141:     (and any packages from step 5, of course).
                   8142: 
1.154     rillig   8143: Chapter 24. Frequently Asked Questions
1.1       dsieger  8144: 
                   8145: This section contains the answers to questions that may arise when you are
                   8146: writing a package. If you don't find your question answered here, first have a
                   8147: look in the other chapters, and if you still don't have the answer, ask on the
                   8148: pkgsrc-users mailing list.
                   8149: 
1.154     rillig   8150: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
                   8151: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
                   8152: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.223     nia      8153: 24.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
                   8154: 24.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.232     gutterid 8155: the := inside it.
1.223     nia      8156: 24.6. Which mailing lists are there for package developers?
                   8157: 24.7. Where is the pkgsrc documentation?
                   8158: 24.8. I have a little time to kill. What shall I do?
1.1       dsieger  8159: 
1.154     rillig   8160: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1       dsieger  8161: 
                   8162:       MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
1.223     nia      8163:       (1).
                   8164: 
                   8165:       MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM when
                   8166:       building the package.
                   8167: 
                   8168:       .MAKEFLAGS is an internal variable of bmake and should not be used by
                   8169:       packages.
1.1       dsieger  8170: 
1.154     rillig   8171: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1       dsieger  8172: 
                   8173:       MAKE is the path to the make(1) program that is used in the pkgsrc
1.223     nia      8174:       infrastructure.
                   8175: 
                   8176:       GMAKE is the path to GNU Make, but you need to say USE_TOOLS+=gmake to
                   8177:       use that.
                   8178: 
                   8179:       MAKE_PROGRAM is the path to the Make program that is used for building
                   8180:       the package.
1.1       dsieger  8181: 
1.154     rillig   8182: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1       dsieger  8183: 
                   8184:       CC is the path to the real C compiler, which can be configured by the
1.223     nia      8185:       pkgsrc user.
1.1       dsieger  8186: 
1.223     nia      8187:       PKG_CC is the path to the compiler wrapper.
1.1       dsieger  8188: 
1.223     nia      8189:       PKGSRC_COMPILER is not a path to a compiler, but the type of compiler
                   8190:       that should be used. See mk/compiler.mk for more information about the
                   8191:       latter variable.
1.1       dsieger  8192: 
1.223     nia      8193: 24.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1       dsieger  8194: 
1.25      wiz      8195:       For optimization reasons, some variables are only available in the "
                   8196:       wrapper" phase and later. To "simulate" the wrapper phase, append 
1.1       dsieger  8197:       PKG_PHASE=wrapper to the above command.
                   8198: 
1.223     nia      8199: 24.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  8200:       the := inside it.
                   8201: 
1.223     nia      8202:       The := is not an assignment operator, even though it may look like one.
1.108     rillig   8203:       Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
                   8204:       is documented in the make(1) man page and which is commonly used in the
                   8205:       form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
                   8206:       string and new_string is package/. That's where the : and the = fall
                   8207:       together.
1.1       dsieger  8208: 
1.223     nia      8209: 24.6. Which mailing lists are there for package developers?
1.1       dsieger  8210: 
                   8211:       tech-pkg
                   8212: 
                   8213:           This is a list for technical discussions related to pkgsrc
                   8214:           development, e.g. soliciting feedback for changes to pkgsrc
                   8215:           infrastructure, proposed new features, questions related to porting
                   8216:           pkgsrc to a new platform, advice for maintaining a package, patches
                   8217:           that affect many packages, help requests moved from pkgsrc-users when
                   8218:           an infrastructure bug is found, etc.
                   8219: 
                   8220:       pkgsrc-bugs
                   8221: 
                   8222:           All bug reports in category "pkg" sent with send-pr(1) appear here.
                   8223:           Please do not report your bugs here directly; use one of the other
                   8224:           mailing lists.
                   8225: 
1.223     nia      8226: 24.7. Where is the pkgsrc documentation?
1.1       dsieger  8227: 
                   8228:       There are many places where you can find documentation about pkgsrc:
                   8229: 
                   8230:         * The pkgsrc guide (this document) is a collection of chapters that
                   8231:           explain large parts of pkgsrc, but some chapters tend to be outdated.
                   8232:           Which ones they are is hard to say.
                   8233: 
1.174     leot     8234:         * On the mailing list archives (see https://mail-index.NetBSD.org/),
                   8235:           you can find discussions about certain features, announcements of new
1.1       dsieger  8236:           parts of the pkgsrc infrastructure and sometimes even announcements
                   8237:           that a certain feature has been marked as obsolete. The benefit here
                   8238:           is that each message has a date appended to it.
                   8239: 
                   8240:         * Many of the files in the mk/ directory start with a comment that
                   8241:           describes the purpose of the file and how it can be used by the
                   8242:           pkgsrc user and package authors. An easy way to find this
                   8243:           documentation is to run bmake help.
                   8244: 
                   8245:         * The CVS log messages are a rich source of information, but they tend
                   8246:           to be highly abbreviated, especially for actions that occur often.
                   8247:           Some contain a detailed description of what has changed, but they are
                   8248:           geared towards the other pkgsrc developers, not towards an average
                   8249:           pkgsrc user. They also only document changes, so if you don't know
                   8250:           what has been before, these messages may not be worth too much to
                   8251:           you.
                   8252: 
                   8253:         * Some parts of pkgsrc are only "implicitly documented", that is the
                   8254:           documentation exists only in the mind of the developer who wrote the
                   8255:           code. To get this information, use the cvs annotate command to see
                   8256:           who has written it and ask on the tech-pkg mailing list, so that
                   8257:           others can find your questions later (see above). To be sure that the
                   8258:           developer in charge reads the mail, you may CC him or her.
                   8259: 
1.223     nia      8260: 24.8. I have a little time to kill. What shall I do?
1.1       dsieger  8261: 
                   8262:       This is not really an FAQ yet, but here's the answer anyway.
                   8263: 
                   8264:         * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
                   8265:           about newer versions of installed packages that are available, but
                   8266:           not yet updated in pkgsrc.
                   8267: 
1.198     leot     8268:         * Browse pkgsrc/doc/TODO -- it contains a list of suggested new
                   8269:           packages and a list of cleanups and enhancements for pkgsrc that
                   8270:           would be nice to have.
1.1       dsieger  8271: 
1.71      wiz      8272:         * Review packages for which review was requested on the tech-pkg
                   8273:           mailing list.
1.1       dsieger  8274: 
                   8275: Part III. The pkgsrc infrastructure internals
                   8276: 
                   8277: This part of the guide deals with everything from the infrastructure that is
                   8278: behind the interfaces described in the developer's guide. A casual package
                   8279: maintainer should not need anything from this part.
                   8280: 
                   8281: Table of Contents
                   8282: 
1.184     rillig   8283: 25. Design of the pkgsrc infrastructure
                   8284:     25.1. The meaning of variable definitions
                   8285:     25.2. Avoiding problems before they arise
                   8286:     25.3. Variable evaluation
                   8287:         25.3.1. At load time
                   8288:         25.3.2. At runtime
                   8289:     25.4. How can variables be specified?
                   8290:     25.5. Designing interfaces for Makefile fragments
                   8291:         25.5.1. Procedures with parameters
                   8292:         25.5.2. Actions taken on behalf of parameters
                   8293:     25.6. The order in which files are loaded
                   8294:         25.6.1. The order in bsd.prefs.mk
                   8295:         25.6.2. The order in bsd.pkg.mk
                   8296: 26. Regression tests
                   8297:     26.1. Running the regression tests
                   8298:     26.2. Adding a new regression test
                   8299:         26.2.1. Overridable functions
                   8300:         26.2.2. Helper functions
                   8301: 27. Porting pkgsrc
                   8302:     27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8303: 
1.184     rillig   8304: Chapter 25. Design of the pkgsrc infrastructure
1.1       dsieger  8305: 
                   8306: Table of Contents
                   8307: 
1.184     rillig   8308: 25.1. The meaning of variable definitions
                   8309: 25.2. Avoiding problems before they arise
                   8310: 25.3. Variable evaluation
                   8311:     25.3.1. At load time
                   8312:     25.3.2. At runtime
                   8313: 25.4. How can variables be specified?
                   8314: 25.5. Designing interfaces for Makefile fragments
                   8315:     25.5.1. Procedures with parameters
                   8316:     25.5.2. Actions taken on behalf of parameters
                   8317: 25.6. The order in which files are loaded
                   8318:     25.6.1. The order in bsd.prefs.mk
                   8319:     25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8320: 
                   8321: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
                   8322: fragment needs a properly specified interface. This chapter explains how such
                   8323: an interface looks like.
                   8324: 
1.184     rillig   8325: 25.1. The meaning of variable definitions
1.1       dsieger  8326: 
                   8327: Whenever a variable is defined in the pkgsrc infrastructure, the location and
                   8328: the way of definition provide much information about the intended use of that
                   8329: variable. Additionally, more documentation may be found in a header comment or
                   8330: in this pkgsrc guide.
                   8331: 
                   8332: A special file is mk/defaults/mk.conf, which lists all variables that are
                   8333: intended to be user-defined. They are either defined using the ?= operator or
                   8334: they are left undefined because defining them to anything would effectively
                   8335: mean "yes". All these variables may be overridden by the pkgsrc user in the
                   8336: MAKECONF file.
                   8337: 
                   8338: Outside this file, the following conventions apply: Variables that are defined
                   8339: using the ?= operator may be overridden by a package.
                   8340: 
                   8341: Variables that are defined using the = operator may be used read-only at
                   8342: run-time.
                   8343: 
                   8344: Variables whose name starts with an underscore must not be accessed outside the
                   8345: pkgsrc infrastructure at all. They may change without further notice.
                   8346: 
                   8347: Note
                   8348: 
                   8349: These conventions are currently not applied consistently to the complete pkgsrc
                   8350: infrastructure.
                   8351: 
1.184     rillig   8352: 25.2. Avoiding problems before they arise
1.1       dsieger  8353: 
                   8354: All variables that contain lists of things should default to being empty. Two
                   8355: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
                   8356: variables cannot simply be modified using the += operator in package Makefiles
                   8357: (or other files included by them), since there is no guarantee whether the
                   8358: variable is already set or not, and what its value is. In the case of
                   8359: DISTFILES, the packages "know" the default value and just define it as in the
                   8360: following example.
                   8361: 
                   8362: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   8363: 
                   8364: Because of the selection of this default value, the same value appears in many
                   8365: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
                   8366: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
                   8367: in many files.
                   8368: 
1.184     rillig   8369: 25.3. Variable evaluation
1.1       dsieger  8370: 
1.184     rillig   8371: 25.3.1. At load time
1.1       dsieger  8372: 
                   8373: Variable evaluation takes place either at load time or at runtime, depending on
                   8374: the context in which they occur. The contexts where variables are evaluated at
                   8375: load time are:
                   8376: 
                   8377:   * The right hand side of the := and != operators,
                   8378: 
                   8379:   * Make directives like .if or .for,
                   8380: 
                   8381:   * Dependency lines.
                   8382: 
                   8383: A special exception are references to the iteration variables of .for loops,
                   8384: which are expanded inline, no matter in which context they appear.
                   8385: 
                   8386: As the values of variables may change during load time, care must be taken not
                   8387: to evaluate them by accident. Typical examples for variables that should not be
                   8388: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
                   8389: clear, here is an example:
                   8390: 
                   8391: CONFIGURE_ARGS=         # none
                   8392: CFLAGS=                 -O
                   8393: CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
                   8394: 
                   8395: CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
                   8396: 
                   8397: CFLAGS+=                -Wall
                   8398: 
                   8399: This code shows how the use of the := operator can quickly lead to unexpected
                   8400: results. The first paragraph is fairly common code. The second paragraph
                   8401: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
                   8402: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
                   8403: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
                   8404: typically occur in completely unrelated files.
                   8405: 
1.184     rillig   8406: 25.3.2. At runtime
1.1       dsieger  8407: 
                   8408: After all the files have been loaded, the values of the variables cannot be
                   8409: changed anymore. Variables that are used in the shell commands are expanded at
                   8410: this point.
                   8411: 
1.184     rillig   8412: 25.4. How can variables be specified?
1.1       dsieger  8413: 
                   8414: There are many ways in which the definition and use of a variable can be
                   8415: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108     rillig   8416: policies. A package can be checked with pkglint -Wall to see whether it meets
                   8417: these rules.
1.1       dsieger  8418: 
1.184     rillig   8419: 25.5. Designing interfaces for Makefile fragments
1.1       dsieger  8420: 
                   8421: Most of the .mk files fall into one of the following classes. Cases where a
                   8422: file falls into more than one class should be avoided as it often leads to
                   8423: subtle bugs.
                   8424: 
1.184     rillig   8425: 25.5.1. Procedures with parameters
1.1       dsieger  8426: 
                   8427: In a traditional imperative programming language some of the .mk files could be
1.198     leot     8428: described as procedures. They take some input parameters and--after
                   8429: inclusion--provide a result in output parameters. Since all variables in
1.23      jakllsch 8430: Makefiles have global scope care must be taken not to use parameter names that
                   8431: have already another meaning. For example, PKGNAME is a bad choice for a
                   8432: parameter name.
1.1       dsieger  8433: 
                   8434: Procedures are completely evaluated at preprocessing time. That is, when
                   8435: calling a procedure all input parameters must be completely resolvable. For
                   8436: example, CONFIGURE_ARGS should never be an input parameter since it is very
                   8437: likely that further text will be added after calling the procedure, which would
                   8438: effectively apply the procedure to only a part of the variable. Also,
1.108     rillig   8439: references to other variables will be modified after calling the procedure.
1.1       dsieger  8440: 
                   8441: A procedure can declare its output parameters either as suitable for use in
                   8442: preprocessing directives or as only available at runtime. The latter
                   8443: alternative is for variables that contain references to other runtime
                   8444: variables.
                   8445: 
                   8446: Procedures shall be written such that it is possible to call the procedure more
                   8447: than once. That is, the file must not contain multiple-inclusion guards.
                   8448: 
                   8449: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
                   8450: To express that the parameters are evaluated at load time, they should be
                   8451: assigned using the := operator, which should be used only for this purpose.
                   8452: 
1.184     rillig   8453: 25.5.2. Actions taken on behalf of parameters
1.1       dsieger  8454: 
                   8455: Action files take some input parameters and may define runtime variables. They
                   8456: shall not define loadtime variables. There are action files that are included
                   8457: implicitly by the pkgsrc infrastructure, while other must be included
                   8458: explicitly.
                   8459: 
                   8460: An example for action files is mk/subst.mk.
                   8461: 
1.184     rillig   8462: 25.6. The order in which files are loaded
1.1       dsieger  8463: 
                   8464: Package Makefiles usually consist of a set of variable definitions, and include
                   8465: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
                   8466: include various other *.mk files if they need to query the availability of
                   8467: certain features like the type of compiler or the X11 implementation. Due to
                   8468: the heavy use of preprocessor directives like .if and .for, the order in which
                   8469: the files are loaded matters.
                   8470: 
                   8471: This section describes at which point the various files are loaded and gives
                   8472: reasons for that order.
                   8473: 
1.184     rillig   8474: 25.6.1. The order in bsd.prefs.mk
1.1       dsieger  8475: 
                   8476: The very first action in bsd.prefs.mk is to define some essential variables
                   8477: like OPSYS, OS_VERSION and MACHINE_ARCH.
                   8478: 
1.4       rillig   8479: Then, the user settings are loaded from the file specified in MAKECONF, which
                   8480: is usually mk.conf. After that, those variables that have not been overridden
                   8481: by the user are loaded from mk/defaults/mk.conf.
1.1       dsieger  8482: 
                   8483: After the user settings, the system settings and platform settings are loaded,
                   8484: which may override the user settings.
                   8485: 
                   8486: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
                   8487: This only happens when building a package, so the proper variables must be used
                   8488: instead of the direct tool names.
                   8489: 
                   8490: As the last steps, some essential variables from the wrapper and the package
                   8491: system flavor are loaded, as well as the variables that have been cached in
                   8492: earlier phases of a package build.
                   8493: 
1.184     rillig   8494: 25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8495: 
                   8496: First, bsd.prefs.mk is loaded.
                   8497: 
                   8498: Then, the various *-vars.mk files are loaded, which fill default values for
                   8499: those variables that have not been defined by the package. These variables may
                   8500: later be used even in unrelated files.
                   8501: 
                   8502: Then, the file bsd.pkg.error.mk provides the target error-check that is added
                   8503: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
                   8504: DELAYED_WARNING_MSG.
                   8505: 
                   8506: Then, the package-specific hacks from hacks.mk are included.
                   8507: 
                   8508: Then, various other files follow. Most of them don't have any dependencies on
                   8509: what they need to have included before or after them, though some do.
                   8510: 
                   8511: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
                   8512: restricts the use of these variables to all the files that have been included
                   8513: before. Appearances in later files will be silently ignored.
                   8514: 
                   8515: Then, the files for the main targets are included, in the order of later
                   8516: execution, though the actual order should not matter.
                   8517: 
                   8518: At last, some more files are included that don't set any interesting variables
                   8519: but rather just define make targets to be executed.
                   8520: 
1.184     rillig   8521: Chapter 26. Regression tests
1.1       dsieger  8522: 
                   8523: Table of Contents
                   8524: 
1.184     rillig   8525: 26.1. Running the regression tests
                   8526: 26.2. Adding a new regression test
                   8527:     26.2.1. Overridable functions
                   8528:     26.2.2. Helper functions
1.1       dsieger  8529: 
                   8530: The pkgsrc infrastructure consists of a large codebase, and there are many
                   8531: corners where every little bit of a file is well thought out, making pkgsrc
                   8532: likely to fail as soon as anything is changed near those parts. To prevent most
                   8533: changes from breaking anything, a suite of regression tests should go along
                   8534: with every important part of the pkgsrc infrastructure. This chapter describes
                   8535: how regression tests work in pkgsrc and how you can add new tests.
                   8536: 
1.184     rillig   8537: 26.1. Running the regression tests
1.1       dsieger  8538: 
1.25      wiz      8539: You first need to install the pkgtools/pkg_regress package, which provides the 
1.1       dsieger  8540: pkg_regress command. Then you can simply run that command, which will run all
1.168     rillig   8541: tests in the regress/ directory.
1.1       dsieger  8542: 
1.184     rillig   8543: 26.2. Adding a new regression test
1.1       dsieger  8544: 
1.168     rillig   8545: Every directory in the regress/ directory that contains a file called spec is
1.1       dsieger  8546: considered a regression test. This file is a shell program that is included by
                   8547: the pkg_regress command. The following functions can be overridden to suit your
                   8548: needs.
                   8549: 
1.184     rillig   8550: 26.2.1. Overridable functions
1.1       dsieger  8551: 
1.108     rillig   8552: These functions do not take any parameters. Although they are called in "set -e
1.168     rillig   8553: " mode, they don't stop at the first failing command. See this Stack Overflow
1.108     rillig   8554: question for details.
1.1       dsieger  8555: 
1.108     rillig   8556: do_setup
1.1       dsieger  8557: 
                   8558:     This function prepares the environment for the test. By default it does
                   8559:     nothing.
                   8560: 
1.108     rillig   8561: do_test
1.1       dsieger  8562: 
                   8563:     This function runs the actual test. By default, it calls TEST_MAKE with the
                   8564:     arguments MAKEARGS_TEST and writes its output including error messages into
                   8565:     the file TEST_OUTFILE.
                   8566: 
1.108     rillig   8567:     When defining this function, make sure that all output that needs to be
                   8568:     checked is written to the correct output file. Example:
                   8569: 
                   8570:     do_test() {
                   8571:             echo "Example output"
                   8572:     } 1>$TEST_OUTFILE 2>&1
                   8573: 
                   8574: check_result
1.1       dsieger  8575: 
                   8576:     This function is run after the test and is typically used to compare the
                   8577:     actual output from the one that is expected. It can make use of the various
1.108     rillig   8578:     helper functions from the next section. Example:
                   8579: 
                   8580:     check_result() {
                   8581:             exit_status 0
                   8582:             output_require "Example"
                   8583:             output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
                   8584:             output_prohibit "no such file or directory"
1.169     rillig   8585:             regress_fail "expected $expected but got $actual for input $input"
1.108     rillig   8586:     }
1.1       dsieger  8587: 
1.108     rillig   8588: do_cleanup
1.1       dsieger  8589: 
                   8590:     This function cleans everything up after the test has been run. By default
                   8591:     it does nothing.
                   8592: 
1.184     rillig   8593: 26.2.2. Helper functions
1.1       dsieger  8594: 
1.168     rillig   8595: regress_fail message...
                   8596: 
                   8597:     This function makes the test fail with the given error message.
                   8598: 
1.108     rillig   8599: exit_status expected
1.1       dsieger  8600: 
1.108     rillig   8601:     This function compares the exitcode of the do_test function with its first
                   8602:     parameter. If they differ, the test will fail.
1.1       dsieger  8603: 
1.108     rillig   8604: output_require regex...
1.1       dsieger  8605: 
                   8606:     This function checks for each of its parameters if the output from do_test
1.108     rillig   8607:     matches the extended regular expression. If it does not, the test will
                   8608:     fail. Example:
                   8609: 
                   8610:     output_require "looks fine"
                   8611:     output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1       dsieger  8612: 
1.177     leot     8613: output_prohibit regex...
1.1       dsieger  8614: 
                   8615:     This function checks for each of its parameters if the output from do_test
                   8616:     () does not match the extended regular expression. If any of the regular
                   8617:     expressions matches, the test will fail.
                   8618: 
1.184     rillig   8619: Chapter 27. Porting pkgsrc
1.1       dsieger  8620: 
                   8621: Table of Contents
                   8622: 
1.184     rillig   8623: 27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8624: 
                   8625: The pkgsrc system has already been ported to many operating systems, hardware
                   8626: architectures and compilers. This chapter explains the necessary steps to make
                   8627: pkgsrc even more portable.
                   8628: 
1.184     rillig   8629: 27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8630: 
                   8631: To port pkgsrc to a new operating system (called MyOS in this example), you
                   8632: need to touch the following files:
                   8633: 
                   8634: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
                   8635: 
                   8636:     This file contains some basic definitions, for example the name of the C
                   8637:     compiler.
                   8638: 
                   8639: mk/bsd.prefs.mk
                   8640: 
1.212     wiz      8641:     Insert code that defines the variables OPSYS, OS_VERSION, OPSYS_VERSION,
1.1       dsieger  8642:     LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
                   8643:     that appear in this file.
                   8644: 
                   8645: mk/platform/MyOS.mk
                   8646: 
                   8647:     This file contains the platform-specific definitions that are used by
                   8648:     pkgsrc. Start by copying one of the other files and edit it to your needs.
                   8649: 
                   8650: mk/tools/tools.MyOS.mk
                   8651: 
                   8652:     This file defines the paths to all the tools that are needed by one or the
                   8653:     other package in pkgsrc, as well as by pkgsrc itself. Find out where these
                   8654:     tools are on your platform and add them.
                   8655: 
                   8656: Now, you should be able to build some basic packages, like lang/perl5, shells/
                   8657: bash.
                   8658: 
                   8659: Appendix A. A simple example package: bison
                   8660: 
                   8661: Table of Contents
                   8662: 
                   8663: A.1. files
                   8664:     A.1.1. Makefile
                   8665:     A.1.2. DESCR
                   8666:     A.1.3. PLIST
                   8667:     A.1.4. Checking a package with pkglint
                   8668: A.2. Steps for building, installing, packaging
                   8669: 
                   8670: We checked to find a piece of software that wasn't in the packages collection,
1.25      wiz      8671: and picked GNU bison. Quite why someone would want to have bison when Berkeley 
1.1       dsieger  8672: yacc is already present in the tree is beyond us, but it's useful for the
                   8673: purposes of this exercise.
                   8674: 
                   8675: A.1. files
                   8676: 
                   8677: A.1.1. Makefile
                   8678: 
1.2       rillig   8679: # $NetBSD$
1.1       dsieger  8680: #
                   8681: 
                   8682: DISTNAME=       bison-1.25
                   8683: CATEGORIES=     devel
1.171     rillig   8684: MASTER_SITES=   ${MASTER_SITE_GNU:=bison/}
1.1       dsieger  8685: 
1.30      dholland 8686: MAINTAINER=     pkgsrc-users@NetBSD.org
1.174     leot     8687: HOMEPAGE=       https://www.gnu.org/software/bison/bison.html
1.1       dsieger  8688: COMMENT=        GNU yacc clone
                   8689: 
                   8690: GNU_CONFIGURE=  yes
1.47      wiz      8691: INFO_FILES=     yes
1.1       dsieger  8692: 
                   8693: .include "../../mk/bsd.pkg.mk"
                   8694: 
                   8695: A.1.2. DESCR
                   8696: 
                   8697: GNU version of yacc.  Can make re-entrant parsers, and numerous other
                   8698: improvements.  Why you would want this when Berkeley yacc(1) is part
                   8699: of the NetBSD source tree is beyond me.
                   8700: 
                   8701: A.1.3. PLIST
                   8702: 
1.2       rillig   8703: @comment $NetBSD$
1.1       dsieger  8704: bin/bison
                   8705: man/man1/bison.1.gz
                   8706: share/bison.simple
                   8707: share/bison.hairy
                   8708: 
                   8709: A.1.4. Checking a package with pkglint
                   8710: 
                   8711: The NetBSD package system comes with pkgtools/pkglint which helps to check the
                   8712: contents of these files. After installation it is quite easy to use, just
1.171     rillig   8713: change to the directory of the package you wish to examine and run pkglint:
1.1       dsieger  8714: 
                   8715: $ pkglint
1.171     rillig   8716: ERROR: Makefile: Each package must define its LICENSE.
                   8717: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
                   8718: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
                   8719: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
                   8720: 1 error, 2 warnings and 1 note found.
                   8721: (Run "pkglint -e" to show explanations.)
                   8722: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172     rillig   8723: (Run "pkglint -F" to automatically fix some issues.)
1.1       dsieger  8724: 
                   8725: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170     rillig   8726: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1       dsieger  8727: 
                   8728: A.2. Steps for building, installing, packaging
                   8729: 
                   8730: Create the directory where the package lives, plus any auxiliary directories:
                   8731: 
                   8732: # cd /usr/pkgsrc/lang
                   8733: # mkdir bison
                   8734: # cd bison
                   8735: # mkdir patches
                   8736: 
1.184     rillig   8737: Create Makefile, DESCR and PLIST (see Chapter 12, Package components - files,
1.1       dsieger  8738: directories and contents) then continue with fetching the distfile:
                   8739: 
                   8740: # make fetch
                   8741: >> bison-1.25.tar.gz doesn't seem to exist on this system.
                   8742: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   8743: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8744: ftp: Error retrieving file: 500 Internal error
                   8745: 
                   8746: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   8747: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8748: ftp: Error retrieving file: 500 Internal error
                   8749: 
                   8750: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   8751: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8752: Successfully retrieved file.
                   8753: 
                   8754: Generate the checksum of the distfile into distinfo:
                   8755: 
                   8756: # make makedistinfo
                   8757: 
                   8758: Now compile:
                   8759: 
                   8760: # make
                   8761: >> Checksum OK for bison-1.25.tar.gz.
                   8762: ===>  Extracting for bison-1.25
                   8763: ===>  Patching for bison-1.25
                   8764: ===>   Ignoring empty patch directory
                   8765: ===>  Configuring for bison-1.25
                   8766: creating cache ./config.cache
                   8767: checking for gcc... cc
                   8768: checking whether we are using GNU C... yes
                   8769: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   8770: checking how to run the C preprocessor... cc -E
                   8771: checking for minix/config.h... no
                   8772: checking for POSIXized ISC... no
                   8773: checking whether cross-compiling... no
                   8774: checking for ANSI C header files... yes
                   8775: checking for string.h... yes
                   8776: checking for stdlib.h... yes
                   8777: checking for memory.h... yes
                   8778: checking for working const... yes
                   8779: checking for working alloca.h... no
                   8780: checking for alloca... yes
                   8781: checking for strerror... yes
                   8782: updating cache ./config.cache
                   8783: creating ./config.status
                   8784: creating Makefile
                   8785: ===>  Building for bison-1.25
                   8786: 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
                   8787: 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
                   8788: 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
                   8789: 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
                   8790: 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
                   8791: 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
                   8792: 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
                   8793: 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
                   8794: 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
                   8795: 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
                   8796: 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
                   8797: 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
                   8798: 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
                   8799: 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
                   8800: 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
                   8801: 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
                   8802: 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
                   8803: 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
                   8804: 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
                   8805: 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
                   8806: 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
                   8807: 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
                   8808: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   8809: rm -f bison.s1
                   8810: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
                   8811: 
                   8812: Everything seems OK, so install the files:
                   8813: 
                   8814: # make install
                   8815: >> Checksum OK for bison-1.25.tar.gz.
                   8816: ===>  Installing for bison-1.25
                   8817: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   8818: rm -f /usr/pkg/bin/bison
                   8819: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   8820: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   8821: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   8822: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   8823: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   8824: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   8825: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
                   8826: ===>  Registering installation for bison-1.25
                   8827: 
                   8828: You can now use bison, and also - if you decide so - remove it with pkg_delete
                   8829: bison. Should you decide that you want a binary package, do this now:
                   8830: 
                   8831: # make package
                   8832: >> Checksum OK for bison-1.25.tar.gz.
                   8833: ===>  Building package for bison-1.25
                   8834: Creating package bison-1.25.tgz
                   8835: Registering depends:.
                   8836: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
                   8837: 
                   8838: Now that you don't need the source and object files any more, clean up:
                   8839: 
                   8840: # make clean
                   8841: ===>  Cleaning for bison-1.25
                   8842: 
1.207     leot     8843: Appendix B. Security hardening
                   8844: 
                   8845: Table of Contents
                   8846: 
                   8847: B.1. Mechanisms
                   8848:     B.1.1. Enabled by default
                   8849:     B.1.2. Not enabled by default
                   8850: B.2. Caveats
                   8851:     B.2.1. Problems with PKGSRC_MKPIE
                   8852:     B.2.2. Problems with PKGSRC_USE_FORTIFY
                   8853:     B.2.3. Problems with PKGSRC_USE_RELRO
                   8854:     B.2.4. Problems with PKGSRC_USE_SSP
                   8855: B.3. Auditing the system
                   8856:     B.3.1. Checking for PIE
                   8857:     B.3.2. Checking for partial RELRO
                   8858:     B.3.3. Checking for full RELRO
                   8859:     B.3.4. Checking for SSP
                   8860: 
                   8861: A number of mechanisms are available in pkgsrc to improve the security of the
                   8862: resulting system. This page describes the mechanisms, and gives hints about
                   8863: detecting and fixing problems.
                   8864: 
                   8865: Mechanisms can be enabled individually in mk.conf, and are individually
                   8866: described below.
                   8867: 
                   8868: Typically, a feature will cause some programs to fail to build or work when
                   8869: first enabled. This can be due to latent problems in the program, and can be
                   8870: due to other reasons. After enough testing to have confidence that user
                   8871: problems will be quite rare, individual mechanisms will be enabled by default.
                   8872: 
                   8873: For each mechanism, see the Caveats section below for an explanation of what
                   8874: might go wrong at compile time and at run time, and how to notice and address
                   8875: these problems.
                   8876: 
                   8877: B.1. Mechanisms
                   8878: 
                   8879: B.1.1. Enabled by default
                   8880: 
                   8881: B.1.1.1. PKGSRC_USE_FORTIFY
                   8882: 
                   8883: This allows substitute wrappers to be used for some commonly used library
                   8884: functions that do not have built-in bounds checking - but could in some cases.
                   8885: 
                   8886: Two mitigation levels are available:
                   8887: 
                   8888:   * "weak" only enables checks at compile-time.
                   8889: 
                   8890:   * "strong" enables checks at compile-time and runtime.
                   8891: 
                   8892: "strong" has been enabled by default since pkgsrc-2017Q3.
                   8893: 
                   8894: B.1.1.2. PKGSRC_USE_SSP
                   8895: 
                   8896: This enables a stack-smashing protection mitigation. It is done by adding a
                   8897: guard variable to functions with vulnerable objects. The guards are initialized
                   8898: when a function is entered and then checked when the function exits. The guard
                   8899: check will fail and the program forcibly exited if the variable was modified in
                   8900: the meantime. This can happen in case of buffer overflows or memory corruption,
                   8901: and therefore exposing these bugs.
                   8902: 
                   8903: Different mitigation levels are available:
                   8904: 
                   8905:   * "yes", which will only protect functions considered vulnerable by the
                   8906:     compiler;
                   8907: 
                   8908:   * "all", which will protect every function;
                   8909: 
                   8910:   * "strong", the default, which will apply a better balance between the two
                   8911:     settings above.
                   8912: 
                   8913: This mitigation is supported by both GCC and clang. It may be supported in
                   8914: additional compilers, possibly under a different name. It is particularly
                   8915: useful for unsafe programming languages, such as C/C++.
                   8916: 
                   8917:   * "yes" is enabled by default where known supported since pkgsrc-2017Q3.
                   8918: 
                   8919:   * "strong" is enabled by default where known supported since pkgsrc-2021Q4.
                   8920: 
                   8921: More details can be found here:
                   8922: 
                   8923:   * Buffer overflow protection on Wikipedia
                   8924: 
                   8925: B.1.1.3. PKGSRC_MKPIE
                   8926: 
                   8927: This requests the creation of PIE (Position Independent Executables) for all
                   8928: executables. The PIE mechanism is normally used for shared libraries, so that
                   8929: they can be loaded at differing addresses at runtime. PIE itself does not have
                   8930: useful security properties; however, it is necessary to fully leverage some,
                   8931: such as ASLR. Some operating systems support Address Space Layout Randomization
                   8932: (ASLR), which causes different addresses to be used each time a program is run.
                   8933: This makes it more difficult for an attacker to guess addresses and thus makes
                   8934: exploits harder to construct. With PIE, ASLR can really be applied to the
                   8935: entire program, instead of the stack and heap only.
                   8936: 
                   8937: PIE executables will only be built for toolchains that are known to support
                   8938: PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
                   8939: 
                   8940: PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch.
                   8941: 
1.219     nia      8942: B.1.1.4. PKGSRC_USE_RELRO
1.207     leot     8943: 
                   8944: This also makes the exploitation of some security vulnerabilities more
                   8945: difficult in some cases.
                   8946: 
                   8947: Two different mitigation levels are available:
                   8948: 
1.219     nia      8949:   * partial (the default): the ELF sections are reordered so that internal data
                   8950:     sections precede the program's own data sections, and non-PLT GOT is
                   8951:     read-only;
1.207     leot     8952: 
                   8953:   * full: in addition to partial RELRO, every relocation is performed
1.218     nia      8954:     immediately when starting the program, allowing the entire GOT to be
                   8955:     read-only. This can greatly slow down startup of large programs.
1.207     leot     8956: 
                   8957: This is currently supported by GCC. Many software distributions now enable this
1.220     nia      8958: feature by default, at the "partial" level.
1.207     leot     8959: 
                   8960: More details can be found here:
                   8961: 
                   8962:   * Hardening ELF binaries using Relocation Read-Only (RELRO)
                   8963: 
1.219     nia      8964: B.1.2. Not enabled by default
                   8965: 
                   8966: B.1.2.1. PKGSRC_MKREPRO
                   8967: 
                   8968: With this option, pkgsrc will try to build packages reproducibly. This allows
                   8969: packages built from the same tree and with the same options, to produce
                   8970: identical results bit by bit. This option should be combined with ASLR and
                   8971: PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to
                   8972: exploit security vulnerabilities.
                   8973: 
                   8974: More details can be found here:
                   8975: 
                   8976:   * Reproducible Builds - a set of software development practices that create
                   8977:     an independently-verifiable path from source to binary code
                   8978: 
                   8979: More work likely needs to be done before pkgsrc is fully reproducible.
                   8980: 
                   8981: B.1.2.2. PKGSRC_USE_STACK_CHECK
1.207     leot     8982: 
                   8983: This uses -fstack-check with GCC for another stack protection mitigation.
                   8984: 
                   8985: It asks the compiler to generate code verifying that it does not corrupt the
                   8986: stack. According to GCC's manual page, this is really only useful for
                   8987: multi-threaded programs.
                   8988: 
                   8989: B.2. Caveats
                   8990: 
                   8991: B.2.1. Problems with PKGSRC_MKPIE
                   8992: 
                   8993: B.2.1.1. Packages failing to build
                   8994: 
                   8995: A number of packages may fail to build with this option enabled. The failures
                   8996: are often related to the absence of the -fPIC compilation flag when building
                   8997: libraries or executables (or ideally -fPIE in the latter case). This flag is
                   8998: added to the CFLAGS already, but requires the package to actually support it.
                   8999: 
                   9000: B.2.1.1.1. How to fix
                   9001: 
                   9002: These instructions are meant as a reference only; they likely need to be
                   9003: adapted for many packages individually.
                   9004: 
                   9005: For packages using Makefiles:
                   9006: 
                   9007: MAKE_FLAGS+=    CFLAGS=${CFLAGS:Q}
                   9008: MAKE_FLAGS+=    LDFLAGS=${LDFLAGS:Q}
                   9009: 
                   9010: For packages using Imakefiles:
                   9011: 
                   9012: MAKE_FLAGS+=    CCOPTIONS=${CFLAGS:Q}
                   9013: MAKE_FLAGS+=    LOCAL_LDFLAGS=${LDFLAGS:Q}
                   9014: 
                   9015: B.2.1.2. Run-time crashes
                   9016: 
                   9017: Some programs may fail to run, or crash at random times once built as PIE. Two
                   9018: scenarios are essentially possible. This is nearly always due to a bug in the
                   9019: program being exposed due to ASLR.
                   9020: 
                   9021: B.2.1.3. Disabling PKGSRC_MKPIE on a per-package basis
                   9022: 
                   9023: Ideally, packages should be fixed for compatibility with MKPIE. However, in
                   9024: some cases this is very difficult, due to complex build systems, packages using
                   9025: non-standard toolchains, or programming languages with odd bootstrapping
                   9026: mechanisms.
                   9027: 
                   9028: To disable PKGSRC_MKPIE on a per-package basis, set MKPIE_SUPPORTED= no in the
                   9029: package's Makefile before bsd.prefs.mk is included.
                   9030: 
                   9031: B.2.2. Problems with PKGSRC_USE_FORTIFY
                   9032: 
                   9033: B.2.2.1. Packages failing to build
                   9034: 
                   9035: This feature makes use of pre-processing directives to look for hardened,
                   9036: alternative implementations of essential library calls. Some programs may fail
                   9037: to build as a result; this usually happens for those trying too hard to be
                   9038: portable, or otherwise abusing definitions in the standard library.
                   9039: 
                   9040: B.2.2.2. Run-time crashes
                   9041: 
                   9042: This feature may cause some programs to crash, usually indicating an actual bug
                   9043: in the program. The fix will typically involve patching the original program's
                   9044: source code.
                   9045: 
                   9046: B.2.2.3. Optimization is required
                   9047: 
                   9048: At least in the case of GCC, FORTIFY will only be applied if optimization is
                   9049: applied while compiling. This means that the CFLAGS should also contain -O, -O2
                   9050: or another optimization level. This cannot easily be applied globally, as some
                   9051: packages may require specific optimization levels.
                   9052: 
                   9053: B.2.2.4. Disabling FORTIFY on a per-package basis
                   9054: 
                   9055: Note
                   9056: 
                   9057: FORTIFY should not be disabled to work around runtime crashes in the program!
                   9058: This is a very bad idea and will expose you to security vulnerabilities.
                   9059: 
                   9060: To disable FORTIFY on a per-package basis, set the following in the package's
                   9061: Makefile before bsd.prefs.mk is included:
                   9062: 
                   9063: FORTIFY_SUPPORTED=      no
                   9064: 
                   9065: B.2.3. Problems with PKGSRC_USE_RELRO
                   9066: 
                   9067: B.2.3.1. Performance impact
                   9068: 
                   9069: For better protection, full RELRO requires every symbol to be resolved when the
                   9070: program starts, rather than simply when required at run-time. This will have
                   9071: more impact on programs using a lot of symbols, or linked to libraries exposing
                   9072: a lot of symbols. Therefore, daemons or programs otherwise running in
                   9073: background are affected only when started. Programs loading plug-ins at
                   9074: run-time are affected when loading the plug-ins.
                   9075: 
                   9076: The impact is not expected to be noticeable on modern hardware, except in some
                   9077: cases for big programs.
                   9078: 
                   9079: B.2.3.2. Run-time crashes
                   9080: 
                   9081: Some programs handle plug-ins and dependencies in a way that conflicts with
                   9082: RELRO: for instance, with an initialization routine listing any other plug-in
                   9083: required. With full RELRO, the missing symbols are resolved before the
                   9084: initialization routine can run, and the dynamic loader will not be able to find
                   9085: them directly and abort as a result. Unfortunately, this is how Xorg loads its
                   9086: drivers. Partial RELRO can be applied instead in this case.
                   9087: 
                   9088: B.2.3.3. Disabling RELRO on a per-package basis
                   9089: 
                   9090: To disable RELRO on a per-package basis, set the following in the package's
                   9091: Makefile before bsd.prefs.mk is included:
                   9092: 
                   9093: RELRO_SUPPORTED=        no
                   9094: 
1.209     nia      9095: It is also possible to at most enable partial RELRO, by setting RELRO_SUPPORTED
                   9096: to partial.
                   9097: 
1.207     leot     9098: B.2.4. Problems with PKGSRC_USE_SSP
                   9099: 
                   9100: B.2.4.1. Packages failing to build
                   9101: 
                   9102: The stack-smashing protection provided by this option does not work for some
                   9103: programs. The most common situation in which this happens is when the program
                   9104: allocates variables on the stack, with the size determined at run-time.
                   9105: 
                   9106: B.2.4.2. Run-time crashes
                   9107: 
                   9108: Again, this feature may cause some programs to crash via a SIGABRT, usually
                   9109: indicating an actual bug in the program.
                   9110: 
                   9111: On NetBSD LOG_CRIT level syslog messages are sent and - by default - appended
                   9112: to /var/log/messages, e.g.:
                   9113: 
                   9114: Jan  6 15:42:51 hostname -: hostname program - - - buffer overflow detected; terminated
                   9115: 
                   9116: (where hostname is the hostname(1) and program is the basename(1) of the
                   9117: program crashed).
                   9118: 
                   9119: Patching the original program is then required.
                   9120: 
                   9121: Rebuilding the package via:
                   9122: 
                   9123: % env CFLAGS=-g INSTALL_UNSTRIPPED=yes make replace
                   9124: 
                   9125: and inspecting the backtrace of the coredump via the debugger should point out
                   9126: the problematic call by inspecting the frame calling the _chk() (SSP) function.
                   9127: 
                   9128: B.2.4.3. Performance impact
                   9129: 
                   9130: The compiler emits extra code when using this feature: a check for buffer
                   9131: overflows is performed when entering and exiting functions, requiring an extra
                   9132: variable on the stack. The level of protection can otherwise be adjusted to
                   9133: affect only those functions considered more sensitive by the compiler (with
                   9134: -fstack-protector instead of -fstack-protector-all).
                   9135: 
                   9136: The impact is not expected to be noticeable on modern hardware. However,
                   9137: programs with a hard requirement to run at the fastest possible speed should
                   9138: avoid using this feature, or using libraries built with this feature.
                   9139: 
                   9140: B.2.4.4. Disabling SSP on a per-package basis
                   9141: 
                   9142: Note
                   9143: 
                   9144: SSP should not be disabled to work around runtime crashes in the program! This
                   9145: is a very bad idea and will expose you to security vulnerabilities.
                   9146: 
                   9147: To disable SSP on a per-package basis, set the following in the package's
                   9148: Makefile before bsd.prefs.mk is included:
                   9149: 
                   9150: SSP_SUPPORTED=  no
                   9151: 
                   9152: B.3. Auditing the system
                   9153: 
                   9154: The illusion of security is worse than having no security at all. This section
                   9155: lists a number of ways to ensure the security features requested are actually
                   9156: effective.
                   9157: 
                   9158: These instructions were obtained and tested on a system derived from NetBSD 7
                   9159: (amd64). YMMV.
                   9160: 
                   9161: B.3.1. Checking for PIE
                   9162: 
                   9163: The ELF executable type in use changes for binaries built as PIE; without:
                   9164: 
                   9165: $ file /path/to/bin/ary
                   9166: /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
                   9167: 
                   9168: as opposed to the following binary, built as PIE:
                   9169: 
                   9170: $ file /path/to/pie/bin/ary
                   9171: /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
                   9172: 
                   9173: The latter result is then what is expected.
                   9174: 
                   9175: B.3.2. Checking for partial RELRO
                   9176: 
                   9177: The following command should list a section called RELRO:
                   9178: 
                   9179: $ objdump -p /path/to/bin/ary
                   9180: 
                   9181: /path/to/bin/ary:     file format elf64-x86-64
                   9182: 
                   9183: Program Header:
                   9184: [...]
                   9185:    RELRO off    0x0000000000000d78 vaddr 0x0000000000600d78 paddr 0x0000000000600d78 align 2**0
                   9186: 
                   9187: This check is now performed automatically if PKG_DEVELOPER is set and RELRO is
                   9188: enabled.
                   9189: 
                   9190: B.3.3. Checking for full RELRO
                   9191: 
                   9192: The dynamic loader will apply RELRO immediately when detecting the presence of
                   9193: the BIND_NOW flag:
                   9194: 
                   9195: $ objdump -x /path/to/bin/ary
                   9196: 
                   9197: /path/to/bin/ary:     file format elf64-x86-64
                   9198: 
                   9199: Dynamic Section:
                   9200: [...]
                   9201:   BIND_NOW             0x0000000000000000
                   9202: 
                   9203: This has to be combined with partial RELRO (see above) to be fully efficient.
                   9204: 
                   9205: This check is now performed automatically (where supported) if PKG_DEVELOPER is
                   9206: set.
                   9207: 
                   9208: B.3.4. Checking for SSP
                   9209: 
1.208     nia      9210: Note
                   9211: 
                   9212: Checking for SSP using this method only works where the operating system uses
                   9213: libssp. libssp is not used on recent NetBSD/FreeBSD/Linux versions.
                   9214: 
1.207     leot     9215: Building objects, binaries and libraries with SSP will affect the presence of
                   9216: additional symbols in the resulting file:
                   9217: 
                   9218: $ nm /path/to/bin/ary
                   9219: [...]
                   9220:                  U __stack_chk_fail
                   9221: 0000000000600ea0 B __stack_chk_guard
                   9222: 
                   9223: This is an indicator that the program was indeed built with support for SSP.
                   9224: 
                   9225: This check is now performed automatically (where supported) if PKG_DEVELOPER is
                   9226: set and SSP is enabled.
                   9227: 
                   9228: Appendix C. Build logs
1.1       dsieger  9229: 
                   9230: Table of Contents
                   9231: 
1.207     leot     9232: C.1. Building figlet
                   9233: C.2. Packaging figlet
1.1       dsieger  9234: 
1.207     leot     9235: C.1. Building figlet
1.1       dsieger  9236: 
                   9237: # make
                   9238: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9239: => figlet221.tar.gz doesn't seem to exist on this system.
                   9240: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   9241: => [172219 bytes]
                   9242: Connected to ftp.plig.net.
                   9243: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   9244: 331 Guest login ok, send your complete e-mail address as password.
                   9245: 230-You are user #5 of 500 simultaneous users allowed.
                   9246: 230-
                   9247: 230-  ___ _             _ _
                   9248: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
                   9249: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   9250: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   9251: 230-         |_|   |_|     |___|         |___|
                   9252: 230-
                   9253: 230-** Welcome to ftp.plig.org **
                   9254: 230-
                   9255: 230-Please note that all transfers from this FTP site are logged. If you
                   9256: 230-do not like this, please disconnect now.
                   9257: 230-
1.19      snj      9258: 230-This archive is available via
1.1       dsieger  9259: 230-
                   9260: 230-HTTP:  http://ftp.plig.org/
                   9261: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   9262: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   9263: 230-
                   9264: 230-Please email comments, bug reports and requests for packages to be
                   9265: 230-mirrored to ftp-admin@plig.org.
                   9266: 230-
                   9267: 230-
                   9268: 230 Logged in anonymously.
                   9269: Remote system type is UNIX.
                   9270: Using binary mode to transfer files.
                   9271: 200 Type okay.
                   9272: 250 "/pub" is new cwd.
                   9273: 250-"/pub/figlet" is new cwd.
                   9274: 250-
                   9275: 250-Welcome to the figlet archive at ftp.figlet.org
                   9276: 250-
                   9277: 250-    ftp://ftp.figlet.org/pub/figlet/
                   9278: 250-
                   9279: 250-The official FIGlet web page is:
                   9280: 250-    http://www.figlet.org/
                   9281: 250-
                   9282: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   9283: 250-contribute a font or something else, you can email us.
                   9284: 250
                   9285: 250 "/pub/figlet/program" is new cwd.
                   9286: 250 "/pub/figlet/program/unix" is new cwd.
                   9287: local: figlet221.tar.gz remote: figlet221.tar.gz
                   9288: 502 Unimplemented command.
                   9289: 227 Entering Passive Mode (195,40,6,41,246,104)
                   9290: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   9291: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   9292: 226 Transfer completed.
                   9293: 172219 bytes received in 00:02 (75.99 KB/s)
                   9294: 221 Goodbye.
                   9295: => Checksum OK for figlet221.tar.gz.
                   9296: ===> Extracting for figlet-2.2.1nb2
                   9297: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   9298: ===> Patching for figlet-2.2.1nb2
                   9299: ===> Applying pkgsrc patches for figlet-2.2.1nb2
                   9300: ===> Overriding tools for figlet-2.2.1nb2
                   9301: ===> Creating toolchain wrappers for figlet-2.2.1nb2
                   9302: ===> Configuring for figlet-2.2.1nb2
                   9303: ===> Building for figlet-2.2.1nb2
                   9304: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   9305: chmod a+x figlet
                   9306: gcc -O2 -o chkfont chkfont.c
                   9307: => Unwrapping files-to-be-installed.
                   9308: #
                   9309: # make install
                   9310: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9311: ===> Installing for figlet-2.2.1nb2
                   9312: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   9313: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   9314: mkdir -p /usr/pkg/share/figlet
                   9315: cp figlet /usr/pkg/bin
                   9316: cp chkfont /usr/pkg/bin
                   9317: chmod 555 figlist showfigfonts
                   9318: cp figlist /usr/pkg/bin
                   9319: cp showfigfonts /usr/pkg/bin
                   9320: cp fonts/*.flf /usr/pkg/share/figlet
                   9321: cp fonts/*.flc /usr/pkg/share/figlet
                   9322: cp figlet.6 /usr/pkg/man/man6
                   9323: ===> Registering installation for figlet-2.2.1nb2
                   9324: #
                   9325: 
1.207     leot     9326: C.2. Packaging figlet
1.1       dsieger  9327: 
                   9328: # make package
                   9329: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9330: ===> Packaging figlet-2.2.1nb2
                   9331: ===> Building binary package for figlet-2.2.1nb2
                   9332: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   9333: Using SrcDir value of /usr/pkg
                   9334: Registering depends:.
                   9335: #
                   9336: 
1.207     leot     9337: Appendix D. Directory layout of the pkgsrc FTP server
1.1       dsieger  9338: 
                   9339: Table of Contents
                   9340: 
1.207     leot     9341: D.1. distfiles: The distributed source files
                   9342: D.2. misc: Miscellaneous things
                   9343: D.3. packages: Binary packages
                   9344: D.4. reports: Bulk build reports
                   9345: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9346: 
                   9347: As in other big projects, the directory layout of pkgsrc is quite complex for
                   9348: newbies. This chapter explains where you find things on the FTP server. The
                   9349: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
                   9350: different, but inside this directory, everything should look the same, no
                   9351: matter on which server you are. This directory contains some subdirectories,
                   9352: which are explained below.
                   9353: 
1.207     leot     9354: D.1. distfiles: The distributed source files
1.1       dsieger  9355: 
                   9356: The directory distfiles contains lots of archive files from all pkgsrc
                   9357: packages, which are mirrored here. The subdirectories are called after their
                   9358: package names and are used when the distributed files have names that don't
                   9359: explicitly contain a version number or are otherwise too generic (for example
                   9360: release.tar.gz).
                   9361: 
1.207     leot     9362: D.2. misc: Miscellaneous things
1.1       dsieger  9363: 
                   9364: This directory contains things that individual pkgsrc developers find worth
                   9365: publishing.
                   9366: 
1.207     leot     9367: D.3. packages: Binary packages
1.1       dsieger  9368: 
1.3       rillig   9369: This directory contains binary packages for the various platforms that are
                   9370: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
                   9371: The meaning of these variables is:
                   9372: 
                   9373:   * OPSYS is the name of the operating system for which the packages have been
1.9       rillig   9374:     built. The name is taken from the output of the uname command, so it may
                   9375:     differ from the one you are used to hear.
1.3       rillig   9376: 
1.8       rillig   9377:   * ARCH is the hardware architecture of the platform for which the packages
1.10      hubertf  9378:     have been built. It also includes the ABI (Application Binary Interface)
                   9379:     for platforms that have several of them.
1.3       rillig   9380: 
1.255     wiz      9381:   * OSVERSION is the version of the operating system. Typically it is the
                   9382:     version defining an ABI, e.g. 9.0.
                   9383: 
                   9384:   * TAG is either 20YYQN for a stable branch, or current for packages built
                   9385:     from the HEAD branch. The latter should only be used when the packages are
                   9386:     updated on a regular basis.
                   9387: 
                   9388: The rationale for this scheme is that users can first search by OPSYS and ARCH,
                   9389: since these are more or less unchangeable. After that, there is a management
                   9390: set of directories with OSVERSION and TAG.
                   9391: 
                   9392: See also README.md in packages for more details, including about symlinks.
1.3       rillig   9393: 
                   9394: In each of these directories, there is a whole binary packages collection for a
                   9395: specific platform. It has a directory called All which contains all binary
1.255     wiz      9396: packages.
1.1       dsieger  9397: 
1.207     leot     9398: D.4. reports: Bulk build reports
1.8       rillig   9399: 
                   9400: Here are the reports from bulk builds, for those who want to fix packages that
                   9401: didn't build on some of the platforms. The structure of subdirectories should
1.207     leot     9402: look like the one in Section D.3, "packages: Binary packages".
1.8       rillig   9403: 
1.207     leot     9404: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9405: 
                   9406: These directories contain the "real" pkgsrc, that is the files that define how
                   9407: to create binary packages from source archives.
                   9408: 
1.149     leot     9409: Each of the current, stable and pkgsrc-20xxQy directories share the same
                   9410: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
                   9411: 
1.1       dsieger  9412: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149     leot     9413: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
                   9414: directory, ready to be downloaded as a whole.
1.1       dsieger  9415: 
1.149     leot     9416: The current directory contains files related to the HEAD branch of the CVS
                   9417: repository. In this directory there is an additional file called
                   9418: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
                   9419: about categories and packages.
                   9420: 
                   9421: The stable directory is a symlink to the latest pkgsrc-20xxQy.
                   9422: 
                   9423: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
                   9424: branch of the CVS repository. In these directories there is an additional file
                   9425: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
                   9426: was branched.
1.148     leot     9427: 
1.207     leot     9428: Appendix E. Help topics
1.154     rillig   9429: 
                   9430: The following list contains all help topics that are available when running 
                   9431: bmake help topic=:index.
                   9432: 
1.257     jkoshy   9433: #!                                -lintl
                   9434: 32bit                             64bit
                   9435: ABI                               ACCEPTABLE_LICENSES
                   9436: ACROREAD_FONTPATH                 ADDITIONAL
                   9437: AFAIK                             AIX
                   9438: ALLOW_NETWORK_ACCESS              ALLOW_NEWER_COMPILER
                   9439: ALLOW_VULNERABLE_PACKAGES         ALL_ENV
1.258   ! wiz      9440: ALSA_PC                           ALTERNATIVES_SRC
        !          9441: AMANDA_TMP                        AMANDA_USER
        !          9442: AMANDA_VAR                        APACHE_GROUP
        !          9443: APACHE_MODULE_NAME                APACHE_MODULE_SRC
        !          9444: APACHE_MODULE_SRCDIR              APACHE_PKG_PREFIX
        !          9445: APACHE_SUEXEC_CONFIGURE_ARGS      APACHE_SUEXEC_DOCROOT
        !          9446: APACHE_USER                       ARGMAX_REQ
        !          9447: ARG_MAX                           ARLA_CACHE
        !          9448: AUDIT_PACKAGES_FLAGS              AUTOCONF_REQD
        !          9449: AUTOMAKE_OVERRIDE                 AUTOMAKE_REQD
        !          9450: AUTO_MKDIRS                       AUX
        !          9451: BDB185_DEFAULT                    BDBBASE
        !          9452: BDB_ACCEPTED                      BDB_DEFAULT
        !          9453: BDB_LIBS                          BDB_TYPE
        !          9454: BINCIMAP_GROUP                    BINCIMAP_LOG_USER
        !          9455: BINCIMAP_USER                     BIND_DIR
        !          9456: BIND_GROUP                        BIND_USER
        !          9457: BINOWN                            BINPKG_SITES
        !          9458: BIN_INSTALL_FLAGS                 BISON_PKGDATADIR
        !          9459: BLAS                              BLAS_ACCEPTED
        !          9460: BLAS_C_INTERFACE                  BLAS_INCLUDES
        !          9461: BLAS_INDEX64                      BLAS_LIBS
        !          9462: BLAS_PC                           BLAS_TYPE
        !          9463: BOOTSTRAP_DEPENDS                 BROKEN
        !          9464: BROKEN_EXCEPT_ON_PLATFORM         BROKEN_ON_PLATFORM
        !          9465: BSDSRCDIR                         BSDXSRCDIR
        !          9466: BSD_MAKE_ENV                      BUILDLINK_AUTO_DIRS
        !          9467: BUILDLINK_AUTO_VARS               BUILDLINK_CFLAGS
        !          9468: BUILDLINK_CONTENTS_FILTER         BUILDLINK_CPPFLAGS
        !          9469: BUILDLINK_DEPMETHOD               BUILDLINK_FILES
1.257     jkoshy   9470: BUILDLINK_FILES_CMD               BUILDLINK_FNAME_TRANSFORM
                   9471: BUILDLINK_LDFLAGS                 BUILDLINK_LIBS
                   9472: BUILDLINK_OPSYS_SUPPORT_PTHREAD   BUILDLINK_PKGNAME
                   9473: BUILDLINK_PREFIX                  BUILDLINK_RPATHDIRS
                   9474: BUILDLINK_TREE                    BUILD_DEFS
                   9475: BUILD_DEFS_EFFECTS                BUILD_DEPENDS
                   9476: BUILD_DIRS                        BUILD_ENV_SHELL
                   9477: BUILD_MAKE_CMD                    BUILD_MAKE_FLAGS
                   9478: BUILD_TARGET                      BUILTIN_FIND_FILES
                   9479: BUILTIN_FIND_FILES_VAR            BUILTIN_FIND_GREP
                   9480: BUILTIN_FIND_HEADERS              BUILTIN_FIND_HEADERS_VAR
                   9481: BUILTIN_FIND_PKGCONFIG            BUILTIN_FIND_PKGCONFIG_VAR
                   9482: BUILTIN_PKG                       BUILTIN_TEST_CURSES_DEFINES
                   9483: BUILTIN_TEST_CURSES_FUNCS         BUILTIN_VERSION_SCRIPT
                   9484: BUILTIN_X11_TYPE                  BUILTIN_X11_VERSION
                   9485: CACTI_GROUP                       CACTI_USER
                   9486: CANNA_GROUP                       CANNA_USER
                   9487: CAT                               CBLAS_LIBS
                   9488: CBLAS_PC                          CCACHE_BASE
                   9489: CCACHE_DIR                        CCACHE_LOGFILE
                   9490: CCACHE_RECACHE                    CC_VERSION
                   9491: CC_VERSION_STRING                 CDRECORD_CONF
                   9492: CDROM_PKG_URL_DIR                 CDROM_PKG_URL_HOST
1.258   ! wiz      9493: CHANGES                           CHECKOUT_DATE
        !          9494: CHECK_COMPILER                    CHECK_FAKEHOME
        !          9495: CHECK_FILES                       CHECK_FILES_ONLY_PREFIX
        !          9496: CHECK_FILES_SKIP                  CHECK_FILES_STRICT
        !          9497: CHECK_HEADERS                     CHECK_HEADERS_SKIP
        !          9498: CHECK_INTERPRETER                 CHECK_INTERPRETER_SKIP
        !          9499: CHECK_PERMS                       CHECK_PERMS_AUTOFIX
        !          9500: CHECK_PERMS_SKIP                  CHECK_PIE
        !          9501: CHECK_PIE_SKIP                    CHECK_PIE_SUPPORTED
        !          9502: CHECK_PORTABILITY                 CHECK_PORTABILITY_EXPERIMENTAL
        !          9503: CHECK_PORTABILITY_SKIP            CHECK_RELRO
        !          9504: CHECK_RELRO_SKIP                  CHECK_RELRO_SUPPORTED
        !          9505: CHECK_SHLIBS                      CHECK_SHLIBS_SKIP
        !          9506: CHECK_SHLIBS_SUPPORTED            CHECK_SHLIBS_TOXIC
        !          9507: CHECK_SSP                         CHECK_SSP_SKIP
        !          9508: CHECK_SSP_SUPPORTED               CHECK_STRIPPED
        !          9509: CHECK_STRIPPED_SKIP               CHECK_WRKREF
        !          9510: CHECK_WRKREF_EXTRA_DIRS           CHECK_WRKREF_SKIP
        !          9511: CLAMAV_DBDIR                      CLAMAV_GROUP
        !          9512: CLAMAV_USER                       CLANGBASE
        !          9513: CLEANDEPENDS                      CLT
        !          9514: CMAKE_DEPENDENCIES_REWRITE        CMAKE_INSTALL_NAME_DIR
        !          9515: CMAKE_INSTALL_PREFIX              CMAKE_MODULE_PATH_OVERRIDE
        !          9516: CMAKE_PKGSRC_BUILD_FLAGS          CMAKE_PREFIX_PATH
        !          9517: CMAKE_USE_GNU_INSTALL_DIRS        COMMON_LISP_DOCFILES
        !          9518: COMMON_LISP_EXAMPLES              COMMON_LISP_EXTRAFILES
        !          9519: COMMON_LISP_PACKAGES              COMMON_LISP_SYSTEM
1.257     jkoshy   9520: COMPILER_RPATH_FLAG               COMPILER_USE_SYMLINKS
                   9521: CONFIGURE_ARGS                    CONFIGURE_DIRS
                   9522: CONFIGURE_ENV                     CONFIGURE_ENV_SHELL
                   9523: CONFIGURE_HAS_INFODIR             CONFIGURE_HAS_MANDIR
                   9524: CONFIGURE_SCRIPT                  CONFIG_SHELL
                   9525: CONFIG_SHELL_FLAGS                CONF_FILES
                   9526: CONF_FILES_MODE                   CONF_FILES_PERMS
                   9527: CONSERVER_DEFAULTHOST             CONSERVER_DEFAULTPORT
                   9528: CP                                CPE
                   9529: CPE_EDITION                       CPE_LANG
                   9530: CPE_OTHER                         CPE_PART
                   9531: CPE_PRODUCT                       CPE_SW_EDITION
                   9532: CPE_TARGET_HW                     CPE_TARGET_SW
                   9533: CPE_UPDATE                        CPE_URI
                   9534: CPE_VENDOR                        CPE_VERSION
                   9535: CPP                               CPP_PRECOMP_FLAGS
                   9536: CREATE_WRKDIR_SYMLINK             CROSSBASE
                   9537: CTFCONVERT                        CTF_FILES_SKIP
                   9538: CTF_SUPPORTED                     CTYPE
                   9539: CUPS_GROUP                        CUPS_SYSTEM_GROUPS
                   9540: CUPS_USER                         CURSES_DEFAULT
1.258   ! wiz      9541: CURSES_TYPE                       CVS_EXTRACTDIR
        !          9542: CVS_MODULE                        CVS_PROJECT
        !          9543: CVS_REPOSITORIES                  CVS_ROOT
        !          9544: CVS_ROOT_GNU                      CVS_ROOT_NONGNU
        !          9545: CVS_ROOT_SOURCEFORGE              CVS_TAG
        !          9546: CXX                               CYRUS_GROUP
        !          9547: CYRUS_IDLE                        CYRUS_USER
        !          9548: DAEMONTOOLS_GROUP                 DAEMONTOOLS_LOG_USER
        !          9549: DARWIN_NO_SYSTEM_LIBS             DARWIN_REQUIRES_FILTER
        !          9550: DBUS_GROUP                        DBUS_USER
        !          9551: DEFANG_GROUP                      DEFANG_USER
        !          9552: DEFAULT_ACCEPTABLE_LICENSES       DEFAULT_DISTFILES
        !          9553: DEFAULT_IRC_SERVER                DEFAULT_SERIAL_DEVICE
        !          9554: DEF_UMASK                         DEINSTALLDEPENDS
        !          9555: DEINSTALL_SRC                     DEINSTALL_TEMPLATES
        !          9556: DELAYED_ERROR_MSG                 DELAYED_WARNING_MSG
        !          9557: DEPENDS                           DEPENDS_TARGET
        !          9558: DEPENDS_TYPE                      DESTDIR
        !          9559: DESTDIR_VARNAME                   DIALER_GROUP
        !          9560: DIGEST_REQD                       DISTDIR
        !          9561: DISTFILES                         DISTINFO_FILE
        !          9562: DISTNAME                          DIST_PATH
        !          9563: DIST_SUBDIR                       DJBDNS_AXFR_USER
        !          9564: DJBDNS_CACHE_USER                 DJBDNS_DJBDNS_GROUP
        !          9565: DJBDNS_LOG_USER                   DJBDNS_RBL_USER
        !          9566: DJBDNS_TINY_USER                  DLOPEN_REQUIRE_PTHREADS
        !          9567: DL_AUTO_VARS                      DL_CFLAGS
        !          9568: DL_LDFLAGS                        DL_LIBS
        !          9569: DNS                               DOCOWN
        !          9570: DOWNLOADED_DISTFILE               DQCACHE_GROUP
        !          9571: DQCACHE_USER                      DT_LAYOUT
        !          9572: DYNAMIC_SITES_CMD                 DYNAMIC_SITES_SCRIPT
        !          9573: ECHO                              ECHO_N
        !          9574: ELK_GUI                           EMACS_TYPE
        !          9575: EMULDIR                           EMULSUBDIR
        !          9576: EMULSUBDIRSLASH                   EMUL_ARCH
        !          9577: EMUL_DISTRO                       EMUL_EXEC_FMT
        !          9578: EMUL_IS_NATIVE                    EMUL_MODULES
        !          9579: EMUL_OPSYS                        EMUL_PKG_FMT
        !          9580: EMUL_PLATFORM                     EMUL_PLATFORMS
        !          9581: EMUL_PREFER                       EMUL_REQD
        !          9582: EMUL_TYPE                         ERROR_MSG
        !          9583: EXIM_GROUP                        EXIM_USER
        !          9584: EXPORT_SYMBOLS_LDFLAGS            EXTRACTOR
        !          9585: EXTRACT_CMD                       EXTRACT_CMD_DEFAULT
        !          9586: EXTRACT_DIR                       EXTRACT_ELEMENTS
        !          9587: EXTRACT_ENV                       EXTRACT_ONLY
        !          9588: EXTRACT_OPTS                      EXTRACT_SUFX
        !          9589: EXTRACT_USING                     FAIL
        !          9590: FAILOVER_FETCH                    FAIL_MSG
        !          9591: FAKE_NCURSES                      FAM
        !          9592: FAM_ACCEPTED                      FAM_DEFAULT
        !          9593: FAM_SERVER                        FCPATH
        !          9594: FEATURE_CPPFLAGS                  FEATURE_LDFLAGS
        !          9595: FEATURE_LIBS                      FETCH_AFTER_ARGS
        !          9596: FETCH_BEFORE_ARGS                 FETCH_CMD
        !          9597: FETCH_OUTPUT_ARGS                 FETCH_PROXY
        !          9598: FETCH_RESUME_ARGS                 FETCH_TIMEOUT
        !          9599: FETCH_USE_IPV4_ONLY               FETCH_USING
        !          9600: FILES_SUBST                       FILES_SUBST_SED
        !          9601: FIX_SYSTEM_HEADERS                FONTDIR
1.257     jkoshy   9602: FONTS_DIRS                        FONTS_VERBOSE
                   9603: FOO_HACKS_MK                      FORCE_CXX_STD
1.258   ! wiz      9604: FORCE_C_STD                       FOSSIL_EXTRACTDIR
        !          9605: FOSSIL_REPO                       FOSSIL_REPOSITORIES
        !          9606: FOSSIL_VERSION                    FOX_USE_XUNICODE
1.257     jkoshy   9607: FREEWNN_GROUP                     FREEWNN_USER
                   9608: FTP_PKG_URL_DIR                   FTP_PKG_URL_HOST
                   9609: GAMEDATAMODE                      GAMEDATA_PERMS
                   9610: GAMEDIRMODE                       GAMEDIR_PERMS
                   9611: GAMEGRP                           GAMEMODE
                   9612: GAMEOWN                           GAMES_GROUP
                   9613: GAMES_USER                        GCC
                   9614: GCCBASE                           GCC_REQD
                   9615: GCC_VERSION_SUFFIX                GEM_BUILD
                   9616: GEM_CLEANBUILD                    GEM_CLEANBUILD_EXTENSIONS
                   9617: GEM_DOCDIR                        GEM_EXTSDIR
                   9618: GEM_HOME                          GEM_KEEPBUILD
                   9619: GEM_LIBDIR                        GEM_NAME
                   9620: GEM_PATH                          GEM_PLUGINSDIR
                   9621: GEM_SPECFILE                      GENERATE_PLIST
                   9622: GHC                               GHOSTSCRIPT_REQD
                   9623: GITHUB_PROJECT                    GITHUB_RELEASE
                   9624: GITHUB_SUBMODULES                 GITHUB_TAG
                   9625: GITHUB_TYPE                       GITLAB_PROJECT
                   9626: GITLAB_RELEASE                    GITLAB_SUBMODULES
                   9627: GITLAB_TAG                        GITLAB_TYPE
1.258   ! wiz      9628: GIT_BRANCH                        GIT_ENV
        !          9629: GIT_EXTRACTDIR                    GIT_REPO
        !          9630: GIT_REPOSITORIES                  GIT_REVISION
        !          9631: GIT_TAG                           GNU
        !          9632: GNU_CONFIGURE                     GNU_CONFIGURE_ICONV
        !          9633: GNU_CONFIGURE_INFODIR             GNU_CONFIGURE_MANDIR
        !          9634: GNU_CONFIGURE_QUIET               GNU_CONFIGURE_STRICT
        !          9635: GODEP_REDIRECTS                   GO_BUILD_PATTERN
        !          9636: GO_DEPS                           GO_DIST_BASE
        !          9637: GO_EXTRA_MOD_DIRS                 GO_MODULE_EXTRACT
        !          9638: GO_MODULE_FILES                   GO_SRCPATH
        !          9639: GROUP_SPECIFIC_PKGS               GRUB_NETWORK_CARDS
        !          9640: GRUB_PRESET_COMMAND               GRUB_SCAN_ARGS
        !          9641: GZIP                              HASKELL_COMPILER
1.257     jkoshy   9642: HASKELL_DISABLE_EXECUTABLES       HASKELL_DISABLE_LIBRARIES
                   9643: HASKELL_ENABLE_DYNAMIC_EXECUTABLE HASKELL_ENABLE_HADDOCK_DOCUMENTATION
                   9644: HASKELL_ENABLE_LIBRARY_PROFILING  HASKELL_ENABLE_SHARED_LIBRARY
                   9645: HASKELL_ENABLE_TESTS              HASKELL_OPTIMIZATION_LEVEL
                   9646: HASKELL_PKG_NAME                  HASKELL_UNRESTRICT_DEPENDENCIES
1.258   ! wiz      9647: HEADER_TEMPLATES                  HG_REPO
        !          9648: HG_REPOSITORIES                   HG_TAG
        !          9649: HOMEPAGE                          HOST_PKGTOOLS_ARGS
        !          9650: HOST_SPECIFIC_PKGS                HOWL_GROUP
        !          9651: HOWL_USER                         ICCBASE
        !          9652: ICECAST_CHROOTDIR                 ICON_THEMES
        !          9653: IDOBASE                           IGNORE_CCACHE
        !          9654: IGNORE_INFO_DIRS                  IGNORE_INTERACTIVE_FETCH
        !          9655: IMAKE                             IMAKEOPTS
        !          9656: IMAKE_MAKE                        IMAKE_MANINSTALL
        !          9657: IMAP_UW_CCLIENT_MBOX_FMT          IMDICTDIR
        !          9658: INCOMPAT_CURSES                   INFO_DIR
        !          9659: INFO_FILES                        INFO_MSG
        !          9660: INIT_SYSTEM                       INN_DATA_DIR
        !          9661: INN_GROUP                         INN_USER
        !          9662: INSTALLATION_DIRS                 INSTALLATION_DIRS_FROM_PLIST
        !          9663: INSTALL_ENV                       INSTALL_SH_OVERRIDE
        !          9664: INSTALL_SRC                       INSTALL_TEMPLATES
        !          9665: INSTALL_UNSTRIPPED                IRCD_HYBRID_IRC_GROUP
        !          9666: IRCD_HYBRID_IRC_USER              IRCD_HYBRID_MAXCONN
        !          9667: IRCD_HYBRID_NICLEN                IRCD_HYBRID_SYSLOG_EVENTS
        !          9668: IRCD_HYBRID_SYSLOG_FACILITY       IRCD_HYBRID_TOPICLEN
        !          9669: IRIX                              IRRD_USE_PGP
        !          9670: JABBERD_GROUP                     JABBERD_LOGDIR
        !          9671: JABBERD_PIDDIR                    JABBERD_SPOOLDIR
        !          9672: JABBERD_USER                      JAVA_APP_PATH
        !          9673: JAVA_APP_TARGETS                  JAVA_BINPREFIX
        !          9674: JAVA_CLASSPATH                    JAVA_HOME
        !          9675: JAVA_LD_LIBRARY_PATH              JAVA_NAME
        !          9676: JAVA_UNLIMIT                      JAVA_WRAPPERS
        !          9677: JPEG_ACCEPTED                     JPEG_DEFAULT
        !          9678: KERBEROS                          KERMIT_SUID_UUCP
        !          9679: KJS_USE_PCRE                      KNEWS_DOMAIN_FILE
        !          9680: KNEWS_DOMAIN_NAME                 KRB5_ACCEPTED
        !          9681: KRB5_DEFAULT                      LANGUAGES
        !          9682: LAPACKE_LIBS                      LAPACKE_PC
        !          9683: LAPACK_LIBS                       LAPACK_PC
        !          9684: LATEX2HTML_ICONPATH               LDCONFIG_ADD_CMD
        !          9685: LDCONFIG_REMOVE_CMD               LDD
        !          9686: LEAFNODE_DATA_DIR                 LEAFNODE_GROUP
        !          9687: LEAFNODE_USER                     LIBDVDCSS_HOMEPAGE
        !          9688: LIBDVDCSS_MASTER_SITES            LIBIMAGEQUANT_TYPE
        !          9689: LIBRSVG_TYPE                      LIBTOOL
        !          9690: LIBTOOLIZE_PLIST                  LIBTOOL_M4_OVERRIDE
        !          9691: LIBUSB_TYPE                       LICENSE
        !          9692: LINKER_RPATH_FLAG                 LINK_RPATH_FLAG
        !          9693: LINUX_BASE_NODEPS                 LINUX_BASE_PREFERRED
        !          9694: LINUX_BASE_REQUIRED               LINUX_LOCALES
1.257     jkoshy   9695: LOCALBASE                         LOCALBASE_LOCKTYPE
                   9696: LOCALPATCHES                      LOVE_DATA
                   9697: LOVE_GAME                         LOVE_VERSION
                   9698: LOWER_OPSYS                       LOWER_OPSYS_VERSUFFIX
                   9699: LOWER_VARIANT_VERSION             LOWER_VENDOR
                   9700: LP32PLATFORMS                     LP64PLATFORMS
                   9701: LUA_BUSTED_ARGS                   LUA_CDIR
                   9702: LUA_COMPILER                      LUA_DOCDIR
                   9703: LUA_EXAMPLESDIR                   LUA_INCDIR
                   9704: LUA_INTERPRETER                   LUA_LDIR
                   9705: LUA_LINKER_MAGIC                  LUA_PKGPREFIX
                   9706: LUA_SELF_CONFLICT                 LUA_USE_BUSTED
                   9707: LUA_VERSIONS_ACCEPTED             LUA_VERSIONS_INCOMPATIBLE
                   9708: LUA_VERSION_DEFAULT               LUA_VERSION_REQD
                   9709: Lua                               MACHINE_PLATFORM
                   9710: MAILAGENT_DOMAIN                  MAILAGENT_EMAIL
                   9711: MAILAGENT_FQDN                    MAILAGENT_ORGANIZATION
1.258   ! wiz      9712: MAJORDOMO_HOMEDIR                 MAJOR_OS_VERSION
        !          9713: MAKEINFO_ARGS                     MAKE_DIRS
        !          9714: MAKE_DIRS_PERMS                   MAKE_ENV
        !          9715: MAKE_FILE                         MAKE_FLAGS
        !          9716: MAKE_JOBS                         MAKE_JOBS_SAFE
        !          9717: MAKE_PROGRAM                      MANCOMPRESSED_IF_MANZ
        !          9718: MANINSTALL                        MANZ
        !          9719: MARIADB_VERSIONS_ALL              MASTER_SITES
        !          9720: MASTER_SITE_BACKUP                MASTER_SITE_LOCAL
        !          9721: MASTER_SITE_MOZILLA               MASTER_SITE_OVERRIDE
        !          9722: MASTER_SITE_PERL_CPAN             MASTER_SORT
        !          9723: MASTER_SORT_RANDOM                MASTER_SORT_REGEX
        !          9724: MECAB_CHARSET                     MEDIATOMB_GROUP
        !          9725: MEDIATOMB_USER                    MIPSPROBASE
        !          9726: MIREDO_GROUP                      MIREDO_USER
        !          9727: MISSING_FEATURES                  MKDIR
        !          9728: MKPIE_SUPPORTED                   MLDONKEY_GROUP
        !          9729: MLDONKEY_HOME                     MLDONKEY_USER
        !          9730: MONOTONE_GROUP                    MONOTONE_USER
        !          9731: MOTIFBASE                         MOTIF_TYPE
        !          9732: MOTIF_TYPE_DEFAULT                MPI_TYPE
        !          9733: MSGFMT_STRIP_MSGCTXT              MSGFMT_STRIP_MSGID_PLURAL
        !          9734: MTOOLS_ENABLE_FLOPPYD             MUST
1.257     jkoshy   9735: MV                                MYSQL_CHARSET
                   9736: MYSQL_DATADIR                     MYSQL_EXTRA_CHARSET
                   9737: MYSQL_GROUP                       MYSQL_USER
                   9738: MYSQL_VERSION                     MYSQL_VERSIONS_ACCEPTED
                   9739: MYSQL_VERSION_DEFAULT             NAGIOSCMD_GROUP
                   9740: NAGIOSDIR                         NAGIOS_GROUP
                   9741: NAGIOS_USER                       NATIVE_EXEC_FMT
                   9742: NATIVE_LOWER_OPSYS                NATIVE_LOWER_VENDOR
                   9743: NATIVE_MACHINE_PLATFORM           NATIVE_OBJECT_FMT
                   9744: NATIVE_OPSYS_VERSION              NATIVE_OS_VARIANT
                   9745: NATIVE_OS_VERSION                 NBPAX_PROGRAM_PREFIX
                   9746: NETBSD_LOGIN_NAME                 NMH_EDITOR
                   9747: NMH_MTA                           NMH_PAGER
                   9748: NODE_VERSIONS_ACCEPTED            NODE_VERSIONS_INCOMPATIBLE
                   9749: NODE_VERSION_DEFAULT              NODE_VERSION_REQD
                   9750: NOLOGIN                           NOTE
                   9751: NOT_FOR_PLATFORM                  NOT_PAX_ASLR_SAFE
                   9752: NOT_PAX_MPROTECT_SAFE             NO_BUILD
                   9753: NO_CHECKSUM                       NO_CONFIGURE
                   9754: NO_SKIP                           NS_PREFERRED
                   9755: NULLMAILER_GROUP                  NULLMAILER_USER
                   9756: OBJECT_FMT                        OBJHOSTNAME
                   9757: OBJMACHINE                        OCAML_FINDLIB_DIRS
                   9758: OCAML_FINDLIB_REGISTER            OCAML_FINDLIB_REGISTER_VERBOSE
                   9759: OCAML_SITELIBDIR                  OMF
                   9760: ONLY_FOR_COMPILER                 ONLY_FOR_PLATFORM
                   9761: OPENSSH_CHROOT                    OPENSSH_GROUP
                   9762: OPENSSH_USER                      OPSYS
                   9763: OPSYS_EMULDIR                     OPSYS_VERSION
                   9764: OS                                OSS_TYPE
                   9765: OSX                               OSX_PATH_TO_M4
1.258   ! wiz      9766: OSX_PATH_TO_YACC                  OS_HAVE_ALSA
        !          9767: OS_HAVE_RCD                       OS_VARIANT
1.257     jkoshy   9768: OS_VERSION                        OTF_FONTS_DIR
                   9769: OVERRIDE_DIRDEPTH                 OVERRIDE_GEMSPEC
1.258   ! wiz      9770: OVERRIDE_GNU_CONFIG_SCRIPTS       OVERRIDE_ROCKSPEC
        !          9771: OWN_DIRS                          OWN_DIRS_PERMS
        !          9772: P4GROUP                           P4PORT
        !          9773: P4ROOT                            P4USER
        !          9774: PACKAGES                          PALMOS_DEFAULT_SDK
        !          9775: PAMBASE                           PAM_DEFAULT
        !          9776: PAPERSIZE                         PASSIVE_FETCH
        !          9777: PATCHDIR                          PATCHFILES
        !          9778: PATCH_ARGS                        PATCH_DEBUG
        !          9779: PATCH_DIST_ARGS                   PATCH_DIST_CAT
        !          9780: PATCH_DIST_STRIP                  PATCH_FUZZ_FACTOR
        !          9781: PATCH_STRIP                       PATH
        !          9782: PCCBASE                           PEAR
        !          9783: PEAR_CHANNEL                      PEAR_CHANNEL_ALIAS
        !          9784: PEAR_CHANNEL_VERSION              PEAR_CMD
        !          9785: PEAR_LIB                          PEAR_PACKAGE_XML
        !          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_CHECK_INSTALLED               PHP_EXTENSION_DIR
        !          9801: PHP_INITIAL_TEENY                 PHP_PKG_PREFIX
        !          9802: PHP_VERSION                       PHP_VERSIONS_ACCEPTED
        !          9803: PHP_VERSIONS_INCOMPATIBLE         PHP_VERSION_DEFAULT
        !          9804: PHP_VERSION_REQD                  PILRC_USE_GTK
        !          9805: PKGCONFIG_BASE                    PKGCONFIG_FILE
        !          9806: PKGCONFIG_OVERRIDE                PKGCONFIG_OVERRIDE_STAGE
        !          9807: PKGDIR                            PKGGNUDIR
        !          9808: PKGINFODIR                        PKGLOCALEDIR
        !          9809: PKGMANDIR                         PKGNAME
        !          9810: PKGNAME_REQD                      PKGPATH
        !          9811: PKGREVISION                       PKGSRC_BLAS_TYPES
        !          9812: PKGSRC_CHANGES                    PKGSRC_COMPILER
        !          9813: PKGSRC_KEEP_BIN_PKGS              PKGSRC_LOCKTYPE
        !          9814: PKGSRC_MAKE_ENV                   PKGSRC_MESSAGE_RECIPIENTS
        !          9815: PKGSRC_MKPIE                      PKGSRC_MKREPRO
        !          9816: PKGSRC_OVERRIDE_MKPIE             PKGSRC_RUN_TEST
        !          9817: PKGSRC_SETENV                     PKGSRC_SLEEPSECS
        !          9818: PKGSRC_TODO                       PKGSRC_USE_CTF
        !          9819: PKGSRC_USE_FORTIFY                PKGSRC_USE_MKTOOLS
        !          9820: PKGSRC_USE_RELRO                  PKGSRC_USE_SSP
        !          9821: PKGSRC_USE_STACK_CHECK            PKGTASKS_DATAFILE
        !          9822: PKGTOOLS_ARGS                     PKGTOOLS_ENV
        !          9823: PKG_ALTERNATIVES                  PKG_APACHE
        !          9824: PKG_APACHE_ACCEPTED               PKG_APACHE_DEFAULT
        !          9825: PKG_BEST_EXISTS                   PKG_BUILD_OPTIONS
        !          9826: PKG_COMPRESSION                   PKG_CONFIG
        !          9827: PKG_CONFIG_PERMS                  PKG_CREATE_USERGROUP
        !          9828: PKG_DBDIR                         PKG_DB_TMPDIR
        !          9829: PKG_DEBUG_LEVEL                   PKG_DEFAULT_OPTIONS
        !          9830: PKG_DESTDIR_SUPPORT               PKG_DEVELOPER
        !          9831: PKG_DISABLED_OPTIONS              PKG_FATAL_ERRORS
        !          9832: PKG_FC                            PKG_FILELIST_CMD
        !          9833: PKG_GECOS                         PKG_GID
        !          9834: PKG_GROUPS                        PKG_GROUPS_VARS
        !          9835: PKG_HOME                          PKG_INIT_SCRIPTS
        !          9836: PKG_JAVA_HOME                     PKG_JVM
        !          9837: PKG_JVMS_ACCEPTED                 PKG_JVM_DEFAULT
        !          9838: PKG_LEGACY_OPTIONS                PKG_LIBTOOL
        !          9839: PKG_MKSYMLINKS                    PKG_OPTIONS
        !          9840: PKG_OPTIONS_DEPRECATED_WARNINGS   PKG_OPTIONS_LEGACY_OPTS
        !          9841: PKG_OPTIONS_LEGACY_VARS           PKG_OPTIONS_NONEMPTY_SETS
        !          9842: PKG_OPTIONS_OPTIONAL_GROUPS       PKG_OPTIONS_REQUIRED_GROUPS
        !          9843: PKG_OPTIONS_VAR                   PKG_PHP
        !          9844: PKG_PHP_MAJOR_VERS                PKG_PHP_VERSION
        !          9845: PKG_RCD_SCRIPTS                   PKG_REFCOUNT_DBDIR
        !          9846: PKG_REGISTER_SHELLS               PKG_RESUME_TRANSFERS
        !          9847: PKG_SHELL                         PKG_SUGGESTED_OPTIONS
        !          9848: PKG_SUPPORTED_OPTIONS             PKG_SYSCONFBASE
        !          9849: PKG_SYSCONFBASEDIR                PKG_SYSCONFDIR
        !          9850: PKG_SYSCONFDIR_PERMS              PKG_SYSCONFSUBDIR
        !          9851: PKG_SYSCONFVAR                    PKG_TOOLS_BIN
        !          9852: PKG_UID                           PKG_UPDATE_FONTS_DB
        !          9853: PKG_USERS                         PKG_USERS_VARS
        !          9854: PKG_VERBOSE                       PLEASE
        !          9855: PLIST                             PLIST_AWK
        !          9856: PLIST_AWK_ENV                     PLIST_SRC
        !          9857: PLIST_SUBST                       PLIST_TYPE
        !          9858: PLIST_VARS                        POPTOP_USE_MPPE
        !          9859: POSSIBLE_GFORTRAN_VERSION         POST_FETCH_HOOK
        !          9860: PREFER                            PREFER_NATIVE
        !          9861: PREFER_NATIVE_PTHREADS            PREFER_PKGSRC
        !          9862: PREFIX                            PREPEND_PATH
        !          9863: PRE_ROOT_CMD                      PRIVILEGED_STAGES
        !          9864: PS                                PTHREAD_AUTO_VARS
        !          9865: PTHREAD_CFLAGS                    PTHREAD_LDFLAGS
        !          9866: PTHREAD_LIBS                      PTHREAD_OPTS
        !          9867: PTHREAD_TYPE                      PVM_SSH
        !          9868: PYPKGPREFIX                       PYTHON_FOR_BUILD_ONLY
        !          9869: PYTHON_SELF_CONFLICT              PYTHON_VERSION
        !          9870: PYTHON_VERSIONED_DEPENDENCIES     PYTHON_VERSIONS_ACCEPTED
        !          9871: PYTHON_VERSIONS_INCOMPATIBLE      PYTHON_VERSION_DEFAULT
        !          9872: PYTHON_VERSION_REQD               PYVERSSUFFIX
        !          9873: QMAILDIR                          QMAIL_ALIAS_USER
        !          9874: QMAIL_DAEMON_USER                 QMAIL_LOG_USER
        !          9875: QMAIL_NOFILES_GROUP               QMAIL_PASSWD_USER
        !          9876: QMAIL_QMAIL_GROUP                 QMAIL_QUEUE_DIR
        !          9877: QMAIL_QUEUE_EXTRA                 QMAIL_QUEUE_USER
        !          9878: QMAIL_REMOTE_USER                 QMAIL_ROOT_USER
        !          9879: QMAIL_SEND_USER                   QORE_LATEST_MODULE_API
        !          9880: QORE_MODULE_API                   QORE_MODULE_DIR
        !          9881: QORE_USER_MODULE_DIR              QORE_VERSION
        !          9882: QPOPPER_FAC                       QPOPPER_SPOOL_DIR
        !          9883: QPOPPER_USER                      RAKE_NAME
        !          9884: RASMOL_DEPTH                      RCD_DIR
        !          9885: RCD_ORDER                         RCD_SCRIPTS
        !          9886: RCD_SCRIPTS_DIR                   RCD_SCRIPTS_EXAMPLEDIR
        !          9887: RCD_SCRIPTS_MODE                  RCD_SCRIPTS_SHELL
        !          9888: RCD_SCRIPT_SRC                    RCD_SUBR
1.257     jkoshy   9889: RDOC                              READLINE_DEFAULT
                   9890: READLINE_TYPE                     REAL_ROOT_GROUP
                   9891: REAL_ROOT_USER                    RECURSIVE_MAKE
                   9892: RELAY_CTRL_DIR                    RELRO_SUPPORTED
                   9893: REPLACE_AWK                       REPLACE_BASH
                   9894: REPLACE_CSH                       REPLACE_KSH
                   9895: REPLACE_LUA                       REPLACE_NODEJS
                   9896: REPLACE_OCTAVE                    REPLACE_PERL
                   9897: REPLACE_PERL6                     REPLACE_PHP
                   9898: REPLACE_PYTHON                    REPLACE_QORE
                   9899: REPLACE_R                         REPLACE_RUBY
                   9900: REPLACE_RUBY_DIRS                 REPLACE_RUBY_PAT
                   9901: REPLACE_SH                        REPLACE_TEXLUA
                   9902: REPLACE_TOOL_PYTHON               REPLACE_WISH
                   9903: REQD_DIRS                         REQD_DIRS_PERMS
                   9904: REQD_FILES                        REQD_FILES_MODE
                   9905: REQD_FILES_PERMS                  RESOLV_AUTO_VARS
                   9906: RESOLV_LDFLAGS                    RESOLV_LIBS
1.258   ! wiz      9907: RM                                ROCKSPEC_NAME
        !          9908: ROCKSPEC_SPECFILE                 ROOT_CMD
1.257     jkoshy   9909: ROOT_GROUP                        ROOT_USER
                   9910: RPCGEN                            RPM
                   9911: RPM2PKG_PLIST                     RPM2PKG_PREFIX
                   9912: RPM2PKG_STAGE                     RPM2PKG_STRIP
                   9913: RPM2PKG_SUBPREFIX                 RPMFILES
                   9914: RPMIGNOREPATH                     RPM_DB_PREFIX
                   9915: RSSH_CVS_PATH                     RSSH_RDIST_PATH
                   9916: RSSH_RSYNC_PATH                   RSSH_SCP_PATH
                   9917: RSSH_SFTP_SERVER_PATH             RUBY
                   9918: RUBYGEM                           RUBYGEM_MANPAGES
                   9919: RUBYGEM_NAME                      RUBYGEM_OPTIONS
                   9920: RUBYGEM_USE_MANPAGES              RUBYGEM_VERBOSE
                   9921: RUBY_ABI_VERSION                  RUBY_ARCH
                   9922: RUBY_ARCHINC                      RUBY_ARCHLIB
                   9923: RUBY_BASE                         RUBY_BASERIDIR
                   9924: RUBY_BUILD_DOCUMENT               RUBY_DLEXT
                   9925: RUBY_DOC                          RUBY_DYNAMIC_DIRS
                   9926: RUBY_EG                           RUBY_ENCODING_ARG
                   9927: RUBY_EXTCONF                      RUBY_EXTCONF_CHECK
                   9928: RUBY_EXTCONF_DEBUG                RUBY_EXTCONF_MAKEFILE
                   9929: RUBY_GEM_ARCH                     RUBY_GEM_BASE
                   9930: RUBY_INC                          RUBY_LIB
                   9931: RUBY_LIB_BASE                     RUBY_NAME
                   9932: RUBY_NOVERSION                    RUBY_PKGPREFIX
                   9933: RUBY_RAILS                        RUBY_RAILS61_VERSION
                   9934: RUBY_RAILS70_VERSION              RUBY_RAILS71_VERSION
                   9935: RUBY_RAILS_ACCEPTED               RUBY_RAILS_DEFAULT
                   9936: RUBY_RAILS_REQD                   RUBY_RAILS_STRICT_DEP
                   9937: RUBY_RIDIR                        RUBY_SETUP
                   9938: RUBY_SHLIB                        RUBY_SHLIBALIAS
                   9939: RUBY_SHLIBVER                     RUBY_SIMPLE_INSTALL
                   9940: RUBY_SITEARCHLIB                  RUBY_SITELIB
                   9941: RUBY_SITELIB_BASE                 RUBY_SITERIDIR
                   9942: RUBY_SLEXT                        RUBY_SRCDIR
                   9943: RUBY_STATICLIB                    RUBY_SUFFIX
                   9944: RUBY_SYSRIDIR                     RUBY_USE_PTHREAD
                   9945: RUBY_VENDORARCHLIB                RUBY_VENDORLIB
                   9946: RUBY_VENDORLIB_BASE               RUBY_VER
                   9947: RUBY_VERSION                      RUBY_VERSIONS_ACCEPTED
                   9948: RUBY_VERSIONS_INCOMPATIBLE        RUBY_VERSION_DEFAULT
                   9949: RUBY_VERSION_REQD                 RUBY_VER_DIR
                   9950: RUN                               RUN_LDCONFIG
                   9951: RUST_TYPE                         SCO
                   9952: SCREWS_GROUP                      SCREWS_USER
                   9953: SCRIPTS_ENV                       SCROLLKEEPER_DATADIR
                   9954: SCROLLKEEPER_REBUILDDB            SCROLLKEEPER_UPDATEDB
                   9955: SDIST_PAWD                        SDL12_TYPE
                   9956: SERIAL_DEVICES                    SETGIDGAME
                   9957: SETGID_GAMES_PERMS                SETUID_ROOT_PERMS
                   9958: SH                                SHLIB
1.258   ! wiz      9959: SHORTNAME                         SIGN_PACKAGES
        !          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                          SSP_SUPPORTED
        !          9969: SSYNC_PAWD                        STEP_MSG
        !          9970: STRIP                             STRIP_DBG
        !          9971: STRIP_DEBUG                       STRIP_DEBUG_SUPPORTED
        !          9972: STRIP_FILES_SKIP                  SU
        !          9973: SUBDIR                            SUBST
        !          9974: SUBST_CLASSES                     SUBST_FILES
        !          9975: SUBST_FILTER_CMD                  SUBST_MESSAGE
        !          9976: SUBST_NOOP_OK                     SUBST_SED
        !          9977: SUBST_SHOW_DIFF                   SUBST_SKIP_TEXT_CHECK
        !          9978: SUBST_STAGE                       SUBST_VARS
        !          9979: SUNWSPROBASE                      SUSE_PREFER
        !          9980: SU_CMD                            SVN_EXTRACTDIR
        !          9981: SVN_REPO                          SVN_REPOSITORIES
        !          9982: SVN_REVISION                      SYSCONFBASE
        !          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                      TLSWRAPPER_CHROOT
        !          9995: TO                                TOOLDIR
        !          9996: TOOLS_ALIASES                     TOOLS_ALWAYS_WRAP
        !          9997: TOOLS_ARGS                        TOOLS_BROKEN
        !          9998: TOOLS_CMD                         TOOLS_CMDLINE_SED
        !          9999: TOOLS_CREATE                      TOOLS_CROSS_DESTDIR
        !          10000: TOOLS_DIR                         TOOLS_FAIL
        !          10001: TOOLS_GNU_MISSING                 TOOLS_LDCONFIG
        !          10002: TOOLS_NOOP                        TOOLS_PATH
        !          10003: TOOLS_SCRIPT                      TOOLS_USE_CROSS_COMPILE
        !          10004: TOOL_DEPENDS                      TTF_FONTDIR
1.257     jkoshy   10005: TTF_FONTS_DIR                     TYPE
                   10006: UAC_REQD_EXECS                    UCSPI_SSL_GROUP
                   10007: UCSPI_SSL_USER                    UNLIMIT_RESOURCES
                   10008: UNPRIVILEGED                      UNPRIVILEGED_GROUP
                   10009: UNPRIVILEGED_GROUPS               UNPRIVILEGED_USER
                   10010: UNWRAP_FILES                      UNWRAP_PATTERNS
                   10011: UPDATE_GEMSPEC                    UPDATE_TARGET
                   10012: URI                               USERGROUP_PHASE
                   10013: USERPPP_GROUP                     USER_SPECIFIC_PKGS
                   10014: USE_ABI_DEPENDS                   USE_APR
                   10015: USE_BSD_MAKEFILE                  USE_BUILTIN
                   10016: USE_CC_FEATURES                   USE_CROSS_COMPILE
                   10017: USE_CURSES                        USE_CWRAPPERS
                   10018: USE_CXX_FEATURES                  USE_DB185
                   10019: USE_FEATURES                      USE_GAMESGROUP
                   10020: USE_GCC_RUNTIME                   USE_IMAKE
                   10021: USE_INDIRECT_DEPENDS              USE_JAVA
                   10022: USE_JAVA2                         USE_LANGUAGES
                   10023: USE_LIBTOOL                       USE_NATIVE_GCC
                   10024: USE_NETBSD_REPO                   USE_PKGSRC_GCC
                   10025: USE_PKGSRC_GCC_RUNTIME            USE_PKGTASKS
                   10026: USE_PKG_ADMIN_DIGEST              USE_RUBY_EXTCONF
                   10027: USE_RUBY_INSTALL                  USE_RUBY_SETUP
1.258   ! wiz      10028: USE_RUBY_SETUP_PKG                USE_TMPFILES
        !          10029: USE_TOOLS                         UUCP_GROUP
        !          10030: UUCP_USER                         VARBASE
        !          10031: VARNAME                           VIM_EXTRA_OPTS
        !          10032: WARNING_MSG                       WCALC_CGIDIR
        !          10033: WCALC_CGIPATH                     WCALC_HTMLDIR
        !          10034: WCALC_HTMLPATH                    WDM_MANAGERS
        !          10035: WRAPPER_CC                        WRAPPER_REORDER_CMDS
        !          10036: WRKDIR                            WRKDIR_BASENAME
        !          10037: WRKDIR_LOCKTYPE                   WRKLOG
        !          10038: WRKOBJDIR                         WRKSRC
        !          10039: X10_PORT                          X11
        !          10040: X11BASE                           X11_PKGSRCDIR
        !          10041: X11_TYPE                          X509_CERTIFICATE
        !          10042: X509_KEY                          XAW_TYPE
        !          10043: XLOCK_DEFAULT_MODE                XMKMF
        !          10044: XMKMF_FLAGS                       XXX
        !          10045: XXXX                              YES
1.257     jkoshy   10046: ZSH_STATIC                        __stdc__
                   10047: _vargroups                        accept
                   10048: acquire-localbase-lock            acquire-lock
                   10049: add                               added
                   10050: administrator                     alloca
                   10051: alternatives                      aslr
                   10052: asprintf                          atlas
                   10053: autoconf                          automake
                   10054: autoreconf                        awk
                   10055: bash                              big-endian
                   10056: bin-install                       bind
                   10057: binpkg-list                       blas
                   10058: bootstrap-depends                 broken
                   10059: broken_on_platform                bsd
                   10060: bsd.prog.mk                       build
                   10061: build-env                         buildlink-directories
                   10062: buildlink-oss-soundcard-h         built-in
                   10063: builtin                           c
                   10064: c++                               ccache
                   10065: cce                               cdefs
                   10066: ceil                              changes
                   10067: changes-entry                     changes-entry-noupdate
                   10068: check                             check-clean
                   10069: check-files                       check-files-clean
                   10070: check-hackage                     check-vulnerable
                   10071: checksum                          checksum-phase
                   10072: clean                             clean-depends
                   10073: cleandir                          commit
                   10074: commit-changes-entry              compact
                   10075: compiler                          conf
                   10076: config.guess                      config.sub
                   10077: configuration                     configure
                   10078: configure-env                     configure-help
                   10079: configure_args                    connect
                   10080: cos                               cpe
                   10081: cputime                           create-usergroup
                   10082: csh                               ctf
1.258   ! wiz      10083: cvs                               debug
        !          10084: declaration                       declare
        !          10085: defined                           depend
        !          10086: dependencies                      depends
        !          10087: depends-checksum                  depends-fetch
        !          10088: deps                              describe
        !          10089: destdir                           disable
        !          10090: distclean                         distinfo
        !          10091: dl                                dlopen
        !          10092: do-buildlink                      do-clean
        !          10093: do-configure                      do-configure-post-hook
        !          10094: do-extract                        do-fetch
        !          10095: do-install                        download
1.257     jkoshy   10096: emul                              emul-distinfo
                   10097: emul-fetch                        emulation
                   10098: emulator                          enable
1.258   ! wiz      10099: endian                            endif
        !          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
        !          10109: fossil                            friend
1.257     jkoshy   10110: fts                               fts_close
                   10111: fts_open                          fts_read
                   10112: fts_set                           gcc
                   10113: gethostbyaddr                     gethostbyname
                   10114: gethostbyname2                    getopt_long
                   10115: getprogname                       getservbyname
                   10116: getservbyport                     getservent
1.258   ! wiz      10117: gettext                           git
        !          10118: github                            gitlab
        !          10119: glob                              gnu
        !          10120: gnu_configure_strict              go
        !          10121: go-deps                           golang
        !          10122: guess-license                     hashbang
        !          10123: heimdal                           help
        !          10124: hg                                imake
1.257     jkoshy   10125: in-tree                           increment
                   10126: indirect                          inet_aton
                   10127: interp                            interpreter
                   10128: intl                              ip4
                   10129: ip6                               ipv4
                   10130: ipv6                              iso
                   10131: kerberos                          krb
                   10132: krb5                              ksh
                   10133: lapack                            latex
                   10134: libiconv                          libintl_bindtextdomain
                   10135: libintl_gettext                   libintl_textdomain
                   10136: libnbcompat                       libs
                   10137: libtool                           licence
                   10138: license                           lintl
                   10139: little-endian                     lock
                   10140: locking                           lua
                   10141: lvalue                            make
                   10142: makesum                           memory
1.258   ! wiz      10143: mercurial                         meta
        !          10144: meta-package                      meta_package
        !          10145: mit-krb5                          mk.conf
        !          10146: mkl                               mount
        !          10147: move                              moved
        !          10148: mprotect                          mremap
        !          10149: native                            nb
        !          10150: nbcompat                          netlib
        !          10151: network                           node
        !          10152: node.js                           nodejs
        !          10153: obstack                           obstack_ptr_grow
        !          10154: occurs                            only
        !          10155: openblas                          options
        !          10156: options.mk                        order
        !          10157: override                          override-intltool
        !          10158: override-message-intltool         package
        !          10159: parallel                          path
        !          10160: pax                               paxctl
        !          10161: pbulk-index                       pc
        !          10162: perl                              perl5
        !          10163: perms                             php
        !          10164: pkg-build-options                 pkg-config
        !          10165: pkg_build_options                 pkgsrc
        !          10166: platform                          plist
        !          10167: post-extract                      post-fetch
        !          10168: post-wrapper                      pre-build-checks-hook
        !          10169: pre-configure-checks-hook         pre-extract
        !          10170: pre-fetch                         print-go-deps
        !          10171: print-plist                       print-summary-data
        !          10172: privileged-install-hook           pypi
        !          10173: python                            r
        !          10174: readme-all                        recursive
        !          10175: recv                              recvfrom
        !          10176: regcomp                           release-localbase-lock
        !          10177: release-lock                      relro
        !          10178: remove                            removed
        !          10179: rename                            renamed
        !          10180: reorder                           replace
        !          10181: replace_interpreter               reproducible
        !          10182: resolv                            root
        !          10183: ruby                              send
        !          10184: sendfile                          sendto
        !          10185: setenv                            setgid
        !          10186: setprogname                       setuid
        !          10187: sh                                shebang
        !          10188: show                              show-all
        !          10189: show-build-defs                   show-depends
        !          10190: show-depends-dirs                 show-depends-pkgpaths
        !          10191: show-depends-recursive            show-deps
        !          10192: show-distfiles                    show-downlevel
        !          10193: show-subdir-var                   show-tools
        !          10194: show-var                          show-vars
        !          10195: snprintf                          socket
        !          10196: ssp                               st_mode
        !          10197: stage-install                     strcasestr
        !          10198: strict                            strip
        !          10199: strndup                           strnlen
        !          10200: strsep                            subst
        !          10201: substitutions                     subversion
1.257     jkoshy   10202: sun                               sunpro
1.258   ! wiz      10203: sunwspro                          svn
        !          10204: symlink                           test
        !          10205: test-env                          tex
        !          10206: texlive                           tmp
        !          10207: todo                              tool
        !          10208: tools                             tools-libtool-m4-override
        !          10209: transitive                        type
        !          10210: ulimit                            undefined
        !          10211: undo-replace                      unlimit
        !          10212: unprivileged                      unprivileged-install-hook
        !          10213: unstripped                        update
        !          10214: updated                           upload
        !          10215: upload-distfiles                  use_tools
        !          10216: user                              utimes
        !          10217: vasprintf                         verbose
        !          10218: vsnprintf                         warn
        !          10219: warning                           warnings
        !          10220: warnx                             wattr_off
        !          10221: wattr_on                          work
        !          10222: wrapper                           wrkdir
1.154     rillig   10223: 
1.207     leot     10224: Appendix F. Editing guidelines for the pkgsrc guide
1.1       dsieger  10225: 
                   10226: Table of Contents
                   10227: 
1.207     leot     10228: F.1. Make targets
                   10229: F.2. Procedure
1.1       dsieger  10230: 
                   10231: This section contains information on editing the pkgsrc guide itself.
                   10232: 
1.207     leot     10233: F.1. Make targets
1.1       dsieger  10234: 
                   10235: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
                   10236: files are created from it:
                   10237: 
                   10238:   * pkgsrc/doc/pkgsrc.txt
                   10239: 
                   10240:   * pkgsrc/doc/pkgsrc.html
                   10241: 
1.174     leot     10242:   * https://www.NetBSD.org/docs/pkgsrc/
1.1       dsieger  10243: 
1.174     leot     10244:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
                   10245:     pkgsrc guide.
1.1       dsieger  10246: 
1.174     leot     10247:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2       rillig   10248:     pkgsrc guide.
1.1       dsieger  10249: 
1.207     leot     10250: F.2. Procedure
1.1       dsieger  10251: 
                   10252: The procedure to edit the pkgsrc guide is:
                   10253: 
1.190     bacon    10254:  1. Make sure you have checked out the htdocs repository into a sibling
                   10255:     directory of your pkgsrc directory. You will need the ability to commit
                   10256:     from both pkgsrc and htdocs.
                   10257: 
                   10258:  2. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46      obache   10259:     other XML-based NetBSD documentation) installed. These are automatically
                   10260:     installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1       dsieger  10261: 
1.190     bacon    10262:  3. Run cd doc/guide to get to the right directory. All further steps will take
1.1       dsieger  10263:     place here.
                   10264: 
1.190     bacon    10265:  4. Edit the XML file(s) in files/.
1.1       dsieger  10266: 
1.190     bacon    10267:  5. Run bmake to check the pkgsrc guide for valid XML and to build the final
1.1       dsieger  10268:     output files. If you get any errors at this stage, you can just edit the
                   10269:     files, as there are only symbolic links in the working directory, pointing
                   10270:     to the files in files/.
                   10271: 
1.190     bacon    10272:  6. (cd files && cvs commit)
1.1       dsieger  10273: 
1.190     bacon    10274:  7. Run bmake clean && bmake to regenerate the output files with the proper RCS
1.1       dsieger  10275:     Ids.
                   10276: 
1.190     bacon    10277:  8. Run bmake regen to install and commit the files in both pkgsrc/doc and
1.1       dsieger  10278:     htdocs.
                   10279: 
                   10280:     Note
                   10281: 
                   10282:     If you have added, removed or renamed some chapters, you need to
                   10283:     synchronize them using cvs add or cvs delete in the htdocs directory.
                   10284: 

CVSweb <webmaster@jp.NetBSD.org>